Bug #27321 Wrong result for outer references in scalar subqueries with aggregates
| Submitted: | 21 Mar 2007 8:59 | Modified: | 17 Apr 2007 20:01 |
|---|---|---|---|
| Reporter: | Georgi Kodinov | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
| Version: | 5.0-bk | OS: | Any |
| Assigned to: | Evgeny Potemkin | CPU Architecture: | Any |
[21 Mar 2007 8:59]
Georgi Kodinov
[31 Mar 2007 22:02]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/23479 ChangeSet@1.2421, 2007-04-01 02:00:09+04:00, evgen@moonbone.local +7 -0 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 the Item_ref should be used to represent such a field.
[31 Mar 2007 23:18]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/23480 ChangeSet@1.2421, 2007-04-01 03:16:50+04:00, evgen@moonbone.local +7 -0 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 the Item_ref 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. Item_outer_ref::val_xxx() methods were added. The direct_ref and the found_in_select_list fields were added to the Item_outer_ref class. Now the fix_inner_refs() function resolves which set of functions, val_xxx() or val_xxx_result(), will be used by an Item_outer_ref object.
[2 Apr 2007 14:45]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/23555 ChangeSet@1.2421, 2007-04-02 18:42:41+04:00, evgen@moonbone.local +8 -0 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 the Item_ref 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. Item_outer_ref::val_xxx() methods were added. The direct_ref and the found_in_select_list fields were added to the Item_outer_ref class. Now the fix_inner_refs() function resolves which set of functions, val_xxx() or val_xxx_result(), will be used by an Item_outer_ref object.
[3 Apr 2007 18:52]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/23707 ChangeSet@1.2421, 2007-04-03 22:49:31+04:00, evgen@moonbone.local +8 -0 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 the Item_ref 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 choose which class to use to access outer field - the Item_ref or the Item_direct_ref. An object of 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.
[13 Apr 2007 17:49]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/24514 ChangeSet@1.2421, 2007-04-13 21:47:38+04:00, evgen@moonbone.local +8 -0 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 the Item_ref 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 choose which class to use to access outer field - the Item_ref or the Item_direct_ref. An object of 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.
[14 Apr 2007 20:21]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/24557 ChangeSet@1.2421, 2007-04-15 00:18:13+04:00, evgen@moonbone.local +8 -0 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.
[15 Apr 2007 16:48]
Bugs System
Pushed into 5.1.18-beta
[15 Apr 2007 16:53]
Bugs System
Pushed into 5.0.40
[15 Apr 2007 17:10]
Igor Babaev
Pushed into 5.1.18-beta Pushed into 5.0.40 Pushed into 4.1.23
[17 Apr 2007 20:01]
Paul DuBois
Noted in 4.1.23, 5.0.40, 5.1.18 changelogs. A subquery could get incorrect values for references to outer query columns when it contained aggregate functions that were aggregated in outer context.
[7 Jun 2007 16:22]
Evgeny Potemkin
Fix for this bug was pushed to 5.0+ only.
[22 Jun 2007 19:16]
Haris Javaid
We moved to 5.0.41 recently and one of our queries broke due to this bug. The subquery is referencing a column from the outer query and there's an aggregate function used in the outer query context.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.048 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.