Documentation Home
MySQL Internals Manual
Download this Manual
EPUB - 0.8Mb OK_Packet

An OK packet is sent from the server to the client to signal successful completion of a command. As of MySQL 5.7.5, OK packes are also used to indicate EOF, and EOF packets are deprecated.

If CLIENT_PROTOCOL_41 is set, the packet contains a warning count.

Table 14.1 Payload of OK Packet

int<1>header[00] or [fe] the OK packet header
int<lenenc>affected_rowsaffected rows
int<lenenc>last_insert_idlast insert-id
if capabilities & CLIENT_PROTOCOL_41 {
int<2>status_flagsStatus Flags
int<2>warningsnumber of warnings
} elseif capabilities & CLIENT_TRANSACTIONS {
int<2>status_flagsStatus Flags
if capabilities & CLIENT_SESSION_TRACK {
string<lenenc>infohuman readable status information
string<lenenc>session_state_changessession state info
} else {
string<EOF>infohuman readable status information

These rules distinguish whether the packet represents OK or EOF:

  • OK: header = 0 and length of packet > 7

  • EOF: header = 0xfe and length of packet < 9

To ensure backward compatibility between old (prior to 5.7.5) and new (5.7.5 and up) versions of MySQL, new clients advertise the CLIENT_DEPRECATE_EOF flag:

  • Old clients do not know about this flag and do not advertise it. Consequently, the server does not send OK packets that represent EOF. (Old servers never do this, anyway. New servers recognize the absence of the flag to mean they should not.)

  • New clients advertise this flag. Old servers do not know this flag and do not send OK packets that represent EOF. New servers recognize the flag and can send OK packets that represent EOF.


OK with CLIENT_PROTOCOL_41. 0 affected rows, last-insert-id was 0, AUTOCOMMIT enabled, 0 warnings. No further info.

07 00 00 02 00 00 00 02    00 00 00
........... Session State Information

State-change information is sent in the OK packet as a array of state-change blocks which are made up of:

Table 14.2 Layout of Changed Session Information

int<1>typetype of data
string<lenenc>datadata of the changed session info

Table 14.3 Types of State Change Information

SESSION_TRACK_SYSTEM_VARIABLES0x00one or more system variables changed. See also: session_track_system_variables
SESSION_TRACK_SCHEMA0x01schema changed. See also: session_track_schema
SESSION_TRACK_STATE_CHANGE0x02"track state change" changed. See also: session_track_state_change

Interpretation of the data field depends on the type value:

string<lenenc>namename of the changed system variable
string<lenenc>valuevalue of the changed system variable

After a SET autocommit = OFF statement:


The length of the data field.

string<lenenc>namename of the changed schema

After a USE test statement:

01 05 04 74 65 73 74

A flag byte that indicates whether session state changes occurred. This flag is represented as an ASCII value. Example:

string<lenenc>is_tracked[31] ("1") if state tracking got enabled.

After a SET SESSION session_track_state_change = 1 statement:

03 02 01 31                                      

Download this Manual
EPUB - 0.8Mb
User Comments
Sign Up Login You must be logged in to post a comment.