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

database/sql: clarify docs for Tx.Stmt().Close() #16346

fxposter opened this issue Jul 13, 2016 · 1 comment

database/sql: clarify docs for Tx.Stmt().Close() #16346

fxposter opened this issue Jul 13, 2016 · 1 comment


Copy link

@fxposter fxposter commented Jul 13, 2016

Tx.Stmt() example (

// res, err := tx.Stmt(updateMoney).Exec(123.45, 98293203)
) shows the following code:

res, err := tx.Stmt(updateMoney).Exec(123.45, 98293203)

Looking at that code I assume there is no need to explicitly close the Stmt returned from tx.Stmt(updateMoney) because example does not even store references to it.

On the other hand, tests (

defer txs.Close()
defer txs.Close()
) are explicitly closing that Stmt.

So I wonder - is there an actual need to .Close() the prepared statements returned from tx.Stmt() or rollback/commit will close them automatically?

/cc @bradfitz

@josharian josharian changed the title Documentation bug(?): database/sql's Tx.Stmt().Close() database/sql: clarify docs for Tx.Stmt().Close() Jul 13, 2016
@josharian josharian added this to the Go1.8 milestone Jul 13, 2016
Copy link

@gopherbot gopherbot commented Nov 16, 2016

CL mentions this issue.

@gopherbot gopherbot closed this in b75b9e1 Nov 16, 2016
@golang golang locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.