Skip to content

Add RowsColumnScanner support (Go 1.27+)#1773

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

Add RowsColumnScanner support (Go 1.27+)#1773
Copilot wants to merge 3 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 (//go:build go1.27): Contains the full mysqlRows struct (with currentRow []driver.Value field to cache decoded values for the current row) plus all existing row methods and the new RowsColumnScanner implementation:
    • (*binaryRows).NextRow() / (*textRows).NextRow() — reads the next row into currentRow, reallocating only when column count changes (e.g. after NextResultSet)
    • (*mysqlRows).ScanColumn(scanCtx, i, dest) — delegates to sql.ConvertAssign with a bounds check
  • rows_before_go127.go (//go:build !go1.27): Contains the original mysqlRows struct and all existing row methods for pre-1.27 builds (no RowsColumnScanner support).

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
mc *mysqlConn
rs resultSet
finish func()
currentRow []driver.Value // used by RowsColumnScanner (Go 1.27+)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot Go <1.27 で currentRow が使われていないというエラーになります。
rows_column_scanner.go を作るのをやめて、 rows.go の中で実装してください。
Go <1.27 で使われない関数があるのは気にしません。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in the latest commit. Since driver.ScanContext only exists in Go 1.27+, rows.go now carries //go:build go1.27 and contains all rows code plus the NextRow/ScanColumn methods. A new rows_before_go127.go with //go:build !go1.27 covers pre-1.27 builds (same structure as the existing conncheck.go / conncheck_dummy.go pattern). rows_column_scanner.go has been deleted.

Copilot AI requested a review from methane May 27, 2026 09:52
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