1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
4
* Copyright (C) 2008 Sun Microsystems
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_ITEM_CMPFUNC_H
21
#define DRIZZLED_ITEM_CMPFUNC_H
22
23
/* compare and test functions */
24
#include <drizzled/common.h>
25
#include <drizzled/comp_creator.h>
26
#include <drizzled/function/math/int.h>
27
#include <drizzled/function/numhybrid.h>
28
#include <drizzled/item/decimal.h>
29
#include <drizzled/item/float.h>
30
#include <drizzled/item/function/boolean.h>
31
#include <drizzled/item/int.h>
32
#include <drizzled/item/row.h>
33
#include <drizzled/item/string.h>
34
#include <drizzled/item/sum.h>
35
#include <drizzled/qsort_cmp.h>
25
#include "drizzled/comp_creator.h"
26
#include "drizzled/item/row.h"
27
#include "drizzled/item/sum.h"
28
#include "drizzled/item/int.h"
29
#include "drizzled/item/float.h"
30
#include "drizzled/item/decimal.h"
31
#include "drizzled/function/math/int.h"
32
#include "drizzled/function/numhybrid.h"
33
#include "drizzled/session.h"
34
#include "drizzled/common.h"
35
#include "drizzled/qsort_cmp.h"
39
40
extern Item_result item_cmp_type(Item_result a,Item_result b);
41
class Item_bool_func2;
43
class Item_sum_hybrid;
41
46
typedef int (Arg_comparator::*arg_cmp_func)();
43
48
typedef int (*Item_field_cmpfunc)(Item_field *f1, Item_field *f2, void *arg);
45
int64_t get_datetime_value(Session *session,
50
uint64_t get_datetime_value(Session *session,
51
56
class Arg_comparator: public memory::SqlAlloc
62
67
bool is_nulls_eq; // TRUE <=> compare for the EQUAL_FUNC
63
68
enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
64
69
CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
65
int64_t (*get_value_func)(Session *session, Item ***item_arg, Item **cache_arg,
66
Item *warn_item, bool *is_null);
70
uint64_t (*get_value_func)(Session *session, Item ***item_arg, Item **cache_arg,
71
Item *warn_item, bool *is_null);
68
73
DTCollation cmp_collation;
72
Arg_comparator(Item **a1, Item **a2);
75
Arg_comparator(): session(0), a_cache(0), b_cache(0) {};
76
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), session(0),
77
a_cache(0), b_cache(0) {};
74
79
int set_compare_func(Item_bool_func2 *owner, Item_result type);
75
80
inline int set_compare_func(Item_bool_func2 *owner_arg)
111
116
int compare_datetime(); // compare args[0] & args[1] as DATETIMEs
113
118
static enum enum_date_cmp_type can_compare_as_dates(Item *a, Item *b,
114
int64_t *const_val_arg);
119
uint64_t *const_val_arg);
116
121
void set_datetime_cmp_func(Item **a1, Item **b1);
117
122
static arg_cmp_func comparator_matrix [5][2];
119
124
friend class Item_func;
127
class Item_bool_func :public Item_int_func
130
Item_bool_func() :Item_int_func() {}
131
Item_bool_func(Item *a) :Item_int_func(a) {}
132
Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {}
133
Item_bool_func(Session *session, Item_bool_func *item) :Item_int_func(session, item) {}
134
bool is_bool_func() { return 1; }
135
void fix_length_and_dec() { decimals=0; max_length=1; }
136
uint32_t decimal_precision() const { return 1; }
124
141
Abstract Item class, to represent <code>X IS [NOT] (TRUE | FALSE)</code>
125
142
boolean predicates.
128
class Item_func_truth : public item::function::Boolean
145
class Item_func_truth : public Item_bool_func
131
148
virtual bool val_bool();
132
149
virtual int64_t val_int();
133
150
virtual void fix_length_and_dec();
134
virtual void print(String *str);
151
virtual void print(String *str, enum_query_type query_type);
137
154
Item_func_truth(Item *a, bool a_value, bool a_affirmative)
138
: item::function::Boolean(a), value(a_value), affirmative(a_affirmative)
155
: Item_bool_func(a), value(a_value), affirmative(a_affirmative)
143
162
True for <code>X IS [NOT] TRUE</code>,
197
219
Item_func_isnotfalse(Item *a) : Item_func_truth(a, false, false) {}
220
~Item_func_isnotfalse() {}
198
221
virtual const char* func_name() const { return "isnotfalse"; }
202
226
#define UNKNOWN ((bool)-1)
231
255
bool result_for_null_param;
233
257
Item_in_optimizer(Item *a, Item_in_subselect *b):
234
item::function::Boolean(a, reinterpret_cast<Item *>(b)), cache(0),
258
Item_bool_func(a, reinterpret_cast<Item *>(b)), cache(0),
235
259
save_cache(0), result_for_null_param(UNKNOWN)
236
260
{ with_subselect= true; }
237
261
bool fix_fields(Session *, Item **);
248
272
class Eq_creator :public Comp_creator
275
Eq_creator() {} /* Remove gcc warning */
276
virtual ~Eq_creator() {} /* Remove gcc warning */
251
277
virtual Item_bool_func2* create(Item *a, Item *b) const;
252
278
virtual const char* symbol(bool invert) const { return invert? "<>" : "="; }
253
279
virtual bool eqne_op() const { return 1; }
258
284
class Ne_creator :public Comp_creator
287
Ne_creator() {} /* Remove gcc warning */
288
virtual ~Ne_creator() {} /* Remove gcc warning */
261
289
virtual Item_bool_func2* create(Item *a, Item *b) const;
262
290
virtual const char* symbol(bool invert) const { return invert? "=" : "<>"; }
263
291
virtual bool eqne_op() const { return 1; }
268
296
class Gt_creator :public Comp_creator
299
Gt_creator() {} /* Remove gcc warning */
300
virtual ~Gt_creator() {} /* Remove gcc warning */
271
301
virtual Item_bool_func2* create(Item *a, Item *b) const;
272
302
virtual const char* symbol(bool invert) const { return invert? "<=" : ">"; }
273
303
virtual bool eqne_op() const { return 0; }
278
308
class Lt_creator :public Comp_creator
311
Lt_creator() {} /* Remove gcc warning */
312
virtual ~Lt_creator() {} /* Remove gcc warning */
281
313
virtual Item_bool_func2* create(Item *a, Item *b) const;
282
314
virtual const char* symbol(bool invert) const { return invert? ">=" : "<"; }
283
315
virtual bool eqne_op() const { return 0; }
288
320
class Ge_creator :public Comp_creator
323
Ge_creator() {} /* Remove gcc warning */
324
virtual ~Ge_creator() {} /* Remove gcc warning */
291
325
virtual Item_bool_func2* create(Item *a, Item *b) const;
292
326
virtual const char* symbol(bool invert) const { return invert? "<" : ">="; }
293
327
virtual bool eqne_op() const { return 0; }
298
332
class Le_creator :public Comp_creator
335
Le_creator() {} /* Remove gcc warning */
336
virtual ~Le_creator() {} /* Remove gcc warning */
301
337
virtual Item_bool_func2* create(Item *a, Item *b) const;
302
338
virtual const char* symbol(bool invert) const { return invert? ">" : "<="; }
303
339
virtual bool eqne_op() const { return 0; }
324
360
virtual enum Functype rev_functype() const { return UNKNOWN_FUNC; }
325
361
bool have_rev_func() const { return rev_functype() != UNKNOWN_FUNC; }
327
virtual inline void print(String *str)
363
virtual inline void print(String *str, enum_query_type query_type)
329
Item_func::print_op(str);
365
Item_func::print_op(str, query_type);
332
368
bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); }
333
369
bool is_bool_func() { return 1; }
334
const charset_info_st *compare_collation() { return cmp.cmp_collation.collation; }
370
const CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
335
371
uint32_t decimal_precision() const { return 1; }
336
372
void top_level_item() { abort_on_null= true; }
354
class Item_func_not :public item::function::Boolean
390
class Item_func_not :public Item_bool_func
357
Item_func_not(Item *a) :item::function::Boolean(a) {}
393
Item_func_not(Item *a) :Item_bool_func(a) {}
358
394
int64_t val_int();
359
395
enum Functype functype() const { return NOT_FUNC; }
360
396
const char *func_name() const { return "not"; }
361
397
Item *neg_transformer(Session *session);
362
virtual void print(String *str);
398
virtual void print(String *str, enum_query_type query_type);
401
class Item_maxmin_subselect;
366
404
trigcond<param>(arg) ::= param? arg : TRUE
391
429
- To wrap condition that is pushed down into subquery
394
class Item_func_trig_cond: public item::function::Boolean
432
class Item_func_trig_cond: public Item_bool_func
398
Item_func_trig_cond(Item *a, bool *f) : item::function::Boolean(a) { trig_var= f; }
436
Item_func_trig_cond(Item *a, bool *f) : Item_bool_func(a) { trig_var= f; }
399
437
int64_t val_int() { return *trig_var ? args[0]->val_int() : 1; }
400
438
enum Functype functype() const { return TRIG_COND_FUNC; };
401
439
const char *func_name() const { return "trigcond"; };
424
462
int64_t val_int();
425
463
enum Functype functype() const { return NOT_ALL_FUNC; }
426
464
const char *func_name() const { return "<not>"; }
427
virtual void print(String *str);
465
virtual void print(String *str, enum_query_type query_type);
428
466
void set_sum_test(Item_sum_hybrid *item) { test_sum_item= item; };
429
467
void set_sub_test(Item_maxmin_subselect *item) { test_sub_item= item; };
430
468
bool empty_underlying_subquery();
586
624
const char *func_name() const { return "between"; }
587
625
bool fix_fields(Session *, Item **);
588
626
void fix_length_and_dec();
589
virtual void print(String *str);
627
virtual void print(String *str, enum_query_type query_type);
590
628
bool is_bool_func() { return 1; }
591
const charset_info_st *compare_collation() { return cmp_collation.collation; }
629
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
592
630
uint32_t decimal_precision() const { return 1; }
601
639
optimize_type select_optimize() const { return OPTIMIZE_NONE; }
602
640
const char *func_name() const { return "strcmp"; }
604
virtual inline void print(String *str)
642
virtual inline void print(String *str, enum_query_type query_type)
606
Item_func::print(str);
644
Item_func::print(str, query_type);
643
681
double real_op();
644
682
int64_t int_op();
645
683
String *str_op(String *);
646
type::Decimal *decimal_op(type::Decimal *);
684
my_decimal *decimal_op(my_decimal *);
647
685
void fix_length_and_dec();
648
686
void find_num_type() {}
649
687
enum Item_result result_type () const { return hybrid_type; }
662
700
double real_op();
663
701
int64_t int_op();
664
702
String *str_op(String *str);
665
type::Decimal *decimal_op(type::Decimal *);
703
my_decimal *decimal_op(my_decimal *);
666
704
enum_field_types field_type() const;
667
705
void fix_length_and_dec();
668
706
const char *func_name() const { return "ifnull"; }
678
716
class Item_func_if :public Item_func
680
Item_result cached_result_type;
718
enum Item_result cached_result_type;
681
719
enum_field_types cached_field_type;
684
Item_func_if(Item *a, Item *b, Item *c) :
686
cached_result_type(INT_RESULT)
721
Item_func_if(Item *a,Item *b,Item *c)
722
:Item_func(a,b,c), cached_result_type(INT_RESULT)
689
724
double val_real();
690
725
int64_t val_int();
691
726
String *val_str(String *str);
692
type::Decimal *val_decimal(type::Decimal *);
693
Item_result result_type () const { return cached_result_type; }
727
my_decimal *val_decimal(my_decimal *);
728
enum Item_result result_type () const { return cached_result_type; }
694
729
enum_field_types field_type() const { return cached_field_type; }
695
730
bool fix_fields(Session *, Item **);
696
731
void fix_length_and_dec();
709
744
double val_real();
710
745
int64_t val_int();
711
746
String *val_str(String *str);
712
type::Decimal *val_decimal(type::Decimal *);
747
my_decimal *val_decimal(my_decimal *);
713
748
enum Item_result result_type () const { return cached_result_type; }
714
749
void fix_length_and_dec();
715
750
uint32_t decimal_precision() const { return args[0]->decimal_precision(); }
716
751
const char *func_name() const { return "nullif"; }
718
virtual inline void print(String *str)
753
virtual inline void print(String *str, enum_query_type query_type)
720
Item_func::print(str);
755
Item_func::print(str, query_type);
723
758
table_map not_null_tables() const { return 0; }
738
773
qsort2_cmp compare;
739
const charset_info_st *collation;
774
const CHARSET_INFO *collation;
741
776
uint32_t used_count;
743
778
in_vector(uint32_t elements,uint32_t element_length,qsort2_cmp cmp_func,
744
const charset_info_st * const cmp_coll)
779
const CHARSET_INFO * const cmp_coll)
745
780
:base((char*) memory::sql_calloc(elements*element_length)),
746
781
size(element_length), compare(cmp_func), collation(cmp_coll),
747
782
count(elements), used_count(elements) {}
784
819
char buff[STRING_BUFFER_USUAL_SIZE];
787
in_string(uint32_t elements,qsort2_cmp cmp_func, const charset_info_st * const cs);
822
in_string(uint32_t elements,qsort2_cmp cmp_func, const CHARSET_INFO * const cs);
789
824
void set(uint32_t pos,Item *item);
790
825
unsigned char *get_value(Item *item);
854
889
/* Cache for the left item. */
855
890
Item *lval_cache;
857
in_datetime(Item *warn_item_arg, uint32_t elements);
892
in_datetime(Item *warn_item_arg, uint32_t elements)
893
:in_int64_t(elements), session(current_session), warn_item(warn_item_arg),
859
895
void set(uint32_t pos,Item *item);
860
896
unsigned char *get_value(Item *item);
861
897
friend int cmp_int64_t(void *cmp_arg, packed_int64_t *a,packed_int64_t *b);
895
931
void value_to_item(uint32_t pos, Item *item)
897
type::Decimal *dec= ((type::Decimal *)base) + pos;
933
my_decimal *dec= ((my_decimal *)base) + pos;
898
934
Item_decimal *item_dec= (Item_decimal*)item;
899
935
item_dec->set_decimal_value(dec);
910
946
class cmp_item :public memory::SqlAlloc
913
const charset_info_st *cmp_charset;
917
cmp_charset= &my_charset_bin;
949
const CHARSET_INFO *cmp_charset;
950
cmp_item() { cmp_charset= &my_charset_bin; }
920
951
virtual ~cmp_item() {}
921
952
virtual void store_value(Item *item)= 0;
922
953
virtual int cmp(Item *item)= 0;
923
954
// for optimized IN with row
924
955
virtual int compare(cmp_item *item)= 0;
925
static cmp_item* get_comparator(Item_result type, const charset_info_st * const cs);
956
static cmp_item* get_comparator(Item_result type, const CHARSET_INFO * const cs);
926
957
virtual cmp_item *make_same()= 0;
927
958
virtual void store_value_by_template(cmp_item *, Item *item)
936
967
String *value_res;
938
969
cmp_item_string () {}
939
cmp_item_string (const charset_info_st * const cs) { cmp_charset= cs; }
940
void set_charset(const charset_info_st * const cs) { cmp_charset= cs; }
970
cmp_item_string (const CHARSET_INFO * const cs) { cmp_charset= cs; }
971
void set_charset(const CHARSET_INFO * const cs) { cmp_charset= cs; }
941
972
friend class cmp_item_sort_string;
942
973
friend class cmp_item_sort_string_in_static;
951
982
cmp_item_sort_string():
952
983
cmp_item_string() {}
953
cmp_item_sort_string(const charset_info_st * const cs):
984
cmp_item_sort_string(const CHARSET_INFO * const cs):
954
985
cmp_item_string(cs),
955
986
value(value_buff, sizeof(value_buff), cs) {}
956
987
void store_value(Item *item)
971
1002
return sortcmp(value_res, l_cmp->value_res, cmp_charset);
973
1004
cmp_item *make_same();
974
void set_charset(const charset_info_st * const cs)
1005
void set_charset(const CHARSET_INFO * const cs)
976
1007
cmp_charset= cs;
977
1008
value.set_quick(value_buff, sizeof(value_buff), cs);
1015
1046
/* Cache for the left item. */
1016
1047
Item *lval_cache;
1018
cmp_item_datetime(Item *warn_item_arg);
1049
cmp_item_datetime(Item *warn_item_arg)
1050
:session(current_session), warn_item(warn_item_arg), lval_cache(0) {}
1020
1051
void store_value(Item *item);
1021
1052
int cmp(Item *arg);
1022
1053
int compare(cmp_item *ci);
1116
1149
Item_result cmp_type;
1117
1150
DTCollation cmp_collation;
1118
1151
enum_field_types cached_field_type;
1119
cmp_item *cmp_items[DECIMAL_RESULT+1]; /* For all result types */
1152
cmp_item *cmp_items[5]; /* For all result types */
1120
1153
cmp_item *case_item;
1122
1155
Item_func_case(List<Item> &list, Item *first_expr_arg, Item *else_expr_arg)
1123
1156
:Item_func(), first_expr_num(-1), else_expr_num(-1),
1124
1157
cached_result_type(INT_RESULT), left_result_type(INT_RESULT), case_item(0)
1126
ncases= list.size();
1159
ncases= list.elements;
1127
1160
if (first_expr_arg)
1129
first_expr_num= list.size();
1162
first_expr_num= list.elements;
1130
1163
list.push_back(first_expr_arg);
1132
1165
if (else_expr_arg)
1134
else_expr_num= list.size();
1167
else_expr_num= list.elements;
1135
1168
list.push_back(else_expr_arg);
1137
1170
set_arguments(list);
1140
1173
double val_real();
1141
1174
int64_t val_int();
1142
1175
String *val_str(String *);
1143
type::Decimal *val_decimal(type::Decimal *);
1176
my_decimal *val_decimal(my_decimal *);
1144
1177
bool fix_fields(Session *session, Item **ref);
1145
1178
void fix_length_and_dec();
1146
1179
uint32_t decimal_precision() const;
1148
1181
enum Item_result result_type () const { return cached_result_type; }
1149
1182
enum_field_types field_type() const { return cached_field_type; }
1150
1183
const char *func_name() const { return "case"; }
1151
virtual void print(String *str);
1184
virtual void print(String *str, enum_query_type query_type);
1152
1185
Item *find_item(String *str);
1153
const charset_info_st *compare_collation() { return cmp_collation.collation; }
1186
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1154
1187
void cleanup();
1155
1188
void agg_str_lengths(Item *arg);
1156
1189
void agg_num_lengths(Item *arg);
1214
1248
optimize_type select_optimize() const
1215
1249
{ return OPTIMIZE_KEY; }
1216
virtual void print(String *str);
1250
virtual void print(String *str, enum_query_type query_type);
1217
1251
enum Functype functype() const { return IN_FUNC; }
1218
1252
const char *func_name() const { return " IN "; }
1219
1253
bool nulls_in_row();
1220
1254
bool is_bool_func() { return 1; }
1221
const charset_info_st *compare_collation() { return cmp_collation.collation; }
1255
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
1224
1258
class cmp_item_row :public cmp_item
1253
1287
/* Functions used by where clause */
1255
class Item_func_isnull :public item::function::Boolean
1289
class Item_func_isnull :public Item_bool_func
1258
1292
int64_t cached_value;
1260
Item_func_isnull(Item *a) :item::function::Boolean(a) {}
1294
Item_func_isnull(Item *a) :Item_bool_func(a) {}
1261
1295
int64_t val_int();
1262
1296
enum Functype functype() const { return ISNULL_FUNC; }
1263
1297
void fix_length_and_dec()
1289
1323
table_map not_null_tables() const { return 0; }
1290
1324
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
1291
1325
Item *neg_transformer(Session *session);
1292
const charset_info_st *compare_collation() { return args[0]->collation.collation; }
1326
const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1295
1329
/* Functions used by HAVING for rewriting IN subquery */
1331
class Item_in_subselect;
1298
1334
This is like IS NOT NULL but it also remembers if it ever has
1299
1335
encountered a NULL.
1320
class Item_func_isnotnull :public item::function::Boolean
1356
class Item_func_isnotnull :public Item_bool_func
1322
1358
bool abort_on_null;
1324
Item_func_isnotnull(Item *a) :item::function::Boolean(a), abort_on_null(0) {}
1360
Item_func_isnotnull(Item *a) :Item_bool_func(a), abort_on_null(0) {}
1325
1361
int64_t val_int();
1326
1362
enum Functype functype() const { return ISNOTNULL_FUNC; }
1327
1363
void fix_length_and_dec()
1333
1369
table_map not_null_tables() const
1334
1370
{ return abort_on_null ? not_null_tables_cache : 0; }
1335
1371
Item *neg_transformer(Session *session);
1336
virtual void print(String *str);
1337
const charset_info_st *compare_collation() { return args[0]->collation.collation; }
1372
virtual void print(String *str, enum_query_type query_type);
1373
const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1338
1374
void top_level_item() { abort_on_null=1; }
1391
1429
using Item::split_sum_func;
1393
1431
/* Item_cond() is only used to create top level items */
1394
Item_cond(): item::function::Boolean(), abort_on_null(1)
1432
Item_cond(): Item_bool_func(), abort_on_null(1)
1395
1433
{ const_item_cache=0; }
1396
1434
Item_cond(Item *i1,Item *i2)
1397
:item::function::Boolean(), abort_on_null(0)
1435
:Item_bool_func(), abort_on_null(0)
1399
1437
list.push_back(i1);
1400
1438
list.push_back(i2);
1402
1440
Item_cond(Session *session, Item_cond *item);
1403
1441
Item_cond(List<Item> &nlist)
1404
:item::function::Boolean(), list(nlist), abort_on_null(0) {}
1405
void add(Item *item) { list.push_back(item); }
1406
void add_at_head(Item *item) { list.push_front(item); }
1442
:Item_bool_func(), list(nlist), abort_on_null(0) {}
1443
bool add(Item *item) { return list.push_back(item); }
1444
bool add_at_head(Item *item) { return list.push_front(item); }
1407
1445
void add_at_head(List<Item> *nlist) { list.prepand(nlist); }
1408
1446
bool fix_fields(Session *, Item **ref);
1409
1447
void fix_after_pullout(Select_Lex *new_parent, Item **ref);
1412
1450
List<Item>* argument_list() { return &list; }
1413
1451
table_map used_tables() const;
1414
1452
void update_used_tables();
1415
virtual void print(String *str);
1453
virtual void print(String *str, enum_query_type query_type);
1416
1454
void split_sum_func(Session *session, Item **ref_pointer_array, List<Item> &fields);
1417
1455
friend int setup_conds(Session *session, TableList *tables, TableList *leaves,
1505
1543
object represents f1=f2= ...=fn to the projection of known fields fi1=...=fik.
1508
class Item_equal: public item::function::Boolean
1546
class Item_equal: public Item_bool_func
1548
List<Item_field> fields; /* list of equal field items */
1549
Item *const_item; /* optional constant item equal to fields items */
1550
cmp_item *eval_item;
1511
typedef List<Item_field> fields_t;
1521
fields_t::iterator begin()
1523
return fields.begin();
1554
: Item_bool_func(), const_item(0), eval_item(0), cond_false(0)
1555
{ const_item_cache=0 ;}
1526
1556
Item_equal(Item_field *f1, Item_field *f2);
1527
1557
Item_equal(Item *c, Item_field *f);
1528
1558
Item_equal(Item_equal *item_equal);
1531
1561
void add(Item_field *f);
1532
1562
uint32_t members();
1533
1563
bool contains(Field *field);
1534
Item_field* get_first() { return &fields.front(); }
1564
Item_field* get_first() { return fields.head(); }
1535
1565
void merge(Item_equal *item);
1536
1566
void update_const();
1537
1567
enum Functype functype() const { return MULT_EQUAL_FUNC; }
1539
1569
const char *func_name() const { return "multiple equal"; }
1540
1570
optimize_type select_optimize() const { return OPTIMIZE_EQUAL; }
1541
1571
void sort(Item_field_cmpfunc cmp, void *arg);
1572
friend class Item_equal_iterator;
1542
1573
void fix_length_and_dec();
1543
1574
bool fix_fields(Session *session, Item **ref);
1544
1575
void update_used_tables();
1545
1576
bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
1546
1577
Item *transform(Item_transformer transformer, unsigned char *arg);
1547
virtual void print(String *str);
1548
const charset_info_st *compare_collation()
1549
{ return fields.front().collation.collation; }
1551
fields_t fields; /* list of equal field items */
1552
Item *const_item; /* optional constant item equal to fields items */
1553
cmp_item *eval_item;
1578
virtual void print(String *str, enum_query_type query_type);
1579
const CHARSET_INFO *compare_collation()
1580
{ return fields.head()->collation.collation; }
1558
1583
class COND_EQUAL: public memory::SqlAlloc
1572
typedef List<Item_field>::iterator Item_equal_iterator;
1598
class Item_equal_iterator : public List_iterator_fast<Item_field>
1601
inline Item_equal_iterator(Item_equal &item_equal)
1602
:List_iterator_fast<Item_field> (item_equal.fields)
1604
inline Item_field* operator++(int)
1606
Item_field *item= (*(List_iterator_fast<Item_field> *) this)++;
1609
inline void rewind(void)
1611
List_iterator_fast<Item_field>::rewind();
1574
1615
class Item_cond_and :public Item_cond
1589
1630
Item* copy_andor_structure(Session *session)
1591
1632
Item_cond_and *item;
1592
item= new Item_cond_and(session, this);
1593
item->copy_andor_arguments(session, this);
1633
if ((item= new Item_cond_and(session, this)))
1634
item->copy_andor_arguments(session, this);
1596
1637
Item *neg_transformer(Session *session);
1619
1660
Item* copy_andor_structure(Session *session)
1621
1662
Item_cond_or *item;
1622
item= new Item_cond_or(session, this);
1623
item->copy_andor_arguments(session, this);
1663
if ((item= new Item_cond_or(session, this)))
1664
item->copy_andor_arguments(session, this);
1626
1667
Item *neg_transformer(Session *session);