Skip to content

get data column wise fetch - #156

Draft
shiwanigupta0809 wants to merge 12 commits into
mainfrom
dev/shiwanigupta/SQLGetDataColumnWise
Draft

get data column wise fetch#156
shiwanigupta0809 wants to merge 12 commits into
mainfrom
dev/shiwanigupta/SQLGetDataColumnWise

Conversation

@shiwanigupta0809

Copy link
Copy Markdown
Contributor

Description

Related Issues

Checklist

  • cargo bfmt passes
  • cargo bclippy passes
  • cargo btest passes
  • New/changed functionality has tests
  • Public API changes are documented

Shiwani Gupta and others added 12 commits July 30, 2026 00:02
Replace full-row materialization in mssql-odbc with msodbcsql-style
column-wise retrieval. SQLFetch positions on a row without decoding any
column; each SQLGetData decodes exactly the requested column, draining
intervening columns, and streams PLP (MAX/xml) values across repeated
calls.

- mssql-tds: add RowWriter::pause_before_first_column hook (default off)
  honored in receive_row_into_internal for ROW/NBCROW; add PlpEncoding
  enum + active_plp_encoding accessor.
- mssql-odbc: add OdbcRowWriter (pause before first column, capture the
  requested column, pause after it) and PlpStream transcoding state
  machine; rewrite SQLFetch to position without materialization and
  SQLGetData for column-wise + PLP streaming; replace StmtState
  current_row with streaming fields.
- Remove old full-row-materialization unit tests; add column-wise guard
  tests, a tds e2e positioning test, and C++ e2e get_data_test.cpp.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Non-decreasing column retrieval is required (SQL_GD_ANY_ORDER is not
advertised). Requesting a column strictly earlier than the last one
retrieved now returns SQL_ERROR / SQLSTATE 07009 (Invalid Descriptor
Index), matching msodbcsql. Re-requesting the just-retrieved column
still returns SQL_NO_DATA per the SQLGetData streaming contract.

Update unit and C++ e2e tests accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
read_new_column checked end_row_fired() before take_captured(). end_row
fires in two cases: the requested column is genuinely past the row end,
AND the requested column is the last column (decoding it also completes
the row). The second case wrongly returned 07009 instead of delivering
the value, breaking every single-column read and every last-column read.

Check take_captured() first and deliver the value when present, even if
end_row fired. Only treat end_row_fired as past-end when nothing was
captured.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add live e2e tests exercising scenarios not previously covered:
- scalar column followed by a PLP column in one row
- skipping an intervening PLP column while advancing
- requesting a column past the end returns 07009
- empty VARCHAR(MAX)/NVARCHAR(MAX) values
- tiny caller buffer forcing many PLP continuation calls
- length indicator: exact-remaining for <=8 KiB values (single wire pump)
  and SQL_NO_TOTAL for >8 KiB values while the wire drains
- NVARCHAR(MAX) round-trip via SQL_C_WCHAR
- unsupported C type returns HYC00 without consuming the column
- VARBINARY(MAX) to character returns HYC00

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reads column 2 (VARCHAR(MAX)) to completion, skips PLP column 3, then
streams column 4 (VARCHAR(MAX)). Verifies PLP stream state fully resets
between columns and a skipped PLP column is drained while advancing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- MultiRowScalarColumns: loop SQLFetch over 3 rows reading scalar columns,
  verifying the get-data cursor resets per row.
- MultiRowPlpStreamedPerRow: stream a PLP column to completion on each of
  two rows, verifying PLP stream state resets across fetches.
- FetchDrainsPartiallyReadPlpFromPriorRow: SQLFetch drains an unfinished
  PLP value from the prior row before positioning on the next row.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The odbc_pause_before_first_then_getdata_columns test and its
OdbcStyleWriter helper duplicated coverage now provided by the
mssql-odbc get_data_test.cpp e2e suite. Column-wise positioning at the
tds layer remains covered by the sparse_* writer tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The api module is reserved for ODBC API entry points. plp_stream and
row_writer are internal column-wise fetch machinery, so move them into a
new fetch_engine module and update all references.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ream

The pause-before-first-column positioning behavior is already covered by
the ODBC-layer fetch/get_data tests; the tds-layer helper and its two
tests are redundant.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fix import ordering after the fetch_engine move and pre-existing rustfmt
wrapping so cargo fmt --check passes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Collapse nested if-let into a let-chain (collapsible_if)
- Scope the stmt mutex guard so it is dropped before the wire-pump await
  (await_holding_lock)
- Drop needless &dbc borrows when passing the &DbcHandle (needless_borrow)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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