Skip to content
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) #5936

Closed
alexbrainman opened this issue Jul 23, 2013 · 1 comment
Closed

database/sql: dangling statement(s) #5936

alexbrainman opened this issue Jul 23, 2013 · 1 comment

Comments

@alexbrainman
Copy link
Member

@alexbrainman alexbrainman commented Jul 23, 2013

Discovered while investigating https://code.google.com/p/odbc/issues/detail?id=12

If I add this:

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
@@ -1046,6 +1046,20 @@
    }
 }
 
+func TestStmtCloseOrder(t *testing.T) {
+   db := newTestDB(t, "people")
+   defer closeDB(t, db)
+
+   db.SetMaxIdleConns(0)
+   setStrictFakeConnClose(t)
+   defer setStrictFakeConnClose(nil)
+
+   _, err := db.Query("SELECT|non_existent|name|")
+   if err == nil {
+       t.Fatal("Quering non-existent table should fail")
+   }
+}
+
 func manyConcurrentQueries(t testOrBench) {
    maxProcs, numReqs := 16, 500
    if testing.Short() {

then test fails with

# go test                                                                    
--- FAIL: TestStmtCloseOrder (0.00 seconds)                                          
        fakedb_test.go:257: failed to close a test fakeConn: can't close; dangling statement(s)                                                                           
FAIL                                                                                 
exit status 1                                                                        
FAIL    database/sql    0.179s                                                       
# hg id                                                                      
e6a6dc0d9c22+ tip                                                                    
#                                                                            

I am not familiar with source code, but I think https://golang.org/cl/11620046
should fix the problem.

Alex
@alexbrainman
Copy link
Member Author

@alexbrainman alexbrainman commented Jul 23, 2013

Comment 1:

This issue was closed by revision a293065.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.