Skip to content

csharp: Fall back to AdbcDriverInit when the derived entrypoint is absent #4630

Description

@ianmcook

What happened?

The C# driver manager derives an entrypoint of AdbcDriver{PascalCase}Init from the driver library filename, but performs only that single symbol lookup. If the driver does not export that exact name, loading fails with EntryPointNotFoundException even though the driver exports the standard AdbcDriverInit.

Compare this to the C/C++ driver manager which tries the derived name and then falls back to AdbcDriverInit (c/driver_manager/adbc_driver_manager.cc):

static const char kDefaultEntrypoint[] = "AdbcDriverInit";
...
status = library.Lookup(name.c_str(), &load_handle, error);
if (status != ADBC_STATUS_OK) {
  status = library.Lookup(kDefaultEntrypoint, &load_handle, error);
}

C# has no equivalent fallback, so drivers that load fine from Go/Python/R fail from C#:

// Manifest declares no entrypoint; C# derives "AdbcDriverClickhouseInit"
using var driver = AdbcDriverManager.FindLoadDriver(
    "clickhouse", loadOptions: AdbcLoadFlags.Default);

// System.EntryPointNotFoundException: Unable to find an entry point named
// 'AdbcDriverClickhouseInit' in shared library.

nm -gU libadbc_driver_clickhouse.dylib | grep -iE 'init$' shows the derived name is
absent but the standard one is present:

_AdbcClickhouseInit
_AdbcDriverInit

You can work around this by passing entrypoint: "AdbcDriverInit" in the client code.

This problem affects the ClickHouse, Exasol, MySQL, and SingleStore drivers. We opened PRs to solve this in the drivers, but we should solve it here too.

Stack Trace

No response

How can we reproduce the bug?

No response

Environment/Setup

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions