feat(ok): add correct handling of ok packets in MYSQL implementation #3910
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.
As per the Mysql documentation, OK and EOF packets have the following structure
OK: header = 0 and length of packet >= 7
EOF: header = 0xfe and length of packet < 8
Right now we are checking to see if the packet is smaller than 9 which is fine for most cases however there are some projects that implement the MySQL protocol which include information in the packet (e.g query speed, rows returned in human readable text)
https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_ok_packet.html
For example in the project manticore https://github.com/manticoresoftware/manticoresearch (Which is why I found this bug) their ok packet to designate the end of the data will include more information. This would result in sqlx treating the the OK packet as a text field due to the fact that the length is larger than 8.
There is a larger deep dive in the manticore project here but the gist is that the current decoder skips the optional info field in valid mysql ok packets