~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.cc

  • Committer: Monty Taylor
  • Date: 2008-10-05 01:41:06 UTC
  • Revision ID: monty@inaugust.com-20081005014106-bulqe4kp7i6ipts1
Moved qsort declarations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
429
429
}
430
430
 
431
431
 
432
 
uint32_t Item::decimal_precision() const
 
432
uint Item::decimal_precision() const
433
433
{
434
434
  Item_result restype= result_type();
435
435
 
469
469
  @param arg   a dummy parameter, is not used here
470
470
*/
471
471
 
472
 
bool Item::cleanup_processor(unsigned char *arg __attribute__((unused)))
 
472
bool Item::cleanup_processor(uchar *arg __attribute__((unused)))
473
473
{
474
474
  if (fixed)
475
475
    cleanup();
524
524
    pointer to newly allocated item is returned.
525
525
*/
526
526
 
527
 
Item* Item::transform(Item_transformer transformer, unsigned char *arg)
 
527
Item* Item::transform(Item_transformer transformer, uchar *arg)
528
528
{
529
529
  return (this->*transformer)(arg);
530
530
}
581
581
  return;
582
582
}
583
583
 
584
 
bool Item_ident::remove_dependence_processor(unsigned char * arg)
 
584
bool Item_ident::remove_dependence_processor(uchar * arg)
585
585
{
586
586
  if (depended_from == (st_select_lex *) arg)
587
587
    depended_from= 0;
607
607
    for the subsequent items.
608
608
*/
609
609
 
610
 
bool Item_field::collect_item_field_processor(unsigned char *arg)
 
610
bool Item_field::collect_item_field_processor(uchar *arg)
611
611
{
612
612
  List<Item_field> *item_list= (List<Item_field>*) arg;
613
613
  List_iterator<Item_field> item_list_it(*item_list);
638
638
    false otherwise
639
639
*/
640
640
 
641
 
bool Item_field::find_item_in_field_list_processor(unsigned char *arg)
 
641
bool Item_field::find_item_in_field_list_processor(uchar *arg)
642
642
{
643
643
  KEY_PART_INFO *first_non_group_part= *((KEY_PART_INFO **) arg);
644
644
  KEY_PART_INFO *last_part= *(((KEY_PART_INFO **) arg) + 1);
661
661
    column read set or to register used fields in a view
662
662
*/
663
663
 
664
 
bool Item_field::register_field_in_read_map(unsigned char *arg)
 
664
bool Item_field::register_field_in_read_map(uchar *arg)
665
665
{
666
666
  Table *table= (Table *) arg;
667
667
  if (field->table == table || !table)
668
668
    bitmap_set_bit(field->table->read_set, field->field_index);
669
 
  if (field->vcol_info && field->vcol_info->expr_item)
670
 
    return field->vcol_info->expr_item->walk(&Item::register_field_in_read_map, 
671
 
                                             1, arg);
672
669
  return 0;
673
670
}
674
671
 
675
 
/*
676
 
  Mark field in bitmap supplied as *arg
677
 
 
678
 
*/
679
 
 
680
 
bool Item_field::register_field_in_bitmap(unsigned char *arg)
681
 
{
682
 
  MY_BITMAP *bitmap= (MY_BITMAP *) arg;
683
 
  assert(bitmap);
684
 
  bitmap_set_bit(bitmap, field->field_index);
685
 
  return false;
686
 
}
687
 
 
688
 
 
689
 
bool Item::check_cols(uint32_t c)
 
672
 
 
673
bool Item::check_cols(uint c)
690
674
{
691
675
  if (c != 1)
692
676
  {
697
681
}
698
682
 
699
683
 
700
 
void Item::set_name(const char *str, uint32_t length, const CHARSET_INFO * const cs)
 
684
void Item::set_name(const char *str, uint length, const CHARSET_INFO * const cs)
701
685
{
702
686
  if (!length)
703
687
  {
708
692
  }
709
693
  if (cs->ctype)
710
694
  {
711
 
    uint32_t orig_len= length;
 
695
    uint orig_len= length;
712
696
    /*
713
697
      This will probably need a better implementation in the future:
714
698
      a function in CHARSET_INFO structure.
813
797
Item *Item_string::safe_charset_converter(const CHARSET_INFO * const tocs)
814
798
{
815
799
  Item_string *conv;
816
 
  uint32_t conv_errors;
 
800
  uint conv_errors;
817
801
  char *ptr;
818
802
  String tmp, cstr, *ostr= val_str(&tmp);
819
803
  cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors);
842
826
{
843
827
  if (const_item())
844
828
  {
845
 
    uint32_t cnv_errors;
 
829
    uint cnv_errors;
846
830
    String *ostr= val_str(&cnvstr);
847
831
    cnvitem->str_value.copy(ostr->ptr(), ostr->length(),
848
832
                            ostr->charset(), tocs, &cnv_errors);
859
843
Item *Item_static_string_func::safe_charset_converter(const CHARSET_INFO * const tocs)
860
844
{
861
845
  Item_string *conv;
862
 
  uint32_t conv_errors;
 
846
  uint conv_errors;
863
847
  String tmp, cstr, *ostr= val_str(&tmp);
864
848
  cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors);
865
849
  if (conv_errors ||
901
885
  As a extra convenience the time structure is reset on error!
902
886
*/
903
887
 
904
 
bool Item::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
 
888
bool Item::get_date(DRIZZLE_TIME *ltime,uint fuzzydate)
905
889
{
906
890
  if (result_type() == STRING_RESULT)
907
891
  {
1055
1039
      Item_ref to allow fields from view being stored in tmp table.
1056
1040
    */
1057
1041
    Item_aggregate_ref *item_ref;
1058
 
    uint32_t el= fields.elements;
 
1042
    uint el= fields.elements;
1059
1043
    Item *real_itm= real_item();
1060
1044
 
1061
1045
    ref_pointer_array[el]= real_itm;
1125
1109
  @endcode
1126
1110
*/
1127
1111
 
1128
 
bool DTCollation::aggregate(DTCollation &dt, uint32_t flags)
 
1112
bool DTCollation::aggregate(DTCollation &dt, uint flags)
1129
1113
{
1130
1114
  if (!my_charset_same(collation, dt.collation))
1131
1115
  {
1245
1229
 
1246
1230
 
1247
1231
static
1248
 
void my_coll_agg_error(Item** args, uint32_t count, const char *fname,
 
1232
void my_coll_agg_error(Item** args, uint count, const char *fname,
1249
1233
                       int item_sep)
1250
1234
{
1251
1235
  if (count == 2)
1259
1243
 
1260
1244
 
1261
1245
bool agg_item_collations(DTCollation &c, const char *fname,
1262
 
                         Item **av, uint32_t count, uint32_t flags, int item_sep)
 
1246
                         Item **av, uint count, uint flags, int item_sep)
1263
1247
{
1264
 
  uint32_t i;
 
1248
  uint i;
1265
1249
  Item **arg;
1266
1250
  c.set(av[0]->collation);
1267
1251
  for (i= 1, arg= &av[item_sep]; i < count; i++, arg++)
1283
1267
 
1284
1268
 
1285
1269
bool agg_item_collations_for_comparison(DTCollation &c, const char *fname,
1286
 
                                        Item **av, uint32_t count, uint32_t flags)
 
1270
                                        Item **av, uint count, uint flags)
1287
1271
{
1288
1272
  return (agg_item_collations(c, fname, av, count,
1289
1273
                              flags | MY_COLL_DISALLOW_NONE, 1));
1322
1306
*/
1323
1307
 
1324
1308
bool agg_item_charsets(DTCollation &coll, const char *fname,
1325
 
                       Item **args, uint32_t nargs, uint32_t flags, int item_sep)
 
1309
                       Item **args, uint nargs, uint flags, int item_sep)
1326
1310
{
1327
1311
  Item **arg, *safe_args[2];
1328
1312
 
1346
1330
 
1347
1331
  THD *thd= current_thd;
1348
1332
  bool res= false;
1349
 
  uint32_t i;
 
1333
  uint i;
1350
1334
 
1351
1335
  for (i= 0, arg= args; i < nargs; i++, arg+= item_sep)
1352
1336
  {
1627
1611
  return result_field->val_str(str,&str_value);
1628
1612
}
1629
1613
 
1630
 
bool Item_field::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
 
1614
bool Item_field::get_date(DRIZZLE_TIME *ltime,uint fuzzydate)
1631
1615
{
1632
1616
  if ((null_value=field->is_null()) || field->get_date(ltime,fuzzydate))
1633
1617
  {
1637
1621
  return 0;
1638
1622
}
1639
1623
 
1640
 
bool Item_field::get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
 
1624
bool Item_field::get_date_result(DRIZZLE_TIME *ltime,uint fuzzydate)
1641
1625
{
1642
1626
  if ((null_value=result_field->is_null()) ||
1643
1627
      result_field->get_date(ltime,fuzzydate))
1781
1765
  This is always 'signed'. Unsigned values are created with Item_uint()
1782
1766
*/
1783
1767
 
1784
 
Item_int::Item_int(const char *str_arg, uint32_t length)
 
1768
Item_int::Item_int(const char *str_arg, uint length)
1785
1769
{
1786
1770
  char *end_ptr= (char*) str_arg + length;
1787
1771
  int error;
1815
1799
}
1816
1800
 
1817
1801
 
1818
 
Item_uint::Item_uint(const char *str_arg, uint32_t length):
 
1802
Item_uint::Item_uint(const char *str_arg, uint length):
1819
1803
  Item_int(str_arg, length)
1820
1804
{
1821
1805
  unsigned_flag= 1;
1822
1806
}
1823
1807
 
1824
1808
 
1825
 
Item_uint::Item_uint(const char *str_arg, int64_t i, uint32_t length):
 
1809
Item_uint::Item_uint(const char *str_arg, int64_t i, uint length):
1826
1810
  Item_int(str_arg, i, length)
1827
1811
{
1828
1812
  unsigned_flag= 1;
1847
1831
}
1848
1832
 
1849
1833
 
1850
 
Item_decimal::Item_decimal(const char *str_arg, uint32_t length,
 
1834
Item_decimal::Item_decimal(const char *str_arg, uint length,
1851
1835
                           const CHARSET_INFO * const charset)
1852
1836
{
1853
1837
  str2my_decimal(E_DEC_FATAL_ERROR, str_arg, length, charset, &decimal_value);
1881
1865
 
1882
1866
 
1883
1867
Item_decimal::Item_decimal(const char *str, const my_decimal *val_arg,
1884
 
                           uint32_t decimal_par, uint32_t length)
 
1868
                           uint decimal_par, uint length)
1885
1869
{
1886
1870
  my_decimal2decimal(val_arg, &decimal_value);
1887
1871
  name= (char*) str;
1901
1885
}
1902
1886
 
1903
1887
 
1904
 
Item_decimal::Item_decimal(const unsigned char *bin, int precision, int scale)
 
1888
Item_decimal::Item_decimal(const uchar *bin, int precision, int scale)
1905
1889
{
1906
1890
  binary2my_decimal(E_DEC_FATAL_ERROR, bin,
1907
1891
                    &decimal_value, precision, scale);
2136
2120
 
2137
2121
static void
2138
2122
default_set_param_func(Item_param *param,
2139
 
                       unsigned char **pos __attribute__((unused)),
 
2123
                       uchar **pos __attribute__((unused)),
2140
2124
                       ulong len __attribute__((unused)))
2141
2125
{
2142
2126
  param->set_null();
2143
2127
}
2144
2128
 
2145
2129
 
2146
 
Item_param::Item_param(uint32_t pos_in_query_arg) :
 
2130
Item_param::Item_param(uint pos_in_query_arg) :
2147
2131
  state(NO_VALUE),
2148
2132
  item_result_type(STRING_RESULT),
2149
2133
  /* Don't pretend to be a literal unless value for this item is set. */
2255
2239
      value.time.minute > 59 || value.time.second > 59)
2256
2240
  {
2257
2241
    char buff[MAX_DATE_STRING_REP_LENGTH];
2258
 
    uint32_t length= my_TIME_to_str(&value.time, buff);
 
2242
    uint length= my_TIME_to_str(&value.time, buff);
2259
2243
    make_truncated_value_warning(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2260
2244
                                 buff, length, time_type, 0);
2261
2245
    set_zero_time(&value.time, DRIZZLE_TIMESTAMP_ERROR);
2275
2259
    Assign string with no conversion: data is converted only after it's
2276
2260
    been written to the binary log.
2277
2261
  */
2278
 
  uint32_t dummy_errors;
 
2262
  uint dummy_errors;
2279
2263
  if (str_value.copy(str, length, &my_charset_bin, &my_charset_bin,
2280
2264
                     &dummy_errors))
2281
2265
    return(true);
2471
2455
}
2472
2456
 
2473
2457
 
2474
 
bool Item_param::get_date(DRIZZLE_TIME *res, uint32_t fuzzydate)
 
2458
bool Item_param::get_date(DRIZZLE_TIME *res, uint fuzzydate)
2475
2459
{
2476
2460
  if (state == TIME_VALUE)
2477
2461
  {
2893
2877
}
2894
2878
 
2895
2879
 
2896
 
bool Item_ref_null_helper::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate)
 
2880
bool Item_ref_null_helper::get_date(DRIZZLE_TIME *ltime, uint fuzzydate)
2897
2881
{  
2898
2882
  return (owner->was_null|= null_value= (*ref)->get_date(ltime, fuzzydate));
2899
2883
}
3150
3134
  Item **select_ref= NULL;
3151
3135
  order_st *group_list= (order_st*) select->group_list.first;
3152
3136
  bool ambiguous_fields= false;
3153
 
  uint32_t counter;
 
3137
  uint counter;
3154
3138
  enum_resolution_type resolution;
3155
3139
 
3156
3140
  /*
3567
3551
      /* Look up in current select's item_list to find aliased fields */
3568
3552
      if (thd->lex->current_select->is_item_list_lookup)
3569
3553
      {
3570
 
        uint32_t counter;
 
3554
        uint counter;
3571
3555
        enum_resolution_type resolution;
3572
3556
        Item** res= find_item_in_list(this, thd->lex->current_select->item_list,
3573
3557
                                      &counter, REPORT_EXCEPT_NOT_FOUND,
3787
3771
    false  otherwise
3788
3772
*/
3789
3773
 
3790
 
bool Item_field::subst_argument_checker(unsigned char **arg)
 
3774
bool Item_field::subst_argument_checker(uchar **arg)
3791
3775
{
3792
3776
  return (result_type() != STRING_RESULT) || (*arg);
3793
3777
}
3817
3801
    - pointer to the field item, otherwise.
3818
3802
*/
3819
3803
 
3820
 
Item *Item_field::equal_fields_propagator(unsigned char *arg)
 
3804
Item *Item_field::equal_fields_propagator(uchar *arg)
3821
3805
{
3822
3806
  if (no_const_subst)
3823
3807
    return this;
3850
3834
  See comments in Arg_comparator::set_compare_func() for details.
3851
3835
*/
3852
3836
 
3853
 
bool Item_field::set_no_const_sub(unsigned char *arg __attribute__((unused)))
 
3837
bool Item_field::set_no_const_sub(uchar *arg __attribute__((unused)))
3854
3838
{
3855
3839
  if (field->charset() != &my_charset_bin)
3856
3840
    no_const_subst=1;
3883
3867
    - this - otherwise.
3884
3868
*/
3885
3869
 
3886
 
Item *Item_field::replace_equal_field(unsigned char *arg __attribute__((unused)))
 
3870
Item *Item_field::replace_equal_field(uchar *arg __attribute__((unused)))
3887
3871
{
3888
3872
  if (item_equal)
3889
3873
  {
3919
3903
  tmp_field->type=              field_type_arg;
3920
3904
  tmp_field->length=max_length;
3921
3905
  tmp_field->decimals=decimals;
 
3906
  if (unsigned_flag)
 
3907
    tmp_field->flags |= UNSIGNED_FLAG;
3922
3908
}
3923
3909
 
3924
3910
void Item::make_field(Send_field *tmp_field)
3977
3963
  /* Check whether we got a well-formed string */
3978
3964
  const CHARSET_INFO * const cs= str->charset();
3979
3965
  int well_formed_error;
3980
 
  uint32_t wlen= cs->cset->well_formed_len(cs,
 
3966
  uint wlen= cs->cset->well_formed_len(cs,
3981
3967
                                       str->ptr(), str->ptr() + str->length(),
3982
3968
                                       str->length(), &well_formed_error);
3983
3969
  if (wlen < str->length())
3985
3971
    THD *thd= current_thd;
3986
3972
    char hexbuf[7];
3987
3973
    enum DRIZZLE_ERROR::enum_warning_level level;
3988
 
    uint32_t diff= str->length() - wlen;
 
3974
    uint diff= str->length() - wlen;
3989
3975
    set_if_smaller(diff, 3);
3990
3976
    octet2hex(hexbuf, str->ptr() + wlen, diff);
3991
3977
    if (send_error)
4093
4079
  /*
4094
4080
    The field functions defines a field to be not null if null_ptr is not 0
4095
4081
  */
4096
 
  unsigned char *null_ptr= maybe_null ? (unsigned char*) "" : 0;
 
4082
  uchar *null_ptr= maybe_null ? (uchar*) "" : 0;
4097
4083
  Field *field;
4098
4084
 
4099
4085
  switch (field_type()) {
4100
4086
  case DRIZZLE_TYPE_NEWDECIMAL:
4101
 
    field= new Field_new_decimal((unsigned char*) 0, max_length, null_ptr, 0,
 
4087
    field= new Field_new_decimal((uchar*) 0, max_length, null_ptr, 0,
4102
4088
                                 Field::NONE, name, decimals, 0,
4103
4089
                                 unsigned_flag);
4104
4090
    break;
4105
4091
  case DRIZZLE_TYPE_TINY:
4106
 
    field= new Field_tiny((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
 
4092
    field= new Field_tiny((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4107
4093
                          name, 0, unsigned_flag);
4108
4094
    break;
4109
4095
  case DRIZZLE_TYPE_LONG:
4110
 
    field= new Field_long((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
 
4096
    field= new Field_long((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4111
4097
                          name, 0, unsigned_flag);
4112
4098
    break;
4113
4099
  case DRIZZLE_TYPE_LONGLONG:
4114
 
    field= new Field_int64_t((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
 
4100
    field= new Field_int64_t((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4115
4101
                              name, 0, unsigned_flag);
4116
4102
    break;
4117
4103
  case DRIZZLE_TYPE_DOUBLE:
4118
 
    field= new Field_double((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
 
4104
    field= new Field_double((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4119
4105
                            name, decimals, 0, unsigned_flag);
4120
4106
    break;
4121
4107
  case DRIZZLE_TYPE_NULL:
4122
 
    field= new Field_null((unsigned char*) 0, max_length, Field::NONE,
 
4108
    field= new Field_null((uchar*) 0, max_length, Field::NONE,
4123
4109
                          name, &my_charset_bin);
4124
4110
    break;
4125
4111
  case DRIZZLE_TYPE_NEWDATE:
4381
4367
}
4382
4368
 
4383
4369
 
4384
 
static uint32_t nr_of_decimals(const char *str, const char *end)
 
4370
static uint nr_of_decimals(const char *str, const char *end)
4385
4371
{
4386
4372
  const char *decimal_point;
4387
4373
 
4409
4395
  value is not a true double value (overflow)
4410
4396
*/
4411
4397
 
4412
 
Item_float::Item_float(const char *str_arg, uint32_t length)
 
4398
Item_float::Item_float(const char *str_arg, uint length)
4413
4399
{
4414
4400
  int error;
4415
4401
  char *end_not_used;
4479
4465
}
4480
4466
 
4481
4467
 
4482
 
inline uint32_t char_val(char X)
 
4468
inline uint char_val(char X)
4483
4469
{
4484
4470
  return (uint) (X >= '0' && X <= '9' ? X-'0' :
4485
4471
                 X >= 'A' && X <= 'Z' ? X-'A'+10 :
4487
4473
}
4488
4474
 
4489
4475
 
4490
 
Item_hex_string::Item_hex_string(const char *str, uint32_t str_length)
 
4476
Item_hex_string::Item_hex_string(const char *str, uint str_length)
4491
4477
{
4492
4478
  max_length=(str_length+1)/2;
4493
4479
  char *ptr=(char*) sql_alloc(max_length+1);
4517
4503
 
4518
4504
  uint64_t value=0;
4519
4505
  for (; ptr != end ; ptr++)
4520
 
    value=(value << 8)+ (uint64_t) (unsigned char) *ptr;
 
4506
    value=(value << 8)+ (uint64_t) (uchar) *ptr;
4521
4507
  return (int64_t) value;
4522
4508
}
4523
4509
 
4571
4557
  str->append("0x");
4572
4558
  for (; ptr != end ; ptr++)
4573
4559
  {
4574
 
    str->append(_dig_vec_lower[((unsigned char) *ptr) >> 4]);
4575
 
    str->append(_dig_vec_lower[((unsigned char) *ptr) & 0x0F]);
 
4560
    str->append(_dig_vec_lower[((uchar) *ptr) >> 4]);
 
4561
    str->append(_dig_vec_lower[((uchar) *ptr) & 0x0F]);
4576
4562
  }
4577
4563
}
4578
4564
 
4608
4594
  In number context this is a int64_t value.
4609
4595
*/
4610
4596
  
4611
 
Item_bin_string::Item_bin_string(const char *str, uint32_t str_length)
 
4597
Item_bin_string::Item_bin_string(const char *str, uint str_length)
4612
4598
{
4613
4599
  const char *end= str + str_length - 1;
4614
 
  unsigned char bits= 0;
4615
 
  uint32_t power= 1;
 
4600
  uchar bits= 0;
 
4601
  uint power= 1;
4616
4602
 
4617
4603
  max_length= (str_length + 7) >> 3;
4618
4604
  char *ptr= (char*) sql_alloc(max_length + 1);
4776
4762
    this field    otherwise
4777
4763
*/
4778
4764
 
4779
 
Item *Item_field::update_value_transformer(unsigned char *select_arg)
 
4765
Item *Item_field::update_value_transformer(uchar *select_arg)
4780
4766
{
4781
4767
  SELECT_LEX *select= (SELECT_LEX*)select_arg;
4782
4768
  assert(fixed);
5299
5285
}
5300
5286
 
5301
5287
 
5302
 
bool Item_ref::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
 
5288
bool Item_ref::get_date(DRIZZLE_TIME *ltime,uint fuzzydate)
5303
5289
{
5304
5290
  return (null_value=(*ref)->get_date_result(ltime,fuzzydate));
5305
5291
}
5413
5399
}
5414
5400
 
5415
5401
 
5416
 
bool Item_direct_ref::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
 
5402
bool Item_direct_ref::get_date(DRIZZLE_TIME *ltime,uint fuzzydate)
5417
5403
{
5418
5404
  return (null_value=(*ref)->get_date(ltime,fuzzydate));
5419
5405
}
5619
5605
  same time it can replace some nodes in the tree.
5620
5606
*/ 
5621
5607
 
5622
 
Item *Item_default_value::transform(Item_transformer transformer, unsigned char *args)
 
5608
Item *Item_default_value::transform(Item_transformer transformer, uchar *args)
5623
5609
{
5624
5610
  Item *new_item= arg->transform(transformer, args);
5625
5611
  if (!new_item)
5747
5733
      new_item= new Item_null(name);
5748
5734
    else
5749
5735
    {
5750
 
      uint32_t length= result->length();
 
5736
      uint length= result->length();
5751
5737
      char *tmp_str= sql_strmake(result->ptr(), length);
5752
5738
      new_item= new Item_string(name, tmp_str, length, result->charset());
5753
5739
    }
5756
5742
  case INT_RESULT:
5757
5743
  {
5758
5744
    int64_t result=item->val_int();
5759
 
    uint32_t length=item->max_length;
 
5745
    uint length=item->max_length;
5760
5746
    bool null_value=item->null_value;
5761
5747
    new_item= (null_value ? (Item*) new Item_null(name) :
5762
5748
               (Item*) new Item_int(name, result, length));
5775
5761
    */
5776
5762
    Item_row *item_row= (Item_row*) item;
5777
5763
    Item_row *comp_item_row= (Item_row*) comp_item;
5778
 
    uint32_t col;
 
5764
    uint col;
5779
5765
    new_item= 0;
5780
5766
    /*
5781
5767
      If item and comp_item are both Item_rows and have same number of cols
5795
5781
  case REAL_RESULT:
5796
5782
  {                                             // It must REAL_RESULT
5797
5783
    double result= item->val_real();
5798
 
    uint32_t length=item->max_length,decimals=item->decimals;
 
5784
    uint length=item->max_length,decimals=item->decimals;
5799
5785
    bool null_value=item->null_value;
5800
5786
    new_item= (null_value ? (Item*) new Item_null(name) : (Item*)
5801
5787
               new Item_float(name, result, decimals, length));
5805
5791
  {
5806
5792
    my_decimal decimal_value;
5807
5793
    my_decimal *result= item->val_decimal(&decimal_value);
5808
 
    uint32_t length= item->max_length, decimals= item->decimals;
 
5794
    uint length= item->max_length, decimals= item->decimals;
5809
5795
    bool null_value= item->null_value;
5810
5796
    new_item= (null_value ?
5811
5797
               (Item*) new Item_null(name) :
6058
6044
}
6059
6045
 
6060
6046
 
6061
 
bool Item_cache_row::allocate(uint32_t num)
 
6047
bool Item_cache_row::allocate(uint num)
6062
6048
{
6063
6049
  item_count= num;
6064
6050
  THD *thd= current_thd;
6072
6058
  example= item;
6073
6059
  if (!values && allocate(item->cols()))
6074
6060
    return 1;
6075
 
  for (uint32_t i= 0; i < item_count; i++)
 
6061
  for (uint i= 0; i < item_count; i++)
6076
6062
  {
6077
6063
    Item *el= item->element_index(i);
6078
6064
    Item_cache *tmp;
6088
6074
{
6089
6075
  null_value= 0;
6090
6076
  item->bring_value();
6091
 
  for (uint32_t i= 0; i < item_count; i++)
 
6077
  for (uint i= 0; i < item_count; i++)
6092
6078
  {
6093
6079
    values[i]->store(item->element_index(i));
6094
6080
    null_value|= values[i]->null_value;
6104
6090
}
6105
6091
 
6106
6092
 
6107
 
bool Item_cache_row::check_cols(uint32_t c)
 
6093
bool Item_cache_row::check_cols(uint c)
6108
6094
{
6109
6095
  if (c != item_count)
6110
6096
  {
6117
6103
 
6118
6104
bool Item_cache_row::null_inside()
6119
6105
{
6120
 
  for (uint32_t i= 0; i < item_count; i++)
 
6106
  for (uint i= 0; i < item_count; i++)
6121
6107
  {
6122
6108
    if (values[i]->cols() > 1)
6123
6109
    {
6137
6123
 
6138
6124
void Item_cache_row::bring_value()
6139
6125
{
6140
 
  for (uint32_t i= 0; i < item_count; i++)
 
6126
  for (uint i= 0; i < item_count; i++)
6141
6127
    values[i]->bring_value();
6142
6128
  return;
6143
6129
}
6251
6237
bool Item_type_holder::join_types(THD *thd __attribute__((unused)),
6252
6238
                                  Item *item)
6253
6239
{
6254
 
  uint32_t max_length_orig= max_length;
6255
 
  uint32_t decimals_orig= decimals;
 
6240
  uint max_length_orig= max_length;
 
6241
  uint decimals_orig= decimals;
6256
6242
  fld_type= Field::field_type_merge(fld_type, get_real_type(item));
6257
6243
  {
6258
6244
    int item_decimals= item->decimals;
6388
6374
  /*
6389
6375
    The field functions defines a field to be not null if null_ptr is not 0
6390
6376
  */
6391
 
  unsigned char *null_ptr= maybe_null ? (unsigned char*) "" : 0;
 
6377
  uchar *null_ptr= maybe_null ? (uchar*) "" : 0;
6392
6378
  Field *field;
6393
6379
 
6394
6380
  switch (fld_type) {
6395
6381
  case DRIZZLE_TYPE_ENUM:
6396
6382
    assert(enum_set_typelib);
6397
 
    field= new Field_enum((unsigned char *) 0, max_length, null_ptr, 0,
 
6383
    field= new Field_enum((uchar *) 0, max_length, null_ptr, 0,
6398
6384
                          Field::NONE, name,
6399
6385
                          get_enum_pack_length(enum_set_typelib->count),
6400
6386
                          enum_set_typelib, collation.collation);