regression test + mysql2 adapter raises correct error if conn is closed.

While investigating the issue described in #10917 I found that it was already solved by 0d63cda however the fix did not add a test-case to prevent regressions from sneaking in.

When I added a test-case I found out that not only the postgresql adapter had a problem but also the mysql2 one, which hasn't been fixed.

This PR adds both a regression test and a fix for the mysql2 adapter.