Commit bb28bffc authored by Igor Babaev's avatar Igor Babaev

Ported the test case for MDEV-25682 from 10.2

No fix for this bug is needed starting from version 10.4.
parent ddddfc33
......@@ -3536,6 +3536,31 @@ SET max_length_for_sort_data=@save_max_length_for_sort_data;
SET max_sort_length= @save_max_sort_length;
SET sql_select_limit= @save_sql_select_limit;
DROP TABLE t1;
#
# MDEV-25682: EXPLAIN for SELECT with ORDER BY after [ORDER BY] LIMIT
#
create table t1 (a int);
insert into t1 values (3), (7), (1);
explain (select a from t1 limit 2) order by a desc;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using filesort
2 DERIVED t1 ALL NULL NULL NULL NULL 3
(select a from t1 limit 2) order by a desc;
a
7
3
create table t2 (a int, b int);
insert into t2 values (3,70), (7,10), (1,40), (4,30);
explain (select b,a from t2 order by a limit 3) order by b desc;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using filesort
2 DERIVED t2 ALL NULL NULL NULL NULL 4 Using filesort
(select b,a from t2 order by a limit 3) order by b desc;
b a
70 3
40 1
30 4
drop table t1,t2;
# End of 10.2 tests
#
# MDEV-16214: Incorrect plan taken by the optimizer , uses INDEX instead of ref access with ORDER BY
......
......@@ -2294,6 +2294,22 @@ SET max_sort_length= @save_max_sort_length;
SET sql_select_limit= @save_sql_select_limit;
DROP TABLE t1;
--echo #
--echo # MDEV-25682: EXPLAIN for SELECT with ORDER BY after [ORDER BY] LIMIT
--echo #
create table t1 (a int);
insert into t1 values (3), (7), (1);
explain (select a from t1 limit 2) order by a desc;
(select a from t1 limit 2) order by a desc;
create table t2 (a int, b int);
insert into t2 values (3,70), (7,10), (1,40), (4,30);
explain (select b,a from t2 order by a limit 3) order by b desc;
(select b,a from t2 order by a limit 3) order by b desc;
drop table t1,t2;
--echo # End of 10.2 tests
--echo #
......
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