Table 4-8. Format of server’s OK packet (continued)
Offset in the body
Length
Description
1 + rows_len
id_len
The value of the generated auto-increment ID for the primary key. Set to 0 if not applicable in the context. The value is stored in the field length format of a data field. I will refer to the length of this value as id_len.
1 + rows_len + id_len
2
Server status bit mask, low byte first. For details on different values, see the macros starting with STATUS_in include/mysql_com.h. In the protocol of version 4.0 and earlier, the status field is present only if it is a nonzero value. In the protocol of version 4.1 and later, it is reported unconditionally.
3 + rows_len + id_len
2
Present only in the protocol of version 4.1 and later. Contains the number of warnings the last command has generated. For example, if the command was COM_QUERYwith LOAD DATA INFILE, and some of the fields or lines could not be properly imported, a number of warnings will be generated. The number is stored with the low byte first.
5 + rows_len + id_lenin
msg_len
An optional field for the status message if one is present in the standard data field format with the field length followed by field value, which in this case is a character string.
1 +rows_len + id_lenor
version 4.1 and later protocol.
3 +rows_len + id_lenin
the older protocol, depending on whether the server status bit mask was included.
To send anOKpacket from inside the server, you must callsend_ok(). In version 4.1 and later, the function is declared in sql/protocol.h, and defined in sql/protocol.cc. In the earlier versions, it is declared in sql/mysql_priv.h and defined in sql/net_pkg.cc.