mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
database/sql: fix typo bug resulting in double-Prepare
Bug reported by Blake Mizerany found while writing his new Postgres driver. R=golang-dev, blake.mizerany CC=golang-dev https://golang.org/cl/5754057
This commit is contained in:
parent
97b13acb67
commit
48eacd90a8
3 changed files with 17 additions and 2 deletions
|
|
@ -82,6 +82,7 @@ type fakeConn struct {
|
|||
mu sync.Mutex
|
||||
stmtsMade int
|
||||
stmtsClosed int
|
||||
numPrepare int
|
||||
}
|
||||
|
||||
func (c *fakeConn) incrStat(v *int) {
|
||||
|
|
@ -339,6 +340,7 @@ func (c *fakeConn) prepareInsert(stmt *fakeStmt, parts []string) (driver.Stmt, e
|
|||
}
|
||||
|
||||
func (c *fakeConn) Prepare(query string) (driver.Stmt, error) {
|
||||
c.numPrepare++
|
||||
if c.db == nil {
|
||||
panic("nil c.db; conn = " + fmt.Sprintf("%#v", c))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue