From: eugene Date: December 21 2005 5:27pm Subject: bk commit into 5.0 tree (evgen:1.1975) BUG#15706 List-Archive: http://lists.mysql.com/commits/331 X-Bug: 15706 Message-Id: <20051221172715.314F122DDBA@localhost.moonbone.local> Below is the list of changes that have just been committed into a local 5.0 repository of evgen. When evgen does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.1975 05/12/21 20:27:08 evgen@stripped +1 -0 Fix bug #15706 find_field_in_tables() returns field from outer select If item->cached_table is set, find_field_in_tables() returns found field even if it doesn't belong to current select. Because Item_field::fix_fields doesn't expect such behaviour, reported bug occurs. Ite_field::fix_fields() was modifed to detect when find_field_in_tables() can return field from outer select and process such fields accordingly. sql/item.cc 1.201 05/12/21 20:20:17 evgen@stripped +16 -4 Fix bug #15706 find_field_in_tables() returns field from outer select Item_field::fix_fields() modified to detect when find_field_in_tables() can return field from outer select and process such fields accordingly. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: evgen # Host: moonbone.local # Root: /work/15706-bug-5.0-mysql --- 1.200/sql/item.cc 2005-12-12 09:19:41 +03:00 +++ 1.201/sql/item.cc 2005-12-21 20:20:17 +03:00 @@ -3263,6 +3263,10 @@ { bool upward_lookup= FALSE; Field *from_field= (Field *)not_found_field; + /* True if find_field_in_tables() can return field from outer select. */ + bool outer_field= cached_table && cached_table->select_lex && + context->select_lex && + cached_table->select_lex != context->select_lex; /* In case of view, find_field_in_tables() write pointer to view field expression to 'reference', i.e. it substitute that expression instead @@ -3275,11 +3279,12 @@ IGNORE_EXCEPT_NON_UNIQUE, !any_privileges, TRUE)) == - not_found_field) + not_found_field || outer_field) { - + if (from_field == not_found_field) + outer_field= 0; /* Look up in current select's item_list to find aliased fields */ - if (thd->lex->current_select->is_item_list_lookup) + if (!outer_field && thd->lex->current_select->is_item_list_lookup) { uint counter; bool not_used; @@ -3317,11 +3322,18 @@ place= prev_subselect_item->parsing_place; /* + If outer_field is set, field was already found by first call + to find_field_in_tables(). Only need to find appropriate context. + */ + if (outer_field && outer_context->select_lex != + cached_table->select_lex) + continue; + /* In case of a view, find_field_in_tables() writes the pointer to the found view field into '*reference', in other words, it substitutes this Item_field with the found expression. */ - if ((from_field= find_field_in_tables(thd, this, + if (outer_field || (from_field= find_field_in_tables(thd, this, outer_context-> first_name_resolution_table, outer_context->