go-sql-driver / mysql

Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package
https://pkg.go.dev/github.com/go-sql-driver/mysql
Mozilla Public License 2.0
14.46k stars 2.3k forks source link

Question: why is ErrInvalidConn returned for all network read error? #1269

Closed ideascf closed 1 year ago

ideascf commented 2 years ago

Reading the code(https://github.com/go-sql-driver/mysql/blob/master/packets.go#L39), all network read errors are replaced by ErrInvalidConn. Can we distinguish read/write timeout from other errors? Is there a reason for the design here?

PS: sometime, we need to known there is a client read timeout error or server-side error

archzkt commented 2 years ago

I had the same problem, I submitted a pull request, but not sure this will eventually be merged into master

1348

methane commented 1 year ago

https://dave.cheney.net/2014/12/24/inspecting-errors

https://www.amazon.com/Philosophy-Software-Design-2nd-ebook/dp/B09B8LFKQL/ref=tmm_kin_swatch_0?_encoding=UTF8&qid=1685252148&sr=8-1 is also good book.

You must not think like "why is this hidden?". You must think like "why is this needed to be exposed?".

PS: sometime, we need to known there is a client read timeout error or server-side error

This can not be enough reason to make "information leakage".