Skip to content

Conversation

petrosagg
Copy link
Contributor

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.

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 blackbeam/rust_mysql_common#136

If we haven't completed the hashshake the server will not be aware of our
capabilities and so its will packets behave as if we have none. This is necessary to
correcly parse an initial error packet which never contains an SQL State field even
if the client capabilities will eventually contain CLIENT_PROTOCOL_41.

https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase.html

Signed-off-by: Petros Angelatos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: Initial error packet ignored after #114
2 participants