1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

BUG#849763: Wrong result with second execution of prepared statement with semijoin + view

- The problem was that Item_direct_view_ref and its embedded Item_field were getting incorrect
  value of item->used_tables() after fix_fields() in the second and subsequent EXECUTE.
- Made relevant fixes in Item_field::fix_fields() and find_field_in_tables(), so that the 
  Item_field gets the correct attributes.
This commit is contained in:
Sergey Petrunya
2011-09-20 20:40:07 +04:00
parent 27cd8d7b70
commit f0323a40d8
7 changed files with 110 additions and 2 deletions

View File

@ -6447,11 +6447,25 @@ find_field_in_tables(THD *thd, Item_ident *item,
{
SELECT_LEX *current_sel= thd->lex->current_select;
SELECT_LEX *last_select= table_ref->select_lex;
bool all_merged= TRUE;
for (SELECT_LEX *sl= current_sel; sl && sl!=last_select;
sl=sl->outer_select())
{
Item *subs= sl->master_unit()->item;
if (subs->type() == Item::SUBSELECT_ITEM &&
((Item_subselect*)subs)->substype() == Item_subselect::IN_SUBS &&
((Item_in_subselect*)subs)->in_strategy & SUBS_SEMI_JOIN)
{
continue;
}
all_merged= FALSE;
break;
}
/*
If the field was an outer referencee, mark all selects using this
sub query as dependent on the outer query
*/
if (current_sel != last_select)
if (!all_merged && current_sel != last_select)
{
mark_select_range_as_dependent(thd, last_select, current_sel,
found, *ref, item);