mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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.
This commit is contained in:
@ -1334,3 +1334,37 @@ a b sum(a)
|
||||
1 2 1
|
||||
1 3 1
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-25441
|
||||
# WITH TIES is not respected with SQL_BUFFER_RESULT and constant in ORDER BY
|
||||
#
|
||||
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;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using temporary
|
||||
SELECT SQL_BUFFER_RESULT 1 AS f FROM t1 ORDER BY f FETCH NEXT 2 ROW WITH TIES;
|
||||
f
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT 1 AS f FROM t1 ORDER BY f FETCH NEXT 2 ROW WITH TIES;
|
||||
f
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
drop table t1;
|
||||
|
Reference in New Issue
Block a user