Commit e5daa094 authored by Sergei Golubchik's avatar Sergei Golubchik

5.3 merge

parents 759fa196 a1975dd2
This diff is collapsed.
This diff is collapsed.
...@@ -392,17 +392,13 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived) ...@@ -392,17 +392,13 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
if (parent_lex->get_free_table_map(&map, &tablenr)) if (parent_lex->get_free_table_map(&map, &tablenr))
{ {
/* There is no enough table bits, fall back to materialization. */ /* There is no enough table bits, fall back to materialization. */
derived->change_refs_to_fields(); goto unconditional_materialization;
derived->set_materialized_derived();
goto exit_merge;
} }
if (dt_select->leaf_tables.elements + tablenr > MAX_TABLES) if (dt_select->leaf_tables.elements + tablenr > MAX_TABLES)
{ {
/* There is no enough table bits, fall back to materialization. */ /* There is no enough table bits, fall back to materialization. */
derived->change_refs_to_fields(); goto unconditional_materialization;
derived->set_materialized_derived();
goto exit_merge;
} }
if (dt_select->options & OPTION_SCHEMA_TABLE) if (dt_select->options & OPTION_SCHEMA_TABLE)
...@@ -473,6 +469,15 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived) ...@@ -473,6 +469,15 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
if (arena) if (arena)
thd->restore_active_arena(arena, &backup); thd->restore_active_arena(arena, &backup);
DBUG_RETURN(res); DBUG_RETURN(res);
unconditional_materialization:
derived->change_refs_to_fields();
derived->set_materialized_derived();
if (!derived->table || !derived->table->created)
res= mysql_derived_create(thd, lex, derived);
if (!res)
res= mysql_derived_fill(thd, lex, derived);
goto exit_merge;
} }
......
...@@ -4975,6 +4975,10 @@ void TABLE_LIST::set_check_merged() ...@@ -4975,6 +4975,10 @@ void TABLE_LIST::set_check_merged()
void TABLE_LIST::set_check_materialized() void TABLE_LIST::set_check_materialized()
{ {
DBUG_ENTER("TABLE_LIST::set_check_materialized");
SELECT_LEX_UNIT *derived= this->derived;
if (view)
derived= &view->unit;
DBUG_ASSERT(derived); DBUG_ASSERT(derived);
if (!derived->first_select()->exclude_from_table_unique_test) if (!derived->first_select()->exclude_from_table_unique_test)
derived->set_unique_exclude(); derived->set_unique_exclude();
...@@ -4987,6 +4991,7 @@ void TABLE_LIST::set_check_materialized() ...@@ -4987,6 +4991,7 @@ void TABLE_LIST::set_check_materialized()
derived->first_select()->first_inner_unit()->first_select()-> derived->first_select()->first_inner_unit()->first_select()->
exclude_from_table_unique_test); exclude_from_table_unique_test);
} }
DBUG_VOID_RETURN;
} }
TABLE *TABLE_LIST::get_real_join_table() TABLE *TABLE_LIST::get_real_join_table()
......
...@@ -2096,7 +2096,7 @@ struct TABLE_LIST ...@@ -2096,7 +2096,7 @@ struct TABLE_LIST
void set_materialized_derived() void set_materialized_derived()
{ {
DBUG_ENTER("set_materialized_derived"); DBUG_ENTER("set_materialized_derived");
derived_type= ((derived_type & DTYPE_MASK) | derived_type= ((derived_type & (derived ? DTYPE_MASK : DTYPE_VIEW)) |
DTYPE_TABLE | DTYPE_MATERIALIZE); DTYPE_TABLE | DTYPE_MATERIALIZE);
set_check_materialized(); set_check_materialized();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
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