~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.h

Merged uint fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
public:
49
49
  const CHARSET_INFO *collation;
50
50
  enum Derivation derivation;
51
 
  uint repertoire;
 
51
  uint32_t repertoire;
52
52
  
53
53
  void set_repertoire_from_charset(const CHARSET_INFO * const cs)
54
54
  {
81
81
  }
82
82
  void set(const CHARSET_INFO * const collation_arg,
83
83
           Derivation derivation_arg,
84
 
           uint repertoire_arg)
 
84
           uint32_t repertoire_arg)
85
85
  {
86
86
    collation= collation_arg;
87
87
    derivation= derivation_arg;
94
94
  }
95
95
  void set(Derivation derivation_arg)
96
96
  { derivation= derivation_arg; }
97
 
  bool aggregate(DTCollation &dt, uint flags= 0);
98
 
  bool set(DTCollation &dt1, DTCollation &dt2, uint flags= 0)
 
97
  bool aggregate(DTCollation &dt, uint32_t flags= 0);
 
98
  bool set(DTCollation &dt1, DTCollation &dt2, uint32_t flags= 0)
99
99
  { set(dt1); return aggregate(dt2, flags); }
100
100
  const char *derivation_name() const
101
101
  {
463
463
  enum traverse_order { POSTFIX, PREFIX };
464
464
  
465
465
  /* Reuse size, only used by SP local variable assignment, otherwize 0 */
466
 
  uint rsize;
 
466
  uint32_t rsize;
467
467
 
468
468
  /*
469
469
    str_values's main purpose is to be used to cache the value in
475
475
  char * orig_name;
476
476
  Item *next;
477
477
  uint32_t max_length;
478
 
  uint name_length;                     /* Length of name */
 
478
  uint32_t name_length;                     /* Length of name */
479
479
  int8_t marker;
480
480
  uint8_t decimals;
481
481
  bool maybe_null;                      /* If item may be null */
507
507
    name=0;
508
508
#endif
509
509
  }             /*lint -e1509 */
510
 
  void set_name(const char *str, uint length, const CHARSET_INFO * const cs);
 
510
  void set_name(const char *str, uint32_t length, const CHARSET_INFO * const cs);
511
511
  void rename(char *new_name);
512
512
  void init_make_field(Send_field *tmp_field,enum enum_field_types type);
513
513
  virtual void cleanup();
735
735
  /* cloning of constant items (0 if it is not const) */
736
736
  virtual Item *clone_item() { return 0; }
737
737
  virtual cond_result eq_cmp_result() const { return COND_OK; }
738
 
  inline uint float_length(uint decimals_par) const
 
738
  inline uint32_t float_length(uint32_t decimals_par) const
739
739
  { return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;}
740
 
  virtual uint decimal_precision() const;
 
740
  virtual uint32_t decimal_precision() const;
741
741
  inline int decimal_int_part() const
742
742
  { return my_decimal_int_part(decimal_precision(), decimals); }
743
743
  /* 
777
777
  /* Called for items that really have to be split */
778
778
  void split_sum_func2(THD *thd, Item **ref_pointer_array, List<Item> &fields,
779
779
                       Item **ref, bool skip_registered);
780
 
  virtual bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
 
780
  virtual bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
781
781
  virtual bool get_time(DRIZZLE_TIME *ltime);
782
 
  virtual bool get_date_result(DRIZZLE_TIME *ltime,uint fuzzydate)
 
782
  virtual bool get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
783
783
  { return get_date(ltime,fuzzydate); }
784
784
  /*
785
785
    The method allows to determine nullness of a complex expression 
912
912
  virtual Item **this_item_addr(THD *thd __attribute__((unused)), Item **addr_arg) { return addr_arg; }
913
913
 
914
914
  // Row emulation
915
 
  virtual uint cols() { return 1; }
916
 
  virtual Item* element_index(uint i __attribute__((unused))) { return this; }
917
 
  virtual Item** addr(uint i __attribute__((unused))) { return 0; }
918
 
  virtual bool check_cols(uint c);
 
915
  virtual uint32_t cols() { return 1; }
 
916
  virtual Item* element_index(uint32_t i __attribute__((unused))) { return this; }
 
917
  virtual Item** addr(uint32_t i __attribute__((unused))) { return 0; }
 
918
  virtual bool check_cols(uint32_t c);
919
919
  // It is not row => null inside is impossible
920
920
  virtual bool null_inside() { return 0; }
921
921
  // used in row subselects to get value of elements
982
982
};
983
983
 
984
984
bool agg_item_collations(DTCollation &c, const char *name,
985
 
                         Item **items, uint nitems, uint flags, int item_sep);
 
985
                         Item **items, uint32_t nitems, uint32_t flags, int item_sep);
986
986
bool agg_item_collations_for_comparison(DTCollation &c, const char *name,
987
 
                                        Item **items, uint nitems, uint flags);
 
987
                                        Item **items, uint32_t nitems, uint32_t flags);
988
988
bool agg_item_charsets(DTCollation &c, const char *name,
989
 
                       Item **items, uint nitems, uint flags, int item_sep);
 
989
                       Item **items, uint32_t nitems, uint32_t flags, int item_sep);
990
990
 
991
991
 
992
992
class Item_num: public Item_basic_constant
1024
1024
    stmts for speeding up their re-execution. Holds NO_CACHED_FIELD_INDEX 
1025
1025
    if index value is not known.
1026
1026
  */
