During the initial handshake there is the possibility that the server replies with an error. Since this happens before the server has seen a HandshakeResponse it cannot assume anything about our capabilities and therefore its error packet will be sent as if we have none. This means that even if our client has the CLIENT_PROTOCOL_41 flag set it must parse this initial error packet as if it doesn't, which basically boils down to not expecting a SQL state field.
This PR is made up of two commits. The first is a unit test that sets up a fake MySQL server that replies with an error packet. The test is verified to fail on current main. The second commit adds a fix for correctly parsing those initial error packets and makes the test pass.
During the initial handshake there is the possibility that the server replies with an error. Since this happens before the server has seen a
HandshakeResponse
it cannot assume anything about our capabilities and therefore its error packet will be sent as if we have none. This means that even if our client has theCLIENT_PROTOCOL_41
flag set it must parse this initial error packet as if it doesn't, which basically boils down to not expecting a SQL state field.This PR is made up of two commits. The first is a unit test that sets up a fake MySQL server that replies with an error packet. The test is verified to fail on current main. The second commit adds a fix for correctly parsing those initial error packets and makes the test pass.
The behavior of the initial error packet is documented in the "Note:" section here: https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase.html
Closes https://github.com/blackbeam/rust_mysql_common/issues/136