]> Cypherpunks repositories - gostls13.git/commit
database/sql: ensure Stmts are correctly closed.
authorGwenael Treguier <gwenn.kahz@gmail.com>
Sat, 10 Mar 2012 23:21:44 +0000 (15:21 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 10 Mar 2012 23:21:44 +0000 (15:21 -0800)
commitc3954dd5da820306dff6bbd73a7801d9739b038f
treef04ce21d78b1599a90da8993f59d9db455109237
parent959d0c7ac0091513fc1a2e53834d027430122ee8
database/sql: ensure Stmts are correctly closed.

To make sure that there is no resource leak,
I suggest to fix the 'fakedb' driver such as it fails when any
Stmt is not closed.
First, add a check in fakeConn.Close().
Then, fix all missing Stmt.Close()/Rows.Close().
I am not sure that the strategy choose in fakeConn.Prepare/prepare* is ok.
The weak point in this patch is the change in Tx.Query:
  - Tests pass without this change,
  - I found it by manually analyzing the code,
  - I just try to make Tx.Query look like DB.Query.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5759050
src/pkg/database/sql/fakedb_test.go
src/pkg/database/sql/sql.go
src/pkg/database/sql/sql_test.go