Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2df7a26

Browse files
authored
stmt.Close() returns nil when double close (#1642)
ErrBadConn needs special care to ensure it is safe to retry. To improve maintenance, I don't want to use the error where I don't have to. Additionally, update the old comment about Go's bug that had been fixed long time ago.
1 parent 9c8d6a5 commit 2df7a26

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

‎statement.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ type mysqlStmt struct {
2424

2525
func (stmt *mysqlStmt) Close() error {
2626
if stmt.mc == nil || stmt.mc.closed.Load() {
27-
// driver.Stmt.Close can be called more than once, thus this function
28-
// has to be idempotent.
29-
// See also Issue #450 and golang/go#16019.
30-
//errLog.Print(ErrInvalidConn)
31-
return driver.ErrBadConn
27+
// driver.Stmt.Close could be called more than once, thus this function
28+
// had to be idempotent. See also Issue #450 and golang/go#16019.
29+
// This bug has been fixed in Go 1.8.
30+
// https://github.com/golang/go/commit/90b8a0ca2d0b565c7c7199ffcf77b15ea6b6db3a
31+
// But we keep this function idempotent because it is safer.
32+
return nil
3233
}
3334

3435
err := stmt.mc.writeCommandPacketUint32(comStmtClose, stmt.id)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /