~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/item_cmpfunc.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:
396
396
    enum_check_fields orig_count_cuted_fields= thd->count_cuted_fields;
397
397
    my_bitmap_map *old_write_map;
398
398
    my_bitmap_map *old_read_map;
399
 
    ulonglong orig_field_val= 0; /* original field value if valid */
 
399
    uint64_t orig_field_val= 0; /* original field value if valid */
400
400
 
401
401
    if (table)
402
402
    {
647
647
    converted value. 0 on error and on zero-dates -- check 'failure'
648
648
*/
649
649
 
650
 
static ulonglong
 
650
static uint64_t
651
651
get_date_from_str(THD *thd, String *str, timestamp_type warn_type,
652
652
                  char *warn_name, bool *error_arg)
653
653
{
654
 
  ulonglong value= 0;
 
654
  uint64_t value= 0;
655
655
  int error;
656
656
  MYSQL_TIME l_time;
657
657
  enum_mysql_timestamp_type ret;
669
669
      warning.
670
670
    */
671
671
    *error_arg= false;
672
 
    value= TIME_to_ulonglong_datetime(&l_time);
 
672
    value= TIME_to_uint64_t_datetime(&l_time);
673
673
  }
674
674
  else
675
675
  {
719
719
*/
720
720
 
721
721
enum Arg_comparator::enum_date_cmp_type
722
 
Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
 
722
Arg_comparator::can_compare_as_dates(Item *a, Item *b, uint64_t *const_value)
723
723
{
724
724
  enum enum_date_cmp_type cmp_type= CMP_DATE_DFLT;
725
725
  Item *str_arg= 0, *date_arg= 0;
756
756
        ((Item_func*)str_arg)->functype() != Item_func::GUSERVAR_FUNC))
757
757
    {
758
758
      THD *thd= current_thd;
759
 
      ulonglong value;
 
759
      uint64_t value;
760
760
      bool error;
761
761
      String tmp, *str_val= 0;
762
762
      timestamp_type t_type= (date_arg->field_type() == MYSQL_TYPE_NEWDATE ?
801
801
    obtained value
802
802
*/
803
803
 
804
 
ulonglong
 
804
uint64_t
805
805
get_time_value(THD *thd __attribute__((__unused__)),
806
806
               Item ***item_arg, Item **cache_arg,
807
807
               Item *warn_item __attribute__((__unused__)),
808
808
               bool *is_null)
809
809
{
810
 
  ulonglong value;
 
810
  uint64_t value;
811
811
  Item *item= **item_arg;
812
812
  MYSQL_TIME ltime;
813
813
 
819
819
  else
820
820
  {
821
821
    *is_null= item->get_time(&ltime);
822
 
    value= !*is_null ? TIME_to_ulonglong_datetime(&ltime) : 0;
 
822
    value= !*is_null ? TIME_to_uint64_t_datetime(&ltime) : 0;
823
823
  }
824
824
  /*
825
825
    Do not cache GET_USER_VAR() function as its const_item() may return true
844
844
                                        Item_result type)
845
845
{
846
846
  enum enum_date_cmp_type cmp_type;
847
 
  ulonglong const_value= (ulonglong)-1;
 
847
  uint64_t const_value= (uint64_t)-1;
848
848
  a= a1;
849
849
  b= a2;
850
850
 
857
857
    a_cache= 0;
858
858
    b_cache= 0;
859
859
 
860
 
    if (const_value != (ulonglong)-1)
 
860
    if (const_value != (uint64_t)-1)
861
861
    {
862
862
      Item_cache_int *cache= new Item_cache_int();
863
863
      /* Mark the cache as non-const to prevent re-caching. */
944
944
    obtained value
945
945
*/
946
946
 
947
 
ulonglong
 
947
uint64_t
948
948
get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
949
949
                   Item *warn_item, bool *is_null)
950
950
{
951
 
  ulonglong value= 0;
 
951
  uint64_t value= 0;
952
952
  String buf, *str= 0;
953
953
  Item *item= **item_arg;
954
954
 
973
973
    *is_null= item->null_value;
974
974
  }
975
975
  if (*is_null)
976
 
    return ~(ulonglong) 0;
 
976
    return ~(uint64_t) 0;
977
977
  /*
978
978
    Convert strings to the integer DATE/DATETIME representation.
979
979
    Even if both dates provided in strings we can't compare them directly as
1035
1035
int Arg_comparator::compare_datetime()
1036
1036
{
1037
1037
  bool is_null= false;
1038
 
  ulonglong a_value, b_value;
 
1038
  uint64_t a_value, b_value;
1039
1039
 
1040
1040
  /* Get DATE/DATETIME/TIME value of the 'a' item. */
1041
1041
  a_value= (*get_value_func)(thd, &a, &a_cache, *b, &is_null);
1262
1262
 
1263
1263
int Arg_comparator::compare_int_unsigned()
1264
1264
{
1265
 
  ulonglong val1= (*a)->val_int();
 
1265
  uint64_t val1= (*a)->val_int();
1266
1266
  if (!(*a)->null_value)
1267
1267
  {
1268
 
    ulonglong val2= (*b)->val_int();
 
1268
    uint64_t val2= (*b)->val_int();
1269
1269
    if (!(*b)->null_value)
1270
1270
    {
1271
1271
      owner->null_value= 0;
1288
1288
  longlong sval1= (*a)->val_int();
1289
1289
  if (!(*a)->null_value)
1290
1290
  {
1291
 
    ulonglong uval2= (ulonglong)(*b)->val_int();
 
1291
    uint64_t uval2= (uint64_t)(*b)->val_int();
1292
1292
    if (!(*b)->null_value)
1293
1293
    {
1294
1294
      owner->null_value= 0;
1295
 
      if (sval1 < 0 || (ulonglong)sval1 < uval2)
 
1295
      if (sval1 < 0 || (uint64_t)sval1 < uval2)
1296
1296
        return -1;
1297
 
      if ((ulonglong)sval1 == uval2)
 
1297
      if ((uint64_t)sval1 == uval2)
1298
1298
        return 0;
1299
1299
      return 1;
1300
1300
    }
1310
1310
 
1311
1311
int Arg_comparator::compare_int_unsigned_signed()
1312
1312
{
1313
 
  ulonglong uval1= (ulonglong)(*a)->val_int();
 
1313
  uint64_t uval1= (uint64_t)(*a)->val_int();
1314
1314
  if (!(*a)->null_value)
1315
1315
  {
1316
1316
    longlong sval2= (*b)->val_int();
1319
1319
      owner->null_value= 0;
1320
1320
      if (sval2 < 0)
1321
1321
        return 1;
1322
 
      if (uval1 < (ulonglong)sval2)
 
1322
      if (uval1 < (uint64_t)sval2)
1323
1323
        return -1;
1324
 
      if (uval1 == (ulonglong)sval2)
 
1324
      if (uval1 == (uint64_t)sval2)
1325
1325
        return 0;
1326
1326
      return 1;
1327
1327
    }
2994
2994
    0           left argument is equal to the right argument.
2995
2995
    1           left argument is greater than the right argument.
2996
2996
*/
2997
 
static inline int cmp_ulongs (ulonglong a_val, ulonglong b_val)
 
2997
static inline int cmp_ulongs (uint64_t a_val, uint64_t b_val)
2998
2998
{
2999
2999
  return a_val < b_val ? -1 : a_val == b_val ? 0 : 1;
3000
3000
}
3033
3033
      One of the args is unsigned and is too big to fit into the 
3034
3034
      positive signed range. Report no match.
3035
3035
    */  
3036
 
    if ((a->unsigned_flag && ((ulonglong) a->val) > (ulonglong) LONGLONG_MAX) ||
3037
 
        (b->unsigned_flag && ((ulonglong) b->val) > (ulonglong) LONGLONG_MAX))
 
3036
    if ((a->unsigned_flag && ((uint64_t) a->val) > (uint64_t) LONGLONG_MAX) ||
 
3037
        (b->unsigned_flag && ((uint64_t) b->val) > (uint64_t) LONGLONG_MAX))
3038
3038
      return a->unsigned_flag ? 1 : -1;
3039
3039
    /*
3040
3040
      Although the signedness differs both args can fit into the signed 
3043
3043
    return cmp_longs (a->val, b->val);
3044
3044
  }
3045
3045
  if (a->unsigned_flag)
3046
 
    return cmp_ulongs ((ulonglong) a->val, (ulonglong) b->val);
 
3046
    return cmp_ulongs ((uint64_t) a->val, (uint64_t) b->val);
3047
3047
  else
3048
3048
    return cmp_longs (a->val, b->val);
3049
3049
}
3835
3835
longlong Item_func_bit_or::val_int()
3836
3836
{
3837
3837
  assert(fixed == 1);
3838
 
  ulonglong arg1= (ulonglong) args[0]->val_int();
 
3838
  uint64_t arg1= (uint64_t) args[0]->val_int();
3839
3839
  if (args[0]->null_value)
3840
3840
  {
3841
3841
    null_value=1; /* purecov: inspected */
3842
3842
    return 0; /* purecov: inspected */
3843
3843
  }
3844
 
  ulonglong arg2= (ulonglong) args[1]->val_int();
 
3844
  uint64_t arg2= (uint64_t) args[1]->val_int();
3845
3845
  if (args[1]->null_value)
3846
3846
  {
3847
3847
    null_value=1;
3855
3855
longlong Item_func_bit_and::val_int()
3856
3856
{
3857
3857
  assert(fixed == 1);
3858
 
  ulonglong arg1= (ulonglong) args[0]->val_int();
 
3858
  uint64_t arg1= (uint64_t) args[0]->val_int();
3859
3859
  if (args[0]->null_value)
3860
3860
  {
3861
3861
    null_value=1; /* purecov: inspected */
3862
3862
    return 0; /* purecov: inspected */
3863
3863
  }
3864
 
  ulonglong arg2= (ulonglong) args[1]->val_int();
 
3864
  uint64_t arg2= (uint64_t) args[1]->val_int();
3865
3865
  if (args[1]->null_value)
3866
3866
  {
3867
3867
    null_value=1; /* purecov: inspected */