diff options
author | unknown <igor@olga.mysql.com> | 2007-03-20 11:51:09 -0700 |
---|---|---|
committer | unknown <igor@olga.mysql.com> | 2007-03-20 11:51:09 -0700 |
commit | 91f7f3181670523aa657420ae47d1d20fcd07aea (patch) | |
tree | 0fa99f2f4100ca4e7de6bbd904c82993d212493b /mysql-test/t | |
parent | 3798a7d5008f8f569f779f096b7fc1e1cfac1031 (diff) | |
download | mariadb-git-91f7f3181670523aa657420ae47d1d20fcd07aea.tar.gz |
Fixed bug #27257: queries containing subqueries with COUNT(*)
aggregated in outer context returned wrong results.
This happened only if the subquery did not contain any references
to outer fields.
As there were no references to outer fields the subquery erroneously
was taken for non-correlated one.
Now any set function aggregated in outer context makes the subquery
correlated.
mysql-test/r/subselect.result:
Added a test case for bug #27257.
mysql-test/t/subselect.test:
Added a test case for bug #27257.
Diffstat (limited to 'mysql-test/t')
-rw-r--r-- | mysql-test/t/subselect.test | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 1655422c51e..a238c8f070b 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2741,4 +2741,25 @@ SELECT * FROM (SELECT 'this is ' 'a test.' AS col1, a AS t2 FROM t1) t; DROP table t1; +# +# Bug #27257: COUNT(*) aggregated in outer query +# + +CREATE TABLE t1 (a int, b int); +CREATE TABLE t2 (m int, n int); +INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4); +INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44); +SELECT COUNT(*), a, + (SELECT m FROM t2 WHERE m = count(*) LIMIT 1) + FROM t1 GROUP BY a; + +SELECT COUNT(*), a, + (SELECT MIN(m) FROM t2 WHERE m = count(*)) + FROM t1 GROUP BY a; + +SELECT COUNT(*), a + FROM t1 GROUP BY a + HAVING (SELECT MIN(m) FROM t2 WHERE m = count(*)) > 1; + +DROP TABLE t1,t2; |