]> Cypherpunks repositories - gostls13.git/commit
database/sql: ensure all driver interfaces are called under single lock
authorDaniel Theophanes <kardianos@gmail.com>
Tue, 17 Oct 2017 22:59:56 +0000 (15:59 -0700)
committerDaniel Theophanes <kardianos@gmail.com>
Wed, 25 Oct 2017 17:21:58 +0000 (17:21 +0000)
commit1126d1483f0397648905fcd4590ae45352cabd69
treec7f08a5cde9cad26e82d8b8a434dbebee1b4071b
parent986582126a371ff927182ba6e61e364c1341171a
database/sql: ensure all driver interfaces are called under single lock

Russ pointed out in a previous CL golang.org/cl/65731 that not only
was the locking incomplete, previous changes did not correctly
lock driver calls in other sections. After inspecting
driverConn, driverStmt, driverResult, Tx, and Rows structs
where driver interfaces are stored, I discovered a few more places
that failed to lock driver calls. The largest of these
was the parameter type converter "driverArgs".

driverArgs was typically called right before another call to the
driver in a locked region, so I made the entire driverArgs expect
a locked driver mutex and combined the region. This should not
be a problem because the connection is pulled out of the connection
pool either way so there shouldn't be contention.

Fixes #21117

Change-Id: I88d46f74dca25fb11a30f0bf8e79785a73133d23
Reviewed-on: https://go-review.googlesource.com/71433
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/database/sql/convert.go
src/database/sql/convert_test.go
src/database/sql/fakedb_test.go
src/database/sql/sql.go
src/database/sql/sql_test.go