Add RowsColumnScanner support (Go 1.27+)#1773
Draft
Copilot wants to merge 4 commits into
Draft
Conversation
Copilot
AI
changed the title
[WIP] Add support for RowsColumnScanner
Add RowsColumnScanner support (Go 1.27+)
May 27, 2026
methane
reviewed
May 27, 2026
…r without readRow()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the
driver.RowsColumnScannerinterface introduced in Go 1.27, which allows drivers to scan row data directly into user-provided destinations, bypassing the intermediatedriver.Valueallocation path.Changes
rows.go: Reverted to original (no build tag). AddsrawCols [][]bytetomysqlRowsfor 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 callingreadRow():(*textRows).NextRow()— reads the packet and stores raw length-encoded byte slices (subslices of the packet buffer) intorawCols, with no intermediate[]driver.Valueallocation.(*binaryRows).NextRow()— reads the packet, processes the null bitmap, and extracts per-column byte subslices based on the binary wire format intorawCols.(*textRows).ScanColumn(scanCtx, i, dest)— fast paths for*[]byte/*sql.RawBytes, then parses bytes byfieldTypeand delegates tosql.ConvertAssign.(*binaryRows).ScanColumn(scanCtx, i, dest)— parses binary wire bytes perfieldType(little-endian integers, IEEE-754 floats, length-encoded strings, binary date/time) and callssql.ConvertAssigndirectly.The key allocation benefit:
rawColsis allocated once as[][]byteand reused across rows, while each element is a zero-copy subslice of the packet buffer. No[]driver.Valueis allocated per row.sql.RawBytesdestinations receive zero-copy access to the packet buffer.When Go 1.27+ is used,
database/sqlautomatically prefersNextRow+ScanColumnoverNext([]driver.Value). For older Go versions, behavior is unchanged.