Skip to content

Add RowsColumnScanner support (Go 1.27+)#1773

Draft
Copilot wants to merge 4 commits into
masterfrom
copilot/support-rows-column-scanner
Draft

Add RowsColumnScanner support (Go 1.27+)#1773
Copilot wants to merge 4 commits into
masterfrom
copilot/support-rows-column-scanner

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 27, 2026

Implements the driver.RowsColumnScanner interface introduced in Go 1.27, which allows drivers to scan row data directly into user-provided destinations, bypassing the intermediate driver.Value allocation path.

Changes

  • rows.go: Reverted to original (no build tag). Adds rawCols [][]byte to mysqlRows for use by the RowsColumnScanner implementation. Unused struct fields are permitted by Go, so no build constraint is needed.
  • rows_column_scanner.go (//go:build go1.27): Implements the interface for both row types without calling readRow():
    • (*textRows).NextRow() — reads the packet and stores raw length-encoded byte slices (subslices of the packet buffer) into rawCols, with no intermediate []driver.Value allocation.
    • (*binaryRows).NextRow() — reads the packet, processes the null bitmap, and extracts per-column byte subslices based on the binary wire format into rawCols.
    • (*textRows).ScanColumn(scanCtx, i, dest) — fast paths for *[]byte/*sql.RawBytes, then parses bytes by fieldType and delegates to sql.ConvertAssign.
    • (*binaryRows).ScanColumn(scanCtx, i, dest) — parses binary wire bytes per fieldType (little-endian integers, IEEE-754 floats, length-encoded strings, binary date/time) and calls sql.ConvertAssign directly.

The key allocation benefit: rawCols is allocated once as [][]byte and reused across rows, while each element is a zero-copy subslice of the packet buffer. No []driver.Value is allocated per row. sql.RawBytes destinations receive zero-copy access to the packet buffer.

When Go 1.27+ is used, database/sql automatically prefers NextRow + ScanColumn over Next([]driver.Value). For older Go versions, behavior is unchanged.

Copilot AI linked an issue May 27, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add support for RowsColumnScanner Add RowsColumnScanner support (Go 1.27+) May 27, 2026
Copilot AI requested a review from methane May 27, 2026 09:18
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 82.731% (-0.07%) from 82.804% — copilot/support-rows-column-scanner into master

Comment thread rows.go Outdated
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.

Support RowsColumnScanner

3 participants