Commit 7b134ffa authored by Monty's avatar Monty Committed by Sergei Golubchik

Make LEX::can_not_use_merged more general

parent f2e3f0db
......@@ -4076,6 +4076,10 @@ bool LEX::can_use_merged()
SYNOPSIS
LEX::can_not_use_merged()
@param no_update_or_delete Set to 1 if we can't use merge with multiple-table
updates, like when used from
TALE_LIST::init_derived()
DESCRIPTION
Temporary table algorithm will be used on all SELECT levels for queries
listed here (see also LEX::can_use_merged()).
......@@ -4085,10 +4089,9 @@ bool LEX::can_use_merged()
TRUE - VIEWs with MERGE algorithms can be used
*/
bool LEX::can_not_use_merged()
bool LEX::can_not_use_merged(bool no_update_or_delete)
{
switch (sql_command)
{
switch (sql_command) {
case SQLCOM_CREATE_VIEW:
case SQLCOM_SHOW_CREATE:
/*
......@@ -4098,6 +4101,13 @@ bool LEX::can_not_use_merged()
*/
case SQLCOM_SHOW_FIELDS:
return TRUE;
case SQLCOM_UPDATE_MULTI:
case SQLCOM_DELETE_MULTI:
if (no_update_or_delete)
return TRUE;
/* Fall through */
default:
return FALSE;
}
......
......@@ -3641,7 +3641,7 @@ struct LEX: public Query_tables_list
bool can_be_merged();
bool can_use_merged();
bool can_not_use_merged();
bool can_not_use_merged(bool no_update_or_delete);
bool only_view_structure();
bool need_correct_ident();
uint8 get_effective_with_check(TABLE_LIST *view);
......
......@@ -1687,7 +1687,7 @@ bool mysql_make_view(THD *thd, TABLE_SHARE *share, TABLE_LIST *table,
if (view_is_mergeable &&
(table->select_lex->master_unit() != &old_lex->unit ||
old_lex->can_use_merged()) &&
!old_lex->can_not_use_merged())
!old_lex->can_not_use_merged(0))
{
/* lex should contain at least one table */
DBUG_ASSERT(view_main_select_tables != 0);
......
......@@ -9341,9 +9341,7 @@ bool TABLE_LIST::init_derived(THD *thd, bool init_view)
/* A subquery might be forced to be materialized due to a side-effect. */
if (!is_materialized_derived() && first_select->is_mergeable() &&
optimizer_flag(thd, OPTIMIZER_SWITCH_DERIVED_MERGE) &&
!thd->lex->can_not_use_merged() &&
!(thd->lex->sql_command == SQLCOM_UPDATE_MULTI ||
thd->lex->sql_command == SQLCOM_DELETE_MULTI) &&
!thd->lex->can_not_use_merged(1) &&
!is_recursive_with_table())
set_merged_derived();
else
......
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