From ac2db256d9a390269a891a2addccf8ae1453cdb2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 3 Oct 2017 21:07:27 +0200 Subject: [PATCH] MDEV-12874 UPDATE statements with the same source and target fix --ps-protocol --- sql/sql_prepare.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 4df92c71006..9de0a6d0e99 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1400,6 +1400,7 @@ static int mysql_test_update(Prepared_statement *stmt, int res; THD *thd= stmt->thd; uint table_count= 0; + TABLE_LIST *update_source_table; SELECT_LEX *select= &stmt->lex->select_lex; #ifndef NO_EMBEDDED_ACCESS_CHECKS uint want_privilege; @@ -1413,9 +1414,11 @@ static int mysql_test_update(Prepared_statement *stmt, if (mysql_handle_derived(thd->lex, DT_INIT)) goto error; - 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;