Commit 7efcc279 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-27072 Subquery using the ALL keyword on date columns produces a wrong result

parent 81d7adb1
......@@ -932,5 +932,17 @@ Warning 1292 Incorrect datetime value: '1995.0000000'
Note 1003 select `test`.`t1`.`f` AS `f` from `test`.`t1` where '0000-00-00' between `test`.`t1`.`f` and <cache>('2012-12-12')
DROP TABLE t1;
#
# MDEV-27072 Subquery using the ALL keyword on date columns produces a wrong result
#
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('2021-11-17'), ('2021-10-17'),('2022-11-17'), ('2020-10-17');
SELECT * FROM t1 WHERE d >= ALL (SELECT * FROM t1);
d
2022-11-17
SELECT * FROM t1 WHERE d <= ALL (SELECT * FROM t1);
d
2020-10-17
DROP TABLE t1;
#
# End of 10.2 tests
#
......@@ -647,6 +647,15 @@ INSERT INTO t1 VALUES ('2020-01-01'),('2020-01-02');
EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1995.0000000 BETWEEN f AND '2012-12-12';
DROP TABLE t1;
--echo #
--echo # MDEV-27072 Subquery using the ALL keyword on date columns produces a wrong result
--echo #
CREATE TABLE t1 (d DATE);
INSERT INTO t1 VALUES ('2021-11-17'), ('2021-10-17'),('2022-11-17'), ('2020-10-17');
SELECT * FROM t1 WHERE d >= ALL (SELECT * FROM t1);
SELECT * FROM t1 WHERE d <= ALL (SELECT * FROM t1);
DROP TABLE t1;
--echo #
--echo # End of 10.2 tests
......
......@@ -3479,7 +3479,7 @@ bool select_max_min_finder_subselect::cmp_str()
but added for safety
*/
val1= cache->val_str(&buf1);
val2= maxmin->val_str(&buf1);
val2= maxmin->val_str(&buf2);
/* Ignore NULLs for ANY and keep them for ALL subqueries */
if (cache->null_value)
......
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