-
Notifications
You must be signed in to change notification settings - Fork 18k
database/sql: driver.Statement may not be close #42205
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
Comments
CC @kardianos |
@coderYPG I'm not seeing why two stmts were created. Can you also print the SQL associated with each statement on |
I think i can explain it. DB.prepareDC prepare a driverStmt with a connection, and release(line 1503) the connection immediately.
but i don't see any call or hook to close the latter driverStmt. |
What happens when you statements should close after a time I believe, esp if you put time limits on open connections. I'm not saying it is great, I don't like how prepared statements are designed in general, but I'm not sure if there is a bug here. |
db.Close() not work. I found tutorial has mention this problem
|
@coderYPG I can explain this: conn 1 is opened when PrepareContext is ran. In the above code, conn 1 is never returned. This is working as intended. Below is code that can run in sql_test.go in the std library.
If you switch releaseConn = false, then the test will fail because almost every unit test checks for pending connections. When the conn doesn't return, it raises a flag. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
modify mysqlConn.PrepareContext
and mysqlStmt.Close
and run code below
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: