mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +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:
@@ -44,11 +44,13 @@ class Sql_cmd_delete final : public Sql_cmd_dml
|
||||
{
|
||||
public:
|
||||
Sql_cmd_delete(bool multitable_arg)
|
||||
: multitable(multitable_arg), save_protocol(NULL) {}
|
||||
: orig_multitable(multitable_arg), multitable(multitable_arg),
|
||||
save_protocol(NULL)
|
||||
{}
|
||||
|
||||
enum_sql_command sql_command_code() const override
|
||||
{
|
||||
return multitable ? SQLCOM_DELETE_MULTI : SQLCOM_DELETE;
|
||||
return orig_multitable ? SQLCOM_DELETE_MULTI : SQLCOM_DELETE;
|
||||
}
|
||||
|
||||
DML_prelocking_strategy *get_dml_prelocking_strategy()
|
||||
@@ -56,6 +58,12 @@ public:
|
||||
return &dml_prelocking_strategy;
|
||||
}
|
||||
|
||||
bool processing_as_multitable_delete_prohibited(THD *thd);
|
||||
|
||||
bool is_multitable() { return multitable; }
|
||||
|
||||
void set_as_multitable() { multitable= true; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
@brief Perform precheck of table privileges for delete statements
|
||||
@@ -78,6 +86,9 @@ protected:
|
||||
*/
|
||||
bool delete_from_single_table(THD *thd);
|
||||
|
||||
/* Original value of the 'multitable' flag set by constructor */
|
||||
const bool orig_multitable;
|
||||
|
||||
/*
|
||||
True if the statement is a multitable delete or converted to such.
|
||||
For a single-table delete this flag is set to true if the statement
|
||||
|
Reference in New Issue
Block a user