[Commits] 7f24e37: MDEV-25679 Wrong result selecting from simple view with LIMIT and ORDER BY

IgorBabaev igor at mariadb.com
Tue Jun 22 22:23:13 EEST 2021


revision-id: 7f24e37fbecd5af08ec473a7a1449f305977c6d7 (mariadb-10.4.11-659-g7f24e37)
parent(s): ce868cd89e352f7ce04d8db260f96893df2bf26c
author: Igor Babaev
committer: Igor Babaev
timestamp: 2021-06-22 12:23:13 -0700
message:

MDEV-25679 Wrong result selecting from simple view with LIMIT and ORDER BY

Cherry-picking only test case.

---
 mysql-test/main/derived_view.result | 21 +++++++++++++++++++++
 mysql-test/main/derived_view.test   | 17 +++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result
index 00940d8..f761a9f 100644
--- a/mysql-test/main/derived_view.result
+++ b/mysql-test/main/derived_view.result
@@ -3480,3 +3480,24 @@ Warnings:
 Note	1003	select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t1`.`a` = 3 and `test`.`t1`.`pk` <= 2
 drop view v1;
 drop table t1,t2,t3;
+#
+# MDEV-25679: view / derived table defined as ordered select with LIMIT
+#
+create table t1 (a int);
+insert into t1 values (3), (7), (1);
+create view v1 as (select a from t1 limit 2) order by a desc;
+(select a from t1 limit 2) order by a desc;
+a
+7
+3
+select * from v1;
+a
+7
+3
+select * from ((select a from t1 limit 2) order by a desc) dt;
+a
+3
+7
+drop view v1;
+drop table t1;
+# End of 10.2 tests
diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test
index 76b15fa..9ab1ddd 100644
--- a/mysql-test/main/derived_view.test
+++ b/mysql-test/main/derived_view.test
@@ -2273,3 +2273,20 @@ eval explain extended $q;
 
 drop view v1;
 drop table t1,t2,t3;
+
+--echo #
+--echo # MDEV-25679: view / derived table defined as ordered select with LIMIT
+--echo #
+
+create table t1 (a int);
+insert into t1 values (3), (7), (1);
+
+create view v1 as (select a from t1 limit 2) order by a desc;
+(select a from t1 limit 2) order by a desc;
+select * from v1;
+select * from ((select a from t1 limit 2) order by a desc) dt;
+
+drop view v1;
+drop table t1;
+
+--echo # End of 10.2 tests


More information about the commits mailing list