Bug #20327 | incorrect results with views, server-side prepared stmts, correlated subquery | ||
---|---|---|---|
Submitted: | 7 Jun 2006 23:14 | Modified: | 13 Dec 2006 19:03 |
Reporter: | Alex Burgel | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Prepared statements | Severity: | S2 (Serious) |
Version: | 5.0.22 | OS: | Linux (linux 2.4.21) |
Assigned to: | Evgeny Potemkin | CPU Architecture: | Any |
[7 Jun 2006 23:14]
Alex Burgel
[17 Oct 2006 13:13]
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/13800 ChangeSet@1.2261, 2006-10-17 17:08:00+04:00, kroki@moonlight.intranet +4 -0 BUG#20327: incorrect results with views, server-side prepared stmts, correlated subquery. A query with sub-SELECT that references fields of a VIEW from outer SELECT could return wrong result if used from prepared statement. The bug happened because during statement preparation fields of a view were merged, and on execution we marked such merged fields as dependent on outer select, though only fields of a view itself should be marked so. The solution is to not mark as dependent fields merged from a view.
[20 Nov 2006 20:30]
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/15576 ChangeSet@1.2302, 2006-11-20 23:32:10+03:00, evgen@moonbone.local +2 -0 Bug#20327: Marking of a wrong field leads to a wrong result on select with view, prepared statement and subquery. When a field of a view from an outer select is resolved the find_field_in_view function creates an Item_direct_view_ref object that references the corresponding view underlying field. After that the view_ref is marked as a dependent one. While resolving view underlying field it also get marked as a dependent one due to current_select still points to the subselect. Marking the view underlying field is wrong and lead to attaching conditions to a wrong table and thus to the wrong result of the whole statement. Now mark_select_range_as_dependent() function isn't called for fields from a view underlying table.
[1 Dec 2006 9:35]
Georgi Kodinov
Pushed in 5.0.32/5.1.14-beta
[13 Dec 2006 19:03]
Paul DuBois
Noted in 5.0.32, 5.1.14 changelogs. A query with a subquery that references columns of a view from the outer SELECT could return an incorrect result if used from a prepared statement.