go-sql-driver/mysql — pull request #143 by arnehormann (2013-10-29 11:17:49+00:00)
Title: no panic on closed connection reuse

Closes https://github.com/go-sql-driver/mysql/issues/142

I'm not sure if this is good to go yet. The test should probably be expanded, it doesn't test all cases I fixed.
Let's take it as a basis for a discussion.

I didn't see a central place to add the checks and I'm not sure if I missed some relevant ones.

How this was created:
I located the places to fix by searching for `mysql(Stmt|Conn|Tx|Rows)\) [A-Z]` in all go files. Those are the only structs containing (or beeing) `mysqlConn`, the exported functions as entry points should suffice for the check and make sure it's not "overchecked".

I changed the `mc.netConn` checks to `mc.buf` in existing code to keep the checked condition the same everywhere. I did not check the disassembled object code for this being faster than comparing `mc.netConn == nil` or writing a small func which is or is not inlined.