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 */
46
42
bool is_nulls_eq; // TRUE <=> compare for the EQUAL_FUNC
47
43
enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
48
44
CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
49
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,
50
46
Item *warn_item, bool *is_null);
52
48
DTCollation cmp_collation;
95
91
int compare_datetime(); // compare args[0] & args[1] as DATETIMEs
97
93
static enum enum_date_cmp_type can_compare_as_dates(Item *a, Item *b,
98
uint64_t *const_val_arg);
94
ulonglong *const_val_arg);
100
96
void set_datetime_cmp_func(Item **a1, Item **b1);
101
97
static arg_cmp_func comparator_matrix [5][2];
112
108
Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {}
113
109
bool is_bool_func() { return 1; }
114
110
void fix_length_and_dec() { decimals=0; max_length=1; }
115
uint32_t decimal_precision() const { return 1; }
111
uint decimal_precision() const { return 1; }
127
123
virtual bool val_bool();
128
virtual int64_t val_int();
124
virtual longlong val_int();
129
125
virtual void fix_length_and_dec();
130
126
virtual void print(String *str, enum_query_type query_type);
231
227
FALSE - result is FALSE
232
228
TRUE - result is NULL
234
bool result_for_null_param;
230
my_bool result_for_null_param;
236
232
Item_in_optimizer(Item *a, Item_in_subselect *b):
237
Item_bool_func(a, reinterpret_cast<Item *>(b)), cache(0),
233
Item_bool_func(a, my_reinterpret_cast(Item *)(b)), cache(0),
238
234
save_cache(0), result_for_null_param(UNKNOWN)
239
{ with_subselect= true; }
235
{ with_subselect= TRUE; }
240
236
bool fix_fields(THD *, Item **);
241
237
bool fix_left(THD *thd, Item **ref);
245
241
const char *func_name() const { return "<in_optimizer>"; }
246
242
Item_cache **get_cache() { return &cache; }
247
243
void keep_top_level_cache();
248
Item *transform(Item_transformer transformer, unsigned char *arg);
244
Item *transform(Item_transformer transformer, uchar *arg);
251
247
class Comp_creator
336
332
Item_bool_func2(Item *a,Item *b)
337
: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) {}
338
334
void fix_length_and_dec();
339
335
void set_cmp_func()
352
348
bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); }
353
349
bool is_bool_func() { return 1; }
354
const CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
355
uint32_t decimal_precision() const { return 1; }
356
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; }
358
354
friend class Arg_comparator;
368
364
Item *neg_transformer(THD *thd);
369
365
virtual Item *negated_item();
370
bool subst_argument_checker(unsigned char **arg __attribute__((unused)))
366
bool subst_argument_checker(uchar **arg) { return TRUE; }
374
369
class Item_func_not :public Item_bool_func
377
372
Item_func_not(Item *a) :Item_bool_func(a) {}
379
374
enum Functype functype() const { return NOT_FUNC; }
380
375
const char *func_name() const { return "not"; }
381
376
Item *neg_transformer(THD *thd);
420
415
Item_func_trig_cond(Item *a, bool *f) : Item_bool_func(a) { trig_var= f; }
421
int64_t val_int() { return *trig_var ? args[0]->val_int() : 1; }
416
longlong val_int() { return *trig_var ? args[0]->val_int() : 1; }
422
417
enum Functype functype() const { return TRIG_COND_FUNC; };
423
418
const char *func_name() const { return "trigcond"; };
424
bool const_item() const { return false; }
419
bool const_item() const { return FALSE; }
425
420
bool *get_trig_var() { return trig_var; }
426
421
/* The following is needed for ICP: */
427
422
table_map used_tables() const { return args[0]->used_tables(); }
444
439
virtual void top_level_item() { abort_on_null= 1; }
445
440
bool top_level() { return abort_on_null; }
447
442
enum Functype functype() const { return NOT_ALL_FUNC; }
448
443
const char *func_name() const { return "<not>"; }
449
444
virtual void print(String *str, enum_query_type query_type);
471
466
Item_func_eq(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
473
468
enum Functype functype() const { return EQ_FUNC; }
474
469
enum Functype rev_functype() const { return EQ_FUNC; }
475
470
cond_result eq_cmp_result() const { return COND_TRUE; }
483
478
Item_func_equal(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
485
480
void fix_length_and_dec();
486
481
table_map not_null_tables() const { return 0; }
487
482
enum Functype functype() const { return EQUAL_FUNC; }
488
483
enum Functype rev_functype() const { return EQUAL_FUNC; }
489
484
cond_result eq_cmp_result() const { return COND_TRUE; }
490
485
const char *func_name() const { return "<=>"; }
491
Item *neg_transformer(THD *thd __attribute__((unused))) { return 0; }
486
Item *neg_transformer(THD *thd) { return 0; }
498
493
Item_func_ge(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
500
495
enum Functype functype() const { return GE_FUNC; }
501
496
enum Functype rev_functype() const { return LE_FUNC; }
502
497
cond_result eq_cmp_result() const { return COND_TRUE; }
511
506
Item_func_gt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
513
508
enum Functype functype() const { return GT_FUNC; }
514
509
enum Functype rev_functype() const { return LT_FUNC; }
515
510
cond_result eq_cmp_result() const { return COND_FALSE; }
524
519
Item_func_le(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {};
526
521
enum Functype functype() const { return LE_FUNC; }
527
522
enum Functype rev_functype() const { return GE_FUNC; }
528
523
cond_result eq_cmp_result() const { return COND_TRUE; }
537
532
Item_func_lt(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
539
534
enum Functype functype() const { return LT_FUNC; }
540
535
enum Functype rev_functype() const { return GT_FUNC; }
541
536
cond_result eq_cmp_result() const { return COND_FALSE; }
550
545
Item_func_ne(Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
552
547
enum Functype functype() const { return NE_FUNC; }
553
548
cond_result eq_cmp_result() const { return COND_FALSE; }
554
549
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
580
575
inline void negate() { negated= !negated; }
581
576
inline void top_level_item() { pred_level= 1; }
582
Item *neg_transformer(THD *thd __attribute__((unused)))
577
Item *neg_transformer(THD *thd)
584
579
negated= !negated;
587
582
bool eq(const Item *item, bool binary_cmp) const;
588
bool subst_argument_checker(unsigned char **arg __attribute__((unused)))
583
bool subst_argument_checker(uchar **arg) { return TRUE; }
601
595
/* Comparators used for DATE/DATETIME comparison. */
602
596
Arg_comparator ge_cmp, le_cmp;
603
597
Item_func_between(Item *a, Item *b, Item *c)
604
:Item_func_opt_neg(a, b, c), compare_as_dates(false) {}
598
:Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) {}
606
600
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
607
601
enum Functype functype() const { return BETWEEN; }
608
602
const char *func_name() const { return "between"; }
610
604
void fix_length_and_dec();
611
605
virtual void print(String *str, enum_query_type query_type);
612
606
bool is_bool_func() { return 1; }
613
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
614
uint32_t decimal_precision() const { return 1; }
607
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
608
uint decimal_precision() const { return 1; }
640
634
class Item_func_interval :public Item_int_func
643
bool use_decimal_comparison;
637
my_bool use_decimal_comparison;
644
638
interval_range *intervals;
646
640
Item_func_interval(Item_row *a)
649
643
allowed_arg_cols= 0; // Fetch this value from first argument
652
646
void fix_length_and_dec();
653
647
const char *func_name() const { return "interval"; }
654
uint32_t decimal_precision() const { return 2; }
648
uint decimal_precision() const { return 2; }
683
677
Item_func_ifnull(Item *a, Item *b) :Item_func_coalesce(a,b) {}
684
678
double real_op();
686
680
String *str_op(String *str);
687
681
my_decimal *decimal_op(my_decimal *);
688
682
enum_field_types field_type() const;
689
683
void fix_length_and_dec();
690
684
const char *func_name() const { return "ifnull"; }
691
Field *tmp_table_field(Table *table);
692
uint32_t decimal_precision() const;
685
Field *tmp_table_field(TABLE *table);
686
uint decimal_precision() const;
702
696
:Item_func(a,b,c), cached_result_type(INT_RESULT)
704
698
double val_real();
706
700
String *val_str(String *str);
707
701
my_decimal *val_decimal(my_decimal *);
708
702
enum Item_result result_type () const { return cached_result_type; }
709
703
enum_field_types field_type() const { return cached_field_type; }
710
704
bool fix_fields(THD *, Item **);
711
705
void fix_length_and_dec();
712
uint32_t decimal_precision() const;
706
uint decimal_precision() const;
713
707
const char *func_name() const { return "if"; }
722
716
:Item_bool_func2(a,b), cached_result_type(INT_RESULT)
724
718
double val_real();
726
720
String *val_str(String *str);
727
721
my_decimal *val_decimal(my_decimal *);
728
722
enum Item_result result_type () const { return cached_result_type; }
729
723
void fix_length_and_dec();
730
uint32_t decimal_precision() const { return args[0]->decimal_precision(); }
724
uint decimal_precision() const { return args[0]->decimal_precision(); }
731
725
const char *func_name() const { return "nullif"; }
733
727
virtual inline void print(String *str, enum_query_type query_type)
753
747
qsort2_cmp compare;
754
const CHARSET_INFO *collation;
748
CHARSET_INFO *collation;
758
in_vector(uint32_t elements,uint32_t element_length,qsort2_cmp cmp_func,
759
const CHARSET_INFO * const cmp_coll)
752
in_vector(uint elements,uint element_length,qsort2_cmp cmp_func,
753
CHARSET_INFO *cmp_coll)
760
754
:base((char*) sql_calloc(elements*element_length)),
761
755
size(element_length), compare(cmp_func), collation(cmp_coll),
762
756
count(elements), used_count(elements) {}
763
757
virtual ~in_vector() {}
764
virtual void set(uint32_t pos,Item *item)=0;
765
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;
768
my_qsort2(base,used_count,size,compare, (void *) collation);
762
my_qsort2(base,used_count,size,compare,collation);
770
764
int find(Item *item);
787
781
item Constant item to store value into. The item must be of the same
788
782
type that create_item() returns.
790
virtual void value_to_item(uint32_t pos __attribute__((unused)),
791
Item *item __attribute__((unused))) { }
784
virtual void value_to_item(uint pos, Item *item) { }
793
786
/* Compare values number pos1 and pos2 for equality */
794
bool compare_elems(uint32_t pos1, uint32_t pos2)
787
bool compare_elems(uint pos1, uint pos2)
796
789
return test(compare(collation, base + pos1*size, base + pos2*size));
803
796
char buff[STRING_BUFFER_USUAL_SIZE];
806
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);
808
void set(uint32_t pos,Item *item);
809
unsigned char *get_value(Item *item);
801
void set(uint pos,Item *item);
802
uchar *get_value(Item *item);
810
803
Item* create_item()
812
805
return new Item_string(collation);
814
void value_to_item(uint32_t pos, Item *item)
807
void value_to_item(uint pos, Item *item)
816
809
String *str=((String*) base)+pos;
817
810
Item_string *to= (Item_string*)item;
828
821
elements of this vector. tmp is used in finding if a given value is in
831
struct packed_int64_t
824
struct packed_longlong
834
int64_t unsigned_flag; // Use int64_t, not bool, to preserve alignment
827
longlong unsigned_flag; // Use longlong, not bool, to preserve alignment
837
in_int64_t(uint32_t elements);
838
void set(uint32_t pos,Item *item);
839
unsigned char *get_value(Item *item);
830
in_longlong(uint elements);
831
void set(uint pos,Item *item);
832
uchar *get_value(Item *item);
841
834
Item* create_item()
844
837
We're created a signed INT, this may not be correct in
845
838
general case (see BUG#19342).
847
return new Item_int((int64_t)0);
840
return new Item_int((longlong)0);
849
void value_to_item(uint32_t pos, Item *item)
842
void value_to_item(uint pos, Item *item)
851
((Item_int*) item)->value= ((packed_int64_t*) base)[pos].val;
852
((Item_int*) item)->unsigned_flag= (bool)
853
((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;
855
848
Item_result result_type() { return INT_RESULT; }
857
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);
873
866
/* Cache for the left item. */
874
867
Item *lval_cache;
876
in_datetime(Item *warn_item_arg, uint32_t elements)
877
: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),
878
871
lval_cache(0) {};
879
void set(uint32_t pos,Item *item);
880
unsigned char *get_value(Item *item);
881
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);
889
in_double(uint32_t elements);
890
void set(uint32_t pos,Item *item);
891
unsigned char *get_value(Item *item);
882
in_double(uint elements);
883
void set(uint pos,Item *item);
884
uchar *get_value(Item *item);
892
885
Item *create_item()
894
887
return new Item_float(0.0, 0);
896
void value_to_item(uint32_t pos, Item *item)
889
void value_to_item(uint pos, Item *item)
898
891
((Item_float*)item)->value= ((double*) base)[pos];
908
in_decimal(uint32_t elements);
909
void set(uint32_t pos, Item *item);
910
unsigned char *get_value(Item *item);
901
in_decimal(uint elements);
902
void set(uint pos, Item *item);
903
uchar *get_value(Item *item);
911
904
Item *create_item()
913
return new Item_decimal(0, false);
906
return new Item_decimal(0, FALSE);
915
void value_to_item(uint32_t pos, Item *item)
908
void value_to_item(uint pos, Item *item)
917
910
my_decimal *dec= ((my_decimal *)base) + pos;
918
911
Item_decimal *item_dec= (Item_decimal*)item;
930
923
class cmp_item :public Sql_alloc
933
const CHARSET_INFO *cmp_charset;
926
CHARSET_INFO *cmp_charset;
934
927
cmp_item() { cmp_charset= &my_charset_bin; }
935
928
virtual ~cmp_item() {}
936
929
virtual void store_value(Item *item)= 0;
937
930
virtual int cmp(Item *item)= 0;
938
931
// for optimized IN with row
939
932
virtual int compare(cmp_item *item)= 0;
940
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);
941
934
virtual cmp_item *make_same()= 0;
942
virtual void store_value_by_template(cmp_item *tmpl __attribute__((unused)),
935
virtual void store_value_by_template(cmp_item *tmpl, Item *item)
945
937
store_value(item);
952
944
String *value_res;
954
946
cmp_item_string () {}
955
cmp_item_string (const CHARSET_INFO * const cs) { cmp_charset= cs; }
956
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; }
957
949
friend class cmp_item_sort_string;
958
950
friend class cmp_item_sort_string_in_static;
967
959
cmp_item_sort_string():
968
960
cmp_item_string() {}
969
cmp_item_sort_string(const CHARSET_INFO * const cs):
961
cmp_item_sort_string(CHARSET_INFO *cs):
970
962
cmp_item_string(cs),
971
963
value(value_buff, sizeof(value_buff), cs) {}
972
964
void store_value(Item *item)
987
979
return sortcmp(value_res, l_cmp->value_res, cmp_charset);
989
981
cmp_item *make_same();
990
void set_charset(const CHARSET_INFO * const cs)
982
void set_charset(CHARSET_INFO *cs)
993
985
value.set_quick(value_buff, sizeof(value_buff), cs);
1086
cmp_item_sort_string_in_static(const CHARSET_INFO * const cs):
1078
cmp_item_sort_string_in_static(CHARSET_INFO *cs):
1087
1079
cmp_item_string(cs) {}
1088
1080
void store_value(Item *item)
1090
1082
value_res= item->val_str(&value);
1092
int cmp(Item *item __attribute__((unused)))
1094
1086
// Should never be called
1098
1090
int compare(cmp_item *ci)
1130
1122
int first_expr_num, else_expr_num;
1131
1123
enum Item_result cached_result_type, left_result_type;
1132
1124
String tmp_value;
1134
1126
Item_result cmp_type;
1135
1127
DTCollation cmp_collation;
1136
1128
enum_field_types cached_field_type;
1153
1145
list.push_back(else_expr_arg);
1155
1147
set_arguments(list);
1156
memset(&cmp_items, 0, sizeof(cmp_items));
1148
bzero(&cmp_items, sizeof(cmp_items));
1158
1150
double val_real();
1160
1152
String *val_str(String *);
1161
1153
my_decimal *val_decimal(my_decimal *);
1162
1154
bool fix_fields(THD *thd, Item **ref);
1163
1155
void fix_length_and_dec();
1164
uint32_t decimal_precision() const;
1156
uint decimal_precision() const;
1165
1157
table_map not_null_tables() const { return 0; }
1166
1158
enum Item_result result_type () const { return cached_result_type; }
1167
1159
enum_field_types field_type() const { return cached_field_type; }
1168
1160
const char *func_name() const { return "case"; }
1169
1161
virtual void print(String *str, enum_query_type query_type);
1170
1162
Item *find_item(String *str);
1171
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1163
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1172
1164
void cleanup();
1173
1165
void agg_str_lengths(Item *arg);
1174
1166
void agg_num_lengths(Item *arg);
1209
1201
Item_func_in(List<Item> &list)
1210
1202
:Item_func_opt_neg(list), array(0), have_null(0),
1211
arg_types_compatible(false)
1203
arg_types_compatible(FALSE)
1213
memset(&cmp_items, 0, sizeof(cmp_items));
1205
bzero(&cmp_items, sizeof(cmp_items));
1214
1206
allowed_arg_cols= 0; // Fetch this value from first argument
1217
1209
bool fix_fields(THD *, Item **);
1218
1210
void fix_length_and_dec();
1219
uint32_t decimal_precision() const { return 1; }
1211
uint decimal_precision() const { return 1; }
1215
DBUG_ENTER("Item_func_in::cleanup");
1223
1216
Item_int_func::cleanup();
1237
1230
const char *func_name() const { return " IN "; }
1238
1231
bool nulls_in_row();
1239
1232
bool is_bool_func() { return 1; }
1240
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1233
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1243
1236
class cmp_item_row :public cmp_item
1245
1238
cmp_item **comparators;
1248
1241
cmp_item_row(): comparators(0), n(0) {}
1249
1242
~cmp_item_row();
1262
1255
cmp_item_row tmp;
1264
in_row(uint32_t elements, Item *);
1257
in_row(uint elements, Item *);
1266
void set(uint32_t pos,Item *item);
1267
unsigned char *get_value(Item *item);
1259
void set(uint pos,Item *item);
1260
uchar *get_value(Item *item);
1268
1261
friend void Item_func_in::fix_length_and_dec();
1269
1262
Item_result result_type() { return ROW_RESULT; }
1301
1294
!with_subselect)
1303
1296
/* Remember if the value is always NULL or never NULL */
1304
cached_value= (int64_t) args[0]->is_null();
1297
cached_value= (longlong) args[0]->is_null();
1308
1301
table_map not_null_tables() const { return 0; }
1309
1302
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
1310
1303
Item *neg_transformer(THD *thd);
1311
const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1304
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1314
1307
/* Functions used by HAVING for rewriting IN subquery */
1327
1320
:Item_func_isnull(a), owner(ow)
1329
1322
enum Functype functype() const { return ISNOTNULLTEST_FUNC; }
1331
1324
const char *func_name() const { return "<is_not_null_test>"; }
1332
1325
void update_used_tables();
1355
1348
{ return abort_on_null ? not_null_tables_cache : 0; }
1356
1349
Item *neg_transformer(THD *thd);
1357
1350
virtual void print(String *str, enum_query_type query_type);
1358
const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1351
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1359
1352
void top_level_item() { abort_on_null=1; }
1387
1380
Item_func_like(Item *a,Item *b, Item *escape_arg, bool escape_used)
1388
: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),
1389
1382
bmGs(0), bmBc(0), escape_item(escape_arg),
1390
1383
escape_used_in_parsing(escape_used) {}
1392
1385
enum Functype functype() const { return LIKE_FUNC; }
1393
1386
optimize_type select_optimize() const;
1394
1387
cond_result eq_cmp_result() const { return COND_TRUE; }
1432
1425
void update_used_tables();
1433
1426
virtual void print(String *str, enum_query_type query_type);
1434
1427
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
1435
friend int setup_conds(THD *thd, TableList *tables, TableList *leaves,
1428
friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
1437
1430
void top_level_item() { abort_on_null=1; }
1438
1431
void copy_andor_arguments(THD *thd, Item_cond *item);
1439
bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
1440
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);
1441
1434
void traverse_cond(Cond_traverser, void *arg, traverse_order order);
1442
1435
void neg_arguments(THD *thd);
1443
enum_field_types field_type() const { return DRIZZLE_TYPE_LONGLONG; }
1444
bool subst_argument_checker(unsigned char **arg __attribute__((unused)))
1446
Item *compile(Item_analyzer analyzer, unsigned char **arg_p,
1447
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);
1539
1531
inline Item* get_const() { return const_item; }
1540
1532
void add(Item *c);
1541
1533
void add(Item_field *f);
1543
1535
bool contains(Field *field);
1544
1536
Item_field* get_first() { return fields.head(); }
1545
1537
void merge(Item_equal *item);
1546
1538
void update_const();
1547
1539
enum Functype functype() const { return MULT_EQUAL_FUNC; }
1549
1541
const char *func_name() const { return "multiple equal"; }
1550
1542
optimize_type select_optimize() const { return OPTIMIZE_EQUAL; }
1551
1543
void sort(Item_field_cmpfunc cmp, void *arg);
1553
1545
void fix_length_and_dec();
1554
1546
bool fix_fields(THD *thd, Item **ref);
1555
1547
void update_used_tables();
1556
bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
1557
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);
1558
1550
virtual void print(String *str, enum_query_type query_type);
1559
const CHARSET_INFO *compare_collation()
1551
CHARSET_INFO *compare_collation()
1560
1552
{ return fields.head()->collation.collation; }
1563
1555
class COND_EQUAL: public Sql_alloc
1566
uint32_t max_members; /* max number of members the current level
1558
uint max_members; /* max number of members the current level
1567
1559
list and all lower level lists */
1568
1560
COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
1569
1561
List<Item_equal> current_level; /* list of multiple equalities of
1603
1595
Item_cond_and(THD *thd, Item_cond_and *item) :Item_cond(thd, item) {}
1604
1596
Item_cond_and(List<Item> &list_arg): Item_cond(list_arg) {}
1605
1597
enum Functype functype() const { return COND_AND_FUNC; }
1607
1599
const char *func_name() const { return "and"; }
1608
1600
table_map not_null_tables() const
1609
1601
{ return abort_on_null ? not_null_tables_cache: and_tables_cache; }
1634
1626
Item_cond_or(THD *thd, Item_cond_or *item) :Item_cond(thd, item) {}
1635
1627
Item_cond_or(List<Item> &list_arg): Item_cond(list_arg) {}
1636
1628
enum Functype functype() const { return COND_OR_FUNC; }
1638
1630
const char *func_name() const { return "or"; }
1639
1631
table_map not_null_tables() const { return and_tables_cache; }
1640
1632
Item* copy_andor_structure(THD *thd)
1669
1661
enum Functype functype() const { return COND_XOR_FUNC; }
1670
1662
/* TODO: remove the next line when implementing XOR optimization */
1671
1663
enum Type type() const { return FUNC_ITEM; }
1673
1665
const char *func_name() const { return "xor"; }
1674
1666
void top_level_item() {}