diff options
-rw-r--r-- | mysql-test/r/null.result | 9 | ||||
-rw-r--r-- | mysql-test/t/null.test | 12 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 9 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 17 |
4 files changed, 34 insertions, 13 deletions
diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index e62ba68c8f6..fe7ed32cbb0 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -373,3 +373,12 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL); dt DROP TABLE t1; +# +# Bug mdev-5132: crash when exeicuting a join query +# with IS NULL and IS NOT NULL in where +# +CREATE TABLE t1 (a DATE, b INT, c INT, KEY(a), KEY(b), KEY(c)) ENGINE=MyISAM; +CREATE TABLE t2 (d DATE) ENGINE=MyISAM; +SELECT * FROM t1,t2 WHERE 1 IS NOT NULL AND t1.b IS NULL; +a b c d +DROP TABLE t1,t2; diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index 4a45240ec68..81951a9ce68 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -283,3 +283,15 @@ SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL); SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL); DROP TABLE t1; + +--echo # +--echo # Bug mdev-5132: crash when exeicuting a join query +--echo # with IS NULL and IS NOT NULL in where +--echo # + +CREATE TABLE t1 (a DATE, b INT, c INT, KEY(a), KEY(b), KEY(c)) ENGINE=MyISAM; +CREATE TABLE t2 (d DATE) ENGINE=MyISAM; + +SELECT * FROM t1,t2 WHERE 1 IS NOT NULL AND t1.b IS NULL; + +DROP TABLE t1,t2; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 514b0fe4580..d1075c3c47f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -539,8 +539,6 @@ void Item_bool_func2::fix_length_and_dec() to the collation of A. */ - sargable= true; - DTCollation coll; if (args[0]->result_type() == STRING_RESULT && args[1]->result_type() == STRING_RESULT && @@ -2185,7 +2183,6 @@ void Item_func_between::fix_length_and_dec() THD *thd= current_thd; max_length= 1; compare_as_dates= 0; - sargable= true; /* As some compare functions are generated after sql_yacc, @@ -3865,7 +3862,6 @@ void Item_func_in::fix_length_and_dec() uint found_types= 0; uint type_cnt= 0, i; Item_result cmp_type= STRING_RESULT; - sargable= true; left_result_type= args[0]->cmp_type(); if (!(found_types= collect_cmp_types(args, arg_count, true))) return; @@ -5491,7 +5487,8 @@ Item_equal::Item_equal(Item *f1, Item *f2, bool with_const_item) equal_items.push_back(f1); equal_items.push_back(f2); compare_as_dates= with_const_item && f2->cmp_type() == TIME_RESULT; - upper_levels= NULL; + upper_levels= NULL; + sargable= TRUE; } @@ -5521,6 +5518,7 @@ Item_equal::Item_equal(Item_equal *item_equal) compare_as_dates= item_equal->compare_as_dates; cond_false= item_equal->cond_false; upper_levels= item_equal->upper_levels; + sargable= TRUE; } @@ -5944,7 +5942,6 @@ void Item_equal::fix_length_and_dec() Item *item= get_first(NO_PARTICULAR_TAB, NULL); eval_item= cmp_item::get_comparator(item->cmp_type(), item, item->collation.collation); - sargable= true; } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 4deda7679ac..c1ef680f3ee 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -118,7 +118,7 @@ public: Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {} Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {} bool is_bool_func() { return 1; } - void fix_length_and_dec() { decimals=0; max_length=1; sargable= true;} + void fix_length_and_dec() { decimals=0; max_length=1; } uint decimal_precision() const { return 1; } }; @@ -364,7 +364,8 @@ protected: public: Item_bool_func2(Item *a,Item *b) - :Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1), abort_on_null(FALSE) {} + :Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1), + abort_on_null(FALSE) { sargable= TRUE; } void fix_length_and_dec(); void set_cmp_func() { @@ -668,7 +669,7 @@ public: /* TRUE <=> arguments will be compared as dates. */ Item *compare_as_dates; Item_func_between(Item *a, Item *b, Item *c) - :Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) {} + :Item_func_opt_neg(a, b, c), compare_as_dates(FALSE) { sargable= TRUE; } longlong val_int(); optimize_type select_optimize() const { return OPTIMIZE_KEY; } enum Functype functype() const { return BETWEEN; } @@ -1280,10 +1281,11 @@ public: Item_func_in(List<Item> &list) :Item_func_opt_neg(list), array(0), have_null(0), - arg_types_compatible(FALSE) + arg_types_compatible(FALSE) { bzero(&cmp_items, sizeof(cmp_items)); allowed_arg_cols= 0; // Fetch this value from first argument + sargable= TRUE; } longlong val_int(); bool fix_fields(THD *, Item **); @@ -1349,7 +1351,7 @@ public: class Item_func_isnull :public Item_bool_func { public: - Item_func_isnull(Item *a) :Item_bool_func(a) {} + Item_func_isnull(Item *a) :Item_bool_func(a) { sargable= TRUE; } longlong val_int(); enum Functype functype() const { return ISNULL_FUNC; } void fix_length_and_dec() @@ -1410,7 +1412,8 @@ class Item_func_isnotnull :public Item_bool_func { bool abort_on_null; public: - Item_func_isnotnull(Item *a) :Item_bool_func(a), abort_on_null(0) {} + Item_func_isnotnull(Item *a) :Item_bool_func(a), abort_on_null(0) + { sargable= TRUE; } longlong val_int(); enum Functype functype() const { return ISNOTNULL_FUNC; } void fix_length_and_dec() @@ -1717,7 +1720,7 @@ public: inline Item_equal() : Item_bool_func(), with_const(FALSE), eval_item(0), cond_false(0), context_field(NULL) - { const_item_cache=0 ;} + { const_item_cache=0; sargable= TRUE; } Item_equal(Item *f1, Item *f2, bool with_const_item); Item_equal(Item_equal *item_equal); /* Currently the const item is always the first in the list of equal items */ |