Skip to content

Add blocking sync row driver reusing the async parse body (L3) - #202

Draft
Saurabh Singh (saurabh500) wants to merge 1 commit into
dev/saurabh/sans-io-expose-l2-timeout-cancelfrom
dev/saurabh/sans-io-expose-l3-blocking-driver
Draft

Add blocking sync row driver reusing the async parse body (L3)#202
Saurabh Singh (saurabh500) wants to merge 1 commit into
dev/saurabh/sans-io-expose-l2-timeout-cancelfrom
dev/saurabh/sans-io-expose-l3-blocking-driver

Conversation

@saurabh500

Copy link
Copy Markdown
Contributor

Layer 3 (internal): blocking sync row driver + sync PLP collect

Part of the bottom-up sans-I/O stack. Based on L2 (dev/saurabh/sans-io-expose-l2-timeout-cancel, #201), not main.

Introduces, under the existing async client, a blocking synchronous row driver and a sync PLP collect that reuse the ONE parse body (TdsCore::step_row) and the ONE PLP leaf (plp_collect_step) verbatim. Only the refill wrapper differs (blocking vs .await). No new parse machine. No public API change (no TdsSyncClient yet — that is Layer 4). All new items are pub(crate).

What is added

  • BlockingByteSource trait + assemble_tds_packet_blocking (byte_source.rs) — the packet framing body minus the await.
  • BlockingRowReader trait, ensure_blocking, collect_plp_bytes_blocking, resolve_header_token_blocking, decode_blocking_async_column, and drive_row_over_buffer_blocking (token_stream.rs) — the async row driver loop minus awaits, calling the identical step_row.
  • BlockingPacketReader shell (blocking_reader.rs) — buffer-owning reader whose refill blocks on a BlockingByteSource.

Tests (named)

  • blocking_driver_matches_async_oracle_across_refill_boundary — mixed int4 + varchar + multi-chunk varbinary(max) PLP; refill boundary swept across every offset; byte-identical vs async oracle.
  • blocking_driver_nbcrow_matches_async_oracle_across_refill_boundary — NBCROW, two-byte bitmap split swept.
  • blocking_driver_truncation_errors_identically_to_async_oracle — truncation/underflow parity (identical error).
  • blocking_driver_multichunk_plp_residency_ceiling — >16384 B varbinary(max) LOB; byte-identical and bounded peak_length() residency (<= 2x max_packet, < payload.len()).

Gates

  • Public-API diff on tds_client.rs + cursor_ops.rs vs L2 tip: empty. No new non-pub(crate) pub.
  • 7-cert nextest baseline preserved exactly (1718 run, 1711 passed, 7 failed = certificate_validator 4 + win_tls::validate 3).
  • cargo bfmt / cargo bclippy / scripts\bfmt.ps1 / scripts\bclippy.ps1 clean.

Draft; do not merge.

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

Copilot-Session: e2c378f8-3ba1-4b48-9ebe-5a4ea2bd2761
@saurabh500
Saurabh Singh (saurabh500) force-pushed the dev/saurabh/sans-io-expose-l3-blocking-driver branch from b17263c to 7e11a11 Compare August 9, 2026 22:02
@saurabh500
Saurabh Singh (saurabh500) marked this pull request as ready for review August 10, 2026 06:38
Copilot AI balanced review requested due to automatic review settings August 10, 2026 06:38
@saurabh500
Saurabh Singh (saurabh500) requested a review from a team as a code owner August 10, 2026 06:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an internal blocking row-decoding path that reuses the existing synchronous parsing core.

Changes:

  • Adds blocking packet assembly and buffered reading.
  • Adds blocking row, token, and PLP drivers.
  • Adds async/blocking parity and residency tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
mssql-tds/src/io/token_stream.rs Adds blocking decoding logic and differential tests.
mssql-tds/src/io/byte_source.rs Adds the blocking byte-source seam and packet assembler.
mssql-tds/src/io/blocking_reader.rs Implements the blocking packet reader.
mssql-tds/src/io.rs Registers the new internal module.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +945 to +953
let total = match sync_token::body_len(reader.row_buffer_mut(), &token_type) {
Ok(total) => total,
Err(_) => {
reader.refill_row_buffer_blocking()?;
continue;
}
};
if reader.row_buffer_mut().ensure(total).is_err() {
reader.refill_row_buffer_blocking()?;
Comment on lines +993 to +998
match collect_plp_bytes_blocking(reader)? {
Some(bytes) => writer.write_bytes(col, bytes),
None => writer.write_null(col),
}

if writer.pause_after_column(col) && col + 1 < len {
@saurabh500
Saurabh Singh (saurabh500) marked this pull request as draft August 10, 2026 06:49
@saurabh500
Saurabh Singh (saurabh500) marked this pull request as ready for review August 10, 2026 07:39
@saurabh500
Saurabh Singh (saurabh500) marked this pull request as draft August 10, 2026 13:28
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.

2 participants