Skip to content

fix(rust): align LoadFlags constants with the C ABI - #39

Open
fornwall wants to merge 1 commit into
mainfrom
fix/rust-core-loadflags-c-abi
Open

fix(rust): align LoadFlags constants with the C ABI#39
fornwall wants to merge 1 commit into
mainfrom
fix/rust-core-loadflags-c-abi

Conversation

@fornwall

Copy link
Copy Markdown
Owner

Problem

The Rust LoadFlags constants in rust/core/src/lib.rs were shifted one bit too high, leaving bit 0 unused and diverging from the canonical ADBC C ABI defined in c/include/arrow-adbc/adbc_driver_manager.h (lines 37-44). Anyone passing a C-documented flag value into the Rust API got wrong behavior.

Fix

Start the shifts at 1 << 0 so the values match the C header exactly:

Constant Old (Rust) New C header
SEARCH_ENV 2 1 ADBC_LOAD_FLAG_SEARCH_ENV 1
SEARCH_USER 4 2 ADBC_LOAD_FLAG_SEARCH_USER 2
SEARCH_SYSTEM 8 4 ADBC_LOAD_FLAG_SEARCH_SYSTEM 4
ALLOW_RELATIVE_PATHS 16 8 ADBC_LOAD_FLAG_ALLOW_RELATIVE_PATHS 8
DEFAULT 30 15 OR of the four

LOAD_FLAG_DEFAULT stays the OR of the four and naturally becomes 15.

Fallout check

All existing uses of these constants (in driver_manager/src/search.rs and the tests) are symbolic — bitwise AND between the constants themselves — so no other code needed changing. A repo-wide grep found no test asserting the old numeric values (no hardcoded 30/16 flag checks).

Verification

  • cargo build --workspace passes.
  • cargo test -p adbc_core passes.
  • cargo test -p adbc_driver_manager --lib search/load tests pass (the remaining failures are environment-only: they require ADBC_DRIVER_MANAGER_TEST_LIB / libadbc_driver_sqlite.so, which are not present in this environment and are unrelated to this change).

🤖 Generated with Claude Code

https://claude.ai/code/session_01XNCrC87g9MkppGpL4MDgh5

The Rust `LoadFlags` constants were shifted one bit too high, leaving
bit 0 unused and diverging from the canonical ADBC C ABI defined in
`c/include/arrow-adbc/adbc_driver_manager.h`. Anyone passing a
C-documented flag value into the Rust API therefore got wrong behavior.

Old (Rust) vs new (matching the C header):

  SEARCH_ENV:            2  -> 1   (ADBC_LOAD_FLAG_SEARCH_ENV 1)
  SEARCH_USER:           4  -> 2   (ADBC_LOAD_FLAG_SEARCH_USER 2)
  SEARCH_SYSTEM:         8  -> 4   (ADBC_LOAD_FLAG_SEARCH_SYSTEM 4)
  ALLOW_RELATIVE_PATHS: 16  -> 8   (ADBC_LOAD_FLAG_ALLOW_RELATIVE_PATHS 8)
  DEFAULT:              30  -> 15  (OR of the four)

The shifts now start at `1 << 0`; `LOAD_FLAG_DEFAULT` remains the OR of
the four and naturally becomes 15. All existing uses are symbolic
(bitwise AND between the constants), so no other code changed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XNCrC87g9MkppGpL4MDgh5
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.

1 participant