Description:
http://dev.mysql.com/doc/internals/en/elements.html
Value Of # Of Bytes Description
First Byte Following
---------- ----------- -----------
0-250 0 = value of first byte
251 0 column value = NULL
only appropriate in a Row Data Packet
252 2 = value of following 16-bit word
253 4 = value of following 32-bit word
254 8 = value of following 64-bit word
when First Byte is 253 length-coded-binary should be followed by 3 bytes, which description should be "value of following 24-bit word".
As "The relevant MySQL source program is sql/protocol.cc net_store_length()." says, net_store_length() defined as follows, which is actually defined in sql-common/pack.c:97:
uchar *net_store_length(uchar *packet, ulonglong length)
{
if (length < (ulonglong) LL(251))
{
*packet=(uchar) length;
return packet+1;
}
/* 251 is reserved for NULL */
if (length < (ulonglong) LL(65536))
{
*packet++=252;
int2store(packet,(uint) length);
return packet+2;
}
if (length < (ulonglong) LL(16777216))
{
*packet++=253;
int3store(packet,(ulong) length);
return packet+3;
}
*packet++=254;
int8store(packet,length);
return packet+8;
}
ps. 16777216= 2^24
How to repeat:
the wrong description about length-coded-binary is here at http://dev.mysql.com/doc/internals/en/elements.html
Suggested fix:
http://dev.mysql.com/doc/internals/en/elements.html
Value Of # Of Bytes Description
First Byte Following
---------- ----------- -----------
0-250 0 = value of first byte
251 0 column value = NULL
only appropriate in a Row Data Packet
252 2 = value of following 16-bit word
253 3 = value of following 24-bit word
254 8 = value of following 64-bit word