diff options
Diffstat (limited to 'sql-common')
-rw-r--r-- | sql-common/client.c | 6 | ||||
-rw-r--r-- | sql-common/pack.c | 22 |
2 files changed, 25 insertions, 3 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 756d1c1972c..e73d9bdbe0b 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -601,7 +601,7 @@ restart: uint last_errno=uint2korr(pos); if (last_errno == 65535 && - (mysql->server_capabilities & CLIENT_PROGRESS)) + (mysql->server_capabilities & CLIENT_PROGRESS_OBSOLETE)) { if (cli_report_progress(mysql, pos+2, (uint) (len-3))) { @@ -1642,10 +1642,10 @@ mysql_init(MYSQL *mysql) How this change impacts existing apps: - existing apps which relyed on the default will see a behaviour change; they will have to set reconnect=1 after mysql_real_connect(). - - existing apps which explicitely asked for reconnection (the only way they + - existing apps which explicitly asked for reconnection (the only way they could do it was by setting mysql.reconnect to 1 after mysql_real_connect()) will not see a behaviour change. - - existing apps which explicitely asked for no reconnection + - existing apps which explicitly asked for no reconnection (mysql.reconnect=0) will not see a behaviour change. */ mysql->reconnect= 0; diff --git a/sql-common/pack.c b/sql-common/pack.c index 4bb4a0b7a4e..5428feb623e 100644 --- a/sql-common/pack.c +++ b/sql-common/pack.c @@ -186,3 +186,25 @@ uchar *safe_net_store_length(uchar *packet, size_t packet_len, ulonglong length) return packet+8; } + +/** + The length of space required to store the resulting length-encoded integer + for the given number. This function can be used at places where one needs to + dynamically allocate the buffer for a given number to be stored as length- + encoded integer. + + @param num [IN] the input number + + @return length of buffer needed to store this number [1, 3, 4, 9]. +*/ + +uint net_length_size(ulonglong num) +{ + if (num < (ulonglong) 251LL) + return 1; + if (num < (ulonglong) 65536LL) + return 3; + if (num < (ulonglong) 16777216LL) + return 4; + return 9; +} |