I looked through the code some more, and I think these lines are where the 
connector should close/wait for outstanding connections to be finished.

https://github.com/golang/go/blob/d36e88f21f56dcf45fed2231fe28f948a31c936b/src/database/sql/sql.go#L951C1-L956C3

I would assume this is the connector’s responsibility as long as it implements 
io.Closer.

I have’t run anything through we I could break point and see what’s going on.

I look through the other structures and it certainly seems like closing and 
waiting (for statements on each connection to be done) is a responsibility.

But the stblib test case would fail if there were open connections are the 
close, based on these:

https://github.com/golang/go/blob/5cd1b73772e339e3b460d53ba37630704a323ca7/src/database/sql/sql_test.go#L176C2-L182C3


> On Nov 6, 2025, at 7:19 PM, Toby Allsopp <[email protected]> wrote:
> 
> On Friday, 7 November 2025 at 14:01:50 UTC+13 robert engels wrote:
> I reviewed the stdlib a bit more, and the driver connection is the “db 
> connection” (upon which statements are run - these are handed out) and these 
> are tracked:
> 
> https://github.com/golang/go/blob/ad3ccd92e4c2ddfc1499a5e038eb0aa0012c0dda/src/database/sql/sql.go#L1447
> 
> https://github.com/golang/go/blob/ad3ccd92e4c2ddfc1499a5e038eb0aa0012c0dda/src/database/sql/sql.go#L750
> 
> 
> Yes, that's true, the DB does track the connections that have been handed 
> out. So it could, if it wanted, do something with them during DB.Close. But 
> it doesn't, unless I'm missing something.
> 
> Is it your contention that there is an issue with the particular driver I'm 
> using in my experiments? I'm a little confused about how the dependency 
> tracking that you linked to is connected to your earlier statement "I think 
> it is driver issue".
> 
> Can you connect the dots for me please?
> 
> Thanks,
> Toby.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion visit 
> https://groups.google.com/d/msgid/golang-nuts/9653482e-8bea-4135-b092-cb449acbeda1n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/golang-nuts/9653482e-8bea-4135-b092-cb449acbeda1n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/8D7A1C40-9AA2-482F-8C43-B70A42120C9B%40ix.netcom.com.

Reply via email to