diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-09-02 15:56:24 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-09-02 15:56:24 +0400 |
commit | 5088cbf4ed7224698678f3eaf406361c6e7db4b8 (patch) | |
tree | 0734093a3c30ecce5855c9ab116923a4e6911753 | |
parent | 0671430252c597ff623a79cd954afb07eff47e91 (diff) | |
download | mariadb-git-5088cbf4ed7224698678f3eaf406361c6e7db4b8.tar.gz |
MDEV-8671 Wrong result for SELECT..WHERE varchar_column=' 1' AND (varchar_column XOR '1')
-rw-r--r-- | mysql-test/r/ctype_cp1251.result | 26 | ||||
-rw-r--r-- | mysql-test/t/ctype_cp1251.test | 13 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 5 |
3 files changed, 44 insertions, 0 deletions
diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result index ffe16753c5c..9d6185a9420 100644 --- a/mysql-test/r/ctype_cp1251.result +++ b/mysql-test/r/ctype_cp1251.result @@ -3363,5 +3363,31 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = ' 1') and (`test`.`t1`.`a` in (1,2,3,'x'))) DROP TABLE t1; # +# MDEV-8671 Wrong result for SELECT..WHERE varchar_column=' 1' AND (varchar_column XOR '1') +# +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET cp1251 COLLATE cp1251_ukrainian_ci); +INSERT INTO t1 VALUES (' 1'),('`1'); +SELECT * FROM t1 WHERE a=' 1'; +a + 1 +`1 +SELECT * FROM t1 WHERE (a XOR '0'); +a + 1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '`1' +SELECT * FROM t1 WHERE a=' 1' AND (a XOR '0'); +a + 1 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '`1' +# ' 1' should not be propagated into (a XIR '0') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=' 1' AND (a XOR '0'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = ' 1') and (`test`.`t1`.`a` xor '0')) +DROP TABLE t1; +# # End of 10.1 tests # diff --git a/mysql-test/t/ctype_cp1251.test b/mysql-test/t/ctype_cp1251.test index 6630497db8f..93fd5cc9a1a 100644 --- a/mysql-test/t/ctype_cp1251.test +++ b/mysql-test/t/ctype_cp1251.test @@ -127,5 +127,18 @@ DROP TABLE t1; --echo # +--echo # MDEV-8671 Wrong result for SELECT..WHERE varchar_column=' 1' AND (varchar_column XOR '1') +--echo # +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET cp1251 COLLATE cp1251_ukrainian_ci); +INSERT INTO t1 VALUES (' 1'),('`1'); +SELECT * FROM t1 WHERE a=' 1'; +SELECT * FROM t1 WHERE (a XOR '0'); +SELECT * FROM t1 WHERE a=' 1' AND (a XOR '0'); +--echo # ' 1' should not be propagated into (a XIR '0') +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=' 1' AND (a XOR '0'); +DROP TABLE t1; + + +--echo # --echo # End of 10.1 tests --echo # diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index b20a741c6b4..d764126151c 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -442,6 +442,11 @@ public: Item_args::propagate_equal_fields(thd, ANY_SUBST, cond); return this; } + void fix_length_and_dec() + { + Item_bool_func::fix_length_and_dec(); + args[0]->cmp_context= args[1]->cmp_context= INT_RESULT; + } }; class Item_func_not :public Item_bool_func |