diff options
Diffstat (limited to 'sql-common/pack.c')
-rw-r--r-- | sql-common/pack.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sql-common/pack.c b/sql-common/pack.c index 16cc13eddbd..43e0098bf29 100644 --- a/sql-common/pack.c +++ b/sql-common/pack.c @@ -96,3 +96,30 @@ void my_net_local_init(NET *net) net->max_packet_size= max(net_buffer_length, max_allowed_packet); } +char * +net_store_length(char *pkg, ulonglong length) +{ + uchar *packet=(uchar*) pkg; + if (length < LL(251)) + { + *packet=(uchar) length; + return (char*) packet+1; + } + /* 251 is reserved for NULL */ + if (length < LL(65536)) + { + *packet++=252; + int2store(packet,(uint) length); + return (char*) packet+2; + } + if (length < LL(16777216)) + { + *packet++=253; + int3store(packet,(ulong) length); + return (char*) packet+3; + } + *packet++=254; + int8store(packet,length); + return (char*) packet+8; +} + |