summaryrefslogtreecommitdiff
path: root/sql/sql_update.h
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2022-07-11 16:57:37 -0700
committerIgor Babaev <igor@askmonty.org>2023-03-15 17:35:22 -0700
commit88ca62dc689fa66d798c129a101069946acc828c (patch)
tree2ed5405f9a24f2ca16e7e99cf097d6f3771d3619 /sql/sql_update.h
parent3a9358a4106a1bd0ae2414f6f0bda50afdd65f0a (diff)
downloadmariadb-git-88ca62dc689fa66d798c129a101069946acc828c.tar.gz
MDEV-28965 Assertion failure when preparing UPDATE with derived table in WHERE
This patch fixes not only the assertion failure in the function Field_iterator_table_ref::set_field_iterator() but also: - fixes the problem of forced materialization of derived tables used in subqueries contained in WHERE clauses of single-table and multi-table UPDATE and DELETE statements - fixes the problem of MDEV-17954 that prevented execution of multi-table DELETE statements if they use in their WHERE clauses references to the tables that are updated. The patch must be considered a complement to the patch for MDEV-28883. Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'sql/sql_update.h')
-rw-r--r--sql/sql_update.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/sql/sql_update.h b/sql/sql_update.h
index d0fc7cb01e1..bd7d58cf97d 100644
--- a/sql/sql_update.h
+++ b/sql/sql_update.h
@@ -46,12 +46,12 @@ class Sql_cmd_update final : public Sql_cmd_dml
{
public:
Sql_cmd_update(bool multitable_arg)
- : multitable(multitable_arg)
- { }
+ : orig_multitable(multitable_arg), multitable(multitable_arg)
+ {}
enum_sql_command sql_command_code() const override
{
- return multitable ? SQLCOM_UPDATE_MULTI : SQLCOM_UPDATE;
+ return orig_multitable ? SQLCOM_UPDATE_MULTI : SQLCOM_UPDATE;
}
DML_prelocking_strategy *get_dml_prelocking_strategy()
@@ -59,6 +59,12 @@ public:
return &multiupdate_prelocking_strategy;
}
+ bool processing_as_multitable_update_prohibited(THD *thd);
+
+ bool is_multitable() { return multitable; }
+
+ void set_as_multitable() { multitable= true; }
+
protected:
/**
@brief Perform precheck of table privileges for update statements
@@ -82,6 +88,9 @@ private:
*/
bool update_single_table(THD *thd);
+ /* Original value of the 'multitable' flag set by constructor */
+ const bool orig_multitable;
+
/*
True if the statement is a multi-table update or converted to such.
For a single-table update this flag is set to true if the statement
@@ -95,7 +104,6 @@ private:
public:
/* The list of the updating expressions used in the set clause */
List<Item> *update_value_list;
-
};
#endif /* SQL_UPDATE_INCLUDED */