From 2a00a073c2c07f2d73d60a6c74c538874f05158b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Sep 2006 19:04:46 +0300 Subject: Bug #21540: Subqueries with no from and aggregate functions return wrong results Mark the containing Item(s) (Item_subselect descendant usually) of a subselect as containing aggregate functions if it has references to aggregates functions that are calculated outside its context. This tels end_send_group() not to make an Item_subselect descendant in select list a copy and causes the correct value being returned. mysql-test/r/func_group.result: Bug #21540: Subqueries with no from and aggregate functions return wrong results - test cases mysql-test/r/subselect.result: Bug #21540: Subqueries with no from and aggregate functions return wrong results - fixed the result of an existing testcase. mysql-test/t/subselect.test: Bug #21540: Subqueries with no from and aggregate functions return wrong results - test cases sql/item_sum.cc: Bug #21540: Subqueries with no from and aggregate functions return wrong results Mark the containing Item (Item_subselect descendant usually) of a subselect as containing aggregate functions if it has references to aggregates functions that are calculated outside its context. This tels end_send_group() not to make an Item_subselect descendant in select list a copy and causes the correct value being returned. --- mysql-test/r/func_group.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test/r/func_group.result') diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index f57b4ad6ce9..da2a7518c86 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -997,7 +997,7 @@ SELECT SQL_NO_CACHE WHERE ttt.a = ccc.b AND ttt.a = t.a GROUP BY ttt.a) AS minid FROM t1 t, t2 c WHERE t.a = c.b; minid -NULL +1 DROP TABLE t1,t2; create table t1 select variance(0); show create table t1; -- cgit v1.2.1 From a952b3fcb21cd09ab00775d10d440cf8df0c48dd Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Sep 2006 12:02:58 +0300 Subject: fixed merge --- mysql-test/r/func_group.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test/r/func_group.result') diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 32d6931c334..c6117053a60 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -860,8 +860,8 @@ CREATE TABLE t1 (a INT, b INT); INSERT INTO t1 VALUES (1,1),(1,2),(2,3); SELECT (SELECT COUNT(DISTINCT t1.b)) FROM t1 GROUP BY t1.a; (SELECT COUNT(DISTINCT t1.b)) -0 2 +1 SELECT (SELECT COUNT(DISTINCT 12)) FROM t1 GROUP BY t1.a; (SELECT COUNT(DISTINCT 12)) 1 -- cgit v1.2.1