1027
 
  uint cached_field_index;
 
1027
  uint32_t cached_field_index;
1028
1028
  /*
1029
1029
    Cached pointer to table which contains this field, used for the same reason
1030
1030
    by prep. stmt. too in case then we have not-fully qualified field.
1085
1085
    if any_privileges set to true then here real effective privileges will
1086
1086
    be stored
1087
1087
  */
1088
 
  uint have_privileges;
 
1088
  uint32_t have_privileges;
1089
1089
  /* field need any privileges (for VIEW creation) */
1090
1090
  bool any_privileges;
1091
1091
  Item_field(Name_resolution_context *context_arg,
1145
1145
  int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
1146
1146
  Field *get_tmp_table_field() { return result_field; }
1147
1147
  Field *tmp_table_field(Table *t_arg __attribute__((unused))) { return result_field; }
1148
 
  bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
1149
 
  bool get_date_result(DRIZZLE_TIME *ltime,uint fuzzydate);
 
1148
  bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
 
1149
  bool get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
1150
1150
  bool get_time(DRIZZLE_TIME *ltime);
1151
1151
  bool is_null() { return field->is_null(); }
1152
1152
  void update_null_value();
1293
1293
    Offset of placeholder inside statement text. Used to create
1294
1294
    no-placeholders version of this statement for the binary log.
1295
1295
  */
1296
 
  uint pos_in_query;
 
1296
  uint32_t pos_in_query;
1297
1297
 
1298
 
  Item_param(uint pos_in_query_arg);
 
1298
  Item_param(uint32_t pos_in_query_arg);
1299
1299
 
1300
1300
  enum Item_result result_type () const { return item_result_type; }
1301
1301
  enum Type type() const { return item_type; }
1306
1306
  my_decimal *val_decimal(my_decimal*);
1307
1307
  String *val_str(String*);
1308
1308
  bool get_time(DRIZZLE_TIME *tm);
1309
 
  bool get_date(DRIZZLE_TIME *tm, uint fuzzydate);
 
1309
  bool get_date(DRIZZLE_TIME *tm, uint32_t fuzzydate);
1310
1310
  int  save_in_field(Field *field, bool no_conversions);
1311
1311
 
1312
1312
  void set_null();
1369
1369
{
1370
1370
public:
1371
1371
  int64_t value;
1372
 
  Item_int(int32_t i,uint length= MY_INT32_NUM_DECIMAL_DIGITS)
 
1372
  Item_int(int32_t i,uint32_t length= MY_INT32_NUM_DECIMAL_DIGITS)
1373
1373
    :value((int64_t) i)
1374
1374
    { max_length=length; fixed= 1; }
1375
 
  Item_int(int64_t i,uint length= MY_INT64_NUM_DECIMAL_DIGITS)
 
1375
  Item_int(int64_t i,uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS)
1376
1376
    :value(i)
1377
1377
    { max_length=length; fixed= 1; }
1378
 
  Item_int(uint64_t i, uint length= MY_INT64_NUM_DECIMAL_DIGITS)
 
1378
  Item_int(uint64_t i, uint32_t length= MY_INT64_NUM_DECIMAL_DIGITS)
1379
1379
    :value((int64_t)i)
1380
1380
    { max_length=length; fixed= 1; unsigned_flag= 1; }
1381
 
  Item_int(const char *str_arg,int64_t i,uint length) :value(i)
 
1381
  Item_int(const char *str_arg,int64_t i,uint32_t length) :value(i)
1382
1382
    { max_length=length; name=(char*) str_arg; fixed= 1; }
1383
 
  Item_int(const char *str_arg, uint length=64);
 
1383
  Item_int(const char *str_arg, uint32_t length=64);
1384
1384
  enum Type type() const { return INT_ITEM; }
1385
1385
  enum Item_result result_type () const { return INT_RESULT; }
1386
1386
  enum_field_types field_type() const { return DRIZZLE_TYPE_LONGLONG; }
1393
1393
  Item *clone_item() { return new Item_int(name,value,max_length); }
1394
1394
  virtual void print(String *str, enum_query_type query_type);
1395
1395
  Item_num *neg() { value= -value; return this; }
1396
 
  uint decimal_precision() const
 
1396
  uint32_t decimal_precision() const
1397
1397
  { return (uint)(max_length - test(value < 0)); }
1398
1398
  bool eq(const Item *, bool binary_cmp) const;
1399
1399
};
1402
1402
class Item_uint :public Item_int
1403
1403
{
1404
1404
public:
1405
 
  Item_uint(const char *str_arg, uint length);
 
1405
  Item_uint(const char *str_arg, uint32_t length);
1406
1406
  Item_uint(uint64_t i) :Item_int((uint64_t) i, 10) {}
1407
 
  Item_uint(const char *str_arg, int64_t i, uint length);
 
1407
  Item_uint(const char *str_arg, int64_t i, uint32_t length);
1408
1408
  double val_real()
1409
1409
    { assert(fixed == 1); return uint64_t2double((uint64_t)value); }
1410
1410
  String *val_str(String*);
1412
1412
  int save_in_field(Field *field, bool no_conversions);
1413
1413
  virtual void print(String *str, enum_query_type query_type);
1414
1414
  Item_num *neg ();
1415
 
  uint decimal_precision() const { return max_length; }
 
1415
  uint32_t decimal_precision() const { return max_length; }
1416
1416
};
1417
1417
 
1418
1418
 
1422
1422
protected:
1423
1423
  my_decimal decimal_value;
1424
1424
public:
1425
 
  Item_decimal(const char *str_arg, uint length, const CHARSET_INFO * const charset);
 
1425
  Item_decimal(const char *str_arg, uint32_t length, const CHARSET_INFO * const charset);
1426
1426
  Item_decimal(const char *str, const my_decimal *val_arg,
1427
 
               uint decimal_par, uint length);
 
1427
               uint32_t decimal_par, uint32_t length);
