1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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>
This commit is contained in:
Igor Babaev
2022-07-11 16:57:37 -07:00
parent 3a9358a410
commit 88ca62dc68
27 changed files with 1106 additions and 79 deletions

View File

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