You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fewer driver.ErrBadConn to prevent repeated queries (#302)
According to the database/sql/driver documentation, ErrBadConn should only
be used when the database was not affected. The driver restarts the same
query on a different connection, then.
The mysql driver did not follow this advice, so queries were repeated if
ErrBadConn is returned but a query succeeded.
This is fixed by changing most ErrBadConn errors to ErrInvalidConn.
The only valid returns of ErrBadConn are at the beginning of a database
interaction when no data was sent to the database yet.
Those valid cases are located the following funcs before attempting to write
to the network or if 0 bytes were written:
* Begin
* BeginTx
* Exec
* ExecContext
* Prepare
* PrepareContext
* Query
* QueryContext
Commit and Rollback could arguably also be on that list, but are left out as
some engines like MyISAM are not supporting transactions.
Tests in b/packets_test.go were changed because they simulate a read not
preceded by a write to the db. This cannot happen as the client has to send
the query first.
0 commit comments