~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/item_strfunc.cc

  • Committer: Brian Aker
  • Date: 2008-07-13 22:21:51 UTC
  • Revision ID: brian@tangent.org-20080713222151-fv2tcpbsc829j2oc
Ulonglong to uint64_t

Show diffs side-by-side

added added

removed removed

Lines of Context:
280
280
 
281
281
void Item_func_concat::fix_length_and_dec()
282
282
{
283
 
  ulonglong max_result_length= 0;
 
283
  uint64_t max_result_length= 0;
284
284
 
285
285
  if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV, 1))
286
286
    return;
449
449
 
450
450
void Item_func_concat_ws::fix_length_and_dec()
451
451
{
452
 
  ulonglong max_result_length;
 
452
  uint64_t max_result_length;
453
453
 
454
454
  if (agg_arg_charsets(collation, args, arg_count, MY_COLL_ALLOW_CONV, 1))
455
455
    return;
459
459
     it is done on parser level in sql_yacc.yy
460
460
     so, (arg_count - 2) is safe here.
461
461
  */
462
 
  max_result_length= (ulonglong) args[0]->max_length * (arg_count - 2);
 
462
  max_result_length= (uint64_t) args[0]->max_length * (arg_count - 2);
463
463
  for (uint i=1 ; i < arg_count ; i++)
464
464
    max_result_length+=args[i]->max_length;
465
465
 
652
652
 
653
653
void Item_func_replace::fix_length_and_dec()
654
654
{
655
 
  ulonglong max_result_length= args[0]->max_length;
 
655
  uint64_t max_result_length= args[0]->max_length;
656
656
  int diff=(int) (args[2]->max_length - args[1]->max_length);
657
657
  if (diff > 0 && args[1]->max_length)
658
658
  {                                             // Calculate of maxreplaces
659
 
    ulonglong max_substrs= max_result_length/args[1]->max_length;
 
659
    uint64_t max_substrs= max_result_length/args[1]->max_length;
660
660
    max_result_length+= max_substrs * (uint) diff;
661
661
  }
662
662
  if (max_result_length >= MAX_BLOB_WIDTH)
702
702
  if (length > res->length() - start)
703
703
    length= res->length() - start;
704
704
 
705
 
  if ((ulonglong) (res->length() - length + res2->length()) >
706
 
      (ulonglong) current_thd->variables.max_allowed_packet)
 
705
  if ((uint64_t) (res->length() - length + res2->length()) >
 
706
      (uint64_t) current_thd->variables.max_allowed_packet)
707
707
  {
708
708
    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
709
709
                        ER_WARN_ALLOWED_PACKET_OVERFLOWED,
722
722
 
723
723
void Item_func_insert::fix_length_and_dec()
724
724
{
725
 
  ulonglong max_result_length;
 
725
  uint64_t max_result_length;
726
726
 
727
727
  // Handle character set for args[0] and args[3].
728
728
  if (agg_arg_charsets(collation, &args[0], 2, MY_COLL_ALLOW_CONV, 3))
729
729
    return;
730
 
  max_result_length= ((ulonglong) args[0]->max_length+
731
 
                      (ulonglong) args[3]->max_length);
 
730
  max_result_length= ((uint64_t) args[0]->max_length+
 
731
                      (uint64_t) args[3]->max_length);
732
732
  if (max_result_length >= MAX_BLOB_WIDTH)
733
733
  {
734
734
    max_result_length= MAX_BLOB_WIDTH;
804
804
  if ((length <= 0) && (!args[1]->unsigned_flag))
805
805
    return &my_empty_string;
806
806
 
807
 
  if ((res->length() <= (ulonglong) length) ||
 
807
  if ((res->length() <= (uint64_t) length) ||
808
808
      (res->length() <= (char_pos= res->charpos((int) length))))
809
809
    return res;
810
810
 
848
848
  if ((length <= 0) && (!args[1]->unsigned_flag))
849
849
    return &my_empty_string; /* purecov: inspected */
850
850
 
851
 
  if (res->length() <= (ulonglong) length)
 
851
  if (res->length() <= (uint64_t) length)
852
852
    return res; /* purecov: inspected */
853
853
 
854
854
  uint start=res->numchars();
895
895
  /* if "unsigned_flag" is set, we have a *huge* positive number. */
896
896
  /* Assumes that the maximum length of a String is < INT_MAX32. */
897
897
  if ((!args[1]->unsigned_flag && (start < INT_MIN32 || start > INT_MAX32)) ||
898
 
      (args[1]->unsigned_flag && ((ulonglong) start > INT_MAX32)))
 
898
      (args[1]->unsigned_flag && ((uint64_t) start > INT_MAX32)))
899
899
    return &my_empty_string;
900
900
 
901
901
  start= ((start < 0) ? res->numchars() + start : start - 1);
1729
1729
String *Item_func_make_set::val_str(String *str)
1730
1730
{
1731
1731
  assert(fixed == 1);
1732
 
  ulonglong bits;
 
1732
  uint64_t bits;
1733
1733
  bool first_found=0;
1734
1734
  Item **ptr=args;
1735
1735
  String *result=&my_empty_string;
1739
1739
    return NULL;
1740
1740
 
1741
1741
  if (arg_count < 64)
1742
 
    bits &= ((ulonglong) 1 << arg_count)-1;
 
1742
    bits &= ((uint64_t) 1 << arg_count)-1;
1743
1743
 
1744
1744
  for (; bits; bits >>= 1, ptr++)
1745
1745
  {
1873
1873
    if (count > INT_MAX32)
1874
1874
      count= INT_MAX32;
1875
1875
 
1876
 
    ulonglong max_result_length= (ulonglong) args[0]->max_length * count;
 
1876
    uint64_t max_result_length= (uint64_t) args[0]->max_length * count;
1877
1877
    if (max_result_length >= MAX_BLOB_WIDTH)
1878
1878
    {
1879
1879
      max_result_length= MAX_BLOB_WIDTH;
1911
1911
 
1912
1912
  /* Assumes that the maximum length of a String is < INT_MAX32. */
1913
1913
  /* Bounds check on count:  If this is triggered, we will error. */
1914
 
  if ((ulonglong) count > INT_MAX32)
 
1914
  if ((uint64_t) count > INT_MAX32)
1915
1915
    count= INT_MAX32;
1916
1916
  if (count == 1)                       // To avoid reallocs
1917
1917
    return res;
1950
1950
    return;
1951
1951
  if (args[1]->const_item())
1952
1952
  {
1953
 
    ulonglong length= 0;
 
1953
    uint64_t length= 0;
1954
1954
 
1955
1955
    if (collation.collation->mbmaxlen > 0)
1956
1956
    {
1957
 
      ulonglong temp= (ulonglong) args[1]->val_int();
 
1957
      uint64_t temp= (uint64_t) args[1]->val_int();
1958
1958
 
1959
1959
      /* Assumes that the maximum length of a String is < INT_MAX32. */
1960
1960
      /* Set here so that rest of code sees out-of-bound value as such. */
1997
1997
  null_value=0;
1998
1998
  /* Assumes that the maximum length of a String is < INT_MAX32. */
1999
1999
  /* Set here so that rest of code sees out-of-bound value as such. */
2000
 
  if ((ulonglong) count > INT_MAX32)
 
2000
  if ((uint64_t) count > INT_MAX32)
2001
2001
    count= INT_MAX32;
2002
2002
  if (count <= (res_char_length= res->numchars()))
2003
2003
  {                                             // String to pad is big enough
2007
2007
  pad_char_length= rpad->numchars();
2008
2008
 
2009
2009
  byte_count= count * collation.collation->mbmaxlen;
2010
 
  if ((ulonglong) byte_count > current_thd->variables.max_allowed_packet)
 
2010
  if ((uint64_t) byte_count > current_thd->variables.max_allowed_packet)
2011
2011
  {
2012
2012
    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
2013
2013
                        ER_WARN_ALLOWED_PACKET_OVERFLOWED,
2053
2053
  
2054
2054
  if (args[1]->const_item())
2055
2055
  {
2056
 
    ulonglong length= 0;
 
2056
    uint64_t length= 0;
2057
2057
 
2058
2058
    if (collation.collation->mbmaxlen > 0)
2059
2059
    {
2060
 
      ulonglong temp= (ulonglong) args[1]->val_int();
 
2060
      uint64_t temp= (uint64_t) args[1]->val_int();
2061
2061
 
2062
2062
      /* Assumes that the maximum length of a String is < INT_MAX32. */
2063
2063
      /* Set here so that rest of code sees out-of-bound value as such. */
2098
2098
  null_value=0;
2099
2099
  /* Assumes that the maximum length of a String is < INT_MAX32. */
2100
2100
  /* Set here so that rest of code sees out-of-bound value as such. */
2101
 
  if ((ulonglong) count > INT_MAX32)
 
2101
  if ((uint64_t) count > INT_MAX32)
2102
2102
    count= INT_MAX32;
2103
2103
 
2104
2104
  res_char_length= res->numchars();
2112
2112
  pad_char_length= pad->numchars();
2113
2113
  byte_count= count * collation.collation->mbmaxlen;
2114
2114
  
2115
 
  if ((ulonglong) byte_count > current_thd->variables.max_allowed_packet)
 
2115
  if ((uint64_t) byte_count > current_thd->variables.max_allowed_packet)
2116
2116
  {
2117
2117
    push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
2118
2118
                        ER_WARN_ALLOWED_PACKET_OVERFLOWED,
2359
2359
  assert(fixed == 1);
2360
2360
  if (args[0]->result_type() != STRING_RESULT)
2361
2361
  {
2362
 
    ulonglong dec;
 
2362
    uint64_t dec;
2363
2363
    char ans[65],*ptr;
2364
2364
    /* Return hex of unsigned longlong value */
2365
2365
    if (args[0]->result_type() == REAL_RESULT ||
2367
2367
    {
2368
2368
      double val= args[0]->val_real();
2369
2369
      if ((val <= (double) LONGLONG_MIN) || 
2370
 
          (val >= (double) (ulonglong) ULONGLONG_MAX))
 
2370
          (val >= (double) (uint64_t) ULONGLONG_MAX))
2371
2371
        dec=  ~(longlong) 0;
2372
2372
      else
2373
 
        dec= (ulonglong) (val + (val > 0 ? 0.5 : -0.5));
 
2373
        dec= (uint64_t) (val + (val > 0 ? 0.5 : -0.5));
2374
2374
    }
2375
2375
    else
2376
 
      dec= (ulonglong) args[0]->val_int();
 
2376
      dec= (uint64_t) args[0]->val_int();
2377
2377
 
2378
2378
    if ((null_value= args[0]->null_value))
2379
2379
      return 0;
2507
2507
String* Item_func_export_set::val_str(String* str)
2508
2508
{
2509
2509
  assert(fixed == 1);
2510
 
  ulonglong the_set = (ulonglong) args[0]->val_int();
 
2510
  uint64_t the_set = (uint64_t) args[0]->val_int();
2511
2511
  String yes_buf, *yes;
2512
2512
  yes = args[1]->val_str(&yes_buf);
2513
2513
  String no_buf, *no;
2515
2515
  String *sep = NULL, sep_buf ;
2516
2516
 
2517
2517
  uint num_set_values = 64;
2518
 
  ulonglong mask = 0x1;
 
2518
  uint64_t mask = 0x1;
2519
2519
  str->length(0);
2520
2520
  str->set_charset(collation.collation);
2521
2521
 
2847
2847
 
2848
2848
static struct rand_struct uuid_rand;
2849
2849
static uint nanoseq;
2850
 
static ulonglong uuid_time=0;
 
2850
static uint64_t uuid_time=0;
2851
2851
static char clock_seq_and_node_str[]="-0000-000000000000";
2852
2852
 
2853
2853
/**
2854
2854
  number of 100-nanosecond intervals between
2855
2855
  1582-10-15 00:00:00.00 and 1970-01-01 00:00:00.00.
2856
2856
*/
2857
 
#define UUID_TIME_OFFSET ((ulonglong) 141427 * 24 * 60 * 60 * 1000 * 10 )
 
2857
#define UUID_TIME_OFFSET ((uint64_t) 141427 * 24 * 60 * 60 * 1000 * 10 )
2858
2858
 
2859
2859
#define UUID_VERSION      0x1000
2860
2860
#define UUID_VARIANT      0x8000
2913
2913
    set_clock_seq_str();
2914
2914
  }
2915
2915
 
2916
 
  ulonglong tv=my_getsystime() + UUID_TIME_OFFSET + nanoseq;
 
2916
  uint64_t tv=my_getsystime() + UUID_TIME_OFFSET + nanoseq;
2917
2917
  if (unlikely(tv < uuid_time))
2918
2918
    set_clock_seq_str();
2919
2919
  else if (unlikely(tv == uuid_time))