1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-12874 UPDATE statements with the same source and target

This commit is contained in:
halfspawn
2017-09-26 11:52:31 +02:00
committed by Sergei Golubchik
parent 26ff92f7ac
commit 1a74d12da6
19 changed files with 1598 additions and 366 deletions

View File

@ -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