~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_cmpfunc.cc

  • Committer: Lee
  • Date: 2008-10-03 23:31:06 UTC
  • mfrom: (413.2.3 drizzle)
  • mto: This revision was merged to the branch mainline in revision 459.
  • Revision ID: lbieber@lbieber-desktop-20081003233106-tgvzu0fh25gb3xeg
breaking out enum field classes

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
    return INT_RESULT;
43
43
}
44
44
 
45
 
static void agg_result_type(Item_result *type, Item **items, uint32_t nitems)
 
45
static void agg_result_type(Item_result *type, Item **items, uint nitems)
46
46
{
47
47
  Item **item, **item_end;
48
48
  bool unsigned_flag= 0;
90
90
 
91
91
static int cmp_row_type(Item* item1, Item* item2)
92
92
{
93
 
  uint32_t n= item1->cols();
 
93
  uint n= item1->cols();
94
94
  if (item2->check_cols(n))
95
95
    return 1;
96
 
  for (uint32_t i=0; i<n; i++)
 
96
  for (uint i=0; i<n; i++)
97
97
  {
98
98
    if (item2->element_index(i)->check_cols(item1->element_index(i)->cols()) ||
99
99
        (item1->element_index(i)->result_type() == ROW_RESULT &&
127
127
    0  otherwise
128
128
*/
129
129
 
130
 
static int agg_cmp_type(Item_result *type, Item **items, uint32_t nitems)
 
130
static int agg_cmp_type(Item_result *type, Item **items, uint nitems)
131
131
{
132
 
  uint32_t i;
 
132
  uint i;
133
133
  type[0]= items[0]->result_type();
134
134
  for (i= 1 ; i < nitems ; i++)
135
135
  {
166
166
  @return aggregated field type.
167
167
*/
168
168
 
169
 
enum_field_types agg_field_type(Item **items, uint32_t nitems)
 
169
enum_field_types agg_field_type(Item **items, uint nitems)
170
170
{
171
 
  uint32_t i;
 
171
  uint i;
172
172
  if (!nitems || items[0]->result_type() == ROW_RESULT )
173
173
    return (enum_field_types)-1;
174
174
  enum_field_types res= items[0]->field_type();
194
194
    Bitmap of collected types - otherwise
195
195
*/
196
196
 
197
 
static uint32_t collect_cmp_types(Item **items, uint32_t nitems)
 
197
static uint collect_cmp_types(Item **items, uint nitems)
198
198
{
199
 
  uint32_t i;
200
 
  uint32_t found_types;
 
199
  uint i;
 
200
  uint found_types;
201
201
  Item_result left_result= items[0]->result_type();
202
202
  assert(nitems > 1);
203
203
  found_types= 0;
510
510
  switch (type) {
511
511
  case ROW_RESULT:
512
512
  {
513
 
    uint32_t n= (*a)->cols();
 
513
    uint n= (*a)->cols();
514
514
    if (n != (*b)->cols())
515
515
    {
516
516
      my_error(ER_OPERAND_COLUMNS, MYF(0), n);
519
519
    }
520
520
    if (!(comparators= new Arg_comparator[n]))
521
521
      return 1;
522
 
    for (uint32_t i=0; i < n; i++)
 
522
    for (uint i=0; i < n; i++)
523
523
    {
524
524
      if ((*a)->element_index(i)->cols() != (*b)->element_index(i)->cols())
525
525
      {
561
561
        which would be transformed to:
562
562
        WHERE col= 'j'
563
563
      */
564
 
      (*a)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
565
 
      (*b)->walk(&Item::set_no_const_sub, false, (unsigned char*) 0);
 
564
      (*a)->walk(&Item::set_no_const_sub, false, (uchar*) 0);
 
565
      (*b)->walk(&Item::set_no_const_sub, false, (uchar*) 0);
566
566
    }
567
567
    break;
568
568
  }
1079
1079
    if ((res2= (*b)->val_str(&owner->tmp_value2)))
1080
1080
    {
1081
1081
      owner->null_value= 0;
1082
 
      uint32_t res1_length= res1->length();
1083
 
      uint32_t res2_length= res2->length();
 
1082
      uint res1_length= res1->length();
 
1083
      uint res2_length= res2->length();
1084
1084
      int cmp= memcmp(res1->ptr(), res2->ptr(), cmin(res1_length,res2_length));
1085
1085
      return cmp ? cmp : (int) (res1_length - res2_length);
1086
1086
    }
1337
1337
  bool was_null= 0;
1338
1338
  (*a)->bring_value();
1339
1339
  (*b)->bring_value();
1340
 
  uint32_t n= (*a)->cols();
1341
 
  for (uint32_t i= 0; i<n; i++)
 
1340
  uint n= (*a)->cols();
 
1341
  for (uint i= 0; i<n; i++)
1342
1342
  {
1343
1343
    res= comparators[i].compare();
1344
1344
    if (owner->null_value)
1380
1380
{
1381
1381
  (*a)->bring_value();
1382
1382
  (*b)->bring_value();
1383
 
  uint32_t n= (*a)->cols();
1384
 
  for (uint32_t i= 0; i<n; i++)
 
1383
  uint n= (*a)->cols();
 
1384
  for (uint i= 0; i<n; i++)
1385
1385
  {
1386
1386
    if (!comparators[i].compare())
1387
1387
      return 0;
1459
1459
  }
1460
1460
  else
1461
1461
  {
1462
 
    uint32_t n= cache->cols();
1463
 
    for (uint32_t i= 0; i < n; i++)
 
1462
    uint n= cache->cols();
 
1463
    for (uint i= 0; i < n; i++)
1464
1464
    {
1465
1465
      if (args[0]->element_index(i)->used_tables())
1466
1466
        ((Item_cache *)cache->element_index(i))->set_used_tables(OUTER_REF_TABLE_BIT);
1547
1547
        }
1548
1548
        else
1549
1549
        {
1550
 
          uint32_t i;
1551
 
          uint32_t ncols= cache->cols();
 
1550
          uint i;
 
1551
          uint ncols= cache->cols();
1552
1552
          /*
1553
1553
            Turn off the predicates that are based on column compares for
1554
1554
            which the left part is currently NULL
1621
1621
    @retval NULL if an error occurred
1622
1622
*/
1623
1623
 
1624
 
Item *Item_in_optimizer::transform(Item_transformer transformer, unsigned char *argument)
 
1624
Item *Item_in_optimizer::transform(Item_transformer transformer, uchar *argument)
1625
1625
{
1626
1626
  Item *new_item;
1627
1627
 
1753
1753
    return 0;
1754
1754
  if (negated != ((Item_func_opt_neg *) item_func)->negated)
1755
1755
    return 0;
1756
 
  for (uint32_t i=0; i < arg_count ; i++)
 
1756
  for (uint i=0; i < arg_count ; i++)
1757
1757
    if (!args[i]->eq(item_func->arguments()[i], binary_cmp))
1758
1758
      return 0;
1759
1759
  return 1;
1762
1762
 
1763
1763
void Item_func_interval::fix_length_and_dec()
1764
1764
{
1765
 
  uint32_t rows= row->cols();
 
1765
  uint rows= row->cols();
1766
1766
  
1767
1767
  use_decimal_comparison= ((row->element_index(0)->result_type() ==
1768
1768
                            DECIMAL_RESULT) ||
1772
1772
  {
1773
1773
    bool not_null_consts= true;
1774
1774
 
1775
 
    for (uint32_t i= 1; not_null_consts && i < rows; i++)
 
1775
    for (uint i= 1; not_null_consts && i < rows; i++)
1776
1776
    {
1777
1777
      Item *el= row->element_index(i);
1778
1778
      not_null_consts&= el->const_item() & !el->is_null();
1784
1784
    {
1785
1785
      if (use_decimal_comparison)
1786
1786
      {
1787
 
        for (uint32_t i= 1; i < rows; i++)
 
1787
        for (uint i= 1; i < rows; i++)
1788
1788
        {
1789
1789
          Item *el= row->element_index(i);
1790
1790
          interval_range *range= intervals + (i-1);
1809
1809
      }
1810
1810
      else
1811
1811
      {
1812
 
        for (uint32_t i= 1; i < rows; i++)
 
1812
        for (uint i= 1; i < rows; i++)
1813
1813
        {
1814
1814
          intervals[i-1].dbl= row->element_index(i)->val_real();
1815
1815
        }
1844
1844
  assert(fixed == 1);
1845
1845
  double value;
1846
1846
  my_decimal dec_buf, *dec= NULL;
1847
 
  uint32_t i;
 
1847
  uint i;
1848
1848
 
1849
1849
  if (use_decimal_comparison)
1850
1850
  {
1862
1862
 
1863
1863
  if (intervals)
1864
1864
  {                                     // Use binary search to find interval
1865
 
    uint32_t start,end;
 
1865
    uint start,end;
1866
1866
    start= 0;
1867
1867
    end=   row->cols()-2;
1868
1868
    while (start != end)
1869
1869
    {
1870
 
      uint32_t mid= (start + end + 1) / 2;
 
1870
      uint mid= (start + end + 1) / 2;
1871
1871
      interval_range *range= intervals + mid;
1872
1872
      bool cmp_result;
1873
1873
      /*
2200
2200
}
2201
2201
 
2202
2202
 
2203
 
uint32_t Item_func_ifnull::decimal_precision() const
 
2203
uint Item_func_ifnull::decimal_precision() const
2204
2204
{
2205
2205
  int max_int_part=cmax(args[0]->decimal_int_part(),args[1]->decimal_int_part());
2206
2206
  return cmin(max_int_part + decimals, DECIMAL_MAX_PRECISION);
2382
2382
}
2383
2383
 
2384
2384
 
2385
 
uint32_t Item_func_if::decimal_precision() const
 
2385
uint Item_func_if::decimal_precision() const
2386
2386
{
2387
2387
  int precision=(cmax(args[1]->decimal_int_part(),args[2]->decimal_int_part())+
2388
2388
                 decimals);
2554
2554
 
2555
2555
Item *Item_func_case::find_item(String *str __attribute__((unused)))
2556
2556
{
2557
 
  uint32_t value_added_map= 0;
 
2557
  uint value_added_map= 0;
2558
2558
 
2559
2559
  if (first_expr_num == -1)
2560
2560
  {
2561
 
    for (uint32_t i=0 ; i < ncases ; i+=2)
 
2561
    for (uint i=0 ; i < ncases ; i+=2)
2562
2562
    {
2563
2563
      // No expression between CASE and the first WHEN
2564
2564
      if (args[i]->val_bool())
2569
2569
  else
2570
2570
  {
2571
2571
    /* Compare every WHEN argument with it and return the first match */
2572
 
    for (uint32_t i=0 ; i < ncases ; i+=2)
 
2572
    for (uint i=0 ; i < ncases ; i+=2)
2573
2573
    {
2574
2574
      cmp_type= item_cmp_type(left_result_type, args[i]->result_type());
2575
2575
      assert(cmp_type != ROW_RESULT);
2671
2671
    buff should match stack usage from
2672
2672
    Item_func_case::val_int() -> Item_func_case::find_item()
2673
2673
  */
2674
 
  unsigned char buff[MAX_FIELD_WIDTH*2+sizeof(String)*2+sizeof(String*)*2+sizeof(double)*2+sizeof(int64_t)*2];
 
2674
  uchar buff[MAX_FIELD_WIDTH*2+sizeof(String)*2+sizeof(String*)*2+sizeof(double)*2+sizeof(int64_t)*2];
2675
2675
  bool res= Item_func::fix_fields(thd, ref);
2676
2676
  /*
2677
2677
    Call check_stack_overrun after fix_fields to be sure that stack variable
2693
2693
 
2694
2694
void Item_func_case::agg_num_lengths(Item *arg)
2695
2695
{
2696
 
  uint32_t len= my_decimal_length_to_precision(arg->max_length, arg->decimals,
 
2696
  uint len= my_decimal_length_to_precision(arg->max_length, arg->decimals,
2697
2697
                                           arg->unsigned_flag) - arg->decimals;
2698
2698
  set_if_bigger(max_length, len); 
2699
2699
  set_if_bigger(decimals, arg->decimals);
2704
2704
void Item_func_case::fix_length_and_dec()
2705
2705
{
2706
2706
  Item **agg;
2707
 
  uint32_t nagg;
2708
 
  uint32_t found_types= 0;
 
2707
  uint nagg;
 
2708
  uint found_types= 0;
2709
2709
  if (!(agg= (Item**) sql_alloc(sizeof(Item*)*(ncases+1))))
2710
2710
    return;
2711
2711
  
2732
2732
  */
2733
2733
  if (first_expr_num != -1)
2734
2734
  {
2735
 
    uint32_t i;
 
2735
    uint i;
2736
2736
    agg[0]= args[first_expr_num];
2737
2737
    left_result_type= agg[0]->result_type();
2738
2738
 
2766
2766
  unsigned_flag= true;
2767
2767
  if (cached_result_type == STRING_RESULT)
2768
2768
  {
2769
 
    for (uint32_t i= 0; i < ncases; i+= 2)
 
2769
    for (uint i= 0; i < ncases; i+= 2)
2770
2770
      agg_str_lengths(args[i + 1]);
2771
2771
    if (else_expr_num != -1)
2772
2772
      agg_str_lengths(args[else_expr_num]);
2773
2773
  }
2774
2774
  else
2775
2775
  {
2776
 
    for (uint32_t i= 0; i < ncases; i+= 2)
 
2776
    for (uint i= 0; i < ncases; i+= 2)
2777
2777
      agg_num_lengths(args[i + 1]);
2778
2778
    if (else_expr_num != -1) 
2779
2779
      agg_num_lengths(args[else_expr_num]);
2783
2783
}
2784
2784
 
2785
2785
 
2786
 
uint32_t Item_func_case::decimal_precision() const
 
2786
uint Item_func_case::decimal_precision() const
2787
2787
{
2788
2788
  int max_int_part=0;
2789
 
  for (uint32_t i=0 ; i < ncases ; i+=2)
 
2789
  for (uint i=0 ; i < ncases ; i+=2)
2790
2790
    set_if_bigger(max_int_part, args[i+1]->decimal_int_part());
2791
2791
 
2792
2792
  if (else_expr_num != -1) 
2808
2808
    args[first_expr_num]->print(str, query_type);
2809
2809
    str->append(' ');
2810
2810
  }
2811
 
  for (uint32_t i=0 ; i < ncases ; i+=2)
 
2811
  for (uint i=0 ; i < ncases ; i+=2)
2812
2812
  {
2813
2813
    str->append(STRING_WITH_LEN("when "));
2814
2814
    args[i]->print(str, query_type);
2828
2828
 
2829
2829
void Item_func_case::cleanup()
2830
2830
{
2831
 
  uint32_t i;
 
2831
  uint i;
2832
2832
  Item_func::cleanup();
2833
2833
  for (i= 0; i <= (uint)DECIMAL_RESULT; i++)
2834
2834
  {
2847
2847
{
2848
2848
  assert(fixed == 1);
2849
2849
  null_value=0;
2850
 
  for (uint32_t i=0 ; i < arg_count ; i++)
 
2850
  for (uint i=0 ; i < arg_count ; i++)
2851
2851
  {
2852
2852
    String *res;
2853
2853
    if ((res=args[i]->val_str(str)))
2861
2861
{
2862
2862
  assert(fixed == 1);
2863
2863
  null_value=0;
2864
 
  for (uint32_t i=0 ; i < arg_count ; i++)
 
2864
  for (uint i=0 ; i < arg_count ; i++)
2865
2865
  {
2866
2866
    int64_t res=args[i]->val_int();
2867
2867
    if (!args[i]->null_value)
2875
2875
{
2876
2876
  assert(fixed == 1);
2877
2877
  null_value=0;
2878
 
  for (uint32_t i=0 ; i < arg_count ; i++)
 
2878
  for (uint i=0 ; i < arg_count ; i++)
2879
2879
  {
2880
2880
    double res= args[i]->val_real();
2881
2881
    if (!args[i]->null_value)
2890
2890
{
2891
2891
  assert(fixed == 1);
2892
2892
  null_value= 0;
2893
 
  for (uint32_t i= 0; i < arg_count; i++)
 
2893
  for (uint i= 0; i < arg_count; i++)
2894
2894
  {
2895
2895
    my_decimal *res= args[i]->val_decimal(decimal_value);
2896
2896
    if (!args[i]->null_value)
3052
3052
 
3053
3053
int in_vector::find(Item *item)
3054
3054
{
3055
 
  unsigned char *result=get_value(item);
 
3055
  uchar *result=get_value(item);
3056
3056
  if (!result || !used_count)
3057
3057
    return 0;                           // Null value
3058
3058
 
3059
 
  uint32_t start,end;
 
3059
  uint start,end;
3060
3060
  start=0; end=used_count-1;
3061
3061
  while (start != end)
3062
3062
  {
3063
 
    uint32_t mid=(start+end+1)/2;
 
3063
    uint mid=(start+end+1)/2;
3064
3064
    int res;
3065
3065
    if ((res=(*compare)(collation, base+mid*size, result)) == 0)
3066
3066
      return 1;
3072
3072
  return (int) ((*compare)(collation, base+start*size, result) == 0);
3073
3073
}
3074
3074
 
3075
 
in_string::in_string(uint32_t elements,qsort2_cmp cmp_func, const CHARSET_INFO * const cs)
 
3075
in_string::in_string(uint elements,qsort2_cmp cmp_func, const CHARSET_INFO * const cs)
3076
3076
  :in_vector(elements, sizeof(String), cmp_func, cs),
3077
3077
   tmp(buff, sizeof(buff), &my_charset_bin)
3078
3078
{}
3082
3082
  if (base)
3083
3083
  {
3084
3084
    // base was allocated with help of sql_alloc => following is OK
3085
 
    for (uint32_t i=0 ; i < count ; i++)
 
3085
    for (uint i=0 ; i < count ; i++)
3086
3086
      ((String*) base)[i].free();
3087
3087
  }
3088
3088
}
3089
3089
 
3090
 
void in_string::set(uint32_t pos,Item *item)
 
3090
void in_string::set(uint pos,Item *item)
3091
3091
{
3092
3092
  String *str=((String*) base)+pos;
3093
3093
  String *res=item->val_str(str);
3110
3110
}
3111
3111
 
3112
3112
 
3113
 
unsigned char *in_string::get_value(Item *item)
 
3113
uchar *in_string::get_value(Item *item)
3114
3114
{
3115
 
  return (unsigned char*) item->val_str(&tmp);
 
3115
  return (uchar*) item->val_str(&tmp);
3116
3116
}
3117
3117
 
3118
 
in_row::in_row(uint32_t elements, Item * item __attribute__((unused)))
 
3118
in_row::in_row(uint elements, Item * item __attribute__((unused)))
3119
3119
{
3120
3120
  base= (char*) new cmp_item_row[count= elements];
3121
3121
  size= sizeof(cmp_item_row);
3134
3134
    delete [] (cmp_item_row*) base;
3135
3135
}
3136
3136
 
3137
 
unsigned char *in_row::get_value(Item *item)
 
3137
uchar *in_row::get_value(Item *item)
3138
3138
{
3139
3139
  tmp.store_value(item);
3140
3140
  if (item->is_null())
3141
3141
    return 0;
3142
 
  return (unsigned char *)&tmp;
 
3142
  return (uchar *)&tmp;
3143
3143
}
3144
3144
 
3145
 
void in_row::set(uint32_t pos, Item *item)
 
3145
void in_row::set(uint pos, Item *item)
3146
3146
{
3147
3147
  ((cmp_item_row*) base)[pos].store_value_by_template(&tmp, item);
3148
3148
  return;
3149
3149
}
3150
3150
 
3151
 
in_int64_t::in_int64_t(uint32_t elements)
 
3151
in_int64_t::in_int64_t(uint elements)
3152
3152
  :in_vector(elements,sizeof(packed_int64_t),(qsort2_cmp) cmp_int64_t, 0)
3153
3153
{}
3154
3154
 
3155
 
void in_int64_t::set(uint32_t pos,Item *item)
 
3155
void in_int64_t::set(uint pos,Item *item)
3156
3156
{
3157
3157
  struct packed_int64_t *buff= &((packed_int64_t*) base)[pos];
3158
3158
  
3160
3160
  buff->unsigned_flag= item->unsigned_flag;
3161
3161
}
3162
3162
 
3163
 
unsigned char *in_int64_t::get_value(Item *item)
 
3163
uchar *in_int64_t::get_value(Item *item)
3164
3164
{
3165
3165
  tmp.val= item->val_int();
3166
3166
  if (item->null_value)
3167
3167
    return 0;
3168
3168
  tmp.unsigned_flag= item->unsigned_flag;
3169
 
  return (unsigned char*) &tmp;
 
3169
  return (uchar*) &tmp;
3170
3170
}
3171
3171
 
3172
 
void in_datetime::set(uint32_t pos,Item *item)
 
3172
void in_datetime::set(uint pos,Item *item)
3173
3173
{
3174
3174
  Item **tmp_item= &item;
3175
3175
  bool is_null;
3179
3179
  buff->unsigned_flag= 1L;
3180
3180
}
3181
3181
 
3182
 
unsigned char *in_datetime::get_value(Item *item)
 
3182
uchar *in_datetime::get_value(Item *item)
3183
3183
{
3184
3184
  bool is_null;
3185
3185
  Item **tmp_item= lval_cache ? &lval_cache : &item;
3187
3187
  if (item->null_value)
3188
3188
    return 0;
3189
3189
  tmp.unsigned_flag= 1L;
3190
 
  return (unsigned char*) &tmp;
 
3190
  return (uchar*) &tmp;
3191
3191
}
3192
3192
 
3193
 
in_double::in_double(uint32_t elements)
 
3193
in_double::in_double(uint elements)
3194
3194
  :in_vector(elements,sizeof(double),(qsort2_cmp) cmp_double, 0)
3195
3195
{}
3196
3196
 
3197
 
void in_double::set(uint32_t pos,Item *item)
 
3197
void in_double::set(uint pos,Item *item)
3198
3198
{
3199
3199
  ((double*) base)[pos]= item->val_real();
3200
3200
}
3201
3201
 
3202
 
unsigned char *in_double::get_value(Item *item)
 
3202
uchar *in_double::get_value(Item *item)
3203
3203
{
3204
3204
  tmp= item->val_real();
3205
3205
  if (item->null_value)
3206
3206
    return 0;                                   /* purecov: inspected */
3207
 
  return (unsigned char*) &tmp;
 
3207
  return (uchar*) &tmp;
3208
3208
}
3209
3209
 
3210
3210
 
3211
 
in_decimal::in_decimal(uint32_t elements)
 
3211
in_decimal::in_decimal(uint elements)
3212
3212
  :in_vector(elements, sizeof(my_decimal),(qsort2_cmp) cmp_decimal, 0)
3213
3213
{}
3214
3214
 
3215
3215
 
3216
 
void in_decimal::set(uint32_t pos, Item *item)
 
3216
void in_decimal::set(uint pos, Item *item)
3217
3217
{
3218
3218
  /* as far as 'item' is constant, we can store reference on my_decimal */
3219
3219
  my_decimal *dec= ((my_decimal *)base) + pos;
3226
3226
}
3227
3227
 
3228
3228
 
3229
 
unsigned char *in_decimal::get_value(Item *item)
 
3229
uchar *in_decimal::get_value(Item *item)
3230
3230
{
3231
3231
  my_decimal *result= item->val_decimal(&val);
3232
3232
  if (item->null_value)
3233
3233
    return 0;
3234
 
  return (unsigned char *)result;
 
3234
  return (uchar *)result;
3235
3235
}
3236
3236
 
3237
3237
 
3282
3282
{
3283
3283
  if (comparators)
3284
3284
  {
3285
 
    for (uint32_t i= 0; i < n; i++)
 
3285
    for (uint i= 0; i < n; i++)
3286
3286
    {
3287
3287
      if (comparators[i])
3288
3288
        delete comparators[i];
3307
3307
  {
3308
3308
    item->bring_value();
3309
3309
    item->null_value= 0;
3310
 
    for (uint32_t i=0; i < n; i++)
 
3310
    for (uint i=0; i < n; i++)
3311
3311
    {
3312
3312
      if (!comparators[i])
3313
3313
        if (!(comparators[i]=
3335
3335
  {
3336
3336
    item->bring_value();
3337
3337
    item->null_value= 0;
3338
 
    for (uint32_t i=0; i < n; i++)
 
3338
    for (uint i=0; i < n; i++)
3339
3339
    {
3340
3340
      if (!(comparators[i]= tmpl->comparators[i]->make_same()))
3341
3341
        break;                                  // new failed
3357
3357
  }
3358
3358
  bool was_null= 0;
3359
3359
  arg->bring_value();
3360
 
  for (uint32_t i=0; i < n; i++)
 
3360
  for (uint i=0; i < n; i++)
3361
3361
  {
3362
3362
    if (comparators[i]->cmp(arg->element_index(i)))
3363
3363
    {
3373
3373
int cmp_item_row::compare(cmp_item *c)
3374
3374
{
3375
3375
  cmp_item_row *l_cmp= (cmp_item_row *) c;
3376
 
  for (uint32_t i=0; i < n; i++)
 
3376
  for (uint i=0; i < n; i++)
3377
3377
  {
3378
3378
    int res;
3379
3379
    if ((res= comparators[i]->compare(l_cmp->comparators[i])))
3508
3508
static int srtcmp_in(const CHARSET_INFO * const cs, const String *x,const String *y)
3509
3509
{
3510
3510
  return cs->coll->strnncollsp(cs,
3511
 
                               (unsigned char *) x->ptr(),x->length(),
3512
 
                               (unsigned char *) y->ptr(),y->length(), 0);
 
3511
                               (uchar *) x->ptr(),x->length(),
 
3512
                               (uchar *) y->ptr(),y->length(), 0);
3513
3513
}
3514
3514
 
3515
3515
 
3522
3522
  /* true <=> arguments values will be compared as DATETIMEs. */
3523
3523
  bool compare_as_datetime= false;
3524
3524
  Item *date_arg= 0;
3525
 
  uint32_t found_types= 0;
3526
 
  uint32_t type_cnt= 0, i;
 
3525
  uint found_types= 0;
 
3526
  uint type_cnt= 0, i;
3527
3527
  Item_result cmp_type= STRING_RESULT;
3528
3528
  left_result_type= args[0]->result_type();
3529
3529
  if (!(found_types= collect_cmp_types(args, arg_count)))
3579
3579
    /* All DATE/DATETIME fields/functions has the STRING result type. */
3580
3580
    if (cmp_type == STRING_RESULT || cmp_type == ROW_RESULT)
3581
3581
    {
3582
 
      uint32_t col, cols= args[0]->cols();
 
3582
      uint col, cols= args[0]->cols();
3583
3583
 
3584
3584
      for (col= 0; col < cols; col++)
3585
3585
      {
3700
3700
    }
3701
3701
    if (array && !(thd->is_fatal_error))                // If not EOM
3702
3702
    {
3703
 
      uint32_t j=0;
3704
 
      for (uint32_t i=1 ; i < arg_count ; i++)
 
3703
      uint j=0;
 
3704
      for (uint i=1 ; i < arg_count ; i++)
3705
3705
      {
3706
3706
        array->set(j,args[i]);
3707
3707
        if (!args[i]->null_value)                       // Skip NULL values
3780
3780
{
3781
3781
  cmp_item *in_item;
3782
3782
  assert(fixed == 1);
3783
 
  uint32_t value_added_map= 0;
 
3783
  uint value_added_map= 0;
3784
3784
  if (array)
3785
3785
  {
3786
3786
    int tmp=array->find(args[0]);
3788
3788
    return (int64_t) (!null_value && tmp != negated);
3789
3789
  }
3790
3790
 
3791
 
  for (uint32_t i= 1 ; i < arg_count ; i++)
 
3791
  for (uint i= 1 ; i < arg_count ; i++)
3792
3792
  {
3793
3793
    Item_result cmp_type= item_cmp_type(left_result_type, args[i]->result_type());
3794
3794
    in_item= cmp_items[(uint)cmp_type];
3876
3876
  List_iterator<Item> li(list);
3877
3877
  Item *item;
3878
3878
  void *orig_thd_marker= thd->thd_marker;
3879
 
  unsigned char buff[sizeof(char*)];                    // Max local vars in function
 
3879
  uchar buff[sizeof(char*)];                    // Max local vars in function
3880
3880
  not_null_tables_cache= used_tables_cache= 0;
3881
3881
  const_item_cache= 1;
3882
3882
 
3979
3979
}
3980
3980
 
3981
3981
 
3982
 
bool Item_cond::walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
 
3982
bool Item_cond::walk(Item_processor processor, bool walk_subquery, uchar *arg)
3983
3983
{
3984
3984
  List_iterator_fast<Item> li(list);
3985
3985
  Item *item;
4008
4008
    Item returned as the result of transformation of the root node 
4009
4009
*/
4010
4010
 
4011
 
Item *Item_cond::transform(Item_transformer transformer, unsigned char *arg)
 
4011
Item *Item_cond::transform(Item_transformer transformer, uchar *arg)
4012
4012
{
4013
4013
  List_iterator<Item> li(list);
4014
4014
  Item *item;
4055
4055
    Item returned as the result of transformation of the root node 
4056
4056
*/
4057
4057
 
4058
 
Item *Item_cond::compile(Item_analyzer analyzer, unsigned char **arg_p,
4059
 
                         Item_transformer transformer, unsigned char *arg_t)
 
4058
Item *Item_cond::compile(Item_analyzer analyzer, uchar **arg_p,
 
4059
                         Item_transformer transformer, uchar *arg_t)
4060
4060
{
4061
4061
  if (!(this->*analyzer)(arg_p))
4062
4062
    return 0;
4069
4069
      The same parameter value of arg_p must be passed
4070
4070
      to analyze any argument of the condition formula.
4071
4071
    */   
4072
 
    unsigned char *arg_v= *arg_p;
 
4072
    uchar *arg_v= *arg_p;
4073
4073
    Item *new_item= item->compile(analyzer, &arg_v, transformer, arg_t);
4074
4074
    if (new_item && new_item != item)
4075
4075
      li.replace(new_item);
4429
4429
        const CHARSET_INFO * const cs= escape_str->charset();
4430
4430
        my_wc_t wc;
4431
4431
        int rc= cs->cset->mb_wc(cs, &wc,
4432
 
                                (const unsigned char*) escape_str->ptr(),
4433
 
                                (const unsigned char*) escape_str->ptr() +
 
4432
                                (const uchar*) escape_str->ptr(),
 
4433
                                (const uchar*) escape_str->ptr() +
4434
4434
                                               escape_str->length());
4435
4435
        escape= (int) (rc > 0 ? wc : '\\');
4436
4436
      }
4447
4447
                                         escape_str->charset(), cs, &unused))
4448
4448
        {
4449
4449
          char ch;
4450
 
          uint32_t errors;
 
4450
          uint errors;
4451
4451
          uint32_t cnvlen= copy_and_convert(&ch, 1, cs, escape_str->ptr(),
4452
4452
                                          escape_str->length(),
4453
4453
                                          escape_str->charset(), &errors);
4510
4510
}
4511
4511
 
4512
4512
#ifdef LIKE_CMP_TOUPPER
4513
 
#define likeconv(cs,A) (unsigned char) (cs)->toupper(A)
 
4513
#define likeconv(cs,A) (uchar) (cs)->toupper(A)
4514
4514
#else
4515
 
#define likeconv(cs,A) (unsigned char) (cs)->sort_order[(unsigned char) (A)]
 
4515
#define likeconv(cs,A) (uchar) (cs)->sort_order[(uchar) (A)]
4516
4516
#endif
4517
4517
 
4518
4518
 
4634
4634
  if (!cs->sort_order)
4635
4635
  {
4636
4636
    for (j = 0; j < plm1; j++)
4637
 
      bmBc[(uint) (unsigned char) pattern[j]] = plm1 - j;
 
4637
      bmBc[(uint) (uchar) pattern[j]] = plm1 - j;
4638
4638
  }
4639
4639
  else
4640
4640
  {
4680
4680
 
4681
4681
      register const int v = plm1 - i;
4682
4682
      turboShift = u - v;
4683
 
      bcShift    = bmBc[(uint) (unsigned char) text[i + j]] - plm1 + i;
 
4683
      bcShift    = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
4684
4684
      shift      = (turboShift > bcShift) ? turboShift : bcShift;
4685
4685
      shift      = (shift > bmGs[i]) ? shift : bmGs[i];
4686
4686
      if (shift == bmGs[i])
4959
4959
  fields.push_back(f);
4960
4960
}
4961
4961
 
4962
 
uint32_t Item_equal::members()
 
4962
uint Item_equal::members()
4963
4963
{
4964
4964
  return fields.elements;
4965
4965
}
5156
5156
                                      item->collation.collation);
5157
5157
}
5158
5158
 
5159
 
bool Item_equal::walk(Item_processor processor, bool walk_subquery, unsigned char *arg)
 
5159
bool Item_equal::walk(Item_processor processor, bool walk_subquery, uchar *arg)
5160
5160
{
5161
5161
  List_iterator_fast<Item_field> it(fields);
5162
5162
  Item *item;
5168
5168
  return Item_func::walk(processor, walk_subquery, arg);
5169
5169
}
5170
5170
 
5171
 
Item *Item_equal::transform(Item_transformer transformer, unsigned char *arg)
 
5171
Item *Item_equal::transform(Item_transformer transformer, uchar *arg)
5172
5172
{
5173
5173
  List_iterator<Item_field> it(fields);
5174
5174
  Item *item;