Skip to content

Reset the Rows field cache on NextResultSet (upstream #858). - #19

Merged
avgvi merged 3 commits into
masterfrom
fix/380-next-result-set
Oct 11, 2026
Merged

avgvi merged 3 commits into
masterfrom
fix/380-next-result-set

Conversation

@avgvi

@avgvi avgvi commented Oct 11, 2026

Copy link
Copy Markdown
Member

Merges upstream jmoiron/sqlx#858 by Kamil Akhmetov with its original commit: Rows froze its field mapping at the first StructScan, so scanning a second result set with a different column layout panicked with reflect: Field index out of range. NextResultSet now clears the cache. Fixes upstream #380 and #857. The test comes from upstream #747 by Peter Magnusson and runs on Postgres and MySQL (SQLite has no multiple result sets). One import-line conflict with the Go 1.24 change was resolved by keeping master.

Local run with Postgres 16, MySQL 8.4 and SQLite: 88 pass, 3 skip, 0 fail.

kamilkoduo and others added 3 commits April 12, 2023 17:32
When reading multiple result sets from sqlx.Rows using StructScan,
some information obtained usCCCing costly reflect operations is
cached for performance optimisation.
However, different result sets in a single sqlx.Rows object might
have different structures, so cache should be invalidated and rebuild
after each NextResultSet call. Now this method is not overwritten,
so old cache interferes with new structures after first result set scan.

Relates #857
@avgvi
avgvi merged commit 50ca638 into master Oct 11, 2026
6 checks passed
@avgvi
avgvi deleted the fix/380-next-result-set branch October 11, 2026 04:19
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