diff options
Diffstat (limited to 'sql/sql_derived.cc')
-rw-r--r-- | sql/sql_derived.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 526d2445d3d..2992bb0da6e 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -87,7 +87,16 @@ mysql_handle_derived(LEX *lex, uint phases) sl && !res; sl= sl->next_select_in_list()) { - for (TABLE_LIST *cursor= sl->get_table_list(); + TABLE_LIST *cursor= sl->get_table_list(); + /* + DT_MERGE_FOR_INSERT is not needed for views/derived tables inside + subqueries. Views and derived tables of subqueries should be + processed normally. + */ + if (phases == DT_MERGE_FOR_INSERT && + cursor && cursor->top_table()->select_lex != &lex->select_lex) + continue; + for (; cursor && !res; cursor= cursor->next_local) { @@ -812,8 +821,7 @@ bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived) result->tmp_table_param.start_recinfo, &result->tmp_table_param.recinfo, (unit->first_select()->options | - thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS), - thd->variables.big_tables)) + thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS))) return(TRUE); } if (open_tmp_table(table)) |