Repository navigation
Phase 3: run statements with COM_QUERY - #8
Merged
Merged
Conversation
The command itself is one byte and the SQL, since CLIENT_QUERY_ATTRIBUTES is not claimed. The work is in the response, whose first byte decides everything: 0x00 an OK for a statement that returned no rows, 0xFF an error, 0xFB the server asking the client to upload a file, anything else a length-encoded column count introducing a resultset. Commands reset the sequence id, so the statement goes out as 0 and the reply arrives as 1 — the tracking phase 1 deliberately left until there was a command to track it across. A resultset returns :resultset_not_implemented rather than a guess. The integration test asserts that too, so the gap is visible rather than implied. 0xFB is refused outright. CLIENT_LOCAL_FILES is not claimed, so a server asking for a file is either broken or hostile, and the answer is not to read the filesystem. Against a real MySQL 8.0 this creates a table, inserts rows and gets their AUTO_INCREMENT ids back, reports rows matched for an update, and returns the server's own error for a missing table.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Every statement that returns no rows now works end to end against a real server —
INSERT,UPDATE,DELETE,CREATE,DROP,SET,USE.58 tests with
--include integration; 50 and 4 excluded without.The command is trivial, the response is the work
COM_QUERYis one byte and the SQL, sinceCLIENT_QUERY_ATTRIBUTESis not claimed. Its response is decided entirely by the first byte:What to look at
0xFBis refused outright.CLIENT_LOCAL_FILESis not claimed, so a server asking the client to upload a file is either broken or hostile. The answer is an error, not a filesystem read. This is the attack the capability refusal in #5 was guarding against, and here is where that guard actually pays.A resultset returns
:resultset_not_implementedrather than a guess, and the integration test asserts that against a realSELECT. The gap is visible in the suite rather than implied by its absence.Sequence ids reset per command. The statement goes out as 0 and the reply arrives as 1. This is the tracking phase 1 deliberately deferred until there was a command to track it across — see the "deliberately not here" list in ROADMAP.md.
query/3returns three-tuples —{:ok, result, client}/{:error, reason, client}— so the read buffer threads through. Leftover bytes from one message belong to the next, and the client is the only thing that can carry them.Integration coverage
Against MySQL 8.0: creates a table, inserts two rows and checks both
AUTO_INCREMENTids, verifiesRows matched: 1in an update's info string, and gets1146 / 42S02 / "doesn't exist"back for a missing table.Next
The resultset: column count, column definitions, then rows as length-encoded strings with
0xFBfor NULL. Every codec it needs already exists, so it is three packet parsers and a loop.