summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.h
diff options
context:
space:
mode:
authorunknown <aivanov@mysql.com>2005-09-06 18:03:08 +0400
committerunknown <aivanov@mysql.com>2005-09-06 18:03:08 +0400
commitf1cc5049810a0bcf701fe994aa3c4f6c5bbae8ab (patch)
treed6ae557d23c29875371111ed32a93908ec4af8f1 /sql/item_cmpfunc.h
parentf53de1f247373f56f30238c18893d6e01bad4d95 (diff)
downloadmariadb-git-f1cc5049810a0bcf701fe994aa3c4f6c5bbae8ab.tar.gz
item_cmpfunc.h:
Fixed bugs #12101, #12102: wrong calculation of not_null_tables() for some expressions. The classes Item_func_between, Item_func_if, Item_func_in are modified. Item_func_between/in objects can represent now [NOT]BETWEEN/IN expressions. The class Item_func_opt_neg is added to factor out the functionality common for the modified classes Item_func_between and Item_func_in. item_cmpfunc.cc: Fixed bugs #12101, #12102: wrong calculation of not_null_tables() for some expressions. Added Item_func_between::fix_fields(), Item_func_if::fix_fields(), Item_func_in::fix_fields(). They correct generic calculation of the not_null_tables attribute when it is needed. Modified Item_func_between::val_int(), Item_func_in::val_int(). opt_range.cc: Fixed bugs #12101, #12102: wrong calculation of not_null_tables() for some expressions. The function get_mm_tree() is modified. There cannot be NOT before BETWEEN/IN anymore. Rather Item_func_between/in objects can represent now [NOT]BETWEEN/IN expressions. sql_yacc.yy: Fixed bugs #12101, #12102: wrong calculation of not_null_tables() for some expressions. Item_func_between/in objects can represent now [NOT]BETWEEN/IN expresions. join_outer.result: Fixed some testcases results (bugs #12101, #12102) join_outer.test: Added testcases for bugs #12101, #12102 mysql-test/t/join_outer.test: Added testcases for bugs #12101, #12102 mysql-test/r/join_outer.result: Fixed some testcases results (bugs #12101, #12102) sql/sql_yacc.yy: Fixed bugs #12101, #12102: wrong calculation of not_null_tables() for some expressions. Item_func_between/in objects can represent now [NOT]BETWEEN/IN expresions. sql/opt_range.cc: Fixed bugs #12101, #12102: wrong calculation of not_null_tables() for some expressions. The function get_mm_tree() is modified. There cannot be NOT before BETWEEN/IN anymore. Rather Item_func_between/in objects can represent now [NOT]BETWEEN/IN expressions. sql/item_cmpfunc.cc: Fixed bugs #12101, #12102: wrong calculation of not_null_tables() for some expressions. Added Item_func_between::fix_fields(), Item_func_if::fix_fields(), Item_func_in::fix_fields(). They correct generic calculation of the not_null_tables attribute when it is needed. Modified Item_func_between::val_int(), Item_func_in::val_int(). sql/item_cmpfunc.h: Fixed bugs #12101, #12102: wrong calculation of not_null_tables() for some expressions. The classes Item_func_between, Item_func_if, Item_func_in are modified. Item_func_between/in objects can represent now [NOT]BETWEEN/IN expressions. The class Item_func_opt_neg is added to factor out the functionality common for the modified classes Item_func_between and Item_func_in.
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r--sql/item_cmpfunc.h55
1 files changed, 38 insertions, 17 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 47884f6064e..2ebf794f0a8 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -358,17 +358,49 @@ public:
};
-class Item_func_between :public Item_int_func
+/*
+ The class Item_func_opt_neg is defined to factor out the functionality
+ common for the classes Item_func_between and Item_func_in. The objects
+ of these classes can express predicates or there negations.
+ The alternative approach would be to create pairs Item_func_between,
+ Item_func_notbetween and Item_func_in, Item_func_notin.
+
+*/
+
+class Item_func_opt_neg :public Item_int_func
+{
+public:
+ bool negated; /* <=> the item represents NOT <func> */
+ bool pred_level; /* <=> [NOT] <func> is used on a predicate level */
+public:
+ Item_func_opt_neg(Item *a, Item *b, Item *c)
+ :Item_int_func(a, b, c), negated(0), pred_level(0) {}
+ Item_func_opt_neg(List<Item> &list)
+ :Item_int_func(list), negated(0), pred_level(0) {}
+public:
+ inline void negate() { negated= !negated; }
+ inline void top_level_item() { pred_level= 1; }
+ Item *neg_transformer(THD *thd)
+ {
+ negated= !negated;
+ return this;
+ }
+};
+
+
+class Item_func_between :public Item_func_opt_neg
{
DTCollation cmp_collation;
public:
Item_result cmp_type;
String value0,value1,value2;
- Item_func_between(Item *a,Item *b,Item *c) :Item_int_func(a,b,c) {}
+ Item_func_between(Item *a, Item *b, Item *c)
+ :Item_func_opt_neg(a, b, c) {}
longlong val_int();
optimize_type select_optimize() const { return OPTIMIZE_KEY; }
enum Functype functype() const { return BETWEEN; }
const char *func_name() const { return "between"; }
+ bool fix_fields(THD *, struct st_table_list *, Item **);
void fix_length_and_dec();
void print(String *str);
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
@@ -433,15 +465,9 @@ public:
longlong val_int();
String *val_str(String *str);
enum Item_result result_type () const { return cached_result_type; }
- bool fix_fields(THD *thd,struct st_table_list *tlist, Item **ref)
- {
- DBUG_ASSERT(fixed == 0);
- args[0]->top_level_item();
- return Item_func::fix_fields(thd, tlist, ref);
- }
+ bool fix_fields(THD *, struct st_table_list *, Item **);
void fix_length_and_dec();
const char *func_name() const { return "if"; }
- table_map not_null_tables() const { return 0; }
};
@@ -736,7 +762,7 @@ public:
}
};
-class Item_func_in :public Item_int_func
+class Item_func_in :public Item_func_opt_neg
{
Item_result cmp_type;
in_vector *array;
@@ -745,11 +771,12 @@ class Item_func_in :public Item_int_func
DTCollation cmp_collation;
public:
Item_func_in(List<Item> &list)
- :Item_int_func(list), array(0), in_item(0), have_null(0)
+ :Item_func_opt_neg(list), array(0), in_item(0), have_null(0)
{
allowed_arg_cols= 0; // Fetch this value from first argument
}
longlong val_int();
+ bool fix_fields(THD *, struct st_table_list *, Item **);
void fix_length_and_dec();
void cleanup()
{
@@ -769,12 +796,6 @@ class Item_func_in :public Item_int_func
bool nulls_in_row();
bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
- /*
- IN() protect from NULL only first argument, if construction like
- "expression IN ()" will be allowed, we will need to check number of
- argument here, because "NOT(NULL IN ())" is TRUE.
- */
- table_map not_null_tables() const { return args[0]->not_null_tables(); }
};
/* Functions used by where clause */