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 __attribute__((__unused__)))
371
370
class Item_func_not :public Item_bool_func
374
373
Item_func_not(Item *a) :Item_bool_func(a) {}
376
375
enum Functype functype() const { return NOT_FUNC; }
377
376
const char *func_name() const { return "not"; }
378
377
Item *neg_transformer(THD *thd);
417
416
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; }
417
longlong val_int() { return *trig_var ? args[0]->val_int() : 1; }
419
418
enum Functype functype() const { return TRIG_COND_FUNC; };
420
419
const char *func_name() const { return "trigcond"; };
421
bool const_item() const { return false; }
420
bool const_item() const { return FALSE; }
422
421
bool *get_trig_var() { return trig_var; }
423
422
/* The following is needed for ICP: */
424
423
table_map used_tables() const { return args[0]->used_tables(); }
441
440
virtual void top_level_item() { abort_on_null= 1; }
442
441
bool top_level() { return abort_on_null; }
444
443
enum Functype functype() const { return NOT_ALL_FUNC; }
445
444
const char *func_name() const { return "<not>"; }
446
445
virtual void print(String *str, enum_query_type query_type);
468
467
Item_func_eq(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
470
469
enum Functype functype() const { return EQ_FUNC; }
471
470
enum Functype rev_functype() const { return EQ_FUNC; }
472
471
cond_result eq_cmp_result() const { return COND_TRUE; }
480
479
Item_func_equal(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
482
481
void fix_length_and_dec();
483
482
table_map not_null_tables() const { return 0; }
484
483
enum Functype functype() const { return EQUAL_FUNC; }
485
484
enum Functype rev_functype() const { return EQUAL_FUNC; }
486
485
cond_result eq_cmp_result() const { return COND_TRUE; }
487
486
const char *func_name() const { return "<=>"; }
488
Item *neg_transformer(THD *thd __attribute__((unused))) { return 0; }
487
Item *neg_transformer(THD *thd __attribute__((__unused__))) { return 0; }
495
494
Item_func_ge(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
497
496
enum Functype functype() const { return GE_FUNC; }
498
497
enum Functype rev_functype() const { return LE_FUNC; }
499
498
cond_result eq_cmp_result() const { return COND_TRUE; }
508
507
Item_func_gt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
510
509
enum Functype functype() const { return GT_FUNC; }
511
510
enum Functype rev_functype() const { return LT_FUNC; }
512
511
cond_result eq_cmp_result() const { return COND_FALSE; }
521
520
Item_func_le(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
523
522
enum Functype functype() const { return LE_FUNC; }
524
523
enum Functype rev_functype() const { return GE_FUNC; }
525
524
cond_result eq_cmp_result() const { return COND_TRUE; }
534
533
Item_func_lt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
536
535
enum Functype functype() const { return LT_FUNC; }
537
536
enum Functype rev_functype() const { return GT_FUNC; }
538
537
cond_result eq_cmp_result() const { return COND_FALSE; }
547
546
Item_func_ne(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
549
548
enum Functype functype() const { return NE_FUNC; }
550
549
cond_result eq_cmp_result() const { return COND_FALSE; }
551
550
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
577
576
inline void negate() { negated= !negated; }
578
577
inline void top_level_item() { pred_level= 1; }
579
Item *neg_transformer(THD *thd __attribute__((unused)))
578
Item *neg_transformer(THD *thd __attribute__((__unused__)))
581
580
negated= !negated;
584
583
bool eq(const Item *item, bool binary_cmp) const;
585
bool subst_argument_checker(unsigned char **arg __attribute__((unused)))
584
bool subst_argument_checker(uchar **arg __attribute__((__unused__)))
598
597
/* Comparators used for DATE/DATETIME comparison. */
599
598
Arg_comparator ge_cmp, le_cmp;
600
599
Item_func_between(Item *a, Item *b, Item *c)
601
:Item_func_opt_neg(a, b, c), compare_as_dates(false) {}
600
:Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) {}
603
602
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
604
603
enum Functype functype() const { return BETWEEN; }
605
604
const char *func_name() const { return "between"; }
607
606
void fix_length_and_dec();
608
607
virtual void print(String *str, enum_query_type query_type);
609
608
bool is_bool_func() { return 1; }
610
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
611
uint32_t decimal_precision() const { return 1; }
609
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
610
uint decimal_precision() const { return 1; }
637
636
class Item_func_interval :public Item_int_func
640
bool use_decimal_comparison;
639
my_bool use_decimal_comparison;
641
640
interval_range *intervals;
643
642
Item_func_interval(Item_row *a)
646
645
allowed_arg_cols= 0; // Fetch this value from first argument
649
648
void fix_length_and_dec();
650
649
const char *func_name() const { return "interval"; }
651
uint32_t decimal_precision() const { return 2; }
650
uint decimal_precision() const { return 2; }
680
679
Item_func_ifnull(Item *a, Item *b) :Item_func_coalesce(a,b) {}
681
680
double real_op();
683
682
String *str_op(String *str);
684
683
my_decimal *decimal_op(my_decimal *);
685
684
enum_field_types field_type() const;
686
685
void fix_length_and_dec();
687
686
const char *func_name() const { return "ifnull"; }
688
Field *tmp_table_field(Table *table);
689
uint32_t decimal_precision() const;
687
Field *tmp_table_field(TABLE *table);
688
uint decimal_precision() const;
699
698
:Item_func(a,b,c), cached_result_type(INT_RESULT)
701
700
double val_real();
703
702
String *val_str(String *str);
704
703
my_decimal *val_decimal(my_decimal *);
705
704
enum Item_result result_type () const { return cached_result_type; }
706
705
enum_field_types field_type() const { return cached_field_type; }
707
706
bool fix_fields(THD *, Item **);
708
707
void fix_length_and_dec();
709
uint32_t decimal_precision() const;
708
uint decimal_precision() const;
710
709
const char *func_name() const { return "if"; }
719
718
:Item_bool_func2(a,b), cached_result_type(INT_RESULT)
721
720
double val_real();
723
722
String *val_str(String *str);
724
723
my_decimal *val_decimal(my_decimal *);
725
724
enum Item_result result_type () const { return cached_result_type; }
726
725
void fix_length_and_dec();
727
uint32_t decimal_precision() const { return args[0]->decimal_precision(); }
726
uint decimal_precision() const { return args[0]->decimal_precision(); }
728
727
const char *func_name() const { return "nullif"; }
730
729
virtual inline void print(String *str, enum_query_type query_type)
750
749
qsort2_cmp compare;
751
const CHARSET_INFO *collation;
750
CHARSET_INFO *collation;
755
in_vector(uint32_t elements,uint32_t element_length,qsort2_cmp cmp_func,
756
const CHARSET_INFO * const cmp_coll)
754
in_vector(uint elements,uint element_length,qsort2_cmp cmp_func,
755
CHARSET_INFO *cmp_coll)
757
756
:base((char*) sql_calloc(elements*element_length)),
758
757
size(element_length), compare(cmp_func), collation(cmp_coll),
759
758
count(elements), used_count(elements) {}
760
759
virtual ~in_vector() {}
761
virtual void set(uint32_t pos,Item *item)=0;
762
virtual unsigned char *get_value(Item *item)=0;
760
virtual void set(uint pos,Item *item)=0;
761
virtual uchar *get_value(Item *item)=0;
765
my_qsort2(base,used_count,size,compare, (void *) collation);
764
my_qsort2(base,used_count,size,compare,collation);
767
766
int find(Item *item);
784
783
item Constant item to store value into. The item must be of the same
785
784
type that create_item() returns.
787
virtual void value_to_item(uint32_t pos __attribute__((unused)),
788
Item *item __attribute__((unused))) { }
786
virtual void value_to_item(uint pos __attribute__((__unused__)),
787
Item *item __attribute__((__unused__))) { }
790
789
/* Compare values number pos1 and pos2 for equality */
791
bool compare_elems(uint32_t pos1, uint32_t pos2)
790
bool compare_elems(uint pos1, uint pos2)
793
792
return test(compare(collation, base + pos1*size, base + pos2*size));
800
799
char buff[STRING_BUFFER_USUAL_SIZE];
803
in_string(uint32_t elements,qsort2_cmp cmp_func, const CHARSET_INFO * const cs);
802
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);
804
void set(uint pos,Item *item);
805
uchar *get_value(Item *item);
807
806
Item* create_item()
809
808
return new Item_string(collation);
811
void value_to_item(uint32_t pos, Item *item)
810
void value_to_item(uint pos, Item *item)
813
812
String *str=((String*) base)+pos;
814
813
Item_string *to= (Item_string*)item;
825
824
elements of this vector. tmp is used in finding if a given value is in
828
struct packed_int64_t
827
struct packed_longlong
831
int64_t unsigned_flag; // Use int64_t, not bool, to preserve alignment
830
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);
833
in_longlong(uint elements);
834
void set(uint pos,Item *item);
835
uchar *get_value(Item *item);
838
837
Item* create_item()
841
840
We're created a signed INT, this may not be correct in
842
841
general case (see BUG#19342).
844
return new Item_int((int64_t)0);
843
return new Item_int((longlong)0);
846
void value_to_item(uint32_t pos, Item *item)
845
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;
847
((Item_int*) item)->value= ((packed_longlong*) base)[pos].val;
848
((Item_int*) item)->unsigned_flag= (my_bool)
849
((packed_longlong*) base)[pos].unsigned_flag;
852
851
Item_result result_type() { return INT_RESULT; }
854
friend int cmp_int64_t(void *cmp_arg, packed_int64_t *a,packed_int64_t *b);
853
friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
870
869
/* Cache for the left item. */
871
870
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),
872
in_datetime(Item *warn_item_arg, uint elements)
873
:in_longlong(elements), thd(current_thd), warn_item(warn_item_arg),
875
874
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);
875
void set(uint pos,Item *item);
876
uchar *get_value(Item *item);
877
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);
885
in_double(uint elements);
886
void set(uint pos,Item *item);
887
uchar *get_value(Item *item);
889
888
Item *create_item()
891
890
return new Item_float(0.0, 0);
893
void value_to_item(uint32_t pos, Item *item)
892
void value_to_item(uint pos, Item *item)
895
894
((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);
904
in_decimal(uint elements);
905
void set(uint pos, Item *item);
906
uchar *get_value(Item *item);
908
907
Item *create_item()
910
return new Item_decimal(0, false);
909
return new Item_decimal(0, FALSE);
912
void value_to_item(uint32_t pos, Item *item)
911
void value_to_item(uint pos, Item *item)
914
913
my_decimal *dec= ((my_decimal *)base) + pos;
915
914
Item_decimal *item_dec= (Item_decimal*)item;
927
926
class cmp_item :public Sql_alloc
930
const CHARSET_INFO *cmp_charset;
929
CHARSET_INFO *cmp_charset;
931
930
cmp_item() { cmp_charset= &my_charset_bin; }
932
931
virtual ~cmp_item() {}
933
932
virtual void store_value(Item *item)= 0;
934
933
virtual int cmp(Item *item)= 0;
935
934
// for optimized IN with row
936
935
virtual int compare(cmp_item *item)= 0;
937
static cmp_item* get_comparator(Item_result type, const CHARSET_INFO * const cs);
936
static cmp_item* get_comparator(Item_result type, CHARSET_INFO *cs);
938
937
virtual cmp_item *make_same()= 0;
939
virtual void store_value_by_template(cmp_item *tmpl __attribute__((unused)),
938
virtual void store_value_by_template(cmp_item *tmpl __attribute__((__unused__)),
942
941
store_value(item);
949
948
String *value_res;
951
950
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; }
951
cmp_item_string (CHARSET_INFO *cs) { cmp_charset= cs; }
952
void set_charset(CHARSET_INFO *cs) { cmp_charset= cs; }
954
953
friend class cmp_item_sort_string;
955
954
friend class cmp_item_sort_string_in_static;
964
963
cmp_item_sort_string():
965
964
cmp_item_string() {}
966
cmp_item_sort_string(const CHARSET_INFO * const cs):
965
cmp_item_sort_string(CHARSET_INFO *cs):
967
966
cmp_item_string(cs),
968
967
value(value_buff, sizeof(value_buff), cs) {}
969
968
void store_value(Item *item)
984
983
return sortcmp(value_res, l_cmp->value_res, cmp_charset);
986
985
cmp_item *make_same();
987
void set_charset(const CHARSET_INFO * const cs)
986
void set_charset(CHARSET_INFO *cs)
990
989
value.set_quick(value_buff, sizeof(value_buff), cs);
1083
cmp_item_sort_string_in_static(const CHARSET_INFO * const cs):
1082
cmp_item_sort_string_in_static(CHARSET_INFO *cs):
1084
1083
cmp_item_string(cs) {}
1085
1084
void store_value(Item *item)
1087
1086
value_res= item->val_str(&value);
1089
int cmp(Item *item __attribute__((unused)))
1088
int cmp(Item *item __attribute__((__unused__)))
1091
1090
// Should never be called
1095
1094
int compare(cmp_item *ci)
1127
1126
int first_expr_num, else_expr_num;
1128
1127
enum Item_result cached_result_type, left_result_type;
1129
1128
String tmp_value;
1131
1130
Item_result cmp_type;
1132
1131
DTCollation cmp_collation;
1133
1132
enum_field_types cached_field_type;
1150
1149
list.push_back(else_expr_arg);
1152
1151
set_arguments(list);
1153
memset(&cmp_items, 0, sizeof(cmp_items));
1152
bzero(&cmp_items, sizeof(cmp_items));
1155
1154
double val_real();
1157
1156
String *val_str(String *);
1158
1157
my_decimal *val_decimal(my_decimal *);
1159
1158
bool fix_fields(THD *thd, Item **ref);
1160
1159
void fix_length_and_dec();
1161
uint32_t decimal_precision() const;
1160
uint decimal_precision() const;
1162
1161
table_map not_null_tables() const { return 0; }
1163
1162
enum Item_result result_type () const { return cached_result_type; }
1164
1163
enum_field_types field_type() const { return cached_field_type; }
1165
1164
const char *func_name() const { return "case"; }
1166
1165
virtual void print(String *str, enum_query_type query_type);
1167
1166
Item *find_item(String *str);
1168
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1167
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1169
1168
void cleanup();
1170
1169
void agg_str_lengths(Item *arg);
1171
1170
void agg_num_lengths(Item *arg);
1206
1205
Item_func_in(List<Item> &list)
1207
1206
:Item_func_opt_neg(list), array(0), have_null(0),
1208
arg_types_compatible(false)
1207
arg_types_compatible(FALSE)
1210
memset(&cmp_items, 0, sizeof(cmp_items));
1209
bzero(&cmp_items, sizeof(cmp_items));
1211
1210
allowed_arg_cols= 0; // Fetch this value from first argument
1214
1213
bool fix_fields(THD *, Item **);
1215
1214
void fix_length_and_dec();
1216
uint32_t decimal_precision() const { return 1; }
1215
uint decimal_precision() const { return 1; }
1219
DBUG_ENTER("Item_func_in::cleanup");
1220
1220
Item_int_func::cleanup();
1234
1234
const char *func_name() const { return " IN "; }
1235
1235
bool nulls_in_row();
1236
1236
bool is_bool_func() { return 1; }
1237
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1237
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1240
1240
class cmp_item_row :public cmp_item
1242
1242
cmp_item **comparators;
1245
1245
cmp_item_row(): comparators(0), n(0) {}
1246
1246
~cmp_item_row();
1259
1259
cmp_item_row tmp;
1261
in_row(uint32_t elements, Item *);
1261
in_row(uint elements, Item *);
1263
void set(uint32_t pos,Item *item);
1264
unsigned char *get_value(Item *item);
1263
void set(uint pos,Item *item);
1264
uchar *get_value(Item *item);
1265
1265
friend void Item_func_in::fix_length_and_dec();
1266
1266
Item_result result_type() { return ROW_RESULT; }
1298
1298
!with_subselect)
1300
1300
/* Remember if the value is always NULL or never NULL */
1301
cached_value= (int64_t) args[0]->is_null();
1301
cached_value= (longlong) args[0]->is_null();
1305
1305
table_map not_null_tables() const { return 0; }
1306
1306
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
1307
1307
Item *neg_transformer(THD *thd);
1308
const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1308
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1311
1311
/* Functions used by HAVING for rewriting IN subquery */
1324
1324
:Item_func_isnull(a), owner(ow)
1326
1326
enum Functype functype() const { return ISNOTNULLTEST_FUNC; }
1328
1328
const char *func_name() const { return "<is_not_null_test>"; }
1329
1329
void update_used_tables();
1352
1352
{ return abort_on_null ? not_null_tables_cache : 0; }
1353
1353
Item *neg_transformer(THD *thd);
1354
1354
virtual void print(String *str, enum_query_type query_type);
1355
const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1355
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1356
1356
void top_level_item() { abort_on_null=1; }
1384
1384
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),
1385
:Item_bool_func2(a,b), canDoTurboBM(FALSE), pattern(0), pattern_len(0),
1386
1386
bmGs(0), bmBc(0), escape_item(escape_arg),
1387
1387
escape_used_in_parsing(escape_used) {}
1389
1389
enum Functype functype() const { return LIKE_FUNC; }
1390
1390
optimize_type select_optimize() const;
1391
1391
cond_result eq_cmp_result() const { return COND_TRUE; }
1429
1429
void update_used_tables();
1430
1430
virtual void print(String *str, enum_query_type query_type);
1431
1431
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
1432
friend int setup_conds(THD *thd, TableList *tables, TableList *leaves,
1432
friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
1434
1434
void top_level_item() { abort_on_null=1; }
1435
1435
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);
1436
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
1437
Item *transform(Item_transformer transformer, uchar *arg);
1438
1438
void traverse_cond(Cond_traverser, void *arg, traverse_order order);
1439
1439
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);
1440
enum_field_types field_type() const { return MYSQL_TYPE_LONGLONG; }
1441
bool subst_argument_checker(uchar **arg __attribute__((__unused__)))
1443
Item *compile(Item_analyzer analyzer, uchar **arg_p,
1444
Item_transformer transformer, uchar *arg_t);
1536
1536
inline Item* get_const() { return const_item; }
1537
1537
void add(Item *c);
1538
1538
void add(Item_field *f);
1540
1540
bool contains(Field *field);
1541
1541
Item_field* get_first() { return fields.head(); }
1542
1542
void merge(Item_equal *item);
1543
1543
void update_const();
1544
1544
enum Functype functype() const { return MULT_EQUAL_FUNC; }
1546
1546
const char *func_name() const { return "multiple equal"; }
1547
1547
optimize_type select_optimize() const { return OPTIMIZE_EQUAL; }
1548
1548
void sort(Item_field_cmpfunc cmp, void *arg);
1550
1550
void fix_length_and_dec();
1551
1551
bool fix_fields(THD *thd, Item **ref);
1552
1552
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);
1553
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
1554
Item *transform(Item_transformer transformer, uchar *arg);
1555
1555
virtual void print(String *str, enum_query_type query_type);
1556
const CHARSET_INFO *compare_collation()
1556
CHARSET_INFO *compare_collation()
1557
1557
{ return fields.head()->collation.collation; }
1560
1560
class COND_EQUAL: public Sql_alloc
1563
uint32_t max_members; /* max number of members the current level
1563
uint max_members; /* max number of members the current level
1564
1564
list and all lower level lists */
1565
1565
COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
1566
1566
List<Item_equal> current_level; /* list of multiple equalities of
1600
1600
Item_cond_and(THD *thd, Item_cond_and *item) :Item_cond(thd, item) {}
1601
1601
Item_cond_and(List<Item> &list_arg): Item_cond(list_arg) {}
1602
1602
enum Functype functype() const { return COND_AND_FUNC; }
1604
1604
const char *func_name() const { return "and"; }
1605
1605
table_map not_null_tables() const
1606
1606
{ return abort_on_null ? not_null_tables_cache: and_tables_cache; }
1631
1631
Item_cond_or(THD *thd, Item_cond_or *item) :Item_cond(thd, item) {}
1632
1632
Item_cond_or(List<Item> &list_arg): Item_cond(list_arg) {}
1633
1633
enum Functype functype() const { return COND_OR_FUNC; }
1635
1635
const char *func_name() const { return "or"; }
1636
1636
table_map not_null_tables() const { return and_tables_cache; }
1637
1637
Item* copy_andor_structure(THD *thd)
1666
1666
enum Functype functype() const { return COND_XOR_FUNC; }
1667
1667
/* TODO: remove the next line when implementing XOR optimization */
1668
1668
enum Type type() const { return FUNC_ITEM; }
1670
1670
const char *func_name() const { return "xor"; }
1671
1671
void top_level_item() {}