summaryrefslogtreecommitdiff
path: root/mysql-test/t/limit.test
diff options
context:
space:
mode:
authortimour/timka@lamia.home <>2006-09-01 15:07:04 +0300
committertimour/timka@lamia.home <>2006-09-01 15:07:04 +0300
commit02e194cea215910dedf35f5141ecf442d6ef5407 (patch)
tree3e3f57b1259be8b80af868ee4f4c15dbf692b032 /mysql-test/t/limit.test
parent50ae5b7989e6148bee11a718c72ebfdade2ccdc8 (diff)
downloadmariadb-git-02e194cea215910dedf35f5141ecf442d6ef5407.tar.gz
Fix for BUG#21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
The problem was due to a prior fix for BUG 9676, which limited the rows stored in a temporary table to the LIMIT clause. This optimization is not applicable to non-group queries with aggregate functions. The fix disables the optimization in this case.
Diffstat (limited to 'mysql-test/t/limit.test')
-rw-r--r--mysql-test/t/limit.test10
1 files changed, 10 insertions, 0 deletions
diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test
index ef9f63067a4..f70cf835588 100644
--- a/mysql-test/t/limit.test
+++ b/mysql-test/t/limit.test
@@ -60,4 +60,14 @@ select 1 as a from t1 union all select 1 from dual limit 1;
(select 1 as a from t1) union all (select 1 from dual) limit 1;
drop table t1;
+#
+# Bug #21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
+#
+create table t1 (a int);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+
# End of 4.1 tests