diff options
-rw-r--r-- | mysql-test/r/type_date.result | 12 | ||||
-rw-r--r-- | mysql-test/t/type_date.test | 9 | ||||
-rw-r--r-- | sql/sql_class.cc | 2 |
3 files changed, 22 insertions, 1 deletions
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index ee50b1c4f2d..8a45ede4851 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -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 # diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index fead1739c06..760427bf26c 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -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 diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2eec056ec9d..21c06029787 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -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) |