New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
database/sql: dangling statement(s) #3865
Labels
Milestone
Comments
The Rows (r) associated to the Stmt (s) isn't closed before the call to s.Close() preventing the underlying driver.Stmt from being closed. But there is no error raised in this case. If a fix is made to raise an error on s.Close(), the test will still fail. So I suggest to fix the test instead and call r.Close() before s.Close(). Or maybe the Rows associated to the Stmt should be closed automatically when the Stmt is closed. |
Did you read database/sql/driver/Stmt.Close documentation? From http://golang.org/pkg/database/sql/driver/#Stmt: >>> // Closing a statement should not interrupt any outstanding // query created from that statement. That is, the following // order of operations is valid: // // * create a driver statement // * call Query on statement, returning Rows // * close the statement // * read from Rows // <<< I think my test here is fine. Alex |
I tried. Probably, too hard. http://code.google.com/p/odbc/source/browse/mssql_test.go#582 Alex |
This issue was updated by revision 8f2430a. R=golang-dev, alex.brainman, nightlyone CC=golang-dev https://golang.org/cl/7324051 |
CL out for review: https://golang.org/cl/7363043 Status changed to Started. |
This issue was closed by revision f7a7716. Status changed to Fixed. |
Brad, This little test diff --git a/src/pkg/database/sql/sql_test.go b/src/pkg/database/sql/sql_test.go --- a/src/pkg/database/sql/sql_test.go +++ b/src/pkg/database/sql/sql_test.go @@ -708,3 +708,17 @@ t.Errorf("error = %q; want %q", err.Error(), want) } } + +func TestALEX(t *testing.T) { + db := newTestDB(t, "people") + defer closeDB(t, db) + stmt, err := db.Prepare("INSERT|people|name=?,age=?") + if err != nil { + t.Fatal(err) + } + defer stmt.Close() + _, err = stmt.Exec("Alice", 10) + if err != nil { + t.Fatal(err) + } +} always creates two driver connections. stmt.Close closes only one of those. Is this expected? It feels wrong to me on both counts. Alex |
alexbrainman
added
fixed
Suggested
Issues that may be good for new contributors looking for work to do.
labels
Feb 24, 2013
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
The text was updated successfully, but these errors were encountered: