~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/item_func.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:
625
625
{
626
626
  assert(fixed == 1);
627
627
 
628
 
  return unsigned_flag ? (double) ((ulonglong) val_int()) : (double) val_int();
 
628
  return unsigned_flag ? (double) ((uint64_t) val_int()) : (double) val_int();
629
629
}
630
630
 
631
631
 
785
785
  case INT_RESULT:
786
786
  {
787
787
    longlong result= int_op();
788
 
    return unsigned_flag ? (double) ((ulonglong) result) : (double) result;
 
788
    return unsigned_flag ? (double) ((uint64_t) result) : (double) result;
789
789
  }
790
790
  case REAL_RESULT:
791
791
    return real_op();
1348
1348
    return 0;
1349
1349
  }
1350
1350
  return (unsigned_flag ?
1351
 
          (ulonglong) value / (ulonglong) val2 :
 
1351
          (uint64_t) value / (uint64_t) val2 :
1352
1352
          value / val2);
1353
1353
}
1354
1354
 
1382
1382
 
1383
1383
  if (args[0]->unsigned_flag)
1384
1384
    result= args[1]->unsigned_flag ? 
1385
 
      ((ulonglong) value) % ((ulonglong) val2) : ((ulonglong) value) % val2;
 
1385
      ((uint64_t) value) % ((uint64_t) val2) : ((uint64_t) value) % val2;
1386
1386
  else
1387
1387
    result= args[1]->unsigned_flag ?
1388
 
      value % ((ulonglong) val2) : value % val2;
 
1388
      value % ((uint64_t) val2) : value % val2;
1389
1389
 
1390
1390
  return result;
1391
1391
}
1496
1496
  if (hybrid_type == INT_RESULT && args[0]->const_item())
