Authentication Protocol Security - Error Packet
(Page 6 of 7 )
When something goes wrong with the processing of a command, the server responds with an error packet. The format is documented in Table 4-9.
Table 4-9. Format of server’s error packet
| Offset in the body | Length | Description |
|---|
| 0 | 1 | A byte containing 255. The client will always treat a response packet starting with a byte containing 255 as an error message. |
| 1 | 2 | The error code. Low byte first. The field will not be included if the server is talking to a very ancient pre-3.23 client, and the subsequent offsets should be adjusted accordingly in that case. |
| 3 | 2 | Character ‘ # ’ followed by the byte containing the value of the ODBC/JDBC SQL state. Present only in version 4.1 and later. |
| 5 in version 4.1 and later, 3 in 4.0 and earlier | Varies | Zero-terminated text of the error message. |
To send an error packet from inside the server, call send_error() , which is defined in sql/protocol.cc in version 4.1 and later, and in sql/net_pkg.cc in version 4.0 and earlier.
EOF Packet The end-of-file (EOF) packet is used to communicate a number of messages:
EOF) packet is used to communicate a number of messages: The end-of-file (EOF) packet is used to communicate a number of messages:
- End-of-field information data in a result set
- End-of-row data in a result set
- Server acknowledgment of COM_SHUTDOWN
- Server reporting success in response to COM_SET_OPTION and COM_DEBUG
- Request for the old-style credentials during authentication
The body of an EOF packet always starts with a byte containing decimal 254. In the pre-4.1 era, there was nothing else in the body in addition to this byte. Version 4.1 added another 4 bytes of status fields with the potential of going up to 7 bytes. The format of the version 4.1 EOF body is outlined in Table 4-10.
Table 4-10. Format of server’s EOF packet
Offset in the body | Length | Description |
0 | 1 | Byte with the decimal 254 |
1 | 2 | Number of warnings |
3 | 2 | Server status bit mask |
The reason for the 7 byte limit in the status bytes area is that the decimal 254 byte followed by an 8 byte string at the beginning of a packet body can have a different meaning: it can specify the number of fields in a result set using the field length format described in the “Data Field ” section, earlier in this chapter.
To send an EOF packet, the server uses send_eof() , which is defined in sql/protocol.cc in 4.1 and later, and in sql/net_pkg.cc in the earlier versions.
Next: Result Set Packets >>
More Database Articles Articles
More By O'Reilly Media
|
This article is excerpted from the book Understanding MySQL Internals, written by Sasha Pachev (O'Reilly, 2007; ISBN: 0596009577). Check it out today at your favorite bookstore. Buy this book now.
|
|