diff options
author | Igor Babaev <igor@askmonty.org> | 2020-10-13 12:25:09 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2020-10-13 12:25:09 -0700 |
commit | aa0b5d6965c75c8b1c3659f064dc62a7a271f2d0 (patch) | |
tree | bf0773e39489a5f89f10a4249e29da4c9b8d2329 /sql/sql_prepare.cc | |
parent | 393ad0215fa4f1833650c801133ae1806cc63ef4 (diff) | |
download | mariadb-git-10.5-mdev-18511.tar.gz |
MDEV-18511: CTE support for UPDATE and DELETE statements10.5-mdev-18511
MDEV-23552: Merge mergeable derived tables used at the top level of UPDATE
statements
A complement for the previous patch that allows to run successfully all
tests from
derived_update.test, cte_update.test, view_update.test,
derived_update_multi.test, cte_update_multi.test, view_update_multi.test
and from
view.test, derived.test, derived_view.test,
cte_nonrecursive, cte recursive
with --ps-protocol.
Some tests from view.test and derived_view were changed though. Later this
will be fixed.
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r-- | sql/sql_prepare.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 54288f273d9..bb163e06c6e 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1368,12 +1368,19 @@ static int mysql_test_update(Prepared_statement *stmt, open_tables(thd, &table_list, &table_count, MYSQL_OPEN_FORCE_SHARED_MDL)) goto error; - if (mysql_handle_derived(thd->lex, DT_INIT)) - goto error; + for (TABLE_LIST *tbl= thd->lex->query_tables; tbl; tbl= tbl->next_global) + { + if (tbl->handle_derived(thd->lex, DT_INIT)) + DBUG_RETURN(1); + } + + table_list->single_table_update= table_list->single_table_updatable(thd); - if (((update_source_table= unique_table(thd, table_list, - table_list->next_global, 0)) || - table_list->is_multitable())) + if ((update_source_table= unique_table(thd, table_list, + table_list->next_global, 0)) || + table_list->is_multitable() || + (table_list->single_table_update && + (update_source_table= table_list->find_table_for_update(thd)))) { DBUG_ASSERT(update_source_table || table_list->view != 0); DBUG_PRINT("info", ("Switch to multi-update")); |