Skip to content

Conversation

@erykwalder
Copy link
Contributor

@erykwalder erykwalder commented Mar 15, 2018

According to https://godoc.org/database/sql/driver#Rows, the Close
operation should not affect the values returned by Next. In normal flow,
this is not an issue, but if Rows is closed by a cancelled context or
another routine, it can be.

This changes the scratch to be a slice, and changes its memory location
when rows are closed before they are done, so that any scanning will not
be affected.

In an attempt to prevent allocations every time the rows are closed,
this only creates a new scratch when rows are closed before they
are done.

According to https://godoc.org/database/sql/driver#Rows, the Close
operation should not affect the values returned by Scan. In normal flow,
this is not an issue, but if Rows is closed by a cancelled context or
another routine, it can be.

This changes the scratch to be a slice, and changes its memory location
when rows are closed before they are done, so that any scanning will not
be affected.
@arp242 arp242 added bug needs-test Needs a test before it can be merged labels Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug needs-test Needs a test before it can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants