Skip to content

Implement APD/IPD descriptor integration for parameter binding#566

Open
sfc-gh-makowalski wants to merge 2 commits intoodbc-bind-parameter-testsfrom
apd-ipd-descriptors
Open

Implement APD/IPD descriptor integration for parameter binding#566
sfc-gh-makowalski wants to merge 2 commits intoodbc-bind-parameter-testsfrom
apd-ipd-descriptors

Conversation

@sfc-gh-makowalski
Copy link
Contributor

Summary

  • Replace parameter_bindings HashMap with proper ODBC APD/IPD descriptors as the source of truth for parameter binding. SQLBindParameter now writes to the APD (C type, data pointer, buffer length, indicator) and IPD (SQL type, column size, decimal digits, direction) separately.
  • Add SQLNumParams and SQLDescribeParam — these read directly from the IPD descriptor, providing parameter metadata to applications.
  • Add APD/IPD branches to SQLGetDescField/SQLSetDescField — applications can now bind parameters via descriptor manipulation as an alternative to SQLBindParameter.

Changes

File Change
types.rs New ApdDescriptor, ApdRecord, IpdDescriptor, IpdRecord structs; DescriptorRef now has Apd/Ipd variants; DescField gains ParameterType (1015) and Nullable (1008); Statement uses ApdDescriptor/IpdDescriptor instead of parameter_bindings HashMap
statement.rs bind_parameter writes to APD+IPD; apply_parameter_bindings reads from APD+IPD; free_stmt(RESET_PARAMS) clears both descriptors; new num_params and describe_param functions
descriptor.rs New get_apd_field/set_apd_field and get_ipd_field/set_ipd_field handlers
c_api.rs New SQLNumParams and SQLDescribeParam FFI exports
param_binding.rs odbc_bindings_to_json now takes &ApdDescriptor, &IpdDescriptor and reconstructs ParameterBinding at execution time
exports.def Added SQLNumParams and SQLDescribeParam
handle_allocation.rs Statement creation uses new descriptor types

Design

Per ODBC spec, parameter binding is split across two descriptors:

  • APD (Application Parameter Descriptor): application-side buffer info (C data type, data pointer, buffer length, indicator/length pointer)
  • IPD (Implementation Parameter Descriptor): server-side type info (SQL data type, column size, decimal digits, parameter direction, nullability)

SQLBindParameter populates both. At execution time, APD+IPD records are zipped into the existing ParameterBinding struct for the conversion pipeline (ParamConverterReadODBCWriteJson → JSON). The conversion layer is unchanged.

Test plan

  • All 540 existing unit tests pass
  • Clippy clean, no warnings
  • E2E bind parameter tests pass (CI)
  • Verify SQLNumParams returns correct count after binding
  • Verify SQLDescribeParam returns correct type info
  • Verify SQLSetDescField on APD/IPD affects execution

Made with Cursor

Copy link
Contributor Author

sfc-gh-makowalski commented Mar 18, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge_queue - adds this PR to the back of the merge queue
  • priority_merge_queue - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sfc-gh-makowalski sfc-gh-makowalski force-pushed the odbc-bind-parameter-tests branch from 26a7d3b to 3a30fe6 Compare March 18, 2026 08:42
@sfc-gh-makowalski sfc-gh-makowalski force-pushed the odbc-bind-parameter-tests branch from 3a30fe6 to 4afa8d8 Compare March 18, 2026 08:43
@sfc-gh-makowalski sfc-gh-makowalski force-pushed the apd-ipd-descriptors branch 2 times, most recently from 2563283 to d68dc81 Compare March 19, 2026 07:18
@sfc-gh-makowalski sfc-gh-makowalski force-pushed the odbc-bind-parameter-tests branch from 4afa8d8 to 128afe0 Compare March 19, 2026 07:18
@sfc-gh-makowalski sfc-gh-makowalski force-pushed the odbc-bind-parameter-tests branch from 128afe0 to 54cbb52 Compare March 19, 2026 07:26
@sfc-gh-makowalski sfc-gh-makowalski force-pushed the odbc-bind-parameter-tests branch from 54cbb52 to 7e0c5ea Compare March 19, 2026 07:45
@sfc-gh-makowalski sfc-gh-makowalski force-pushed the odbc-bind-parameter-tests branch from 7e0c5ea to 0306feb Compare March 19, 2026 07:53
@sfc-gh-makowalski sfc-gh-makowalski force-pushed the odbc-bind-parameter-tests branch from 0306feb to 7596afe Compare March 19, 2026 08:34
@sfc-gh-makowalski sfc-gh-makowalski force-pushed the odbc-bind-parameter-tests branch from 7596afe to c24ae71 Compare March 19, 2026 08:42
@sfc-gh-makowalski sfc-gh-makowalski changed the base branch from odbc-bind-parameter-tests to graphite-base/566 March 20, 2026 13:26
@sfc-gh-makowalski sfc-gh-makowalski changed the base branch from graphite-base/566 to odbc-bind-parameter-tests March 20, 2026 13:27
Replace the ad-hoc parameter_bindings HashMap with proper ODBC
descriptor types (ApdDescriptor/IpdDescriptor) as the source of truth
for parameter binding. SQLBindParameter now writes to APD (application
side: C type, data pointer, buffer length, indicator) and IPD
(implementation side: SQL type, column size, decimal digits, direction)
separately. At execution time, records are zipped into ParameterBinding
for the existing conversion pipeline.

- Add ApdDescriptor with ApdRecord and IpdDescriptor with IpdRecord
- Add DescriptorRef::Apd/Ipd variants for proper dispatch
- Add APD/IPD branches to get_desc_field/set_desc_field
- Add DescField::ParameterType (1015) and DescField::Nullable (1008)
- Implement SQLNumParams and SQLDescribeParam (FFI + exports)
- SQLFreeStmt(SQL_RESET_PARAMS) now clears APD+IPD records
- column_size and decimal_digits are now stored in IPD (previously ignored)

Made-with: Cursor
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