-
Notifications
You must be signed in to change notification settings - Fork 795
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
Not clear if caller is required to close in case of QueryRow or if QueryRow properly closes in case of error #274
Comments
For example, in the native
|
|
Thanks @jackc . So then you're confirming that I do not need to close when I use the Could I add this to the godoc or README to make it more explicit for others? Thanks again! |
Correct, you do not need to call |
Fair enough. It's just that I was in the habit of either Now that I understand, I'm fine with leaving it out of the godoc if you prefer. Closing. Thanks again for your help, much appreciated! |
Had the same query, probably we should mention that we don't have to explicitly close rows while using QueryRow |
Same |
Hi,
Thanks for pgx - it's awesome and I'm really enjoying using it.
I'm trying to be paranoid about closing connections (good) to prevent potential resource leaks, but it's not clear to me if I'm required to call close after using pgx's
QueryRow("").Scan()
combination of methods?For example, in your godoc example, I see:
However, when I look at the implementation of
Row.Scan
here, it's not clear to me that it closes theRows
object properly in case of error:I could totally be missing something, sorry if I am, but I don't see how
rows
is closed properly if there's an error returned before the close is reached at the bottom. Why not defer the close at the top of theScan
method implementation.If the idiom is to write
QueryRow("").Scan()
then I don't ever access the underlyingRows
object, so I have no real ability to close it cleanly.What do you think?
Thanks!
The text was updated successfully, but these errors were encountered: