Skip to content

Commit 8446d16

Browse files
authored
issue 1062: Keep track of (context cancelled) error on connection, and make rows.Next return it (#1064)
* add reproducer for issue 1062 see #1062 * Keep track of an error for a connection. Instead of just whether the connection is ErrBadConn. Often times, the error will still be ErrBadConn. But for expired/cancelled contexts, it will be the error for the context. Most functions still return ErrBadConn per the database/sql/driver contract ("ErrBadConn should only be returned from [...] a query method"). For rows.Next() we return the context-related error. The database/sql/driver contract doesn't look very precise. Is Next a "query method" and should database/sql handle ErrBadConns when Next returns them? Do we have more functions that should return the canceled-context error message? * in test for QueryRowContext, fail for all unexpected errors, not just for the one unexpected error * in TestContextCancel*, accept context.Canceled as valid error * explicitly test for driver.ErrBadConn in test that breaks the connection feedback from otan * move the mutex-protected data in a struct with the mutex, and fix an unsafe usage. there may be unsafeness in this file. feedback from otan
1 parent 6a102c0 commit 8446d16

7 files changed

+155
-130
lines changed

0 commit comments

Comments
 (0)