~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/item.h

MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
 
125
125
struct Hybrid_type
126
126
{
127
 
  longlong integer;
 
127
  int64_t integer;
128
128
 
129
129
  double real;
130
130
  /*
162
162
  virtual void set_zero(Hybrid_type *val) const { val->real= 0.0; }
163
163
  virtual void add(Hybrid_type *val, Field *f) const
164
164
  { val->real+= f->val_real(); }
165
 
  virtual void div(Hybrid_type *val, ulonglong u) const
166
 
  { val->real/= ulonglong2double(u); }
 
165
  virtual void div(Hybrid_type *val, uint64_t u) const
 
166
  { val->real/= uint64_t2double(u); }
167
167
 
168
 
  virtual longlong val_int(Hybrid_type *val,
 
168
  virtual int64_t val_int(Hybrid_type *val,
169
169
                           bool unsigned_flag __attribute__((__unused__))) const
170
 
  { return (longlong) rint(val->real); }
 
170
  { return (int64_t) rint(val->real); }
171
171
  virtual double val_real(Hybrid_type *val) const { return val->real; }
172
172
  virtual my_decimal *val_decimal(Hybrid_type *val, my_decimal *buf) const;
173
173
  virtual String *val_str(Hybrid_type *val, String *buf, uint8 decimals) const;
187
187
  /* Hybrid_type operations. */
188
188
  virtual void set_zero(Hybrid_type *val) const;
189
189
  virtual void add(Hybrid_type *val, Field *f) const;
190
 
  virtual void div(Hybrid_type *val, ulonglong u) const;
 
190
  virtual void div(Hybrid_type *val, uint64_t u) const;
191
191
 
192
 
  virtual longlong val_int(Hybrid_type *val, bool unsigned_flag) const;
 
192
  virtual int64_t val_int(Hybrid_type *val, bool unsigned_flag) const;
193
193
  virtual double val_real(Hybrid_type *val) const;
194
194
  virtual my_decimal *val_decimal(Hybrid_type *val,
195
195
                                  my_decimal *buf __attribute__((__unused__))) const
212
212
  { val->integer= 0; }
213
213
  virtual void add(Hybrid_type *val, Field *f) const
214
214
  { val->integer+= f->val_int(); }
215
 
  virtual void div(Hybrid_type *val, ulonglong u) const
216
 
  { val->integer/= (longlong) u; }
 
215
  virtual void div(Hybrid_type *val, uint64_t u) const
 
216
  { val->integer/= (int64_t) u; }
217
217
 
218
 
  virtual longlong val_int(Hybrid_type *val,
 
218
  virtual int64_t val_int(Hybrid_type *val,
219
219
                           bool unsigned_flag __attribute__((__unused__))) const
220
220
  { return val->integer; }
221
221
  virtual double val_real(Hybrid_type *val) const
300
300
  void *error_processor_data;
301
301
 
302
302
  /*
303
 
    When TRUE items are resolved in this context both against the
304
 
    SELECT list and this->table_list. If FALSE, items are resolved
 
303
    When true items are resolved in this context both against the
 
304
    SELECT list and this->table_list. If false, items are resolved
305
305
    only against this->table_list.
306
306
  */
307
307
  bool resolve_in_select_list;
320
320
 
321
321
  void init()
322
322
  {
323
 
    resolve_in_select_list= FALSE;
 
323
    resolve_in_select_list= false;
324
324
    error_processor= &dummy_error_processor;
325
325
    first_name_resolution_table= NULL;
326
326
    last_name_resolution_table= NULL;
329
329
  void resolve_in_table_list_only(TABLE_LIST *tables)
330
330
  {
331
331
    table_list= first_name_resolution_table= tables;
332
 
    resolve_in_select_list= FALSE;
 
332
    resolve_in_select_list= false;
333
333
  }
334
334
 
335
335
  void process_error(THD *thd)
391
391
  etc etc). An Item* tree is assumed to have the same monotonicity properties
392
392
  as its correspoinding function F:
393
393
 
394
 
  [signed] longlong F(field1, field2, ...) {
 
394
  [signed] int64_t F(field1, field2, ...) {
395
395
    put values of field_i into table record buffer;
396
396
    return item->val_int(); 
397
397
  }
420
420
                    OUT: Parameter to be passed to the transformer
421
421
 
422
422
    RETURN 
423
 
      TRUE   Invoke the transformer
424
 
      FALSE  Don't do it
 
423
      true   Invoke the transformer
 
424
      false  Don't do it
425
425
 
426
426
*/
427
427
typedef bool (Item::*Item_analyzer) (uchar **argp);
556
556
 
557
557
    SYNOPSIS
558
558
      val_int_endpoint()
559
 
        left_endp  FALSE  <=> The interval is "x < const" or "x <= const"
560
 
                   TRUE   <=> The interval is "x > const" or "x >= const"
 
559
        left_endp  false  <=> The interval is "x < const" or "x <= const"
 
560
                   true   <=> The interval is "x > const" or "x >= const"
561
561
 
562
 
        incl_endp  IN   TRUE <=> the comparison is '<' or '>'
563
 
                        FALSE <=> the comparison is '<=' or '>='
 
562
        incl_endp  IN   true <=> the comparison is '<' or '>'
 
563
                        false <=> the comparison is '<=' or '>='
564
564
                   OUT  The same but for the "F(x) $CMP$ F(const)" comparison
565
565
 
566
566
    DESCRIPTION
582
582
    RETURN
583
583
      The output range bound, which equal to the value of val_int()
584
584
        - If the value of the function is NULL then the bound is the
585
 
          smallest possible value of LONGLONG_MIN
 
585
          smallest possible value of INT64_MIN
586
586
  */
587
 
  virtual longlong val_int_endpoint(bool left_endp __attribute__((__unused__)),
 
587
  virtual int64_t val_int_endpoint(bool left_endp __attribute__((__unused__)),
588
588
                                    bool *incl_endp __attribute__((__unused__)))
589
589
  { assert(0); return 0; }
590
590
 
597
597
      val_real()
598
598
 
599
599
    RETURN
600
 
      In case of NULL value return 0.0 and set null_value flag to TRUE.
601
 
      If value is not null null_value flag will be reset to FALSE.
 
600
      In case of NULL value return 0.0 and set null_value flag to true.
 
601
      If value is not null null_value flag will be reset to false.
602
602
  */
603
603
  virtual double val_real()=0;
604
604
  /*
608
608
      val_int()
609
609
 
610
610
    RETURN
611
 
      In case of NULL value return 0 and set null_value flag to TRUE.
612
 
      If value is not null null_value flag will be reset to FALSE.
 
611
      In case of NULL value return 0 and set null_value flag to true.
 
612
      If value is not null null_value flag will be reset to false.
613
613
  */
614
 
  virtual longlong val_int()=0;
 
614
  virtual int64_t val_int()=0;
615
615
  /*
616
616
    This is just a shortcut to avoid the cast. You should still use
617
617
    unsigned_flag to check the sign of the item.
618
618
  */
619
 
  inline ulonglong val_uint() { return (ulonglong) val_int(); }
 
619
  inline uint64_t val_uint() { return (uint64_t) val_int(); }
620
620
  /*
621
621
    Return string representation of this item object.
622
622
 
648
648
 
649
649
    RETURN
650
650
      In case of NULL value return 0 (NULL pointer) and set null_value flag
651
 
      to TRUE.
652
 
      If value is not null null_value flag will be reset to FALSE.
 
651
      to true.
 
652
      If value is not null null_value flag will be reset to false.
653
653
  */
654
654
  virtual String *val_str(String *str)=0;
655
655
  /*
666
666
 
667
667
    RETURN
668
668
      Return pointer on my_decimal (it can be other then passed via argument)
669
 
        if value is not NULL (null_value flag will be reset to FALSE).
 
669
        if value is not NULL (null_value flag will be reset to false).
670
670
      In case of NULL value it return 0 pointer and set null_value flag
671
 
        to TRUE.
 
671
        to true.
672
672
  */
673
673
  virtual my_decimal *val_decimal(my_decimal *decimal_buffer)= 0;
674
674
  /*
675
675
    Return boolean value of item.
676
676
 
677
677
    RETURN
678
 
      FALSE value is false or NULL
679
 
      TRUE value is true (not equal to 0)
 
678
      false value is false or NULL
 
679
      true value is true (not equal to 0)
680
680
  */
681
681
  virtual bool val_bool();
682
682
  virtual String *val_nodeset(String*) { return 0; }
689
689
  my_decimal *val_decimal_from_string(my_decimal *decimal_value);
690
690
  my_decimal *val_decimal_from_date(my_decimal *decimal_value);
691
691
  my_decimal *val_decimal_from_time(my_decimal *decimal_value);
692
 
  longlong val_int_from_decimal();
 
692
  int64_t val_int_from_decimal();
693
693
  double val_real_from_decimal();
694
694
 
695
695
  int save_time_in_field(Field *field);
709
709
    way as *val* methods do it.
710
710
  */
711
711
  virtual double  val_result() { return val_real(); }
712
 
  virtual longlong val_int_result() { return val_int(); }
 
712
  virtual int64_t val_int_result() { return val_int(); }
713
713
  virtual String *str_result(String* tmp) { return val_str(tmp); }
714
714
  virtual my_decimal *val_decimal_result(my_decimal *val)
715
715
  { return val_decimal(val); }
799
799
 
800
800
  /*
801
801
    Inform the item that there will be no distinction between its result
802
 
    being FALSE or NULL.
 
802
    being false or NULL.
803
803
 
804
804
    NOTE
805
805
      This function will be called for eg. Items that are top-level AND-parts
936
936
  }
937
937
 
938
938
  /*
939
 
    result_as_longlong() must return TRUE for Items representing DATE/TIME
 
939
    result_as_int64_t() must return true for Items representing DATE/TIME
940
940
    functions and DATE/TIME table fields.
941
941
    Those Items have result_type()==STRING_RESULT (and not INT_RESULT), but
942
942
    their values should be compared as integers (because the integer
943
943
    representation is more precise than the string one).
944
944
  */
945
 
  virtual bool result_as_longlong() { return FALSE; }
 
945
  virtual bool result_as_int64_t() { return false; }
946
946
  bool is_datetime();
947
947
 
948
948
  /*
1043
1043
  bool remove_dependence_processor(uchar * arg);
1044
1044
  virtual void print(String *str, enum_query_type query_type);
1045
1045
  virtual bool change_context_processor(uchar *cntx)
1046
 
    { context= (Name_resolution_context *)cntx; return FALSE; }
 
1046
    { context= (Name_resolution_context *)cntx; return false; }
1047
1047
  friend bool insert_fields(THD *thd, Name_resolution_context *context,
1048
1048
                            const char *db_name,
1049
1049
                            const char *table_name, List_iterator<Item> *it,
1065
1065
 
1066
1066
  enum Type type() const { return FIELD_ITEM; }
1067
1067
  double val_real() { return field->val_real(); }
1068
 
  longlong val_int() { return field->val_int(); }
 
1068
  int64_t val_int() { return field->val_int(); }
1069
1069
  String *val_str(String *str) { return field->val_str(str); }
1070
1070
  my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); }
1071
1071
  void make_field(Send_field *tmp_field);
1084
1084
  Item_equal *item_equal;
1085
1085
  bool no_const_subst;
1086
1086
  /*
1087
 
    if any_privileges set to TRUE then here real effective privileges will
 
1087
    if any_privileges set to true then here real effective privileges will
1088
1088
    be stored
1089
1089
  */
1090
1090
  uint have_privileges;
1112
1112
  enum Type type() const { return FIELD_ITEM; }
1113
1113
  bool eq(const Item *item, bool binary_cmp) const;
1114
1114
  double val_real();
1115
 
  longlong val_int();
 
1115
  int64_t val_int();
1116
1116
  my_decimal *val_decimal(my_decimal *);
1117
1117
  String *val_str(String*);
1118
1118
  double val_result();
1119
 
  longlong val_int_result();
 
1119
  int64_t val_int_result();
1120
1120
  String *str_result(String* tmp);
1121
1121
  my_decimal *val_decimal_result(my_decimal *);
1122
1122
  bool val_bool_result();
1144
1144
  {
1145
1145
    return MONOTONIC_STRICT_INCREASING;
1146
1146
  }
1147
 
  longlong val_int_endpoint(bool left_endp, bool *incl_endp);
 
1147
  int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
1148
1148
  Field *get_tmp_table_field() { return result_field; }
1149
1149
  Field *tmp_table_field(TABLE *t_arg __attribute__((__unused__))) { return result_field; }
1150
1150
  bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
1157
1157
  bool find_item_in_field_list_processor(uchar *arg);
1158
1158
  bool register_field_in_read_map(uchar *arg);
1159
1159
  void cleanup();
1160
 
  bool result_as_longlong()
 
1160
  bool result_as_int64_t()
1161
1161
  {
1162
 
    return field->can_be_compared_as_longlong();
 
1162
    return field->can_be_compared_as_int64_t();
1163
1163
  }
1164
1164
  Item_equal *find_item_equal(COND_EQUAL *cond_equal);
1165
1165
  bool subst_argument_checker(uchar **arg);
1183
1183
public:
1184
1184
  Item_null(char *name_par=0)
1185
1185
  {
1186
 
    maybe_null= null_value= TRUE;
 
1186
    maybe_null= null_value= true;
1187
1187
    max_length= 0;
1188
1188
    name= name_par ? name_par : (char*) "NULL";
1189
1189
    fixed= 1;
1192
1192
  enum Type type() const { return NULL_ITEM; }
1193
1193
  bool eq(const Item *item, bool binary_cmp) const;
1194
1194
  double val_real();
1195
 
  longlong val_int();
 
1195
  int64_t val_int();
1196
1196
  String *val_str(String *str);
1197
1197
  my_decimal *val_decimal(my_decimal *);
1198
1198
  int save_in_field(Field *field, bool no_conversions);
1255
1255
  my_decimal decimal_value;
1256
1256
  union
1257
1257
  {
1258
 
    longlong integer;
 
1258
    int64_t integer;
1259
1259
    double   real;
1260
1260
    /*
1261
1261
      Character sets conversion info for string values.
1304
1304
  enum_field_types field_type() const { return param_type; }
1305
1305
 
1306
1306
  double val_real();
1307
 
  longlong val_int();
 
1307
  int64_t val_int();
1308
1308
  my_decimal *val_decimal(my_decimal*);
1309
1309
  String *val_str(String*);
1310
1310
  bool get_time(MYSQL_TIME *tm);
1312
1312
  int  save_in_field(Field *field, bool no_conversions);
1313
1313
 
1314
1314
  void set_null();
1315
 
  void set_int(longlong i, uint32 max_length_arg);
 
1315
  void set_int(int64_t i, uint32 max_length_arg);
1316
1316
  void set_double(double i);
1317
1317
  void set_decimal(const char *str, ulong length);
1318
1318
  bool set_str(const char *str, ulong length);
1351
1351
    words, avoid pointing at one item from two different nodes of the tree.
1352
1352
    Return a new basic constant item if parameter value is a basic
1353
1353
    constant, assert otherwise. This method is called only if
1354
 
    basic_const_item returned TRUE.
 
1354
    basic_const_item returned true.
1355
1355
  */
1356
1356
  Item *safe_charset_converter(CHARSET_INFO *tocs);
1357
1357
  Item *clone_item();
1358
1358
  /*
1359
1359
    Implement by-value equality evaluation if parameter value
1360
1360
    is set and is a basic constant (integer, real or string).
1361
 
    Otherwise return FALSE.
 
1361
    Otherwise return false.
1362
1362
  */
1363
1363
  bool eq(const Item *item, bool binary_cmp) const;
1364
1364
  /** Item is a argument to a limit clause. */
1369
1369
class Item_int :public Item_num
1370
1370
{
1371
1371
public:
1372
 
  longlong value;
 
1372
  int64_t value;
1373
1373
  Item_int(int32 i,uint length= MY_INT32_NUM_DECIMAL_DIGITS)
1374
 
    :value((longlong) i)
 
1374
    :value((int64_t) i)
1375
1375
    { max_length=length; fixed= 1; }
1376
 
  Item_int(longlong i,uint length= MY_INT64_NUM_DECIMAL_DIGITS)
 
1376
  Item_int(int64_t i,uint length= MY_INT64_NUM_DECIMAL_DIGITS)
1377
1377
    :value(i)
1378
1378
    { max_length=length; fixed= 1; }
1379
 
  Item_int(ulonglong i, uint length= MY_INT64_NUM_DECIMAL_DIGITS)
1380
 
    :value((longlong)i)
 
1379
  Item_int(uint64_t i, uint length= MY_INT64_NUM_DECIMAL_DIGITS)
 
1380
    :value((int64_t)i)
1381
1381
    { max_length=length; fixed= 1; unsigned_flag= 1; }
1382
 
  Item_int(const char *str_arg,longlong i,uint length) :value(i)
 
1382
  Item_int(const char *str_arg,int64_t i,uint length) :value(i)
1383
1383
    { max_length=length; name=(char*) str_arg; fixed= 1; }
1384
1384
  Item_int(const char *str_arg, uint length=64);
1385
1385
  enum Type type() const { return INT_ITEM; }
1386
1386
  enum Item_result result_type () const { return INT_RESULT; }
1387
1387
  enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
1388
 
  longlong val_int() { assert(fixed == 1); return value; }
 
1388
  int64_t val_int() { assert(fixed == 1); return value; }
1389
1389
  double val_real() { assert(fixed == 1); return (double) value; }
1390
1390
  my_decimal *val_decimal(my_decimal *);
1391
1391
  String *val_str(String*);
1404
1404
{
1405
1405
public:
1406
1406
  Item_uint(const char *str_arg, uint length);
1407
 
  Item_uint(ulonglong i) :Item_int((ulonglong) i, 10) {}
1408
 
  Item_uint(const char *str_arg, longlong i, uint length);
 
1407
  Item_uint(uint64_t i) :Item_int((uint64_t) i, 10) {}
 
1408
  Item_uint(const char *str_arg, int64_t i, uint length);
1409
1409
  double val_real()
1410
 
    { assert(fixed == 1); return ulonglong2double((ulonglong)value); }
 
1410
    { assert(fixed == 1); return uint64_t2double((uint64_t)value); }
1411
1411
  String *val_str(String*);
1412
1412
  Item *clone_item() { return new Item_uint(name, value, max_length); }
1413
1413
  int save_in_field(Field *field, bool no_conversions);
1427
1427
  Item_decimal(const char *str, const my_decimal *val_arg,
1428
1428
               uint decimal_par, uint length);
1429
1429
  Item_decimal(my_decimal *value_par);
1430
 
  Item_decimal(longlong val, bool unsig);
 
1430
  Item_decimal(int64_t val, bool unsig);
1431
1431
  Item_decimal(double val, int precision, int scale);
1432
1432
  Item_decimal(const uchar *bin, int precision, int scale);
1433
1433
 
1434
1434
  enum Type type() const { return DECIMAL_ITEM; }
1435
1435
  enum Item_result result_type () const { return DECIMAL_RESULT; }
1436
1436
  enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
1437
 
  longlong val_int();
 
1437
  int64_t val_int();
1438
1438
  double val_real();
1439
1439
  String *val_str(String*);
1440
1440
  my_decimal *val_decimal(my_decimal *val __attribute__((__unused__)))
1482
1482
  enum Type type() const { return REAL_ITEM; }
1483
1483
  enum_field_types field_type() const { return MYSQL_TYPE_DOUBLE; }
1484
1484
  double val_real() { assert(fixed == 1); return value; }
1485
 
  longlong val_int()
 
1485
  int64_t val_int()
1486
1486
  {
1487
1487
    assert(fixed == 1);
1488
 
    if (value <= (double) LONGLONG_MIN)
1489
 
    {
1490
 
       return LONGLONG_MIN;
1491
 
    }
1492
 
    else if (value >= (double) (ulonglong) LONGLONG_MAX)
1493
 
    {
1494
 
      return LONGLONG_MAX;
1495
 
    }
1496
 
    return (longlong) rint(value);
 
1488
    if (value <= (double) INT64_MIN)
 
1489
    {
 
1490
       return INT64_MIN;
 
1491
    }
 
1492
    else if (value >= (double) (uint64_t) INT64_MAX)
 
1493
    {
 
1494
      return INT64_MAX;
 
1495
    }
 
1496
    return (int64_t) rint(value);
1497
1497
  }
1498
1498
  String *val_str(String*);
1499
1499
  my_decimal *val_decimal(my_decimal *);
1531
1531
  Item_string(const char *str,uint length,
1532
1532
              CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
1533
1533
              uint repertoire= MY_REPERTOIRE_UNICODE30)
1534
 
    : m_cs_specified(FALSE)
 
1534
    : m_cs_specified(false)
1535
1535
  {
1536
1536
    str_value.set_or_copy_aligned(str, length, cs);
1537
1537
    collation.set(cs, dv, repertoire);
1550
1550
  }
1551
1551
  /* Just create an item and do not fill string representation */
1552
1552
  Item_string(CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE)
1553
 
    : m_cs_specified(FALSE)
 
1553
    : m_cs_specified(false)
1554
1554
  {
1555
1555
    collation.set(cs, dv);
1556
1556
    max_length= 0;
1561
1561
  Item_string(const char *name_par, const char *str, uint length,
1562
1562
              CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
1563
1563
              uint repertoire= MY_REPERTOIRE_UNICODE30)
1564
 
    : m_cs_specified(FALSE)
 
1564
    : m_cs_specified(false)
1565
1565
  {
1566
1566
    str_value.set_or_copy_aligned(str, length, cs);
1567
1567
    collation.set(cs, dv, repertoire);
1588
1588
  }
1589
1589
  enum Type type() const { return STRING_ITEM; }
1590
1590
  double val_real();
1591
 
  longlong val_int();
 
1591
  int64_t val_int();
1592
1592
  String *val_str(String*)
1593
1593
  {
1594
1594
    assert(fixed == 1);
1614
1614
  virtual void print(String *str, enum_query_type query_type);
1615
1615
 
1616
1616
  /**
1617
 
    Return TRUE if character-set-introducer was explicitly specified in the
 
1617
    Return true if character-set-introducer was explicitly specified in the
1618
1618
    original query for this item (text literal).
1619
1619
 
1620
1620
    This operation is to be called from Item_string::print(). The idea is
1628
1628
    one day when we start using original query as a view definition.
1629
1629
 
1630
1630
    @return This operation returns the value of m_cs_specified attribute.
1631
 
      @retval TRUE if character set introducer was explicitly specified in
 
1631
      @retval true if character set introducer was explicitly specified in
1632
1632
      the original query.
1633
 
      @retval FALSE otherwise.
 
1633
      @retval false otherwise.
1634
1634
  */
1635
1635
  inline bool is_cs_specified() const
1636
1636
  {
1721
1721
  enum_field_types int_field_type;
1722
1722
public:
1723
1723
  Item_return_int(const char *name_arg, uint length,
1724
 
                  enum_field_types field_type_arg, longlong value= 0)
 
1724
                  enum_field_types field_type_arg, int64_t value= 0)
1725
1725
    :Item_int(name_arg, value, length), int_field_type(field_type_arg)
1726
1726
  {
1727
1727
    unsigned_flag=1;
1739
1739
  double val_real()
1740
1740
  { 
1741
1741
    assert(fixed == 1); 
1742
 
    return (double) (ulonglong) Item_hex_string::val_int();
 
1742
    return (double) (uint64_t) Item_hex_string::val_int();
1743
1743
  }
1744
 
  longlong val_int();
 
1744
  int64_t val_int();
1745
1745
  bool basic_const_item() const { return 1; }
1746
1746
  String *val_str(String*) { assert(fixed == 1); return &str_value; }
1747
1747
  my_decimal *val_decimal(my_decimal *);
1815
1815
  */
1816
1816
  Item_ref(Name_resolution_context *context_arg, Item **item,
1817
1817
           const char *table_name_arg, const char *field_name_arg,
1818
 
           bool alias_name_used_arg= FALSE);
 
1818
           bool alias_name_used_arg= false);
1819
1819
 
1820
1820
  /* Constructor need to process subselect with temporary tables (see Item) */
1821
1821
  Item_ref(THD *thd, Item_ref *item)
1827
1827
    return ref && (*ref)->eq(it, binary_cmp);
1828
1828
  }
1829
1829
  double val_real();
1830
 
  longlong val_int();
 
1830
  int64_t val_int();
1831
1831
  my_decimal *val_decimal(my_decimal *);
1832
1832
  bool val_bool();
1833
1833
  String *val_str(String* tmp);
1834
1834
  bool is_null();
1835
1835
  bool get_date(MYSQL_TIME *ltime,uint fuzzydate);
1836
1836
  double val_result();
1837
 
  longlong val_int_result();
 
1837
  int64_t val_int_result();
1838
1838
  String *str_result(String* tmp);
1839
1839
  my_decimal *val_decimal_result(my_decimal *);
1840
1840
  bool val_bool_result();
1872
1872
  bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
1873
1873
  { return (*ref)->walk(processor, walk_subquery, arg); }
1874
1874
  virtual void print(String *str, enum_query_type query_type);
1875
 
  bool result_as_longlong()
 
1875
  bool result_as_int64_t()
1876
1876
  {
1877
 
    return (*ref)->result_as_longlong();
 
1877
    return (*ref)->result_as_int64_t();
1878
1878
  }
1879
1879
  void cleanup();
1880
1880
  Item_field *filed_for_view_update()
1922
1922
  Item_direct_ref(Name_resolution_context *context_arg, Item **item,
1923
1923
                  const char *table_name_arg,
1924
1924
                  const char *field_name_arg,
1925
 
                  bool alias_name_used_arg= FALSE)
 
1925
                  bool alias_name_used_arg= false)
1926
1926
    :Item_ref(context_arg, item, table_name_arg,
1927
1927
              field_name_arg, alias_name_used_arg)
1928
1928
  {}
1930
1930
  Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {}
1931
1931
 
1932
1932
  double val_real();
1933
 
  longlong val_int();
 
1933
  int64_t val_int();
1934
1934
  String *val_str(String* tmp);
1935
1935
  my_decimal *val_decimal(my_decimal *);
1936
1936
  bool val_bool();
1984
1984
  /* The aggregate function under which this outer ref is used, if any. */
1985
1985
  Item_sum *in_sum_func;
1986
1986
  /*
1987
 
    TRUE <=> that the outer_ref is already present in the select list
 
1987
    true <=> that the outer_ref is already present in the select list
1988
1988
    of the outer select.
1989
1989
  */
1990
1990
  bool found_in_select_list;
2026
2026
/*
2027
2027
  An object of this class:
2028
2028
   - Converts val_XXX() calls to ref->val_XXX_result() calls, like Item_ref.
2029
 
   - Sets owner->was_null=TRUE if it has returned a NULL value from any
 
2029
   - Sets owner->was_null=true if it has returned a NULL value from any
2030
2030
     val_XXX() function. This allows to inject an Item_ref_null_helper
2031
2031
     object into subquery and then check if the subquery has produced a row
2032
2032
     with NULL value.
2043
2043
    :Item_ref(context_arg, item, table_name_arg, field_name_arg),
2044
2044
     owner(master) {}
2045
2045
  double val_real();
2046
 
  longlong val_int();
 
2046
  int64_t val_int();
2047
2047
  String* val_str(String* s);
2048
2048
  my_decimal *val_decimal(my_decimal *);
2049
2049
  bool val_bool();
2073
2073
{
2074
2074
  Item *ref;
2075
2075
public:
2076
 
  Item_int_with_ref(longlong i, Item *ref_arg, my_bool unsigned_arg) :
 
2076
  Item_int_with_ref(int64_t i, Item *ref_arg, my_bool unsigned_arg) :
2077
2077
    Item_int(i), ref(ref_arg)
2078
2078
  {
2079
2079
    unsigned_flag= unsigned_arg;
2120
2120
            my_strntod(str_value.charset(), (char*) str_value.ptr(),
2121
2121
                       str_value.length(), &end_not_used, &err_not_used));
2122
2122
  }
2123
 
  longlong val_int()
 
2123
  int64_t val_int()
2124
2124
  {
2125
2125
    int err;
2126
2126
    return null_value ? 0LL : my_strntoll(str_value.charset(),str_value.ptr(),
2174
2174
class Cached_item_int :public Cached_item
2175
2175
{
2176
2176
  Item *item;
2177
 
  longlong value;
 
2177
  int64_t value;
2178
2178
public:
2179
2179
  Cached_item_int(Item *item_par) :item(item_par),value(0) {}
2180
2180
  bool cmp(void);
2324
2324
  virtual void print(String *str, enum_query_type query_type);
2325
2325
  bool eq_def(Field *field) 
2326
2326
  { 
2327
 
    return cached_field ? cached_field->eq_def (field) : FALSE;
 
2327
    return cached_field ? cached_field->eq_def (field) : false;
2328
2328
  }
2329
2329
  bool eq(const Item *item,
2330
2330
          bool binary_cmp __attribute__((__unused__))) const
2337
2337
class Item_cache_int: public Item_cache
2338
2338
{
2339
2339
protected:
2340
 
  longlong value;
 
2340
  int64_t value;
2341
2341
public:
2342
2342
  Item_cache_int(): Item_cache(), value(0) {}
2343
2343
  Item_cache_int(enum_field_types field_type_arg):
2344
2344
    Item_cache(field_type_arg), value(0) {}
2345
2345
 
2346
2346
  void store(Item *item);
2347
 
  void store(Item *item, longlong val_arg);
 
2347
  void store(Item *item, int64_t val_arg);
2348
2348
  double val_real() { assert(fixed == 1); return (double) value; }
2349
 
  longlong val_int() { assert(fixed == 1); return value; }
 
2349
  int64_t val_int() { assert(fixed == 1); return value; }
2350
2350
  String* val_str(String *str);
2351
2351
  my_decimal *val_decimal(my_decimal *);
2352
2352
  enum Item_result result_type() const { return INT_RESULT; }
2353
 
  bool result_as_longlong() { return TRUE; }
 
2353
  bool result_as_int64_t() { return true; }
2354
2354
};
2355
2355
 
2356
2356
 
2362
2362
 
2363
2363
  void store(Item *item);
2364
2364
  double val_real() { assert(fixed == 1); return value; }
2365
 
  longlong val_int();
 
2365
  int64_t val_int();
2366
2366
  String* val_str(String *str);
2367
2367
  my_decimal *val_decimal(my_decimal *);
2368
2368
  enum Item_result result_type() const { return REAL_RESULT; }
2378
2378
 
2379
2379
  void store(Item *item);
2380
2380
  double val_real();
2381
 
  longlong val_int();
 
2381
  int64_t val_int();
2382
2382
  String* val_str(String *str);
2383
2383
  my_decimal *val_decimal(my_decimal *);
2384
2384
  enum Item_result result_type() const { return DECIMAL_RESULT; }
2401
2401
  {}
2402
2402
  void store(Item *item);
2403
2403
  double val_real();
2404
 
  longlong val_int();
 
2404
  int64_t val_int();
2405
2405
  String* val_str(String *) { assert(fixed == 1); return value; }
2406
2406
  my_decimal *val_decimal(my_decimal *);
2407
2407
  enum Item_result result_type() const { return STRING_RESULT; }
2439
2439
    illegal_method_call((const char*)"val");
2440
2440
    return 0;
2441
2441
  };
2442
 
  longlong val_int()
 
2442
  int64_t val_int()
2443
2443
  {
2444
2444
    illegal_method_call((const char*)"val_int");
2445
2445
    return 0;
2500
2500
  enum_field_types field_type() const { return fld_type; };
2501
2501
  enum Type type() const { return TYPE_HOLDER; }
2502
2502
  double val_real();
2503
 
  longlong val_int();
 
2503
  int64_t val_int();
2504
2504
  my_decimal *val_decimal(my_decimal *);
2505
2505
  String *val_str(String*);
2506
2506
  bool join_types(THD *thd, Item *);