Skip to content

Expose caller-driven async statement C ABI - #356

Merged
jay-xiao446 merged 8 commits into
mainfrom
jay/odbc-async-c-abi
Sep 28, 2026
Merged

jay-xiao446 merged 8 commits into
mainfrom
jay/odbc-async-c-abi

Conversation

@jay-xiao446

Copy link
Copy Markdown
Collaborator

Summary

  • implement the existing kernel_statement_submit entry point
  • expose one-shot status, result materialisation, query id, row count, detached cancellation, and close for async statements
  • document ownership and terminal-status behavior in the public C header
  • preserve the existing synchronous ABI

Testing

  • cargo test --lib c_abi::statement::tests
  • cargo test --test v0_c_abi_canceller_wiremock async_c_abi_submit_poll_and_materialise
  • compile include/databricks_kernel.h as C11 with warnings as errors

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 Medium

Looks good — the async C ABI wiring is sound (owned result stream avoids the sync path's borrow/UAF concerns, retry-safe stream_taken, consistent null guards, close consumes the handle with Drop as a fire-and-forget backstop). One medium doc-mismatch: the rustdoc on kernel_statement_submit and its section banner still say the async path is "deferred in v0 / skeleton", contradicting the implementation this PR adds.

Comment thread src/c_abi/statement.rs Resolved
@jay-xiao446 jay-xiao446 added the engineer-bot Apply to an issue to trigger the engineer-bot; on a PR to enable engineer follow-up label Sep 23, 2026
oss-engineer-bot Bot pushed a commit that referenced this pull request Sep 23, 2026
Addresses:
  - #4077996477 at src/c_abi/statement.rs:882

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 2 Low

Solid implementation of the caller-driven async statement C ABI. Ownership and lifecycle are correct: the owned ResultStream is self-contained (so into_raw_result_stream is the right choice and close-ordering is free), the query-id CString is freed on close, the closed-swap drop semantics correctly re-fire cleanup on close failure, and the single-consumption/null guards all check out. Two low-severity notes only: (F1) get_result_stream is non-blocking and needs the caller to poll to terminal first — undocumented in the header; (F2) the one-shot status Cancelled arm drops the SEA extended-status fields the sync path carries. Nit: ExecutedAsyncHandle.stream_taken is a plain bool while the sync ExecutedHandle.stream_taken is an AtomicBool — harmless given same-handle calls aren't concurrency-safe anyway, but worth aligning.

Comment thread include/databricks_kernel.h Resolved
Comment thread src/c_abi/statement.rs Resolved
oss-engineer-bot Bot pushed a commit that referenced this pull request Sep 23, 2026
Addresses:
  - #4078118799 at include/databricks_kernel.h:878
  - #4078118801 at src/c_abi/statement.rs:946

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
oss-engineer-bot Bot pushed a commit that referenced this pull request Sep 23, 2026
Addresses:
  - #4078384352 at src/c_abi/statement.rs:924

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 Medium

Solid, well-tested addition — the async C ABI wiring is sound: null guards, out-param sentinels, catch_ffi panic barriers around the sync prologue/epilogue, single-consumption stream guard, and detached-canceller ownership all look correct, and the wiremock tests cover submit/poll/materialise plus the Failed/Cancelled/non-terminal/double-take paths. One medium maintainability concern: the Cancelled status arm hand-duplicates the extended-status carry-over instead of sharing carry_extended_status, which will drift from the Failed arm if a field is added.

Comment thread src/c_abi/statement.rs Resolved

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 Low

Solid, well-tested PR that un-defers the async statement C ABI. FFI safety is handled correctly (every sync prologue/epilogue is under catch_ffi, out-pointers are pre-written, close consumes the handle on all paths, and the status enum discriminants match the C header 1:1); the wiremock tests cover submit→poll→materialise plus the Failed/Cancelled/pre-terminal/double-take guards. One low-severity test-coverage gap noted inline. Nit (not in diff, so summary-only): the KernelStatementStatusKind header comment at include/databricks_kernel.h:157 still reads "Reserved for the async submit path" — stale now that the path is implemented; the PR updated the sibling handle-typedef comment (line 204) but missed this one.

Comment thread src/c_abi/statement.rs Resolved

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

jay-xiao446 and others added 8 commits September 25, 2026 20:24
Signed-off-by: Jay Xiao <jay.xiao@databricks.com>
Addresses:
  - #4077996477 at src/c_abi/statement.rs:882

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4078118799 at include/databricks_kernel.h:878
  - #4078118801 at src/c_abi/statement.rs:946

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4078194838 at tests/v0_c_abi_canceller_wiremock.rs:82

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4078323347 at src/c_abi/statement.rs:1116
  - #4078323354 at include/databricks_kernel.h:879

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4078384352 at src/c_abi/statement.rs:924

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4078447417 at src/c_abi/statement.rs:976

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses:
  - #4078534358 at src/c_abi/statement.rs:1045

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

@cathleeny cathleeny left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

This branch was previously deployed

1 inactive deployment
azure-prod — c901af48 Deployed Sep 25, 2026 by jay-xiao446 via v0 TLS (mitmproxy) #867
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engineer-bot Apply to an issue to trigger the engineer-bot; on a PR to enable engineer follow-up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants