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 */
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
20
#ifndef DRIZZLED_ITEM_CMPFUNC_H
21
#define DRIZZLED_ITEM_CMPFUNC_H
17
23
/* compare and test functions */
19
#ifdef USE_PRAGMA_INTERFACE
20
#pragma interface /* gcc class implementation */
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"
23
35
extern Item_result item_cmp_type(Item_result a,Item_result b);
24
36
class Item_bool_func2;
25
37
class Arg_comparator;
38
class Item_sum_hybrid;
27
41
typedef int (Arg_comparator::*arg_cmp_func)();
29
typedef int (*Item_field_cmpfunc)(Item_field *f1, Item_field *f2, void *arg);
43
typedef int (*Item_field_cmpfunc)(Item_field *f1, Item_field *f2, void *arg);
31
45
class Arg_comparator: public Sql_alloc
36
50
Arg_comparator *comparators; // used only for compare_row()
38
52
/* Fields used in DATE/DATETIME comparison. */
40
54
enum_field_types a_type, b_type; // Types of a and b items
41
55
Item *a_cache, *b_cache; // Cached values of a and b items
42
56
bool is_nulls_eq; // TRUE <=> compare for the EQUAL_FUNC
43
57
enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
44
58
CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
45
uint64_t (*get_value_func)(THD *thd, Item ***item_arg, Item **cache_arg,
59
uint64_t (*get_value_func)(Session *session, Item ***item_arg, Item **cache_arg,
46
60
Item *warn_item, bool *is_null);
48
62
DTCollation cmp_collation;
50
Arg_comparator(): thd(0), a_cache(0), b_cache(0) {};
51
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), thd(0),
64
Arg_comparator(): session(0), a_cache(0), b_cache(0) {};
65
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), session(0),
52
66
a_cache(0), b_cache(0) {};
54
68
int set_compare_func(Item_bool_func2 *owner, Item_result type);
105
119
Item_bool_func() :Item_int_func() {}
106
120
Item_bool_func(Item *a) :Item_int_func(a) {}
107
121
Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {}
108
Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {}
122
Item_bool_func(Session *session, Item_bool_func *item) :Item_int_func(session, item) {}
109
123
bool is_bool_func() { return 1; }
110
124
void fix_length_and_dec() { decimals=0; max_length=1; }
111
uint decimal_precision() const { return 1; }
125
uint32_t decimal_precision() const { return 1; }
230
244
bool result_for_null_param;
232
246
Item_in_optimizer(Item *a, Item_in_subselect *b):
233
Item_bool_func(a, my_reinterpret_cast(Item *)(b)), cache(0),
247
Item_bool_func(a, reinterpret_cast<Item *>(b)), cache(0),
234
248
save_cache(0), result_for_null_param(UNKNOWN)
235
249
{ with_subselect= true; }
236
bool fix_fields(THD *, Item **);
237
bool fix_left(THD *thd, Item **ref);
250
bool fix_fields(Session *, Item **);
251
bool fix_left(Session *session, Item **ref);
239
253
int64_t val_int();
241
255
const char *func_name() const { return "<in_optimizer>"; }
242
256
Item_cache **get_cache() { return &cache; }
243
257
void keep_top_level_cache();
244
Item *transform(Item_transformer transformer, uchar *arg);
250
Comp_creator() {} /* Remove gcc warning */
251
virtual ~Comp_creator() {} /* Remove gcc warning */
252
virtual Item_bool_func2* create(Item *a, Item *b) const = 0;
253
virtual const char* symbol(bool invert) const = 0;
254
virtual bool eqne_op() const = 0;
255
virtual bool l_op() const = 0;
258
Item *transform(Item_transformer transformer, unsigned char *arg);
258
261
class Eq_creator :public Comp_creator
384
393
trigcond<param>(arg) ::= param? arg : TRUE
386
The class Item_func_trig_cond is used for guarded predicates
395
The class Item_func_trig_cond is used for guarded predicates
387
396
which are employed only for internal purposes.
388
397
A guarded predicate is an object consisting of an a regular or
389
a guarded predicate P and a pointer to a boolean guard variable g.
398
a guarded predicate P and a pointer to a boolean guard variable g.
390
399
A guarded predicate P/g is evaluated to true if the value of the
391
400
guard g is false, otherwise it is evaluated to the same value that
392
401
the predicate P: val(P/g)= g ? val(P):true.
398
407
the objects consisting of three elements: a predicate P, a pointer
399
408
to a variable g and a firing value s with following evaluation
400
409
rule: val(P/g,s)= g==s? val(P) : true. It will allow us to build only
401
one item for the objects of the form P/g1/g2...
410
one item for the objects of the form P/g1/g2...
403
412
Objects of this class are built only for query execution after
404
413
the execution plan has been already selected. That's why this
405
class needs only val_int out of generic methods.
414
class needs only val_int out of generic methods.
407
416
Current uses of Item_func_trig_cond objects:
408
417
- To wrap selection conditions when executing outer joins
409
418
- To wrap condition that is pushed down into subquery
576
585
inline void negate() { negated= !negated; }
577
586
inline void top_level_item() { pred_level= 1; }
578
Item *neg_transformer(THD *thd __attribute__((unused)))
587
Item *neg_transformer(Session *)
580
589
negated= !negated;
583
592
bool eq(const Item *item, bool binary_cmp) const;
584
bool subst_argument_checker(uchar **arg __attribute__((unused)))
593
bool subst_argument_checker(unsigned char **)
602
611
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
603
612
enum Functype functype() const { return BETWEEN; }
604
613
const char *func_name() const { return "between"; }
605
bool fix_fields(THD *, Item **);
614
bool fix_fields(Session *, Item **);
606
615
void fix_length_and_dec();
607
616
virtual void print(String *str, enum_query_type query_type);
608
617
bool is_bool_func() { return 1; }
609
618
const CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
610
uint decimal_precision() const { return 1; }
619
uint32_t decimal_precision() const { return 1; }
684
693
enum_field_types field_type() const;
685
694
void fix_length_and_dec();
686
695
const char *func_name() const { return "ifnull"; }
687
Field *tmp_table_field(TABLE *table);
688
uint decimal_precision() const;
696
Field *tmp_table_field()
698
return Item_func::tmp_table_field();
700
Field *tmp_table_field(Table *table);
701
uint32_t decimal_precision() const;
703
716
my_decimal *val_decimal(my_decimal *);
704
717
enum Item_result result_type () const { return cached_result_type; }
705
718
enum_field_types field_type() const { return cached_field_type; }
706
bool fix_fields(THD *, Item **);
719
bool fix_fields(Session *, Item **);
707
720
void fix_length_and_dec();
708
uint decimal_precision() const;
721
uint32_t decimal_precision() const;
709
722
const char *func_name() const { return "if"; }
723
736
my_decimal *val_decimal(my_decimal *);
724
737
enum Item_result result_type () const { return cached_result_type; }
725
738
void fix_length_and_dec();
726
uint decimal_precision() const { return args[0]->decimal_precision(); }
739
uint32_t decimal_precision() const { return args[0]->decimal_precision(); }
727
740
const char *func_name() const { return "nullif"; }
729
742
virtual inline void print(String *str, enum_query_type query_type)
749
762
qsort2_cmp compare;
750
763
const CHARSET_INFO *collation;
754
in_vector(uint elements,uint element_length,qsort2_cmp cmp_func,
767
in_vector(uint32_t elements,uint32_t element_length,qsort2_cmp cmp_func,
755
768
const CHARSET_INFO * const cmp_coll)
756
769
:base((char*) sql_calloc(elements*element_length)),
757
770
size(element_length), compare(cmp_func), collation(cmp_coll),
758
771
count(elements), used_count(elements) {}
759
772
virtual ~in_vector() {}
760
virtual void set(uint pos,Item *item)=0;
761
virtual uchar *get_value(Item *item)=0;
773
virtual void set(uint32_t pos,Item *item)=0;
774
virtual unsigned char *get_value(Item *item)=0;
764
777
my_qsort2(base,used_count,size,compare, (void *) collation);
766
779
int find(Item *item);
769
782
Create an instance of Item_{type} (e.g. Item_decimal) constant object
770
783
which type allows it to hold an element of this vector without any
783
796
item Constant item to store value into. The item must be of the same
784
797
type that create_item() returns.
786
virtual void value_to_item(uint pos __attribute__((unused)),
787
Item *item __attribute__((unused))) { }
799
virtual void value_to_item(uint32_t, Item *) { }
789
801
/* Compare values number pos1 and pos2 for equality */
790
bool compare_elems(uint pos1, uint pos2)
802
bool compare_elems(uint32_t pos1, uint32_t pos2)
792
804
return test(compare(collation, base + pos1*size, base + pos2*size));
799
811
char buff[STRING_BUFFER_USUAL_SIZE];
802
in_string(uint elements,qsort2_cmp cmp_func, const CHARSET_INFO * const cs);
814
in_string(uint32_t elements,qsort2_cmp cmp_func, const CHARSET_INFO * const cs);
804
void set(uint pos,Item *item);
805
uchar *get_value(Item *item);
816
void set(uint32_t pos,Item *item);
817
unsigned char *get_value(Item *item);
806
818
Item* create_item()
808
820
return new Item_string(collation);
810
void value_to_item(uint pos, Item *item)
822
void value_to_item(uint32_t pos, Item *item)
812
824
String *str=((String*) base)+pos;
813
825
Item_string *to= (Item_string*)item;
814
826
to->str_value= *str;
823
835
Here we declare a temporary variable (tmp) of the same type as the
824
elements of this vector. tmp is used in finding if a given value is in
836
elements of this vector. tmp is used in finding if a given value is in
827
struct packed_int64_t
839
struct packed_int64_t
830
842
int64_t unsigned_flag; // Use int64_t, not bool, to preserve alignment
833
in_int64_t(uint elements);
834
void set(uint pos,Item *item);
835
uchar *get_value(Item *item);
845
in_int64_t(uint32_t elements);
846
void set(uint32_t pos,Item *item);
847
unsigned char *get_value(Item *item);
837
849
Item* create_item()
840
We're created a signed INT, this may not be correct in
852
We're created a signed INT, this may not be correct in
841
853
general case (see BUG#19342).
843
855
return new Item_int((int64_t)0);
845
void value_to_item(uint pos, Item *item)
857
void value_to_item(uint32_t pos, Item *item)
847
859
((Item_int*) item)->value= ((packed_int64_t*) base)[pos].val;
848
860
((Item_int*) item)->unsigned_flag= (bool)
863
875
class in_datetime :public in_int64_t
867
879
/* An item used to issue warnings. */
869
881
/* Cache for the left item. */
870
882
Item *lval_cache;
872
in_datetime(Item *warn_item_arg, uint elements)
873
:in_int64_t(elements), thd(current_thd), warn_item(warn_item_arg),
884
in_datetime(Item *warn_item_arg, uint32_t elements)
885
:in_int64_t(elements), session(current_session), warn_item(warn_item_arg),
874
886
lval_cache(0) {};
875
void set(uint pos,Item *item);
876
uchar *get_value(Item *item);
887
void set(uint32_t pos,Item *item);
888
unsigned char *get_value(Item *item);
877
889
friend int cmp_int64_t(void *cmp_arg, packed_int64_t *a,packed_int64_t *b);
885
in_double(uint elements);
886
void set(uint pos,Item *item);
887
uchar *get_value(Item *item);
897
in_double(uint32_t elements);
898
void set(uint32_t pos,Item *item);
899
unsigned char *get_value(Item *item);
888
900
Item *create_item()
890
902
return new Item_float(0.0, 0);
892
void value_to_item(uint pos, Item *item)
904
void value_to_item(uint32_t pos, Item *item)
894
906
((Item_float*)item)->value= ((double*) base)[pos];
904
in_decimal(uint elements);
905
void set(uint pos, Item *item);
906
uchar *get_value(Item *item);
916
in_decimal(uint32_t elements);
917
void set(uint32_t pos, Item *item);
918
unsigned char *get_value(Item *item);
907
919
Item *create_item()
909
921
return new Item_decimal(0, false);
911
void value_to_item(uint pos, Item *item)
923
void value_to_item(uint32_t pos, Item *item)
913
925
my_decimal *dec= ((my_decimal *)base) + pos;
914
926
Item_decimal *item_dec= (Item_decimal*)item;
935
947
virtual int compare(cmp_item *item)= 0;
936
948
static cmp_item* get_comparator(Item_result type, const CHARSET_INFO * const cs);
937
949
virtual cmp_item *make_same()= 0;
938
virtual void store_value_by_template(cmp_item *tmpl __attribute__((unused)),
950
virtual void store_value_by_template(cmp_item *, Item *item)
941
952
store_value(item);
945
class cmp_item_string :public cmp_item
956
class cmp_item_string :public cmp_item
948
959
String *value_res;
1022
1033
uint64_t value;
1025
1036
/* Item used for issuing warnings. */
1026
1037
Item *warn_item;
1027
1038
/* Cache for the left item. */
1028
1039
Item *lval_cache;
1030
1041
cmp_item_datetime(Item *warn_item_arg)
1031
:thd(current_thd), warn_item(warn_item_arg), lval_cache(0) {}
1042
:session(current_session), warn_item(warn_item_arg), lval_cache(0) {}
1032
1043
void store_value(Item *item);
1033
1044
int cmp(Item *arg);
1034
1045
int compare(cmp_item *ci);
1155
1166
int64_t val_int();
1156
1167
String *val_str(String *);
1157
1168
my_decimal *val_decimal(my_decimal *);
1158
bool fix_fields(THD *thd, Item **ref);
1169
bool fix_fields(Session *session, Item **ref);
1159
1170
void fix_length_and_dec();
1160
uint decimal_precision() const;
1171
uint32_t decimal_precision() const;
1161
1172
table_map not_null_tables() const { return 0; }
1162
1173
enum Item_result result_type () const { return cached_result_type; }
1163
1174
enum_field_types field_type() const { return cached_field_type; }
1210
1221
allowed_arg_cols= 0; // Fetch this value from first argument
1212
1223
int64_t val_int();
1213
bool fix_fields(THD *, Item **);
1224
bool fix_fields(Session *, Item **);
1214
1225
void fix_length_and_dec();
1215
uint decimal_precision() const { return 1; }
1226
uint32_t decimal_precision() const { return 1; }
1219
1230
Item_int_func::cleanup();
1222
for (i= 0; i <= (uint)DECIMAL_RESULT + 1; i++)
1233
for (i= 0; i <= (uint32_t)DECIMAL_RESULT + 1; i++)
1224
1235
delete cmp_items[i];
1225
1236
cmp_items[i]= 0;
1258
1269
cmp_item_row tmp;
1260
in_row(uint elements, Item *);
1271
in_row(uint32_t elements, Item *);
1262
void set(uint pos,Item *item);
1263
uchar *get_value(Item *item);
1273
void set(uint32_t pos,Item *item);
1274
unsigned char *get_value(Item *item);
1264
1275
friend void Item_func_in::fix_length_and_dec();
1265
1276
Item_result result_type() { return ROW_RESULT; }
1349
1360
optimize_type select_optimize() const { return OPTIMIZE_NULL; }
1350
1361
table_map not_null_tables() const
1351
1362
{ return abort_on_null ? not_null_tables_cache : 0; }
1352
Item *neg_transformer(THD *thd);
1363
Item *neg_transformer(Session *session);
1353
1364
virtual void print(String *str, enum_query_type query_type);
1354
1365
const CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
1355
1366
void top_level_item() { abort_on_null=1; }
1374
1385
enum { alphabet_size = 256 };
1376
1387
Item *escape_item;
1378
1389
bool escape_used_in_parsing;
1383
1396
Item_func_like(Item *a,Item *b, Item *escape_arg, bool escape_used)
1384
:Item_bool_func2(a,b), canDoTurboBM(false), pattern(0), pattern_len(0),
1397
:Item_bool_func2(a,b), canDoTurboBM(false), pattern(0), pattern_len(0),
1385
1398
bmGs(0), bmBc(0), escape_item(escape_arg),
1386
escape_used_in_parsing(escape_used) {}
1399
escape_used_in_parsing(escape_used), escape(NULL) {}
1387
1400
int64_t val_int();
1388
1401
enum Functype functype() const { return LIKE_FUNC; }
1389
1402
optimize_type select_optimize() const;
1390
1403
cond_result eq_cmp_result() const { return COND_TRUE; }
1391
1404
const char *func_name() const { return "like"; }
1392
bool fix_fields(THD *thd, Item **ref);
1405
bool fix_fields(Session *session, Item **ref);
1393
1406
void cleanup();
1413
1429
list.push_back(i1);
1414
1430
list.push_back(i2);
1416
Item_cond(THD *thd, Item_cond *item);
1432
Item_cond(Session *session, Item_cond *item);
1417
1433
Item_cond(List<Item> &nlist)
1418
1434
:Item_bool_func(), list(nlist), abort_on_null(0) {}
1419
1435
bool add(Item *item) { return list.push_back(item); }
1420
1436
bool add_at_head(Item *item) { return list.push_front(item); }
1421
1437
void add_at_head(List<Item> *nlist) { list.prepand(nlist); }
1422
bool fix_fields(THD *, Item **ref);
1423
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
1438
bool fix_fields(Session *, Item **ref);
1439
void fix_after_pullout(Select_Lex *new_parent, Item **ref);
1425
1441
enum Type type() const { return COND_ITEM; }
1426
1442
List<Item>* argument_list() { return &list; }
1427
1443
table_map used_tables() const;
1428
1444
void update_used_tables();
1429
1445
virtual void print(String *str, enum_query_type query_type);
1430
void split_sum_func(THD *thd, Item **ref_pointer_array, List<Item> &fields);
1431
friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
1446
void split_sum_func(Session *session, Item **ref_pointer_array, List<Item> &fields);
1447
friend int setup_conds(Session *session, TableList *tables, TableList *leaves,
1433
1449
void top_level_item() { abort_on_null=1; }
1434
void copy_andor_arguments(THD *thd, Item_cond *item);
1435
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
1436
Item *transform(Item_transformer transformer, uchar *arg);
1450
void copy_andor_arguments(Session *session, Item_cond *item);
1451
bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
1452
Item *transform(Item_transformer transformer, unsigned char *arg);
1437
1453
void traverse_cond(Cond_traverser, void *arg, traverse_order order);
1438
void neg_arguments(THD *thd);
1454
void neg_arguments(Session *session);
1439
1455
enum_field_types field_type() const { return DRIZZLE_TYPE_LONGLONG; }
1440
bool subst_argument_checker(uchar **arg __attribute__((unused)))
1456
bool subst_argument_checker(unsigned char **)
1441
1457
{ return true; }
1442
Item *compile(Item_analyzer analyzer, uchar **arg_p,
1443
Item_transformer transformer, uchar *arg_t);
1458
Item *compile(Item_analyzer analyzer, unsigned char **arg_p,
1459
Item_transformer transformer, unsigned char *arg_t);
1461
1477
A conjunction of the predicates f2=f1 and f3=f1 and f3=f2 will be
1462
1478
substituted for the item representing the same multiple equality
1464
An item Item_equal(f1,f2) can appear instead of a conjunction of
1480
An item Item_equal(f1,f2) can appear instead of a conjunction of
1465
1481
f2=f1 and f1=f2, or instead of just the predicate f1=f2.
1467
An item of the class Item_equal inherits equalities from outer
1483
An item of the class Item_equal inherits equalities from outer
1468
1484
conjunctive levels.
1470
1486
Suppose we have a where condition of the following form:
1490
1506
It also can give us additional index scans and can allow us to
1491
1507
improve selectivity estimates.
1493
3. An object Item_equal(t1.f1,...,tk.fk) is used to optimize the
1494
selected execution plan for the query: if table ti is accessed
1509
3. An object Item_equal(t1.f1,...,tk.fk) is used to optimize the
1510
selected execution plan for the query: if table ti is accessed
1495
1511
before the table tj then in any predicate P in the where condition
1496
1512
the occurrence of tj.fj is substituted for ti.fi. This can allow
1497
1513
an evaluation of the predicate at an earlier step.
1499
When feature 1 is supported they say that join transitive closure
1515
When feature 1 is supported they say that join transitive closure
1501
1517
When feature 2 is supported they say that search argument transitive
1502
1518
closure is employed.
1535
1551
inline Item* get_const() { return const_item; }
1536
1552
void add(Item *c);
1537
1553
void add(Item_field *f);
1539
1555
bool contains(Field *field);
1540
1556
Item_field* get_first() { return fields.head(); }
1541
1557
void merge(Item_equal *item);
1542
1558
void update_const();
1543
1559
enum Functype functype() const { return MULT_EQUAL_FUNC; }
1545
1561
const char *func_name() const { return "multiple equal"; }
1546
1562
optimize_type select_optimize() const { return OPTIMIZE_EQUAL; }
1547
1563
void sort(Item_field_cmpfunc cmp, void *arg);
1548
1564
friend class Item_equal_iterator;
1549
1565
void fix_length_and_dec();
1550
bool fix_fields(THD *thd, Item **ref);
1566
bool fix_fields(Session *session, Item **ref);
1551
1567
void update_used_tables();
1552
bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
1553
Item *transform(Item_transformer transformer, uchar *arg);
1568
bool walk(Item_processor processor, bool walk_subquery, unsigned char *arg);
1569
Item *transform(Item_transformer transformer, unsigned char *arg);
1554
1570
virtual void print(String *str, enum_query_type query_type);
1555
const CHARSET_INFO *compare_collation()
1571
const CHARSET_INFO *compare_collation()
1556
1572
{ return fields.head()->collation.collation; }
1559
1575
class COND_EQUAL: public Sql_alloc
1562
uint max_members; /* max number of members the current level
1563
list and all lower level lists */
1578
uint32_t max_members; /* max number of members the current level
1579
list and all lower level lists */
1564
1580
COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */
1565
List<Item_equal> current_level; /* list of multiple equalities of
1581
List<Item_equal> current_level; /* list of multiple equalities of
1566
1582
the current and level */
1569
1585
upper_levels= 0;
1591
1607
class Item_cond_and :public Item_cond
1594
COND_EQUAL cond_equal; /* contains list of Item_equal objects for
1610
COND_EQUAL cond_equal; /* contains list of Item_equal objects for
1595
1611
the current and level and reference
1596
to multiple equalities of upper and levels */
1612
to multiple equalities of upper and levels */
1597
1613
Item_cond_and() :Item_cond() {}
1598
1614
Item_cond_and(Item *i1,Item *i2) :Item_cond(i1,i2) {}
1599
Item_cond_and(THD *thd, Item_cond_and *item) :Item_cond(thd, item) {}
1615
Item_cond_and(Session *session, Item_cond_and *item) :Item_cond(session, item) {}
1600
1616
Item_cond_and(List<Item> &list_arg): Item_cond(list_arg) {}
1601
1617
enum Functype functype() const { return COND_AND_FUNC; }
1602
1618
int64_t val_int();
1603
1619
const char *func_name() const { return "and"; }
1604
1620
table_map not_null_tables() const
1605
1621
{ return abort_on_null ? not_null_tables_cache: and_tables_cache; }
1606
Item* copy_andor_structure(THD *thd)
1622
Item* copy_andor_structure(Session *session)
1608
1624
Item_cond_and *item;
1609
if ((item= new Item_cond_and(thd, this)))
1610
item->copy_andor_arguments(thd, this);
1625
if ((item= new Item_cond_and(session, this)))
1626
item->copy_andor_arguments(session, this);
1613
Item *neg_transformer(THD *thd);
1629
Item *neg_transformer(Session *session);
1616
1632
inline bool is_cond_and(Item *item)
1628
1644
Item_cond_or() :Item_cond() {}
1629
1645
Item_cond_or(Item *i1,Item *i2) :Item_cond(i1,i2) {}
1630
Item_cond_or(THD *thd, Item_cond_or *item) :Item_cond(thd, item) {}
1646
Item_cond_or(Session *session, Item_cond_or *item) :Item_cond(session, item) {}
1631
1647
Item_cond_or(List<Item> &list_arg): Item_cond(list_arg) {}
1632
1648
enum Functype functype() const { return COND_OR_FUNC; }
1633
1649
int64_t val_int();
1634
1650
const char *func_name() const { return "or"; }
1635
1651
table_map not_null_tables() const { return and_tables_cache; }
1636
Item* copy_andor_structure(THD *thd)
1652
Item* copy_andor_structure(Session *session)
1638
1654
Item_cond_or *item;
1639
if ((item= new Item_cond_or(thd, this)))
1640
item->copy_andor_arguments(thd, this);
1655
if ((item= new Item_cond_or(session, this)))
1656
item->copy_andor_arguments(session, this);
1643
Item *neg_transformer(THD *thd);
1659
Item *neg_transformer(Session *session);
1646
1662
inline bool is_cond_or(Item *item)