Skip to content

refactor(c/driver_manager): split up adbc_driver_manager.cc for easier maintenance#4029

Open
zeroshade wants to merge 12 commits intoapache:mainfrom
zeroshade:split-up-driver-manager
Open

refactor(c/driver_manager): split up adbc_driver_manager.cc for easier maintenance#4029
zeroshade wants to merge 12 commits intoapache:mainfrom
zeroshade:split-up-driver-manager

Conversation

@zeroshade
Copy link
Member

As discussed in some of the recent PRs, this refactors the adbc_driver_manager.cc file and splits things up into multiple files based on the API surface they are relevant to. This makes future maintenance easier for the C++ driver manager.

This also updates the pre-commit config to ensure the files stay in sync with the go/adbc/drivermgr files etc.

zeroshade and others added 10 commits February 27, 2026 15:54
Extracted driver discovery and loading logic into separate file:
- LoadDriverManifest: TOML manifest parsing
- ManagedLibrary: Dynamic library management with GetDriverInfo, FindDriver, SearchPathsForDriver, Load, and Lookup methods
- GetEnvPaths/GetSearchPaths: Search path resolution
- HasExtension: Cross-platform extension checking
- Windows Registry integration (RegistryKey class, LoadDriverFromRegistry)
- InternalAdbcDriverManagerDefaultEntrypoint: Default entrypoint generation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Extracted all public ADBC API functions from the monolithic driver
manager file into a dedicated API implementation file:

- Database API (New, Init, Release, Get/SetOption variants)
- Connection API (New, Init, Release, Commit, Rollback, Get/SetOption,
  GetInfo, GetObjects, etc.)
- Statement API (Bind, Execute, Prepare, Get/SetOption, etc.)
- Driver loading API (AdbcLoadDriver, AdbcLoadDriverFromInitFunc)
- Default stubs for unimplemented driver functions
- ErrorArrayStream wrapper for enhanced error reporting
- Helper structures (TempDatabase, TempConnection) moved to internal header

Updated internal header to include shared structures and function
declarations needed across multiple translation units.

Updated CMake build to include new source files.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Added inline destructor implementation for OwnedError
- Added declarations for AdbcFindLoadDriver and ReleaseDriver functions
- Removed static keyword from ReleaseDriver to allow cross-file usage
- Removed redundant extern declarations from API file

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixed multiple categories of compilation and linker errors after splitting
the driver manager into separate source files:

**Duplicate Definitions:**
- Removed duplicate structure definitions (ParseDriverUriResult, DriverInfo,
  OwnedError) from .cc files; kept only in internal header
- Removed duplicate error handling functions (SetError, AppendError) from
  anonymous namespaces in .cc files
- Moved error handling implementations to global namespace in main file
- Removed duplicate AdbcStatusCodeMessage (kept in API file)

**Namespace Issues:**
- Moved enums and type aliases from anonymous namespaces to internal header
- Moved utility functions (AddSearchPathsToError) out of anonymous namespace
- Created wrapper for ReleaseDriver to expose from anonymous namespace
- Moved FilesystemProfile and ProcessProfileValue/LoadProfileFile out of
  anonymous namespace in profiles file

**Visibility and Linkage:**
- Added declarations to internal header for shared functions
- Removed declarations for functions that should remain file-local
- Made CurrentArch() inline to avoid multiple definition errors
- Properly scoped helper functions within anonymous namespaces

**Unused Code:**
- Commented out unused helper functions (GetProfileSearchPaths, GetEnvPaths,
  kAdbcProfilePath) to avoid unused-function warnings
- Removed GetProfileSearchPaths declaration from internal header

**Cross-file Dependencies:**
- Added include of internal header in profiles file
- Moved AdbcErrorFromArrayStream and AdbcErrorGetDetail to API file with
  ErrorArrayStream helpers
- Ensured all split files can access shared utilities

Build now completes successfully with no errors or warnings.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ementation

The AdbcProfileProviderFilesystem function was not moved to the profiles file
during the refactoring. This commit:

- Uncomments and activates GetEnvPaths helper function
- Uncomments and activates GetProfileSearchPaths helper function
- Adds the main AdbcProfileProviderFilesystem function implementation
- Adds CHECK_STATUS macro definition needed by the profiles file
- Uncomments kAdbcProfilePath constant

This fixes the undefined symbol error that was preventing tests from running.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to mark these as generated in gitattributes?

Comment on lines +34 to +38
// Forward declare C types from adbc_driver_manager.h for use in C++ contexts
struct AdbcConnectionProfile;
typedef AdbcStatusCode (*AdbcConnectionProfileProvider)(
const char* profile_name, const char* additional_search_path_list,
struct AdbcConnectionProfile* out, struct AdbcError* error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're including adbc_driver_manager.h, what is there to forward declare?

Comment on lines +17 to +19

#ifndef ADBC_DRIVER_MANAGER_INTERNAL_H
#define ADBC_DRIVER_MANAGER_INTERNAL_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#pragma once?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants