summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2021-04-22 20:02:08 -0700
committerIgor Babaev <igor@askmonty.org>2021-04-22 20:02:08 -0700
commite3a25793be936d9682a711a00d6b4bf708b6fb8d (patch)
tree6f1047164d7df4499687d1e598d7b46128fcf200 /sql/sql_class.h
parent6f271302b649ee11e7987b46fe24824c2ca2be7c (diff)
downloadmariadb-git-e3a25793be936d9682a711a00d6b4bf708b6fb8d.tar.gz
MDEV-24823 Crash with invalid multi-table update of view in 2nd execution of SP
Before this patch mergeable derived tables / view used in a multi-table update / delete were merged before the preparation stage. When the merge of a derived table / view is performed the on expression attached to it is fixed and ANDed with the where condition of the select S containing this derived table / view. It happens after the specification of the derived table / view has been merged into S. If the ON expression refers to a non existing field an error is reported and some other mergeable derived tables / views remain unmerged. It's not a problem if the multi-table update / delete statement is standalone. Yet if it is used in a stored procedure the select with incompletely merged derived tables / views may cause a problem for the second call of the procedure. This does not happen for select queries using derived tables / views, because in this case their specifications are merged after the preparation stage at which all ON expressions are fixed. This patch makes sure that merging of the derived tables / views used in a multi-table update / delete statement is performed after the preparation stage. Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 5ab93de7957..4f0df744b92 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -6117,7 +6117,8 @@ public:
class multi_update :public select_result_interceptor
{
TABLE_LIST *all_tables; /* query/update command tables */
- List<TABLE_LIST> *leaves; /* list of leves of join table tree */
+ List<TABLE_LIST> *leaves; /* list of leaves of join table tree */
+ List<TABLE_LIST> updated_leaves; /* list of of updated leaves */
TABLE_LIST *update_tables;
TABLE **tmp_tables, *main_table, *table_to_update;
TMP_TABLE_PARAM *tmp_table_param;
@@ -6155,6 +6156,7 @@ public:
List<Item> *fields, List<Item> *values,
enum_duplicates handle_duplicates, bool ignore);
~multi_update();
+ bool init(THD *thd);
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
int send_data(List<Item> &items);
bool initialize_tables (JOIN *join);