summaryrefslogtreecommitdiff
path: root/mysql-test/main/fetch_first.test
diff options
context:
space:
mode:
authorVicențiu Ciorbaru <vicentiu@mariadb.org>2021-04-18 22:58:34 +0300
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2021-04-21 14:09:17 +0300
commitaeccdddedd5d3d306dd317e6b366d50bc807726b (patch)
tree2bbd7733374407baad2c7b4547d5d0b87ccca247 /mysql-test/main/fetch_first.test
parent44a6af65f56ccbcb9a7ca6ba1d021a2b23c07666 (diff)
downloadmariadb-git-aeccdddedd5d3d306dd317e6b366d50bc807726b.tar.gz
MDEV-25441 WITH TIES is not respected with SQL_BUFFER_RESULT and constant in ORDER BY
Pushing LIMIT to temp aggregation table is possible, but not when WITH TIES is used. In a degenerate case with constant ORDER BY, the constant gets removed and the code assumed the limit is push-able. Ensure that if WITH TIES is present, that this does not happen.
Diffstat (limited to 'mysql-test/main/fetch_first.test')
-rw-r--r--mysql-test/main/fetch_first.test11
1 files changed, 11 insertions, 0 deletions
diff --git a/mysql-test/main/fetch_first.test b/mysql-test/main/fetch_first.test
index 6995c1cb5b1..76c0a8b8b39 100644
--- a/mysql-test/main/fetch_first.test
+++ b/mysql-test/main/fetch_first.test
@@ -1028,6 +1028,17 @@ group by a, b
order by (select 1), a
fetch first 1 rows with ties;
+drop table t1;
+
+--echo #
+--echo # MDEV-25441
+--echo # WITH TIES is not respected with SQL_BUFFER_RESULT and constant in ORDER BY
+--echo #
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+explain SELECT SQL_BUFFER_RESULT 1 AS f FROM t1 ORDER BY f FETCH NEXT 2 ROW WITH TIES;
+SELECT SQL_BUFFER_RESULT 1 AS f FROM t1 ORDER BY f FETCH NEXT 2 ROW WITH TIES;
+SELECT 1 AS f FROM t1 ORDER BY f FETCH NEXT 2 ROW WITH TIES;
drop table t1;