95
96
my_strntoll(res->charset(), res->ptr(), res->length(), 10, NULL,
102
String *Item_func_md5::val_str(String *str)
104
DBUG_ASSERT(fixed == 1);
105
String * sptr= args[0]->val_str(str);
106
str->set_charset(&my_charset_bin);
113
my_MD5Init (&context);
114
my_MD5Update (&context,(uchar *) sptr->ptr(), sptr->length());
115
my_MD5Final (digest, &context);
116
if (str->alloc(32)) // Ensure that memory is free
121
sprintf((char *) str->ptr(),
122
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
123
digest[0], digest[1], digest[2], digest[3],
124
digest[4], digest[5], digest[6], digest[7],
125
digest[8], digest[9], digest[10], digest[11],
126
digest[12], digest[13], digest[14], digest[15]);
127
str->length((uint) 32);
135
void Item_func_md5::fix_length_and_dec()
139
The MD5() function treats its parameter as being a case sensitive. Thus
140
we set binary collation on it so different instances of MD5() will be
143
args[0]->collation.set(
144
get_charset_by_csname(args[0]->collation.collation->csname,
145
MY_CS_BINSORT,MYF(0)), DERIVATION_COERCIBLE);
654
702
if (length > res->length() - start)
655
703
length= res->length() - start;
657
if ((uint64_t) (res->length() - length + res2->length()) >
658
(uint64_t) current_thd->variables.max_allowed_packet)
705
if ((ulonglong) (res->length() - length + res2->length()) >
706
(ulonglong) current_thd->variables.max_allowed_packet)
660
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
708
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
661
709
ER_WARN_ALLOWED_PACKET_OVERFLOWED,
662
710
ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
663
711
func_name(), current_thd->variables.max_allowed_packet);
666
714
res=copy_if_not_alloced(str,res,res->length());
667
res->replace((uint32_t) start,(uint32_t) length,*res2);
715
res->replace((uint32) start,(uint32) length,*res2);
675
723
void Item_func_insert::fix_length_and_dec()
677
uint64_t max_result_length;
725
ulonglong max_result_length;
679
727
// Handle character set for args[0] and args[3].
680
728
if (agg_arg_charsets(collation, &args[0], 2, MY_COLL_ALLOW_CONV, 3))
682
max_result_length= ((uint64_t) args[0]->max_length+
683
(uint64_t) args[3]->max_length);
730
max_result_length= ((ulonglong) args[0]->max_length+
731
(ulonglong) args[3]->max_length);
684
732
if (max_result_length >= MAX_BLOB_WIDTH)
686
734
max_result_length= MAX_BLOB_WIDTH;
703
751
if (multiply == 1)
706
754
res= copy_if_not_alloced(str,res,res->length());
707
755
len= converter(collation.collation, (char*) res->ptr(), res->length(),
708
756
(char*) res->ptr(), res->length());
709
assert(len <= res->length());
757
DBUG_ASSERT(len <= res->length());
710
758
res->length(len);
714
uint32_t len= res->length() * multiply;
762
uint len= res->length() * multiply;
715
763
tmp_value.alloc(len);
716
764
tmp_value.set_charset(collation.collation);
717
765
len= converter(collation.collation, (char*) res->ptr(), res->length(),
822
870
String *Item_func_substr::val_str(String *str)
872
DBUG_ASSERT(fixed == 1);
825
873
String *res = args[0]->val_str(str);
826
/* must be int64_t to avoid truncation */
827
int64_t start= args[1]->val_int();
828
/* Assumes that the maximum length of a String is < INT32_MAX. */
874
/* must be longlong to avoid truncation */
875
longlong start= args[1]->val_int();
876
/* Assumes that the maximum length of a String is < INT_MAX32. */
829
877
/* Limit so that code sees out-of-bound value properly. */
830
int64_t length= arg_count == 3 ? args[2]->val_int() : INT32_MAX;
878
longlong length= arg_count == 3 ? args[2]->val_int() : INT_MAX32;
833
881
if ((null_value=(args[0]->null_value || args[1]->null_value ||
834
882
(arg_count == 3 && args[2]->null_value))))
839
887
(length == 0 || !args[2]->unsigned_flag))
840
888
return &my_empty_string;
842
/* Assumes that the maximum length of a String is < INT32_MAX. */
890
/* Assumes that the maximum length of a String is < INT_MAX32. */
843
891
/* Set here so that rest of code sees out-of-bound value as such. */
844
if ((length <= 0) || (length > INT32_MAX))
892
if ((length <= 0) || (length > INT_MAX32))
847
895
/* if "unsigned_flag" is set, we have a *huge* positive number. */
848
/* Assumes that the maximum length of a String is < INT32_MAX. */
849
if ((!args[1]->unsigned_flag && (start < INT32_MIN || start > INT32_MAX)) ||
850
(args[1]->unsigned_flag && ((uint64_t) start > INT32_MAX)))
896
/* Assumes that the maximum length of a String is < INT_MAX32. */
897
if ((!args[1]->unsigned_flag && (start < INT_MIN32 || start > INT_MAX32)) ||
898
(args[1]->unsigned_flag && ((ulonglong) start > INT_MAX32)))
851
899
return &my_empty_string;
853
901
start= ((start < 0) ? res->numchars() + start : start - 1);
855
903
if ((start < 0) || ((uint) start + 1 > res->length()))
856
904
return &my_empty_string;
858
length= res->charpos((int) length, (uint32_t) start);
906
length= res->charpos((int) length, (uint32) start);
859
907
tmp_length= res->length() - start;
860
length= cmin(length, tmp_length);
908
length= min(length, tmp_length);
862
if (!start && (int64_t) res->length() == length)
910
if (!start && (longlong) res->length() == length)
864
tmp_value.set(*res, (uint32_t) start, (uint32_t) length);
912
tmp_value.set(*res, (uint32) start, (uint32) length);
865
913
return &tmp_value;
873
921
collation.set(args[0]->collation);
874
922
if (args[1]->const_item())
876
int32_t start= (int32_t) args[1]->val_int();
924
int32 start= (int32) args[1]->val_int();
878
926
max_length= ((uint)(-start) > max_length) ? 0 : (uint)(-start);
880
max_length-= cmin((uint)(start - 1), max_length);
928
max_length-= min((uint)(start - 1), max_length);
882
930
if (arg_count == 3 && args[2]->const_item())
884
int32_t length= (int32_t) args[2]->val_int();
932
int32 length= (int32) args[2]->val_int();
886
934
max_length=0; /* purecov: inspected */
1256
Item *Item_func_sysconst::safe_charset_converter(const CHARSET_INFO * const tocs)
1304
/* Item_func_password */
1306
String *Item_func_password::val_str(String *str)
1308
DBUG_ASSERT(fixed == 1);
1309
String *res= args[0]->val_str(str);
1310
if ((null_value=args[0]->null_value))
1312
if (res->length() == 0)
1313
return &my_empty_string;
1314
make_scrambled_password(tmp_value, res->c_ptr());
1315
str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH, res->charset());
1319
char *Item_func_password::alloc(THD *thd, const char *password)
1321
char *buff= (char *) thd->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1);
1323
make_scrambled_password(buff, password);
1327
/* Item_func_old_password */
1329
String *Item_func_old_password::val_str(String *str)
1331
DBUG_ASSERT(fixed == 1);
1332
String *res= args[0]->val_str(str);
1333
if ((null_value=args[0]->null_value))
1335
if (res->length() == 0)
1336
return &my_empty_string;
1337
make_scrambled_password_323(tmp_value, res->c_ptr());
1338
str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH_323, res->charset());
1342
char *Item_func_old_password::alloc(THD *thd, const char *password)
1344
char *buff= (char *) thd->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1);
1346
make_scrambled_password_323(buff, password);
1351
#define bin_to_ascii(c) ((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.')
1353
String *Item_func_encrypt::val_str(String *str)
1355
DBUG_ASSERT(fixed == 1);
1356
String *res =args[0]->val_str(str);
1359
char salt[3],*salt_ptr;
1360
if ((null_value=args[0]->null_value))
1362
if (res->length() == 0)
1363
return &my_empty_string;
1366
{ // generate random salt
1367
time_t timestamp=current_thd->query_start();
1368
salt[0] = bin_to_ascii( (ulong) timestamp & 0x3f);
1369
salt[1] = bin_to_ascii(( (ulong) timestamp >> 5) & 0x3f);
1374
{ // obtain salt from the first two bytes
1375
String *salt_str=args[1]->val_str(&tmp_value);
1376
if ((null_value= (args[1]->null_value || salt_str->length() < 2)))
1378
salt_ptr= salt_str->c_ptr();
1380
pthread_mutex_lock(&LOCK_crypt);
1381
char *tmp= crypt(res->c_ptr(),salt_ptr);
1384
pthread_mutex_unlock(&LOCK_crypt);
1388
str->set(tmp, (uint) strlen(tmp), &my_charset_bin);
1390
pthread_mutex_unlock(&LOCK_crypt);
1395
#endif /* HAVE_CRYPT */
1398
void Item_func_encode::fix_length_and_dec()
1400
max_length=args[0]->max_length;
1401
maybe_null=args[0]->maybe_null || args[1]->maybe_null;
1402
collation.set(&my_charset_bin);
1405
String *Item_func_encode::val_str(String *str)
1409
String tmp_pw_value(pw_buff, sizeof(pw_buff), system_charset_info);
1411
DBUG_ASSERT(fixed == 1);
1413
if (!(res=args[0]->val_str(str)))
1415
null_value=1; /* purecov: inspected */
1416
return 0; /* purecov: inspected */
1419
if (!(password=args[1]->val_str(& tmp_pw_value)))
1426
res=copy_if_not_alloced(str,res,res->length());
1427
SQL_CRYPT sql_crypt(password->ptr());
1429
sql_crypt.encode((char*) res->ptr(),res->length());
1430
res->set_charset(&my_charset_bin);
1434
String *Item_func_decode::val_str(String *str)
1438
String tmp_pw_value(pw_buff, sizeof(pw_buff), system_charset_info);
1440
DBUG_ASSERT(fixed == 1);
1442
if (!(res=args[0]->val_str(str)))
1444
null_value=1; /* purecov: inspected */
1445
return 0; /* purecov: inspected */
1448
if (!(password=args[1]->val_str(& tmp_pw_value)))
1455
res=copy_if_not_alloced(str,res,res->length());
1456
SQL_CRYPT sql_crypt(password->ptr());
1458
sql_crypt.decode((char*) res->ptr(),res->length());
1463
Item *Item_func_sysconst::safe_charset_converter(CHARSET_INFO *tocs)
1258
1465
Item_string *conv;
1259
uint32_t conv_errors;
1260
1467
String tmp, cstr, *ostr= val_str(&tmp);
1261
1468
cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors);
1262
1469
if (conv_errors ||
1682
1889
collation.set(args[0]->collation);
1683
1890
if (args[1]->const_item())
1685
/* must be int64_t to avoid truncation */
1686
int64_t count= args[1]->val_int();
1892
/* must be longlong to avoid truncation */
1893
longlong count= args[1]->val_int();
1688
/* Assumes that the maximum length of a String is < INT32_MAX. */
1895
/* Assumes that the maximum length of a String is < INT_MAX32. */
1689
1896
/* Set here so that rest of code sees out-of-bound value as such. */
1690
if (count > INT32_MAX)
1897
if (count > INT_MAX32)
1693
uint64_t max_result_length= (uint64_t) args[0]->max_length * count;
1900
ulonglong max_result_length= (ulonglong) args[0]->max_length * count;
1694
1901
if (max_result_length >= MAX_BLOB_WIDTH)
1696
1903
max_result_length= MAX_BLOB_WIDTH;
1726
1933
if (count <= 0 && (count == 0 || !args[1]->unsigned_flag))
1727
1934
return &my_empty_string;
1729
/* Assumes that the maximum length of a String is < INT32_MAX. */
1936
/* Assumes that the maximum length of a String is < INT_MAX32. */
1730
1937
/* Bounds check on count: If this is triggered, we will error. */
1731
if ((uint64_t) count > INT32_MAX)
1938
if ((ulonglong) count > INT_MAX32)
1733
1940
if (count == 1) // To avoid reallocs
1735
1942
length=res->length();
1736
1943
// Safe length check
1737
1944
if (length > current_thd->variables.max_allowed_packet / (uint) count)
1739
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
1946
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1740
1947
ER_WARN_ALLOWED_PACKET_OVERFLOWED,
1741
1948
ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
1742
1949
func_name(), current_thd->variables.max_allowed_packet);
1799
2006
String *Item_func_rpad::val_str(String *str)
1802
uint32_t res_byte_length,res_char_length,pad_char_length,pad_byte_length;
2008
DBUG_ASSERT(fixed == 1);
2009
uint32 res_byte_length,res_char_length,pad_char_length,pad_byte_length;
1804
2011
const char *ptr_pad;
1805
/* must be int64_t to avoid truncation */
1806
int64_t count= args[1]->val_int();
2012
/* must be longlong to avoid truncation */
2013
longlong count= args[1]->val_int();
2014
longlong byte_count;
1808
2015
String *res= args[0]->val_str(str);
1809
2016
String *rpad= args[2]->val_str(&rpad_str);
1824
2031
pad_char_length= rpad->numchars();
1826
2033
byte_count= count * collation.collation->mbmaxlen;
1827
if ((uint64_t) byte_count > current_thd->variables.max_allowed_packet)
2034
if ((ulonglong) byte_count > current_thd->variables.max_allowed_packet)
1829
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2036
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1830
2037
ER_WARN_ALLOWED_PACKET_OVERFLOWED,
1831
2038
ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
1832
2039
func_name(), current_thd->variables.max_allowed_packet);
1929
2136
pad_char_length= pad->numchars();
1930
2137
byte_count= count * collation.collation->mbmaxlen;
1932
if ((uint64_t) byte_count > current_thd->variables.max_allowed_packet)
2139
if ((ulonglong) byte_count > current_thd->variables.max_allowed_packet)
1934
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2141
push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
1935
2142
ER_WARN_ALLOWED_PACKET_OVERFLOWED,
1936
2143
ER(ER_WARN_ALLOWED_PACKET_OVERFLOWED),
1937
2144
func_name(), current_thd->variables.max_allowed_packet);
1987
2194
dec= my_strntoll(res->charset(), res->ptr(), res->length(),
1988
2195
-from_base, &endptr, &err);
1990
dec= (int64_t) my_strntoull(res->charset(), res->ptr(), res->length(),
2197
dec= (longlong) my_strntoull(res->charset(), res->ptr(), res->length(),
1991
2198
from_base, &endptr, &err);
1993
ptr= int64_t2str(dec, ans, to_base);
1994
if (str->copy(ans, (uint32_t) (ptr-ans), default_charset()))
2200
ptr= longlong2str(dec, ans, to_base);
2201
if (str->copy(ans, (uint32) (ptr-ans), default_charset()))
1995
2202
return &my_empty_string;
2105
2312
String *Item_func_charset::val_str(String *str)
2108
uint32_t dummy_errors;
2314
DBUG_ASSERT(fixed == 1);
2110
const CHARSET_INFO * const cs= args[0]->collation.collation;
2317
CHARSET_INFO *cs= args[0]->collation.collation;
2112
2319
str->copy(cs->csname, strlen(cs->csname),
2113
&my_charset_utf8_general_ci, collation.collation, &dummy_errors);
2320
&my_charset_latin1, collation.collation, &dummy_errors);
2117
2324
String *Item_func_collation::val_str(String *str)
2120
uint32_t dummy_errors;
2121
const CHARSET_INFO * const cs= args[0]->collation.collation;
2326
DBUG_ASSERT(fixed == 1);
2328
CHARSET_INFO *cs= args[0]->collation.collation;
2124
2331
str->copy(cs->name, strlen(cs->name),
2125
&my_charset_utf8_general_ci, collation.collation, &dummy_errors);
2332
&my_charset_latin1, collation.collation, &dummy_errors);
2130
2337
void Item_func_weight_string::fix_length_and_dec()
2132
const CHARSET_INFO * const cs= args[0]->collation.collation;
2339
CHARSET_INFO *cs= args[0]->collation.collation;
2133
2340
collation.set(&my_charset_bin, args[0]->collation.derivation);
2134
2341
flags= my_strxfrm_flag_normalize(flags, cs->levels_for_order);
2135
max_length= cs->mbmaxlen * cmax(args[0]->max_length, nweights);
2342
max_length= cs->mbmaxlen * max(args[0]->max_length, nweights);
2141
2348
String *Item_func_weight_string::val_str(String *str)
2144
const CHARSET_INFO * const cs= args[0]->collation.collation;
2145
uint32_t tmp_length, frm_length;
2351
CHARSET_INFO *cs= args[0]->collation.collation;
2352
uint tmp_length, frm_length;
2353
DBUG_ASSERT(fixed == 1);
2148
2355
if (args[0]->result_type() != STRING_RESULT ||
2149
2356
!(res= args[0]->val_str(str)))
2152
2359
tmp_length= cs->coll->strnxfrmlen(cs, cs->mbmaxlen *
2153
cmax(res->length(), nweights));
2360
max(res->length(), nweights));
2155
2362
if (tmp_value.alloc(tmp_length))
2158
2365
frm_length= cs->coll->strnxfrm(cs,
2159
(unsigned char*) tmp_value.ptr(), tmp_length,
2366
(uchar*) tmp_value.ptr(), tmp_length,
2160
2367
nweights ? nweights : tmp_length,
2161
(const unsigned char*) res->ptr(), res->length(),
2368
(const uchar*) res->ptr(), res->length(),
2163
2370
tmp_value.length(frm_length);
2173
2380
String *Item_func_hex::val_str(String *str)
2383
DBUG_ASSERT(fixed == 1);
2177
2384
if (args[0]->result_type() != STRING_RESULT)
2180
2387
char ans[65],*ptr;
2181
/* Return hex of unsigned int64_t value */
2388
/* Return hex of unsigned longlong value */
2182
2389
if (args[0]->result_type() == REAL_RESULT ||
2183
2390
args[0]->result_type() == DECIMAL_RESULT)
2185
2392
double val= args[0]->val_real();
2186
if ((val <= (double) INT64_MIN) ||
2187
(val >= (double) (uint64_t) UINT64_MAX))
2393
if ((val <= (double) LONGLONG_MIN) ||
2394
(val >= (double) (ulonglong) ULONGLONG_MAX))
2190
dec= (uint64_t) (val + (val > 0 ? 0.5 : -0.5));
2397
dec= (ulonglong) (val + (val > 0 ? 0.5 : -0.5));
2193
dec= (uint64_t) args[0]->val_int();
2400
dec= (ulonglong) args[0]->val_int();
2195
2402
if ((null_value= args[0]->null_value))
2197
ptr= int64_t2str(dec,ans,16);
2198
if (str->copy(ans,(uint32_t) (ptr-ans),default_charset()))
2404
ptr= longlong2str(dec,ans,16);
2405
if (str->copy(ans,(uint32) (ptr-ans),default_charset()))
2199
2406
return &my_empty_string; // End of memory
2390
2600
void Item_func_export_set::fix_length_and_dec()
2392
uint32_t length=cmax(args[1]->max_length,args[2]->max_length);
2393
uint32_t sep_length=(arg_count > 3 ? args[3]->max_length : 1);
2602
uint length=max(args[1]->max_length,args[2]->max_length);
2603
uint sep_length=(arg_count > 3 ? args[3]->max_length : 1);
2394
2604
max_length=length*64+sep_length*63;
2396
if (agg_arg_charsets(collation, args+1, cmin((uint)4,arg_count)-1,
2606
if (agg_arg_charsets(collation, args+1, min(4,arg_count)-1,
2397
2607
MY_COLL_ALLOW_CONV, 1))
2423
2633
String *Item_func_quote::val_str(String *str)
2635
DBUG_ASSERT(fixed == 1);
2427
2637
Bit mask that has 1 for set for the position of the following characters:
2431
static unsigned char escmask[32]=
2641
static uchar escmask[32]=
2433
2643
0x01, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00,
2434
2644
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
2710
longlong Item_func_uncompressed_length::val_int()
2712
DBUG_ASSERT(fixed == 1);
2713
String *res= args[0]->val_str(&value);
2717
return 0; /* purecov: inspected */
2720
if (res->is_empty()) return 0;
2723
res->ptr() using is safe because we have tested that string is not empty,
2724
res->c_ptr() is not used because:
2725
- we do not need \0 terminated string to get first 4 bytes
2726
- c_ptr() tests simbol after string end (uninitialiozed memory) which
2729
return uint4korr(res->ptr()) & 0x3FFFFFFF;
2732
longlong Item_func_crc32::val_int()
2734
DBUG_ASSERT(fixed == 1);
2735
String *res=args[0]->val_str(&value);
2739
return 0; /* purecov: inspected */
2742
return (longlong) crc32(0L, (uchar*)res->ptr(), res->length());
2745
#ifdef HAVE_COMPRESS
2748
String *Item_func_compress::val_str(String *str)
2750
int err= Z_OK, code;
2754
char *tmp, *last_char;
2755
DBUG_ASSERT(fixed == 1);
2757
if (!(res= args[0]->val_str(str)))
2763
if (res->is_empty()) return res;
2766
Citation from zlib.h (comment for compress function):
2768
Compresses the source buffer into the destination buffer. sourceLen is
2769
the byte length of the source buffer. Upon entry, destLen is the total
2770
size of the destination buffer, which must be at least 0.1% larger than
2771
sourceLen plus 12 bytes.
2772
We assume here that the buffer can't grow more than .25 %.
2774
new_size= res->length() + res->length() / 5 + 12;
2776
// Check new_size overflow: new_size <= res->length()
2777
if (((uint32) (new_size+5) <= res->length()) ||
2778
buffer.realloc((uint32) new_size + 4 + 1))
2784
body= ((Byte*)buffer.ptr()) + 4;
2786
// As far as we have checked res->is_empty() we can use ptr()
2787
if ((err= compress(body, &new_size,
2788
(const Bytef*)res->ptr(), res->length())) != Z_OK)
2790
code= err==Z_MEM_ERROR ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_BUF_ERROR;
2791
push_warning(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,code,ER(code));
2796
tmp= (char*)buffer.ptr(); // int4store is a macro; avoid side effects
2797
int4store(tmp, res->length() & 0x3FFFFFFF);
2799
/* This is to ensure that things works for CHAR fields, which trim ' ': */
2800
last_char= ((char*)body)+new_size-1;
2801
if (*last_char == ' ')
2807
buffer.length((uint32)new_size + 4);
2812
String *Item_func_uncompress::val_str(String *str)
2814
DBUG_ASSERT(fixed == 1);
2815
String *res= args[0]->val_str(str);
2823
if (res->is_empty())
2826
/* If length is less than 4 bytes, data is corrupt */
2827
if (res->length() <= 4)
2829
push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,
2830
ER_ZLIB_Z_DATA_ERROR,
2831
ER(ER_ZLIB_Z_DATA_ERROR));
2835
/* Size of uncompressed data is stored as first 4 bytes of field */
2836
new_size= uint4korr(res->ptr()) & 0x3FFFFFFF;
2837
if (new_size > current_thd->variables.max_allowed_packet)
2839
push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,
2840
ER_TOO_BIG_FOR_UNCOMPRESS,
2841
ER(ER_TOO_BIG_FOR_UNCOMPRESS),
2842
current_thd->variables.max_allowed_packet);
2845
if (buffer.realloc((uint32)new_size))
2848
if ((err= uncompress((Byte*)buffer.ptr(), &new_size,
2849
((const Bytef*)res->ptr())+4,res->length())) == Z_OK)
2851
buffer.length((uint32) new_size);
2855
code= ((err == Z_BUF_ERROR) ? ER_ZLIB_Z_BUF_ERROR :
2856
((err == Z_MEM_ERROR) ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR));
2857
push_warning(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,code,ER(code));
2502
2867
DCE 1.1: Remote Procedure Call,
2508
2873
static struct rand_struct uuid_rand;
2509
static uint32_t nanoseq;
2510
static uint64_t uuid_time=0;
2874
static uint nanoseq;
2875
static ulonglong uuid_time=0;
2511
2876
static char clock_seq_and_node_str[]="-0000-000000000000";
2514
2879
number of 100-nanosecond intervals between
2515
2880
1582-10-15 00:00:00.00 and 1970-01-01 00:00:00.00.
2517
#define UUID_TIME_OFFSET ((uint64_t) 141427 * 24 * 60 * 60 * 1000 * 10 )
2882
#define UUID_TIME_OFFSET ((ulonglong) 141427 * 24 * 60 * 60 * 1000 * 10 )
2519
2884
#define UUID_VERSION 0x1000
2520
2885
#define UUID_VARIANT 0x8000
2522
static void tohex(char *to, uint32_t from, uint32_t len)
2887
static void tohex(char *to, uint from, uint len)