Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rows.Close() is not required #2170

Closed
gromas opened this issue Nov 21, 2024 · 2 comments
Closed

rows.Close() is not required #2170

gromas opened this issue Nov 21, 2024 · 2 comments

Comments

@gromas
Copy link

gromas commented Nov 21, 2024

pgx/rows.go

Line 471 in b9e2b20

rows.Close()

rows.Close() is not required while we have defer rows.Close() above

@felix-roehrich
Copy link
Contributor

rows.Close() may change the result of rows.Err() so this is not equivalent, rather with this an error may go unnoticed.

@jackc
Copy link
Owner

jackc commented Nov 29, 2024

rows.Close() may change the result of rows.Err() so this is not equivalent, rather with this an error may go unnoticed.

This is correct. From the docs for Rows.Err():

Err must only be called after the Rows is closed

@jackc jackc closed this as completed Nov 29, 2024
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

No branches or pull requests

3 participants