summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2011-09-20 20:40:07 +0400
committerSergey Petrunya <psergey@askmonty.org>2011-09-20 20:40:07 +0400
commitf0323a40d8cbc5228015c1565a4800fd05fd61a8 (patch)
treecefb6b9ba9567df1f2b6a56dd9a26206469d887f /sql/sql_base.cc
parent27cd8d7b70cc22693b9dab35ac2d1e720b8fc7a7 (diff)
downloadmariadb-git-f0323a40d8cbc5228015c1565a4800fd05fd61a8.tar.gz
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.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index bca8167f2b9..e2142bc2734 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -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);