summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-11-13 12:55:40 +0200
committerMonty <monty@mariadb.org>2021-01-28 11:50:54 +0200
commit5430e126973a267597d49e15f5c96e7b94a207c9 (patch)
tree511eed0ef017d3d871605dc18420c04bc2c2681a
parent78025d81a10ce7d92ff792a50f7e68aff3234e04 (diff)
downloadmariadb-git-5430e126973a267597d49e15f5c96e7b94a207c9.tar.gz
Make LEX::can_not_use_merged more general
-rw-r--r--sql/sql_lex.cc16
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_view.cc2
-rw-r--r--sql/table.cc4
4 files changed, 16 insertions, 8 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 663fdfbb56d..a567194fd49 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -4028,6 +4028,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()).
@@ -4037,10 +4041,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:
/*
@@ -4050,6 +4053,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;
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index b7aa0cb5cd2..4c904a4f15d 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -3616,7 +3616,7 @@ public:
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);
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 6933e8e2358..f2523c66bd6 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -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);
diff --git a/sql/table.cc b/sql/table.cc
index 2515f337e46..57b1e10fd3f 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -9249,9 +9249,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