summaryrefslogtreecommitdiff
path: root/mysql-test/t/limit.test
diff options
context:
space:
mode:
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 6df865278f6..cf7789428b2 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