1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1
/* Copyright (C) 2000-2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21
17
/* compare and test functions */
19
#ifdef USE_PRAGMA_INTERFACE
20
#pragma interface /* gcc class implementation */
24
23
extern Item_result item_cmp_type(Item_result a,Item_result b);
25
24
class Item_bool_func2;
43
42
bool is_nulls_eq; // TRUE <=> compare for the EQUAL_FUNC
44
43
enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
45
44
CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
46
uint64_t (*get_value_func)(THD *thd, Item ***item_arg, Item **cache_arg,
45
ulonglong (*get_value_func)(THD *thd, Item ***item_arg, Item **cache_arg,
47
46
Item *warn_item, bool *is_null);
49
48
DTCollation cmp_collation;
92
91
int compare_datetime(); // compare args[0] & args[1] as DATETIMEs
94
93
static enum enum_date_cmp_type can_compare_as_dates(Item *a, Item *b,
95
uint64_t *const_val_arg);
94
ulonglong *const_val_arg);
97
96
void set_datetime_cmp_func(Item **a1, Item **b1);
98
97
static arg_cmp_func comparator_matrix [5][2];
109
108
Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {}
110
109
bool is_bool_func() { return 1; }
111
110
void fix_length_and_dec() { decimals=0; max_length=1; }
112
uint32_t decimal_precision() const { return 1; }
111
uint decimal_precision() const { return 1; }
124
123
virtual bool val_bool();
125
virtual int64_t val_int();
124
virtual longlong val_int();
126
125
virtual void fix_length_and_dec();
127
126
virtual void print(String *str, enum_query_type query_type);
228
227
FALSE - result is FALSE
229
228
TRUE - result is NULL
231
bool result_for_null_param;
230
my_bool result_for_null_param;
233
232
Item_in_optimizer(Item *a, Item_in_subselect *b):
234
Item_bool_func(a, reinterpret_cast<Item *>(b)), cache(0),
233
Item_bool_func(a, my_reinterpret_cast(Item *)(b)), cache(0),
235
234
save_cache(0), result_for_null_param(UNKNOWN)
236
{ with_subselect= true; }
235
{ with_subselect= TRUE; }
237
236
bool fix_fields(THD *, Item **);
238
237
bool fix_left(THD *thd, Item **ref);
242
241
const char *func_name() const { return "<in_optimizer>"; }
243
242
Item_cache **get_cache() { return &cache; }
244
243
void keep_top_level_cache();
245
Item *transform(Item_transformer transformer, unsigned char *arg);
244
Item *transform(Item_transformer transformer, uchar *arg);
248
247
class Comp_creator
333
332
Item_bool_func2(Item *a,Item *b)
334
:Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1), abort_on_null(false) {}
333
:Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1), abort_on_null(FALSE) {}
335
334
void fix_length_and_dec();
336
335
void set_cmp_func()
349
348
bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); }
350
349
bool is_bool_func() { return 1; }
351
const CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
352
uint32_t decimal_precision() const { return 1; }
353
void top_level_item() { abort_on_null= true; }
350
CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
351
uint decimal_precision() const { return 1; }
352
void top_level_item() { abort_on_null= TRUE; }
355
354
friend class Arg_comparator;
365
364
Item *neg_transformer(THD *thd);
366
365
virtual Item *negated_item();
367
bool subst_argument_checker(unsigned char **arg __attribute__((unused)))
366
bool subst_argument_checker(uchar **arg) { return TRUE; }
371
369
class Item_func_not :public Item_bool_func
374
372
Item_func_not(Item *a) :Item_bool_func(a) {}
376
374
enum Functype functype() const { return NOT_FUNC; }
377
375
const char *func_name() const { return "not"; }
378
376
Item *neg_transformer(THD *thd);
417
415
Item_func_trig_cond(Item *a, bool *f) : Item_bool_func(a) { trig_var= f; }
418
int64_t val_int() { return *trig_var ? args[0]->val_int() : 1; }
416
longlong val_int() { return *trig_var ? args[0]->val_int() : 1; }
419
417
enum Functype functype() const { return TRIG_COND_FUNC; };
420
418
const char *func_name() const { return "trigcond"; };
421
bool const_item() const { return false; }
419
bool const_item() const { return FALSE; }
422
420
bool *get_trig_var() { return trig_var; }
423
421
/* The following is needed for ICP: */
424
422
table_map used_tables() const { return args[0]->used_tables(); }
441
439
virtual void top_level_item() { abort_on_null= 1; }
442
440
bool top_level() { return abort_on_null; }
444
442
enum Functype functype() const { return NOT_ALL_FUNC; }
445
443
const char *func_name() const { return "<not>"; }
446
444
virtual void print(String *str, enum_query_type query_type);
468
466
Item_func_eq(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
470
468
enum Functype functype() const { return EQ_FUNC; }
471
469
enum Functype rev_functype() const { return EQ_FUNC; }
472
470
cond_result eq_cmp_result() const { return COND_TRUE; }
480
478
Item_func_equal(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
482
480
void fix_length_and_dec();
483
481
table_map not_null_tables() const { return 0; }
484
482
enum Functype functype() const { return EQUAL_FUNC; }
485
483
enum Functype rev_functype() const { return EQUAL_FUNC; }
486
484
cond_result eq_cmp_result() const { return COND_TRUE; }
487
485
const char *func_name() const { return "<=>"; }
488
Item *neg_transformer(THD *thd __attribute__((unused))) { return 0; }
486
Item *neg_transformer(THD *thd) { return 0; }
495
493
Item_func_ge(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
497
495
enum Functype functype() const { return GE_FUNC; }
498
496
enum Functype rev_functype() const { return LE_FUNC; }
499
497
cond_result eq_cmp_result() const { return COND_TRUE; }
508
506
Item_func_gt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
510
508
enum Functype functype() const { return GT_FUNC; }
511
509
enum Functype rev_functype() const { return LT_FUNC; }
512
510
cond_result eq_cmp_result() const { return COND_FALSE; }
521
519
Item_func_le(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
523
521
enum Functype functype() const { return LE_FUNC; }
524
522
enum Functype rev_functype() const { return GE_FUNC; }
525
523
cond_result eq_cmp_result() const { return COND_TRUE; }
534
532
Item_func_lt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
536
534
enum Functype functype() const { return LT_FUNC; }
537
535
enum Functype rev_functype() const { return GT_FUNC; }
538
536
cond_result eq_cmp_result() const { return COND_FALSE; }
547
545
Item_func_ne(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
549
547
enum Functype functype() const { return NE_FUNC; }
550
548
cond_result eq_cmp_result() const { return COND_FALSE; }
551
549
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
577
575
inline void negate() { negated= !negated; }
578
576
inline void top_level_item() { pred_level= 1; }
579
Item *neg_transformer(THD *thd __attribute__((unused)))
577
Item *neg_transformer(THD *thd)
581
579
negated= !negated;
584
582
bool eq(const Item *item, bool binary_cmp) const;
585
bool subst_argument_checker(unsigned char **arg __attribute__((unused)))
583
bool subst_argument_checker(uchar **arg) { return TRUE; }
598
595
/* Comparators used for DATE/DATETIME comparison. */
599
596
Arg_comparator ge_cmp, le_cmp;
600
597
Item_func_between(Item *a, Item *b, Item *c)
601
:Item_func_opt_neg(a, b, c), compare_as_dates(false) {}
598
:Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) {}
603
600
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
604
601
enum Functype functype() const { return BETWEEN; }
605
602
const char *func_name() const { return "between"; }
607
604
void fix_length_and_dec();
608
605
virtual void print(String *str, enum_query_type query_type);
609
606
bool is_bool_func() { return 1; }
610
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
611
uint32_t decimal_precision() const { return 1; }
607
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
608
uint decimal_precision() const { return 1; }
637
634
class Item_func_interval :public Item_int_func
640
bool use_decimal_comparison;
637
my_bool use_decimal_comparison;
641
638
interval_range *intervals;
643
640
Item_func_interval(Item_row *a)
646
643
allowed_arg_cols= 0; // Fetch this value from first argument
649
646
void fix_length_and_dec();
650
647
const char *func_name() const { return "interval"; }
651
uint32_t decimal_precision() const { return 2; }
648
uint decimal_precision() const { return 2; }
680
677
Item_func_ifnull(Item *a, Item *b) :Item_func_coalesce(a,b) {}
681
678
double real_op();
683
680
String *str_op(String *str);
684
681
my_decimal *decimal_op(my_decimal *);
685
682
enum_field_types field_type() const;
686
683
void fix_length_and_dec();
687
684
const char *func_name() const { return "ifnull"; }
688
Field *tmp_table_field(Table *table);
689
uint32_t decimal_precision() const;
685
Field *tmp_table_field(TABLE *table);
686
uint decimal_precision() const;
699
696
:Item_func(a,b,c), cached_result_type(INT_RESULT)
701
698
double val_real();
703
700
String *val_str(String *str);
704
701
my_decimal *val_decimal(my_decimal *);
705
702
enum Item_result result_type () const { return cached_result_type; }
706
703
enum_field_types field_type() const { return cached_field_type; }
707
704
bool fix_fields(THD *, Item **);
708
705
void fix_length_and_dec();
709
uint32_t decimal_precision() const;
706
uint decimal_precision() const;
710
707
const char *func_name() const { return "if"; }
719
716
:Item_bool_func2(a,b), cached_result_type(INT_RESULT)
721
718
double val_real();
723
720
String *val_str(String *str);
724
721
my_decimal *val_decimal(my_decimal *);
725
722
enum Item_result result_type () const { return cached_result_type; }
726
723
void fix_length_and_dec();
727
uint32_t decimal_precision() const { return args[0]->decimal_precision(); }
724
uint decimal_precision() const { return args[0]->decimal_precision(); }
728
725
const char *func_name() const { return "nullif"; }
730
727
virtual inline void print(String *str, enum_query_type query_type)
750
747
qsort2_cmp compare;
751
const CHARSET_INFO *collation;
748
CHARSET_INFO *collation;
755
in_vector(uint32_t elements,uint32_t element_length,qsort2_cmp cmp_func,
756
const CHARSET_INFO * const cmp_coll)
752
in_vector(uint elements,uint element_length,qsort2_cmp cmp_func,
753
CHARSET_INFO *cmp_coll)
757
754
:base((char*) sql_calloc(elements*element_length)),
758
755
size(element_length), compare(cmp_func), collation(cmp_coll),
759
756
count(elements), used_count(elements) {}
760
757
virtual ~in_vector() {}
761
virtual void set(uint32_t pos,Item *item)=0;
762
virtual unsigned char *get_value(Item *item)=0;
758
virtual void set(uint pos,Item *item)=0;
759
virtual uchar *get_value(Item *item)=0;
765
my_qsort2(base,used_count,size,compare, (void *) collation);
762
my_qsort2(base,used_count,size,compare,collation);
767
764
int find(Item *item);
784
781
item Constant item to store value into. The item must be of the same
785
782
type that create_item() returns.
787
virtual void value_to_item(uint32_t pos __attribute__((unused)),
788
Item *item __attribute__((unused))) { }
784
virtual void value_to_item(uint pos, Item *item) { }
790
786
/* Compare values number pos1 and pos2 for equality */
791
bool compare_elems(uint32_t pos1, uint32_t pos2)
787
bool compare_elems(uint pos1, uint pos2)
793
789
return test(compare(collation, base + pos1*size, base + pos2*size));
800
796
char buff[STRING_BUFFER_USUAL_SIZE];
803
in_string(uint32_t elements,qsort2_cmp cmp_func, const CHARSET_INFO * const cs);
799
in_string(uint elements,qsort2_cmp cmp_func, CHARSET_INFO *cs);
805
void set(uint32_t pos,Item *item);
806
unsigned char *get_value(Item *item);
801
void set(uint pos,Item *item);
802
uchar *get_value(Item *item);
807
803
Item* create_item()
809
805
return new Item_string(collation);
811
void value_to_item(uint32_t pos, Item *item)
807
void value_to_item(uint pos, Item *item)
813
809
String *str=((String*) base)+pos;
814
810
Item_string *to= (Item_string*)item;
825
821
elements of this vector. tmp is used in finding if a given value is in
828
struct packed_int64_t
824
struct packed_longlong
831
int64_t unsigned_flag; // Use int64_t, not bool, to preserve alignment
827
longlong unsigned_flag; // Use longlong, not bool, to preserve alignment
834
in_int64_t(uint32_t elements);
835
void set(uint32_t pos,Item *item);
836
unsigned char *get_value(Item *item);
830
in_longlong(uint elements);
831
void set(uint pos,Item *item);
832
uchar *get_value(Item *item);
838
834
Item* create_item()
841
837
We're created a signed INT, this may not be correct in
842
838
general case (see BUG#19342).
844
return new Item_int((int64_t)0);
840
return new Item_int((longlong)0);
846
void value_to_item(uint32_t pos, Item *item)
842
void value_to_item(uint pos, Item *item)
848
((Item_int*) item)->value= ((packed_int64_t*) base)[pos].val;
849
((Item_int*) item)->unsigned_flag= (bool)
850
((packed_int64_t*) base)[pos].unsigned_flag;
844
((Item_int*) item)->value= ((packed_longlong*) base)[pos].val;
845
((Item_int*) item)->unsigned_flag= (my_bool)
846
((packed_longlong*) base)[pos].unsigned_flag;
852
848
Item_result result_type() { return INT_RESULT; }
854
friend int cmp_int64_t(void *cmp_arg, packed_int64_t *a,packed_int64_t *b);
850
friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
870
866
/* Cache for the left item. */
871
867
Item *lval_cache;
873
in_datetime(Item *warn_item_arg, uint32_t elements)
874
:in_int64_t(elements), thd(current_thd), warn_item(warn_item_arg),
869
in_datetime(Item *warn_item_arg, uint elements)
870
:in_longlong(elements), thd(current_thd), warn_item(warn_item_arg),
875
871
lval_cache(0) {};
876
void set(uint32_t pos,Item *item);
877
unsigned char *get_value(Item *item);
878
friend int cmp_int64_t(void *cmp_arg, packed_int64_t *a,packed_int64_t *b);
872
void set(uint pos,Item *item);
873
uchar *get_value(Item *item);
874
friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
886
in_double(uint32_t elements);
887
void set(uint32_t pos,Item *item);
888
unsigned char *get_value(Item *item);
882
in_double(uint elements);
883
void set(uint pos,Item *item);
884
uchar *get_value(Item *item);
889
885
Item *create_item()
891
887
return new Item_float(0.0, 0);
893
void value_to_item(uint32_t pos, Item *item)
889
void value_to_item(uint pos, Item *item)
895
891
((Item_float*)item)->value= ((double*) base)[pos];
905
in_decimal(uint32_t elements);
906
void set(uint32_t pos, Item *item);
907
unsigned char *get_value(Item *item);
901
in_decimal(uint elements);
902
void set(uint pos, Item *item);
903
uchar *get_value(Item *item);
908
904
Item *create_item()
910
return new Item_decimal(0, false);
906
return new Item_decimal(0, FALSE);
912
void value_to_item(uint32_t pos, Item *item)
908
void value_to_item(uint pos, Item *item)
914
910
my_decimal *dec= ((my_decimal *)base) + pos;
915
911
Item_decimal *item_dec= (Item_decimal*)item;
927
923
class cmp_item :public Sql_alloc
930
const CHARSET_INFO *cmp_charset;
926
CHARSET_INFO *cmp_charset;
931
927
cmp_item() { cmp_charset= &my_charset_bin; }
932
928
virtual ~cmp_item() {}
933
929
virtual void store_value(Item *item)= 0;
934
930
virtual int cmp(Item *item)= 0;
935
931
// for optimized IN with row
936
932
virtual int compare(cmp_item *item)= 0;
937
static cmp_item* get_comparator(Item_result type, const CHARSET_INFO * const cs);
933
static cmp_item* get_comparator(Item_result type, CHARSET_INFO *cs);
938
934
virtual cmp_item *make_same()= 0;
939
virtual void store_value_by_template(cmp_item *tmpl __attribute__((unused)),
935
virtual void store_value_by_template(cmp_item *tmpl, Item *item)
942
937
store_value(item);
949
944
String *value_res;
951
946
cmp_item_string () {}
952
cmp_item_string (const CHARSET_INFO * const cs) { cmp_charset= cs; }
953
void set_charset(const CHARSET_INFO * const cs) { cmp_charset= cs; }
947
cmp_item_string (CHARSET_INFO *cs) { cmp_charset= cs; }
948
void set_charset(CHARSET_INFO *cs) { cmp_charset= cs; }
954
949
friend class cmp_item_sort_string;
955
950
friend class cmp_item_sort_string_in_static;
964
959
cmp_item_sort_string():
965
960
cmp_item_string() {}
966
cmp_item_sort_string(const CHARSET_INFO * const cs):
961
cmp_item_sort_string(CHARSET_INFO *cs):
967
962
cmp_item_string(cs),
968
963
value(value_buff, sizeof(value_buff), cs) {}
969
964
void store_value(Item *item)
984
979
return sortcmp(value_res, l_cmp->value_res, cmp_charset);
986
981
cmp_item *make_same();
987
void set_charset(const CHARSET_INFO * const cs)
982
void set_charset(CHARSET_INFO *cs)
990
985
value.set_quick(value_buff, sizeof(value_buff), cs);
1083
cmp_item_sort_string_in_static(const CHARSET_INFO * const cs):
1078
cmp_item_sort_string_in_static(CHARSET_INFO *cs):
1084
1079
cmp_item_string(cs) {}
1085
1080
void store_value(Item *item)
1087
1082
value_res= item->val_str(&value);
1089
int cmp(Item *item __attribute__((unused)))
1091
1086
// Should never be called
1095
1090
int compare(cmp_item *ci)
1127
1122
int first_expr_num, else_expr_num;
1128
1123
enum Item_result cached_result_type, left_result_type;
1129
1124
String tmp_value;
1131
1126
Item_result cmp_type;
1132
1127
DTCollation cmp_collation;
1133
1128
enum_field_types cached_field_type;
1150
1145
list.push_back(else_expr_arg);
1152
1147
set_arguments(list);
1153
memset(&cmp_items, 0, sizeof(cmp_items));
1148
bzero(&cmp_items, sizeof(cmp_items));
1155
1150
double val_real();
1157
1152
String *val_str(String *);
1158
1153
my_decimal *val_decimal(my_decimal *);
1159
1154
bool fix_fields(THD *thd, Item **ref);
1160
1155
void fix_length_and_dec();
1161
uint32_t decimal_precision() const;
1156
uint decimal_precision() const;
1162
1157
table_map not_null_tables() const { return 0; }
1163
1158
enum Item_result result_type () const { return cached_result_type; }
1164
1159
enum_field_types field_type() const { return cached_field_type; }
1165
1160
const char *func_name() const { return "case"; }
1166
1161
virtual void print(String *str, enum_query_type query_type);
1167
1162
Item *find_item(String *str);
1168
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1163
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1169
1164
void cleanup();
1170
1165
void agg_str_lengths(Item *arg);
1171
1166
void agg_num_lengths(Item *arg);
1206
1201
Item_func_in(List<Item> &list)
1207
1202
:Item_func_opt_neg(list), array(0), have_null(0),
1208
arg_types_compatible(false)
1203
arg_types_compatible(FALSE)
1210
memset(&cmp_items, 0, sizeof(cmp_items));
1205
bzero(&cmp_items, sizeof(cmp_items));
1211
1206
allowed_arg_cols= 0; // Fetch this value from first argument
1214
1209
bool fix_fields(THD *, Item **);
1215
1210
void fix_length_and_dec();
1216
uint32_t decimal_precision() const { return 1; }
1211
uint decimal_precision() const { return 1; }
1215
DBUG_ENTER("Item_func_in::cleanup");
1220
1216
Item_int_func::cleanup();
1234
1230
const char *func_name() const { return " IN "; }
1235
1231
bool nulls_in_row();
1236
1232
bool is_bool_func() { return 1; }
1237
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1233
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1240
1236
class cmp_item_row :public cmp_item
1242
1238
cmp_item **comparators;
1245
1241
cmp_item_row(): comparators(0), n(0) {}
1246
1242
~cmp_item_row();
1259
1255
cmp_item_row tmp;
1261
in_row(uint32_t elements, Item *);
1257
in_row(uint elements, Item *);
1263
void set(uint32_t pos,Item *item);
1264
unsigned char *get_value(Item *item);
1259
void set(uint pos,Item *item);
1260
uchar *get_value(Item *item);
1265
1261
friend void Item_func_in::fix_length_and_dec();
1266
1262
Item_result result_type() { return ROW_RESULT; }
1298
1294
!with_subselect)
1300
1296
/* Remember if the value is always NULL or never NULL */
1301
cached_value= (int64_t) args[0]->is_null();
1297
cached_value= (longlong) args[0]->is_null();
1305
1301
table_map not_null_tables() const { return 0; }
1306
1302
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
1307
1303
Item *neg_transformer(THD *thd);
1308
const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1304
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1311
1307
/* Functions used by HAVING for rewriting IN subquery */
1324
1320
:Item_func_isnull(a), owner(ow)
1326
1322
enum Functype functype() const { return ISNOTNULLTEST_FUNC; }
1328
1324
const char *func_name() const { return "<is_not_null_test>"; }
1329
1325
void update_used_tables();
1352
1348
{ return abort_on_null ? not_null_tables_cache : 0; }
1353
1349
Item *neg_transformer(THD *thd);
1354
1350
virtual void print(String *str, enum_query_type query_type);
1355
const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1351
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1356
1352
void top_level_item() { abort_on_null=1; }
1384
1380
Item_func_like(Item *a,Item *b, Item *escape_arg, bool escape_used)
1385
:Item_bool_func2(a,b), canDoTurboBM(false), pattern(0), pattern_len(0),
1381
:Item_bool_func2(a,b), canDoTurboBM(FALSE), pattern(0), pattern_len(0),
1386
1382
bmGs(0), bmBc(0), escape_item(escape_arg),
1387
1383
escape_used_in_parsing(escape_used) {}
1389
1385
enum Functype functype() const { return LIKE_FUNC; }
1390
1386
optimize_type select_optimize() const;
1391
1387
cond_result eq_cmp_result() const { return COND_TRUE; }
1429
1425
void update_used_tables();
1430
1426
virtual void print(String *str, enum_query_type query_type);
1431
1427
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
1432
friend int setup_conds(THD *thd, TableList *tables, TableList *leaves,
1428
friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
1434
1430
void top_level_item() { abort_on_null=1; }
1435
1431
void copy_andor_arguments(THD *thd, Item_cond *item);
1436
bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
1437
Item *transform(Item_transformer transformer, unsigned char *arg);
1432
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
1433
Item *transform(Item_transformer transformer, uchar *arg);
1438
1434
void traverse_cond(Cond_traverser, void *arg, traverse_order order);
1439
1435
void neg_arguments(THD *thd);
1440
enum_field_types field_type() const { return DRIZZLE_TYPE_LONGLONG; }
1441
bool subst_argument_checker(unsigned char **arg __attribute__((unused)))
1443
Item *compile(Item_analyzer analyzer, unsigned char **arg_p,
1444
Item_transformer transformer, unsigned char *arg_t);
1436
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
1437
bool subst_argument_checker(uchar **arg) { return TRUE; }
1438
Item *compile(Item_analyzer analyzer, uchar **arg_p,
1439
Item_transformer transformer, uchar *arg_t);
1536
1531
inline Item* get_const() { return const_item; }
1537
1532
void add(Item *c);
1538
1533
void add(Item_field *f);
1540
1535
bool contains(Field *field);
1541
1536
Item_field* get_first() { return fields.head(); }
1542
1537
void merge(Item_equal *item);
1543
1538
void update_const();
1544
1539
enum Functype functype() const { return MULT_EQUAL_FUNC; }
1546
1541
const char *func_name() const { return "multiple equal"; }
1547
1542
optimize_type select_optimize() const { return OPTIMIZE_EQUAL; }
1548
1543
void sort(Item_field_cmpfunc cmp, void *arg);
1550
1545
void fix_length_and_dec();
1551
1546
bool fix_fields(THD *thd, Item **ref);
1552
1547
void update_used_tables();
1553
bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
1554
Item *transform(Item_transformer transformer, unsigned char *arg);
1548
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
1549
Item *transform(Item_transformer transformer, uchar *arg);
1555
1550
virtual void print(String *str, enum_query_type query_type);
1556
const CHARSET_INFO *compare_collation()
1551
CHARSET_INFO *compare_collation()
1557
1552
{ return fields.head()->collation.collation; }
1560
1555
class COND_EQUAL: public Sql_alloc
1563
uint32_t max_members; /* max number of members the current level
1558
uint max_members; /* max number of members the current level
1564
1559
list and all lower level lists */
1565
1560
COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
1566
1561
List<Item_equal> current_level; /* list of multiple equalities of
1600
1595
Item_cond_and(THD *thd, Item_cond_and *item) :Item_cond(thd, item) {}
1601
1596
Item_cond_and(List<Item> &list_arg): Item_cond(list_arg) {}
1602
1597
enum Functype functype() const { return COND_AND_FUNC; }
1604
1599
const char *func_name() const { return "and"; }
1605
1600
table_map not_null_tables() const
1606
1601
{ return abort_on_null ? not_null_tables_cache: and_tables_cache; }
1631
1626
Item_cond_or(THD *thd, Item_cond_or *item) :Item_cond(thd, item) {}
1632
1627
Item_cond_or(List<Item> &list_arg): Item_cond(list_arg) {}
1633
1628
enum Functype functype() const { return COND_OR_FUNC; }
1635
1630
const char *func_name() const { return "or"; }
1636
1631
table_map not_null_tables() const { return and_tables_cache; }
1637
1632
Item* copy_andor_structure(THD *thd)
1666
1661
enum Functype functype() const { return COND_XOR_FUNC; }
1667
1662
/* TODO: remove the next line when implementing XOR optimization */
1668
1663
enum Type type() const { return FUNC_ITEM; }
1670
1665
const char *func_name() const { return "xor"; }
1671
1666
void top_level_item() {}