Commit 44a99777 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-8698 Wrong result for SELECT..WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin;

parent 787adc61
...@@ -8019,5 +8019,25 @@ Warnings: ...@@ -8019,5 +8019,25 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (`test`.`t1`.`a` in (<cache>(('a' collate latin1_bin)),'b'))) Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (`test`.`t1`.`a` in (<cache>(('a' collate latin1_bin)),'b')))
DROP TABLE t1; DROP TABLE t1;
# #
# MDEV-8698 Wrong result for SELECT..WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin;
#
SET NAMES latin1;
CREATE TABLE t1 (a VARCHAR(10));
INSERT INTO t1 VALUES ('a'),('A'),('b'),('B'),('c'),('C');
SELECT * FROM t1 WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin;
a
a
b
c
SELECT * FROM t1 WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin AND a='a';
a
a
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin AND a='a';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a` = 'a') and (`test`.`t1`.`a` between 'a' and <cache>(('c' collate latin1_bin))))
DROP TABLE t1;
#
# End of 10.1 tests # End of 10.1 tests
# #
...@@ -287,6 +287,17 @@ SELECT * FROM t1 WHERE a IN ('a' COLLATE latin1_bin,'b') AND a='a'; ...@@ -287,6 +287,17 @@ SELECT * FROM t1 WHERE a IN ('a' COLLATE latin1_bin,'b') AND a='a';
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN ('a' COLLATE latin1_bin,'b') AND a='a'; EXPLAIN EXTENDED SELECT * FROM t1 WHERE a IN ('a' COLLATE latin1_bin,'b') AND a='a';
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-8698 Wrong result for SELECT..WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin;
--echo #
SET NAMES latin1;
CREATE TABLE t1 (a VARCHAR(10));
INSERT INTO t1 VALUES ('a'),('A'),('b'),('B'),('c'),('C');
SELECT * FROM t1 WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin;
SELECT * FROM t1 WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin AND a='a';
EXPLAIN EXTENDED SELECT * FROM t1 WHERE a BETWEEN 'a' AND 'c' COLLATE latin1_bin AND a='a';
DROP TABLE t1;
--echo # --echo #
--echo # End of 10.1 tests --echo # End of 10.1 tests
--echo # --echo #
...@@ -2199,6 +2199,8 @@ void Item_func_between::fix_length_and_dec() ...@@ -2199,6 +2199,8 @@ void Item_func_between::fix_length_and_dec()
return; return;
if (agg_cmp_type(&m_compare_type, args, 3)) if (agg_cmp_type(&m_compare_type, args, 3))
return; return;
args[0]->cmp_context= args[1]->cmp_context= args[2]->cmp_context=
m_compare_type;
if (m_compare_type == STRING_RESULT && if (m_compare_type == STRING_RESULT &&
agg_arg_charsets_for_comparison(cmp_collation, args, 3)) agg_arg_charsets_for_comparison(cmp_collation, args, 3))
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment