~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/item_cmpfunc.h

  • Committer: Brian Aker
  • Date: 2008-07-13 22:45:08 UTC
  • Revision ID: brian@tangent.org-20080713224508-hb20z4okblotb39a
longlong replacement

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
{
122
122
public:
123
123
  virtual bool val_bool();
124
 
  virtual longlong val_int();
 
124
  virtual int64_t val_int();
125
125
  virtual void fix_length_and_dec();
126
126
  virtual void print(String *str, enum_query_type query_type);
127
127
 
236
236
  bool fix_fields(THD *, Item **);
237
237
  bool fix_left(THD *thd, Item **ref);
238
238
  bool is_null();
239
 
  longlong val_int();
 
239
  int64_t val_int();
240
240
  void cleanup();
241
241
  const char *func_name() const { return "<in_optimizer>"; }
242
242
  Item_cache **get_cache() { return &cache; }
371
371
{
372
372
public:
373
373
  Item_func_not(Item *a) :Item_bool_func(a) {}
374
 
  longlong val_int();
 
374
  int64_t val_int();
375
375
  enum Functype functype() const { return NOT_FUNC; }
376
376
  const char *func_name() const { return "not"; }
377
377
  Item *neg_transformer(THD *thd);
414
414
  bool *trig_var;
415
415
public:
416
416
  Item_func_trig_cond(Item *a, bool *f) : Item_bool_func(a) { trig_var= f; }
417
 
  longlong val_int() { return *trig_var ? args[0]->val_int() : 1; }
 
417
  int64_t val_int() { return *trig_var ? args[0]->val_int() : 1; }
418
418
  enum Functype functype() const { return TRIG_COND_FUNC; };
419
419
  const char *func_name() const { return "trigcond"; };
420
420
  bool const_item() const { return false; }
439
439
    {}
440
440
  virtual void top_level_item() { abort_on_null= 1; }
441
441
  bool top_level() { return abort_on_null; }
442
 
  longlong val_int();
 
442
  int64_t val_int();
443
443
  enum Functype functype() const { return NOT_ALL_FUNC; }
444
444
  const char *func_name() const { return "<not>"; }
445
445
  virtual void print(String *str, enum_query_type query_type);
455
455
public:
456
456
 
457
457
  Item_func_nop_all(Item *a) :Item_func_not_all(a) {}
458
 
  longlong val_int();
 
458
  int64_t val_int();
459
459
  const char *func_name() const { return "<nop>"; }
460
460
  Item *neg_transformer(THD *thd);
461
461
};
465
465
{
466
466
public:
467
467
  Item_func_eq(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
468
 
  longlong val_int();
 
468
  int64_t val_int();
469
469
  enum Functype functype() const { return EQ_FUNC; }
470
470
  enum Functype rev_functype() const { return EQ_FUNC; }
471
471
  cond_result eq_cmp_result() const { return COND_TRUE; }
477
477
{
478
478
public:
479
479
  Item_func_equal(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
480
 
  longlong val_int();
 
480
  int64_t val_int();
481
481
  void fix_length_and_dec();
482
482
  table_map not_null_tables() const { return 0; }
483
483
  enum Functype functype() const { return EQUAL_FUNC; }
492
492
{
493
493
public:
494
494
  Item_func_ge(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
495
 
  longlong val_int();
 
495
  int64_t val_int();
496
496
  enum Functype functype() const { return GE_FUNC; }
497
497
  enum Functype rev_functype() const { return LE_FUNC; }
498
498
  cond_result eq_cmp_result() const { return COND_TRUE; }
505
505
{
506
506
public:
507
507
  Item_func_gt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
508
 
  longlong val_int();
 
508
  int64_t val_int();
509
509
  enum Functype functype() const { return GT_FUNC; }
510
510
  enum Functype rev_functype() const { return LT_FUNC; }
511
511
  cond_result eq_cmp_result() const { return COND_FALSE; }
518
518
{
519
519
public:
520
520
  Item_func_le(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
521
 
  longlong val_int();
 
521
  int64_t val_int();
522
522
  enum Functype functype() const { return LE_FUNC; }
523
523
  enum Functype rev_functype() const { return GE_FUNC; }
524
524
  cond_result eq_cmp_result() const { return COND_TRUE; }
531
531
{
532
532
public:
533
533
  Item_func_lt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
534
 
  longlong val_int();
 
534
  int64_t val_int();
535
535
  enum Functype functype() const { return LT_FUNC; }
536
536
  enum Functype rev_functype() const { return GT_FUNC; }
537
537
  cond_result eq_cmp_result() const { return COND_FALSE; }
544
544
{
545
545
public:
546
546
  Item_func_ne(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
547
 
  longlong val_int();
 
547
  int64_t val_int();
548
548
  enum Functype functype() const { return NE_FUNC; }
549
549
  cond_result eq_cmp_result() const { return COND_FALSE; }
550
550
  optimize_type select_optimize() const { return OPTIMIZE_KEY; } 
598
598
  Arg_comparator ge_cmp, le_cmp;
599
599
  Item_func_between(Item *a, Item *b, Item *c)
600
600
    :Item_func_opt_neg(a, b, c), compare_as_dates(false) {}
601
 
  longlong val_int();
 
601
  int64_t val_int();
602
602
  optimize_type select_optimize() const { return OPTIMIZE_KEY; }
603
603
  enum Functype functype() const   { return BETWEEN; }
604
604
  const char *func_name() const { return "between"; }
615
615
{
616
616
public:
617
617
  Item_func_strcmp(Item *a,Item *b) :Item_bool_func2(a,b) {}
618
 
  longlong val_int();
 
618
  int64_t val_int();
619
619
  optimize_type select_optimize() const { return OPTIMIZE_NONE; }
620
620
  const char *func_name() const { return "strcmp"; }
621
621
 
644
644
  {
645
645
    allowed_arg_cols= 0;    // Fetch this value from first argument
646
646
  }
647
 
  longlong val_int();
 
647
  int64_t val_int();
648
648
  void fix_length_and_dec();
649
649
  const char *func_name() const { return "interval"; }
650
650
  uint decimal_precision() const { return 2; }
659
659
public:
660
660
  Item_func_coalesce(List<Item> &list) :Item_func_numhybrid(list) {}
661
661
  double real_op();
662
 
  longlong int_op();
 
662
  int64_t int_op();
663
663
  String *str_op(String *);
664
664
  my_decimal *decimal_op(my_decimal *);
665
665
  void fix_length_and_dec();
678
678
public:
679
679
  Item_func_ifnull(Item *a, Item *b) :Item_func_coalesce(a,b) {}
680
680
  double real_op();
681
 
  longlong int_op();
 
681
  int64_t int_op();
682
682
  String *str_op(String *str);
683
683
  my_decimal *decimal_op(my_decimal *);
684
684
  enum_field_types field_type() const;
698
698
    :Item_func(a,b,c), cached_result_type(INT_RESULT)
699
699
  {}
700
700
  double val_real();
701
 
  longlong val_int();
 
701
  int64_t val_int();
702
702
  String *val_str(String *str);
703
703
  my_decimal *val_decimal(my_decimal *);
704
704
  enum Item_result result_type () const { return cached_result_type; }
718
718
    :Item_bool_func2(a,b), cached_result_type(INT_RESULT)
719
719
  {}
720
720
  double val_real();
721
 
  longlong val_int();
 
721
  int64_t val_int();
722
722
  String *val_str(String *str);
723
723
  my_decimal *val_decimal(my_decimal *);
724
724
  enum Item_result result_type () const { return cached_result_type; }
816
816
  Item_result result_type() { return STRING_RESULT; }
817
817
};
818
818
 
819
 
class in_longlong :public in_vector
 
819
class in_int64_t :public in_vector
820
820
{
821
821
protected:
822
822
  /*
824
824
    elements of this vector. tmp is used in finding if a given value is in 
825
825
    the list. 
826
826
  */
827
 
  struct packed_longlong 
 
827
  struct packed_int64_t 
828
828
  {
829
 
    longlong val;
830
 
    longlong unsigned_flag;  // Use longlong, not bool, to preserve alignment
 
829
    int64_t val;
 
830
    int64_t unsigned_flag;  // Use int64_t, not bool, to preserve alignment
831
831
  } tmp;
832
832
public:
833
 
  in_longlong(uint elements);
 
833
  in_int64_t(uint elements);
834
834
  void set(uint pos,Item *item);
835
835
  uchar *get_value(Item *item);
836
836
  
840
840
      We're created a signed INT, this may not be correct in 
841
841
      general case (see BUG#19342).
842
842
    */
843
 
    return new Item_int((longlong)0);
 
843
    return new Item_int((int64_t)0);
844
844
  }
845
845
  void value_to_item(uint pos, Item *item)
846
846
  {
847
 
    ((Item_int*) item)->value= ((packed_longlong*) base)[pos].val;
 
847
    ((Item_int*) item)->value= ((packed_int64_t*) base)[pos].val;
848
848
    ((Item_int*) item)->unsigned_flag= (my_bool)
849
 
      ((packed_longlong*) base)[pos].unsigned_flag;
 
849
      ((packed_int64_t*) base)[pos].unsigned_flag;
850
850
  }
851
851
  Item_result result_type() { return INT_RESULT; }
852
852
 
853
 
  friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
 
853
  friend int cmp_int64_t(void *cmp_arg, packed_int64_t *a,packed_int64_t *b);
854
854
};
855
855
 
856
856
 
860
860
  If the left item is a constant one then its value is cached in the
861
861
  lval_cache variable.
862
862
*/
863
 
class in_datetime :public in_longlong
 
863
class in_datetime :public in_int64_t
864
864
{
865
865
public:
866
866
  THD *thd;
870
870
  Item *lval_cache;
871
871
 
872
872
  in_datetime(Item *warn_item_arg, uint elements)
873
 
    :in_longlong(elements), thd(current_thd), warn_item(warn_item_arg),
 
873
    :in_int64_t(elements), thd(current_thd), warn_item(warn_item_arg),
874
874
     lval_cache(0) {};
875
875
  void set(uint pos,Item *item);
876
876
  uchar *get_value(Item *item);
877
 
  friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
 
877
  friend int cmp_int64_t(void *cmp_arg, packed_int64_t *a,packed_int64_t *b);
878
878
};
879
879
 
880
880
 
992
992
 
993
993
class cmp_item_int :public cmp_item
994
994
{
995
 
  longlong value;
 
995
  int64_t value;
996
996
public:
997
997
  cmp_item_int() {}                           /* Remove gcc warning */
998
998
  void store_value(Item *item)
1152
1152
    bzero(&cmp_items, sizeof(cmp_items));
1153
1153
  }
1154
1154
  double val_real();
1155
 
  longlong val_int();
 
1155
  int64_t val_int();
1156
1156
  String *val_str(String *);
1157
1157
  my_decimal *val_decimal(my_decimal *);
1158
1158
  bool fix_fields(THD *thd, Item **ref);
1209
1209
    bzero(&cmp_items, sizeof(cmp_items));
1210
1210
    allowed_arg_cols= 0;  // Fetch this value from first argument
1211
1211
  }
1212
 
  longlong val_int();
 
1212
  int64_t val_int();
1213
1213
  bool fix_fields(THD *, Item **);
1214
1214
  void fix_length_and_dec();
1215
1215
  uint decimal_precision() const { return 1; }
1270
1270
class Item_func_isnull :public Item_bool_func
1271
1271
{
1272
1272
protected:
1273
 
  longlong cached_value;
 
1273
  int64_t cached_value;
1274
1274
public:
1275
1275
  Item_func_isnull(Item *a) :Item_bool_func(a) {}
1276
 
  longlong val_int();
 
1276
  int64_t val_int();
1277
1277
  enum Functype functype() const { return ISNULL_FUNC; }
1278
1278
  void fix_length_and_dec()
1279
1279
  {
1288
1288
    {
1289
1289
      used_tables_cache= 0;                     /* is always false */
1290
1290
      const_item_cache= 1;
1291
 
      cached_value= (longlong) 0;
 
1291
      cached_value= (int64_t) 0;
1292
1292
    }
1293
1293
    else
1294
1294
    {
1297
1297
          !with_subselect)
1298
1298
      {
1299
1299
        /* Remember if the value is always NULL or never NULL */
1300
 
        cached_value= (longlong) args[0]->is_null();
 
1300
        cached_value= (int64_t) args[0]->is_null();
1301
1301
      }
1302
1302
    }
1303
1303
  }
1323
1323
    :Item_func_isnull(a), owner(ow)
1324
1324
  {}
1325
1325
  enum Functype functype() const { return ISNOTNULLTEST_FUNC; }
1326
 
  longlong val_int();
 
1326
  int64_t val_int();
1327
1327
  const char *func_name() const { return "<is_not_null_test>"; }
1328
1328
  void update_used_tables();
1329
1329
  /*
1339
1339
  bool abort_on_null;
1340
1340
public:
1341
1341
  Item_func_isnotnull(Item *a) :Item_bool_func(a), abort_on_null(0) {}
1342
 
  longlong val_int();
 
1342
  int64_t val_int();
1343
1343
  enum Functype functype() const { return ISNOTNULL_FUNC; }
1344
1344
  void fix_length_and_dec()
1345
1345
  {
1384
1384
    :Item_bool_func2(a,b), canDoTurboBM(false), pattern(0), pattern_len(0), 
1385
1385
     bmGs(0), bmBc(0), escape_item(escape_arg),
1386
1386
     escape_used_in_parsing(escape_used) {}
1387
 
  longlong val_int();
 
1387
  int64_t val_int();
1388
1388
  enum Functype functype() const { return LIKE_FUNC; }
1389
1389
  optimize_type select_optimize() const;
1390
1390
  cond_result eq_cmp_result() const { return COND_TRUE; }
1541
1541
  void merge(Item_equal *item);
1542
1542
  void update_const();
1543
1543
  enum Functype functype() const { return MULT_EQUAL_FUNC; }
1544
 
  longlong val_int(); 
 
1544
  int64_t val_int(); 
1545
1545
  const char *func_name() const { return "multiple equal"; }
1546
1546
  optimize_type select_optimize() const { return OPTIMIZE_EQUAL; }
1547
1547
  void sort(Item_field_cmpfunc cmp, void *arg);
1599
1599
  Item_cond_and(THD *thd, Item_cond_and *item) :Item_cond(thd, item) {}
1600
1600
  Item_cond_and(List<Item> &list_arg): Item_cond(list_arg) {}
1601
1601
  enum Functype functype() const { return COND_AND_FUNC; }
1602
 
  longlong val_int();
 
1602
  int64_t val_int();
1603
1603
  const char *func_name() const { return "and"; }
1604
1604
  table_map not_null_tables() const
1605
1605
  { return abort_on_null ? not_null_tables_cache: and_tables_cache; }
1630
1630
  Item_cond_or(THD *thd, Item_cond_or *item) :Item_cond(thd, item) {}
1631
1631
  Item_cond_or(List<Item> &list_arg): Item_cond(list_arg) {}
1632
1632
  enum Functype functype() const { return COND_OR_FUNC; }
1633
 
  longlong val_int();
 
1633
  int64_t val_int();
1634
1634
  const char *func_name() const { return "or"; }
1635
1635
  table_map not_null_tables() const { return and_tables_cache; }
1636
1636
  Item* copy_andor_structure(THD *thd)
1665
1665
  enum Functype functype() const { return COND_XOR_FUNC; }
1666
1666
  /* TODO: remove the next line when implementing XOR optimization */
1667
1667
  enum Type type() const { return FUNC_ITEM; }
1668
 
  longlong val_int();
 
1668
  int64_t val_int();
1669
1669
  const char *func_name() const { return "xor"; }
1670
1670
  void top_level_item() {}
1671
1671
};