1428
1428
  Item_decimal(my_decimal *value_par);
1429
1429
  Item_decimal(int64_t val, bool unsig);
1430
1430
  Item_decimal(double val, int precision, int scale);
1451
1451
    unsigned_flag= !decimal_value.sign();
1452
1452
    return this;
1453
1453
  }
1454
 
  uint decimal_precision() const { return decimal_value.precision(); }
 
1454
  uint32_t decimal_precision() const { return decimal_value.precision(); }
1455
1455
  bool eq(const Item *, bool binary_cmp) const;
1456
1456
  void set_decimal_value(my_decimal *value_par);
1457
1457
};
1463
1463
public:
1464
1464
  double value;
1465
1465
  // Item_real() :value(0) {}
1466
 
  Item_float(const char *str_arg, uint length);
1467
 
  Item_float(const char *str,double val_arg,uint decimal_par,uint length)
 
1466
  Item_float(const char *str_arg, uint32_t length);
 
1467
  Item_float(const char *str,double val_arg,uint32_t decimal_par,uint32_t length)
1468
1468
    :value(val_arg)
1469
1469
  {
1470
1470
    presentation= name=(char*) str;
1472
1472
    max_length=length;
1473
1473
    fixed= 1;
1474
1474
  }
1475
 
  Item_float(double value_par, uint decimal_par) :presentation(0), value(value_par)
 
1475
  Item_float(double value_par, uint32_t decimal_par) :presentation(0), value(value_par)
