summaryrefslogtreecommitdiff
path: root/mysql-test/r/subselect3.result
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-04-15 08:31:34 +0400
committerunknown <evgen@moonbone.local>2007-04-15 08:31:34 +0400
commit1cf3b96513db0ca2a0e217e2be512cdcaa04c82e (patch)
treedb1a04d110b3d1a52904be6a4dc49835a46c7e4e /mysql-test/r/subselect3.result
parent6e93d2939df73eceb8b39e0c2e08e96fb4c764d2 (diff)
downloadmariadb-git-1cf3b96513db0ca2a0e217e2be512cdcaa04c82e.tar.gz
Bug#27321: Wrong subquery result in a grouping select.
The Item_outer_ref class based on the Item_direct_ref class was always used to represent an outer field. But if the outer select is a grouping one and the outer field isn't under an aggregate function which is aggregated in that outer select an Item_ref object should be used to represent such a field. If the outer select in which the outer field is resolved isn't grouping then the Item_field class should be used to represent such a field. This logic also should be used for an outer field resolved through its alias name. Now the Item_field::fix_outer_field() uses Item_outer_field objects to represent aliased and non-aliased outer fields for grouping outer selects only. Now the fix_inner_refs() function chooses which class to use to access outer field - the Item_ref or the Item_direct_ref. An object of the chosen class substitutes the original field in the Item_outer_ref object. The direct_ref and the found_in_select_list fields were added to the Item_outer_ref class. mysql-test/t/subselect3.test: Some test cases were corrected after the fix for the bug#27321. mysql-test/r/subselect3.result: Some test cases were corrected after the fix for the bug#27321. mysql-test/t/subselect.test: Added a test case for the bug#27321: Wrong subquery result in a grouping select. mysql-test/r/subselect.result: Added a test case for the bug#27321: Wrong subquery result in a grouping select. Some test cases were corrected after this fix. sql/sql_union.cc: Bug#27321: Wrong subquery result in a grouping select. Cleanup of the inner_refs_list. sql/sql_select.cc: Bug#27321: Wrong subquery result in a grouping select. Now the fix_inner_refs() function chooses which class to use to access outer field - the Item_ref or the Item_direct_ref. An object of the chosen class substitutes the original field in the Item_outer_ref object. A comment is corrected. sql/item.cc: Bug#27321: Wrong subquery result in a grouping select. Now the Item_field::fix_outer_field() uses Item_outer_field objects to represent aliased and non-aliased outer fields for grouping outer selects only. sql/item.h: Bug#27321: Wrong subquery result in a grouping select. The direct_ref and the found_in_select_list fields were added to the Item_outer_ref class.
Diffstat (limited to 'mysql-test/r/subselect3.result')
-rw-r--r--mysql-test/r/subselect3.result10
1 files changed, 2 insertions, 8 deletions
diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result
index 6a7a601ccf9..33e7fc54ed2 100644
--- a/mysql-test/r/subselect3.result
+++ b/mysql-test/r/subselect3.result
@@ -432,7 +432,7 @@ alter table t1 add index idx(oref,ie);
explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 7
-2 DEPENDENT SUBQUERY t1 ref_or_null idx idx 10 t2.oref,func 4 Using where; Using index; Full scan on NULL key
+2 DEPENDENT SUBQUERY t1 ref_or_null idx idx 10 test.t2.oref,func 4 Using where; Using index; Full scan on NULL key
select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2;
oref a Z
ee NULL NULL
@@ -457,7 +457,7 @@ group by grp having min(ie) > 1) Z
from t2;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 7
-2 DEPENDENT SUBQUERY t1 ref idx idx 5 t2.oref 2 Using where; Using temporary; Using filesort
+2 DEPENDENT SUBQUERY t1 ref idx idx 5 test.t2.oref 2 Using where; Using temporary; Using filesort
select oref, a,
a in (select min(ie) from t1 where oref=t2.oref
group by grp having min(ie) > 1) Z
@@ -661,12 +661,6 @@ SELECT * FROM t1 GROUP by t1.a
HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c
HAVING MAX(t2.b+t1.a) < 10));
a b c
-SELECT a, AVG(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=AVG(t1.b))
-AS test FROM t1 GROUP BY a;
-a AVG(b) test
-1 4.0000 NULL
-2 2.0000 k
-3 2.5000 NULL
SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c;
a b c
1 3 c