database/sql: prevent ErrBadConn from driver.Open() #35191
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
because it seems this error is only meant to be internal, and if
ErrBadConn
is returned from here it can also be returned from the public api.See some confusion about this here: go-sql-driver/mysql#1020
And a fix in the postgres driver here: lib/pq@04c77ed
If we already had this check a while back, then go-sql-driver/mysql#867 would never have been accepted and we'd have gone down the route of a custom dial function, preventing the concern now that users of https://github.com/go-sql-driver/mysql will start seeing higher error rates if the PR is reverted.