]> Cypherpunks repositories - gostls13.git/commitdiff
database/sql: clarify when statement in transaction is closed
authorIan Lance Taylor <iant@golang.org>
Wed, 16 Nov 2016 01:14:13 +0000 (17:14 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 16 Nov 2016 16:04:18 +0000 (16:04 +0000)
Fixes #16346.

Change-Id: Ie75a4ae7011036dd2c1f121a7a5e38d10177721e
Reviewed-on: https://go-review.googlesource.com/33296
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/database/sql/sql.go

index 43227e92eac3ede8334656e2df82056c6a041565..d3803e85c3a9482b2fe9129b7b356094a00042fb 100644 (file)
@@ -1436,8 +1436,8 @@ func (tx *Tx) Rollback() error {
 
 // Prepare creates a prepared statement for use within a transaction.
 //
-// The returned statement operates within the transaction and can no longer
-// be used once the transaction has been committed or rolled back.
+// The returned statement operates within the transaction and will be closed
+// when the transaction has been committed or rolled back.
 //
 // To use an existing prepared statement on this transaction, see Tx.Stmt.
 //
@@ -1506,8 +1506,8 @@ func (tx *Tx) Prepare(query string) (*Stmt, error) {
 //  ...
 //  res, err := tx.StmtContext(ctx, updateMoney).Exec(123.45, 98293203)
 //
-// The returned statement operates within the transaction and can no longer
-// be used once the transaction has been committed or rolled back.
+// The returned statement operates within the transaction and will be closed
+// when the transaction has been committed or rolled back.
 func (tx *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt {
        // TODO(bradfitz): optimize this. Currently this re-prepares
        // each time. This is fine for now to illustrate the API but
@@ -1551,8 +1551,8 @@ func (tx *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt {
 //  ...
 //  res, err := tx.Stmt(updateMoney).Exec(123.45, 98293203)
 //
-// The returned statement operates within the transaction and can no longer
-// be used once the transaction has been committed or rolled back.
+// The returned statement operates within the transaction and will be closed
+// when the transaction has been committed or rolled back.
 func (tx *Tx) Stmt(stmt *Stmt) *Stmt {
        return tx.StmtContext(context.Background(), stmt)
 }