1497
1497
  {
1498
1498
    longlong val= args[0]->val_int();
1499
 
    if ((ulonglong) val >= (ulonglong) LONGLONG_MIN &&
1500
 
        ((ulonglong) val != (ulonglong) LONGLONG_MIN ||
 
1499
    if ((uint64_t) val >= (uint64_t) LONGLONG_MIN &&
 
1500
        ((uint64_t) val != (uint64_t) LONGLONG_MIN ||
1501
1501
          args[0]->type() != INT_ITEM))        
1502
1502
    {
1503
1503
      /*
1727
1727
{
1728
1728
  assert(fixed == 1);
1729
1729
  uint shift;
1730
 
  ulonglong res= ((ulonglong) args[0]->val_int() <<
 
1730
  uint64_t res= ((uint64_t) args[0]->val_int() <<
1731
1731
                  (shift=(uint) args[1]->val_int()));
1732
1732
  if (args[0]->null_value || args[1]->null_value)
1733
1733
  {
1742
1742
{
1743
1743
  assert(fixed == 1);
1744
1744
  uint shift;
1745
 
  ulonglong res= (ulonglong) args[0]->val_int() >>
 
1745
  uint64_t res= (uint64_t) args[0]->val_int() >>
1746
1746
    (shift=(uint) args[1]->val_int());
1747
1747
  if (args[0]->null_value || args[1]->null_value)
1748
1748
  {
1757
1757
longlong Item_func_bit_neg::val_int()
1758
1758
{
1759
1759
  assert(fixed == 1);
1760
 
  ulonglong res= (ulonglong) args[0]->val_int();
 
1760
  uint64_t res= (uint64_t) args[0]->val_int();
1761
1761
  if ((null_value=args[0]->null_value))
1762
1762
    return 0;
1763
1763
  return ~res;
1990
1990
{
1991
1991
  double tmp;
1992
1992
  bool dec_negative= (dec < 0) && !dec_unsigned;
1993
 
  ulonglong abs_dec= dec_negative ? -dec : dec;
 
1993
  uint64_t abs_dec= dec_negative ? -dec : dec;
1994
1994
  /*
1995
1995
    tmp2 is here to avoid return the value with 80 bit precision
1996
1996
    This will fix that the test round(0.1,1) = round(0.1,1) is true
2030
2030
 
2031
2031
/*
2032
2032
  Rounds a given value to a power of 10 specified as the 'to' argument,
2033
 
  avoiding overflows when the value is close to the ulonglong range boundary.
 
2033
  avoiding overflows when the value is close to the uint64_t range boundary.
2034
2034
*/
2035
2035
 
2036
 
static inline ulonglong my_unsigned_round(ulonglong value, ulonglong to)
 
2036
static inline uint64_t my_unsigned_round(uint64_t value, uint64_t to)
2037
2037
{
2038
 
  ulonglong tmp= value / to * to;
 
2038
  uint64_t tmp= value / to * to;
2039
2039
  return (value - tmp < (to >> 1)) ? tmp : tmp + to;
2040
2040
}
2041
2041
 
2045
2045
  longlong value= args[0]->val_int();
2046
2046
  longlong dec= args[1]->val_int();
2047
2047
  decimals= 0;
2048
 
  ulonglong abs_dec;
 
2048
  uint64_t abs_dec;
2049
2049
  if ((null_value= args[0]->null_value || args[1]->null_value))
2050
2050
    return 0;
2051
2051
  if ((dec >= 0) || args[1]->unsigned_flag)
2061
2061
  
2062
2062
  if (truncate)
2063
2063
    value= (unsigned_flag) ?
2064
 
      ((ulonglong) value / tmp) * tmp : (value / tmp) * tmp;
 
2064
      ((uint64_t) value / tmp) * tmp : (value / tmp) * tmp;
2065
2065
  else
2066
2066
    value= (unsigned_flag || value >= 0) ?
2067
 
      my_unsigned_round((ulonglong) value, tmp) :
2068
 
      -(longlong) my_unsigned_round((ulonglong) -value, tmp);
 
2067
      my_unsigned_round((uint64_t) value, tmp) :
 
2068
      -(longlong) my_unsigned_round((uint64_t) -value, tmp);
2069
2069
  return value;
2070
2070
}
2071
2071
 
2075
2075
  my_decimal val, *value= args[0]->val_decimal(&val);
2076
2076
  longlong dec= args[1]->val_int();
2077
2077
  if (dec >= 0 || args[1]->unsigned_flag)
2078
 
    dec= min((ulonglong) dec, decimals);
 
2078
    dec= min((uint64_t) dec, decimals);
2079
2079
  else if (dec < INT_MIN)
2080
2080
    dec= INT_MIN;
2081
2081
    
2234
2234
   #    index of the least/greatest argument
2235
2235
*/
2236
2236
 
2237
 
uint Item_func_min_max::cmp_datetimes(ulonglong *value)
 
2237
uint Item_func_min_max::cmp_datetimes(uint64_t *value)
2238
2238
{
2239
 
  ulonglong min_max= 0;
 
2239
  uint64_t min_max= 0;
2240
2240
  uint min_max_idx= 0;
2241
2241
 
2242
2242
  for (uint i=0; i < arg_count ; i++)
2243
2243
  {
2244
2244
    Item **arg= args + i;
2245
2245
    bool is_null;
2246
 
    ulonglong res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null);
 
2246
    uint64_t res= get_datetime_value(thd, &arg, 0, datetime_item, &is_null);
2247
2247
    if ((null_value= args[i]->null_value))
2248
2248
      return 0;
2249
2249
    if (i == 0 || (res < min_max ? cmp_sign : -cmp_sign) > 0)
2341
2341
  double value=0.0;
2342
2342
  if (compare_as_dates)
2343
2343
  {
2344
 
    ulonglong result= 0;
 
2344
    uint64_t result= 0;
2345
2345
    (void)cmp_datetimes(&result);
2346
2346
    return (double)result;
2347
2347
  }
2368
2368
  longlong value=0;
2369
2369
  if (compare_as_dates)
2370
2370
  {
2371
 
    ulonglong result= 0;
 
2371
    uint64_t result= 0;
2372
2372
    (void)cmp_datetimes(&result);
2373
2373
    return (longlong)result;
2374
2374
  }
2396
2396
 
2397
2397
  if (compare_as_dates)
2398
2398
  {
2399
 
    ulonglong value= 0;
 
2399
    uint64_t value= 0;
2400
2400
    (void)cmp_datetimes(&value);
2401
 
    ulonglong2decimal(value, dec);
 
2401
    uint64_t2decimal(value, dec);
2402
2402
    return dec;
2403
2403
  }
2404
2404
  for (uint i=0; i < arg_count ; i++)
2670
2670
  assert(fixed == 1);
2671
2671
  if (enum_value)
2672
2672
  {
2673
 
    ulonglong tmp=(ulonglong) args[1]->val_int();
 
2673
    uint64_t tmp=(uint64_t) args[1]->val_int();
2674
2674
    if (!(null_value=args[1]->null_value || args[0]->null_value))
2675
2675
    {
2676
2676
      if (tmp & enum_bit)
2736
2736
longlong Item_func_bit_count::val_int()
2737
2737
{
2738
2738
  assert(fixed == 1);
2739
 
  ulonglong value= (ulonglong) args[0]->val_int();
 
2739
  uint64_t value= (uint64_t) args[0]->val_int();
2740
2740
  if ((null_value= args[0]->null_value))
2741
2741
    return 0; /* purecov: inspected */
2742
2742
  return (longlong) my_count_bits(value);
3352
3352
  String tmp(buff,sizeof(buff), &my_charset_bin);
3353
3353
  my_decimal tmp_decimal;
3354
3354
  THD *thd=current_thd;
3355
 
  ulonglong loop_count;
 
3355
  uint64_t loop_count;
3356
3356
 
3357
 
  loop_count= (ulonglong) args[0]->val_int();
 
3357
  loop_count= (uint64_t) args[0]->val_int();
3358
3358
 
3359
3359
  if (args[0]->null_value ||
3360
3360
      (!args[0]->unsigned_flag && (((longlong) loop_count) < 0)))
3373
3373
  }
3374
3374
 
3375
3375
  null_value=0;
3376
 
  for (ulonglong loop=0 ; loop < loop_count && !thd->killed; loop++)
 
3376
  for (uint64_t loop=0 ; loop < loop_count && !thd->killed; loop++)
3377
3377
  {
3378
3378
    switch (args[1]->result_type()) {
3379
3379
    case REAL_RESULT:
3703
3703
    if (!unsigned_flag)
3704
3704
      str->set(*(longlong*) value, &my_charset_bin);
3705
3705
    else
3706
 
      str->set(*(ulonglong*) value, &my_charset_bin);
 
3706
      str->set(*(uint64_t*) value, &my_charset_bin);
3707
3707
    break;
3708
3708
  case DECIMAL_RESULT:
3709
3709
    my_decimal2string(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, 0, 0, str);
4452
4452
longlong Item_func_bit_xor::val_int()
4453
4453
{
4454
4454
  assert(fixed == 1);
4455
 
  ulonglong arg1= (ulonglong) args[0]->val_int();
4456
 
  ulonglong arg2= (ulonglong) args[1]->val_int();
 
4455
  uint64_t arg1= (uint64_t) args[0]->val_int();
 
4456
  uint64_t arg2= (uint64_t) args[1]->val_int();
4457
4457
  if ((null_value= (args[0]->null_value || args[1]->null_value)))
4458
4458
    return 0;
4459
4459
  return (longlong) (arg1 ^ arg2);