summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorkonstantin@mysql.com <>2004-10-22 22:51:16 +0400
committerkonstantin@mysql.com <>2004-10-22 22:51:16 +0400
commite3abcb6b535d7f6aac38305a8661629d95ce72d3 (patch)
tree9ddb77acd9ee81b116c0132fcd2d00fd6dc1342f /mysql-test
parent016d5adeeb77eec5d52bfaf57641b0d6c2bea2fa (diff)
downloadmariadb-git-e3abcb6b535d7f6aac38305a8661629d95ce72d3.tar.gz
A fix and test case for Bug#6088 "FOUND_ROWS returns wrong values for
prepared statements when LIMIT is used" and post-review comments. The fix changes the approach we calculate the need for ORDER BY in UNION: the previous was not PS friendly, as it damaged SELECT_LEX options in case of single select.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/ps.result24
-rw-r--r--mysql-test/r/subselect.result6
-rw-r--r--mysql-test/t/ps.test14
3 files changed, 41 insertions, 3 deletions
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 0950a066e64..036d50efbba 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -410,3 +410,27 @@ a a
1.1 1.2
2.1 2.2
deallocate prepare stmt;
+create table t1 (a int);
+insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+prepare stmt from "select sql_calc_found_rows * from t1 limit 2";
+execute stmt;
+a
+1
+2
+select found_rows();
+found_rows()
+10
+execute stmt;
+a
+1
+2
+select found_rows();
+found_rows()
+10
+execute stmt;
+a
+1
+2
+select found_rows();
+found_rows()
+10
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 8bcf7f9bff2..04c5f685f58 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -176,17 +176,17 @@ a b
a b
1 7
2 7
-3 8
4 8
+3 8
explain extended (select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using filesort
-3 UNION t4 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+3 UNION t4 ALL NULL NULL NULL NULL 3 Using where
4 SUBQUERY t2 ALL NULL NULL NULL NULL 2
NULL UNION RESULT <union1,3> ALL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 (select test.t2.a AS `a`,test.t2.b AS `b` from test.t2 where (test.t2.b = (select test.t3.a AS `a` from test.t3 order by test.t3.a desc limit 1))) union (select test.t4.a AS `a`,test.t4.b AS `b` from test.t4 where (test.t4.b = (select (max(test.t2.a) * 4) AS `max(t2.a)*4` from test.t2)) order by test.t4.a)
+Note 1003 (select test.t2.a AS `a`,test.t2.b AS `b` from test.t2 where (test.t2.b = (select test.t3.a AS `a` from test.t3 order by test.t3.a desc limit 1))) union (select test.t4.a AS `a`,test.t4.b AS `b` from test.t4 where (test.t4.b = (select (max(test.t2.a) * 4) AS `max(t2.a)*4` from test.t2)) order by a)
select (select a from t3 where a<t2.a*4 order by 1 desc limit 1), a from t2;
(select a from t3 where a<t2.a*4 order by 1 desc limit 1) a
3 1
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 04ab8aa62a8..5a32080a4c7 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -415,3 +415,17 @@ execute stmt;
execute stmt;
execute stmt;
deallocate prepare stmt;
+
+#
+# Bug#6088 "FOUND_ROWS returns wrong values for prepared statements when
+# LIMIT is used"
+#
+create table t1 (a int);
+insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+prepare stmt from "select sql_calc_found_rows * from t1 limit 2";
+execute stmt;
+select found_rows();
+execute stmt;
+select found_rows();
+execute stmt;
+select found_rows();