This command sends an SQL statement to the server for execution immediately, without the prepare/execute steps.
With the COM_QUERY command, the client sends the server an SQL statement to be executed immediately.
int<1> 0x03 : COM_QUERY header.
SQL statement.
The SQL statement should be properly escaped. The escape character is usually a backslash '' = 0x5c. However, if the status flag returned by the last had the NO_BACKSLASH_ESCAPES bit set, the escape character is a single quote (' = 0x60).
If the escape character is a backslash, the following characters are escaped:
Single quote (' = 0x60).
Backslash (\ = 0x5c).
Double quote (" = 0x22
If the escape character is a single quote, only the single quote (' = 0x60) can be escaped.
The server can answer with 4 different responses that can be differentiated by the first byte (packet header):
0xFF - if any error occurs.
0x00 - when query execution works without result set.
0xFB - if the query was LOCAL INFILE ....
This page is licensed: CC BY-SA / Gnu FDL
Null character (0x00).
Or a result set, when the query returns results (in case of a SELECT query, for example).
1b 00 00 00 03 44 52 4f 50 20 54 41 42 4c 45 20
.....DROP TABLE
49 46 20 45 58 49 53 54 53 20 62 75 6c 6b 31
IF EXISTS bulk1