Hi Serg. Please review a patch for MDEV-10236.
Thanks.
commit bb3afc8aea61bc090a1119be0a1dad32d9dc8feb Author: Alexander Barkov <[email protected]> Date: Wed Jun 22 16:30:15 2016 +0400 MDEV-10236 Where expression with NOT function gives incorrect result diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index 0d012e2..fcaaeb2 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -1572,5 +1572,22 @@ SELECT * FROM t1 WHERE NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(NULLIF(N i DROP TABLE t1; # +# MDEV-10236 Where expression with NOT function gives incorrect result +# +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1),(2),(3); +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE ((c1 IS NOT NULL) >= (NOT TRUE)) IS NOT NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`c1` AS `c1` from `test`.`t1` where (((`test`.`t1`.`c1` is not null) >= <cache>((not(1)))) is not null) +SELECT * FROM t1 WHERE ((c1 IS NOT NULL) >= (NOT TRUE)) IS NOT NULL; +c1 +1 +2 +3 +DROP TABLE t1; +# # End of 10.1 tests # diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index a5db444..84b3f06 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -1008,5 +1008,16 @@ DROP TABLE t1; --echo # +--echo # MDEV-10236 Where expression with NOT function gives incorrect result +--echo # +CREATE TABLE t1 (c1 INT); +INSERT INTO t1 VALUES (1),(2),(3); +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE ((c1 IS NOT NULL) >= (NOT TRUE)) IS NOT NULL; +SELECT * FROM t1 WHERE ((c1 IS NOT NULL) >= (NOT TRUE)) IS NOT NULL; +DROP TABLE t1; + + +--echo # --echo # End of 10.1 tests --echo # diff --git a/sql/item.h b/sql/item.h index bef57c4..93da398 100644 --- a/sql/item.h +++ b/sql/item.h @@ -5050,7 +5050,7 @@ class Item_cache: public Item_basic_constant bool basic_const_item() const { return MY_TEST(example && example->basic_const_item()); } virtual void clear() { null_value= TRUE; value_cached= FALSE; } - bool is_null() { return null_value; } + bool is_null() { return !has_value(); } virtual bool is_expensive() { if (value_cached)
_______________________________________________ Mailing list: https://launchpad.net/~maria-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~maria-developers More help : https://help.launchpad.net/ListHelp

