From fe499575af62bebdc42f804645da089f8e268bc4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2006 14:52:11 +0300 Subject: 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. sql/sql_base.cc: Bug#20327: Marking of a wrong field leads to a wrong result on select with view, prepared statement and subquery. Now mark_select_range_as_dependent() function isn't called for fields from a view underlying table. mysql-test/r/ps.result: Added a test case for bug#20327: Marking of a wrong field leads to a wrong result on select with view, prepared statement and subquery. mysql-test/t/ps.test: Added a test case for bug#20327: Marking of a wrong field leads to a wrong result on select with view,prepared statement and subquery. --- sql/sql_base.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3984ceac6a9..314452fac89 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3303,6 +3303,12 @@ find_field_in_tables(THD *thd, Item_ident *item, { if (found == WRONG_GRANT) return (Field*) 0; + + /* + Only views fields should be marked as dependent, not an underlying + fields. + */ + if (!table_ref->belong_to_view) { SELECT_LEX *current_sel= thd->lex->current_select; SELECT_LEX *last_select= table_ref->select_lex; -- cgit v1.2.1