[+] teach Rows.CloseError to set the error#241
Merged
pashagolub merged 1 commit intopashagolub:masterfrom Aug 19, 2025
Merged
Conversation
`Rows.Close` doesn't return an error, so up to now `Rows.CloseError` was a no-op. However, pgx's `Rows.Err` can return an error after `Rows.Next` returns false, or after `Rows.Close` has been called. Add `rowSets.close()` to mark the current rows closed, jump the record number to the last row, and to set the close error for that row. Then have `rowSets.Close()` call it and `rowSets.Next()` call it once it has processed the last row. These changes cause both `Rows.Err` and `Rows.Scan` to return the close error once it has been set. Add tests for this behavior. While at it, have `Rows.Scan` return immediately when the rows have been closed, rather than carrying out all the scanning. Add tests to test these behaviors. Fixes pashagolub#238. Authors: * asayapini <asayapini@ozon.ru> * David E. Wheeler <david@justatheory.com>
Rows.CloseError to set the error
Owner
|
Thanks! |
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.
Rows.Closedoesn't return an error, so up to nowRows.CloseErrorwas a no-op. However, pgx'sRows.Errcan return an error afterRows.Nextreturns false, or afterRows.Closehas been called.Add
rowSets.close()to mark the current rows closed, jump the record number to the last row, and to set the close error for that row. Then haverowSets.Close()call it androwSets.Next()call it once it has processed the last row. These changes cause bothRows.ErrandRows.Scanto return the close error once it has been set. Add tests for this behavior.While at it, have
Rows.Scanreturn immediately when the rows have been closed, rather than carrying out all the scanning.Add tests to test these behaviors.
Fixes #238.
Authors: