Commit c4930a82 authored by Sergei Golubchik's avatar Sergei Golubchik

don't set derived->merged until derived is really irreversibly merged

it was set before big if() that could decide not to merge and
go with materialization.

this fixes a crash in main.view test
parent 4771ae4b
......@@ -388,7 +388,6 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
thd->save_prep_leaf_list= TRUE;
arena= thd->activate_stmt_arena_if_needed(&backup); // For easier test
derived->merged= TRUE;
if (!derived->merged_for_insert ||
(derived->is_multitable() &&
......@@ -452,6 +451,7 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
if (parent_lex->join)
parent_lex->join->table_count+= dt_select->join->table_count - 1;
}
derived->merged= TRUE;
if (derived->get_unit()->prepared)
{
Item *expr= derived->on_expr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment