diff options
author | halfspawn <j.brauge@qualiac.com> | 2017-09-26 11:52:31 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-10-03 20:23:34 +0200 |
commit | 1a74d12da674d49304ffdc62e100ba8d19f90f13 (patch) | |
tree | c7cfd2b8f5a65ab3a4d38cb8ae1710eba821da14 /sql | |
parent | 26ff92f7ac2dc373769b8053e936e4593a2ee302 (diff) | |
download | mariadb-git-1a74d12da674d49304ffdc62e100ba8d19f90f13.tar.gz |
MDEV-12874 UPDATE statements with the same source and target
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_update.cc | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index a0c1f3598b5..c6959509a08 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -278,6 +278,7 @@ int mysql_update(THD *thd, killed_state killed_status= NOT_KILLED; Update_plan query_plan(thd->mem_root); Explain_update *explain; + TABLE_LIST *update_source_table; query_plan.index= MAX_KEY; query_plan.using_filesort= FALSE; DBUG_ENTER("mysql_update"); @@ -290,9 +291,11 @@ int mysql_update(THD *thd, if (mysql_handle_derived(thd->lex, DT_INIT)) DBUG_RETURN(1); - if (table_list->is_multitable()) + if (((update_source_table=unique_table(thd, table_list, + table_list->next_global, 0)) || + table_list->is_multitable())) { - DBUG_ASSERT(table_list->view != 0); + DBUG_ASSERT(update_source_table || table_list->view != 0); DBUG_PRINT("info", ("Switch to multi-update")); /* pass counter value */ thd->lex->table_count= table_count; @@ -1540,16 +1543,6 @@ int mysql_multi_update_prepare(THD *thd) } DBUG_PRINT("info", ("table: %s want_privilege: %u", tl->alias, (uint) table->grant.want_privilege)); - if (tl->lock_type != TL_READ && - tl->lock_type != TL_READ_NO_INSERT) - { - TABLE_LIST *duplicate; - if ((duplicate= unique_table(thd, tl, table_list, 0))) - { - update_non_unique_table_error(table_list, "UPDATE", duplicate); - DBUG_RETURN(TRUE); - } - } } /* Set exclude_from_table_unique_test value back to FALSE. It is needed for |