1476
1476
  {
1477
1477
    decimals= (uint8_t) decimal_par;
1478
1478
    fixed= 1;
1509
1509
{
1510
1510
  const char *func_name;
1511
1511
public:
1512
 
  Item_static_float_func(const char *str, double val_arg, uint decimal_par,
1513
 
                        uint length)
 
1512
  Item_static_float_func(const char *str, double val_arg, uint32_t decimal_par,
 
1513
                        uint32_t length)
1514
1514
    :Item_float(NULL, val_arg, decimal_par, length), func_name(str)
1515
1515
  {}
1516
1516
 
1527
1527
class Item_string :public Item_basic_constant
1528
1528
{
1529
1529
public:
1530
 
  Item_string(const char *str,uint length,
 
1530
  Item_string(const char *str,uint32_t length,
1531
1531
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
1532
 
              uint repertoire= MY_REPERTOIRE_UNICODE30)
 
1532
              uint32_t repertoire= MY_REPERTOIRE_UNICODE30)
1533
1533
    : m_cs_specified(false)
1534
1534
  {
1535
1535
    str_value.set_or_copy_aligned(str, length, cs);
1557
1557
    decimals= NOT_FIXED_DEC;
1558
1558
    fixed= 1;
1559
1559
  }
1560
 
  Item_string(const char *name_par, const char *str, uint length,
 
1560
  Item_string(const char *name_par, const char *str, uint32_t length,
1561
1561
              const CHARSET_INFO * const cs, Derivation dv= DERIVATION_COERCIBLE,
1562
 
              uint repertoire= MY_REPERTOIRE_UNICODE30)
 
1562
              uint32_t repertoire= MY_REPERTOIRE_UNICODE30)
1563
1563
    : m_cs_specified(false)
1564
1564
  {
1565
1565
    str_value.set_or_copy_aligned(str, length, cs);
1574
1574
    This is used in stored procedures to avoid memory leaks and
1575
1575
    does a deep copy of its argument.
1576
1576
  */
1577
 
  void set_str_with_copy(const char *str_arg, uint length_arg)
 
1577
  void set_str_with_copy(const char *str_arg, uint32_t length_arg)
1578
1578
  {
1579
1579
    str_value.copy(str_arg, length_arg, collation.collation);
1580
1580
    max_length= str_value.numchars() * collation.collation->mbmaxlen;
1605
1605
                           str_value.length(), collation.collation);
1606
1606
  }
1607
1607
  Item *safe_charset_converter(const CHARSET_INFO * const tocs);
1608
 
  inline void append(char *str, uint length)
 
1608
  inline void append(char *str, uint32_t length)
1609
1609
  {
1610
1610
    str_value.append(str, length);
1611
1611
    max_length= str_value.numchars() * collation.collation->mbmaxlen;
1660
1660
{
1661
1661
  const char *func_name;
1662
1662
public:
1663
 
  Item_static_string_func(const char *name_par, const char *str, uint length,
 
1663
  Item_static_string_func(const char *name_par, const char *str, uint32_t length,
1664
1664
                          const CHARSET_INFO * const cs,
1665
1665
                          Derivation dv= DERIVATION_COERCIBLE)
1666
1666
    :Item_string(NULL, str, length, cs, dv), func_name(name_par)
1691
1691
class Item_blob :public Item_string
1692
1692
{
1693
1693
public:
1694
 
  Item_blob(const char *name, uint length) :
 
1694
  Item_blob(const char *name, uint32_t length) :
1695
1695
    Item_string(name, length, &my_charset_bin)
1696
1696
  { max_length= length; }
1697
1697
  enum Type type() const { return TYPE_HOLDER; }
1708
1708
class Item_empty_string :public Item_string
1709
1709
{
1710
1710
public:
1711
 
  Item_empty_string(const char *header,uint length, const CHARSET_INFO * cs= NULL) :
 
1711
  Item_empty_string(const char *header,uint32_t length, const CHARSET_INFO * cs= NULL) :
1712
1712
    Item_string("",0, cs ? cs : &my_charset_utf8_general_ci)
1713
1713
    { name=(char*) header; max_length= cs ? length * cs->mbmaxlen : length; }
1714
1714
  void make_field(Send_field *field);
1719
1719
{
1720
1720
  enum_field_types int_field_type;
1721
1721
public:
1722
 
  Item_return_int(const char *name_arg, uint length,
 
1722
  Item_return_int(const char *name_arg, uint32_t length,
1723
1723
                  enum_field_types field_type_arg, int64_t value= 0)
1724
1724
    :Item_int(name_arg, value, length), int_field_type(field_type_arg)
1725
1725
  {
1733
1733
{
1734
1734
public:
1735
1735
  Item_hex_string() {}
1736
 
  Item_hex_string(const char *str,uint str_length);
 
1736
  Item_hex_string(const char *str,uint32_t str_length);
1737
1737
  enum Type type() const { return VARBIN_ITEM; }
1738
1738
  double val_real()
1739
1739
  { 
1757
1757
class Item_bin_string: public Item_hex_string
1758
1758
{
1759
1759
public:
1760
 
  Item_bin_string(const char *str,uint str_length);
 
1760
  Item_bin_string(const char *str,uint32_t str_length);
1761
1761
};
1762
1762
 
1763
1763
class Item_result_field :public Item    /* Item with result field */
1831
1831
  bool val_bool();
1832
1832
  String *val_str(String* tmp);
1833
1833
  bool is_null();
1834
 
  bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
 
1834
  bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
1835
1835
  double val_result();
1836
1836
  int64_t val_int_result();
1837
1837
  String *str_result(String* tmp);
1881
1881
  virtual Ref_Type ref_type() { return REF; }
1882
1882
 
1883
1883
  // Row emulation: forwarding of ROW-related calls to ref
1884
 
  uint cols()
 
1884
  uint32_t cols()
1885
1885
  {
1886
1886
    return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1;
1887
1887
  }
1888
 
  Item* element_index(uint i)
 
1888
  Item* element_index(uint32_t i)
1889
1889
  {
1890
1890
    return ref && result_type() == ROW_RESULT ? (*ref)->element_index(i) : this;
1891
1891
  }
1892
 
  Item** addr(uint i)
 
1892
  Item** addr(uint32_t i)
1893
1893
  {
1894
1894
    return ref && result_type() == ROW_RESULT ? (*ref)->addr(i) : 0;
1895
1895
  }
1896
 
  bool check_cols(uint c)
 
1896
  bool check_cols(uint32_t c)
1897
1897
  {
1898
1898
    return ref && result_type() == ROW_RESULT ? (*ref)->check_cols(c) 
1899
1899
                                              : Item::check_cols(c);
1934
1934
  my_decimal *val_decimal(my_decimal *);
1935
1935
  bool val_bool();
1936
1936
  bool is_null();
1937
 
  bool get_date(DRIZZLE_TIME *ltime,uint fuzzydate);
 
1937
  bool get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate);
1938
1938
  virtual Ref_Type ref_type() { return DIRECT_REF; }
1939
1939
};
1940
1940
 
2046
2046
  String* val_str(String* s);
2047
2047
  my_decimal *val_decimal(my_decimal *);
2048
2048
  bool val_bool();
2049
 
  bool get_date(DRIZZLE_TIME *ltime, uint fuzzydate);
 
2049
  bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate);
2050
2050
  virtual void print(String *str, enum_query_type query_type);
2051
2051
  /*
2052
2052
    we add RAND_TABLE_BIT to prevent moving this item from HAVING to WHERE
2193
2193
{
2194
2194
  unsigned char *buff;
2195
2195
  Field *field;
2196
 
  uint length;
 
2196
  uint32_t length;
2197
2197
 
2198
2198
public:
2199
2199
  Cached_item_field(Field *arg_field) : field(arg_field)
2301
2301
 
2302
2302
  void set_used_tables(table_map map) { used_table_map= map; }
2303
2303
 
2304
 
  virtual bool allocate(uint i __attribute__((unused)))
 
2304
  virtual bool allocate(uint32_t i __attribute__((unused)))
2305
2305
  { return 0; }
2306
2306
  virtual bool setup(Item *item)
2307
2307
  {
2411
2411
class Item_cache_row: public Item_cache
2412
2412
{
2413
2413
  Item_cache  **values;
2414
 
  uint item_count;
 
2414
  uint32_t item_count;
2415
2415
  bool save_array;
2416
2416
public:
2417
2417
  Item_cache_row()
2421
2421
    'allocate' used only in row transformer, to preallocate space for row 
2422
2422
    cache.
2423
2423
  */
2424
 
  bool allocate(uint num);
 
2424
  bool allocate(uint32_t num);
2425
2425
  /*
2426
2426
    'setup' is needed only by row => it not called by simple row subselect
2427
2427
    (only by IN subselect (in subselect optimizer))
2456
2456
 
2457
2457
  enum Item_result result_type() const { return ROW_RESULT; }
2458
2458
  
2459
 
  uint cols() { return item_count; }
2460
 
  Item *element_index(uint i) { return values[i]; }
2461
 
  Item **addr(uint i) { return (Item **) (values + i); }
2462
 
  bool check_cols(uint c);
 
2459
  uint32_t cols() { return item_count; }
 
2460
  Item *element_index(uint32_t i) { return values[i]; }
 
2461
  Item **addr(uint32_t i) { return (Item **) (values + i); }
 
2462
  bool check_cols(uint32_t c);
2463
2463
  bool null_inside();
2464
2464
  void bring_value();
2465
2465
  void keep_array() { save_array= 1; }