fix(rust): align LoadFlags constants with the C ABI - #39
Open
fornwall wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Rust
LoadFlagsconstants inrust/core/src/lib.rswere shifted one bit too high, leaving bit 0 unused and diverging from the canonical ADBC C ABI defined inc/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 << 0so the values match the C header exactly:SEARCH_ENVADBC_LOAD_FLAG_SEARCH_ENV 1SEARCH_USERADBC_LOAD_FLAG_SEARCH_USER 2SEARCH_SYSTEMADBC_LOAD_FLAG_SEARCH_SYSTEM 4ALLOW_RELATIVE_PATHSADBC_LOAD_FLAG_ALLOW_RELATIVE_PATHS 8DEFAULTLOAD_FLAG_DEFAULTstays the OR of the four and naturally becomes 15.Fallout check
All existing uses of these constants (in
driver_manager/src/search.rsand 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 hardcoded30/16flag checks).Verification
cargo build --workspacepasses.cargo test -p adbc_corepasses.cargo test -p adbc_driver_manager --libsearch/load tests pass (the remaining failures are environment-only: they requireADBC_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