1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +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

@ -2811,6 +2811,23 @@ bool multi_update::send_eof()
}
/**
@brief Check whether conversion to multi-table update is prohibited
@param thd global context the processed statement
@returns true if conversion is prohibited, false otherwise
@todo
Introduce handler level flag for storage engines that would prohibit
such conversion for any single-table update.
*/
bool Sql_cmd_update::processing_as_multitable_update_prohibited(THD *thd)
{
return false;
}
/**
@brief Perform precheck of table privileges for update statements
@ -2894,7 +2911,9 @@ bool Sql_cmd_update::prepare_inner(THD *thd)
"updating and querying the same temporal periods table");
DBUG_RETURN(TRUE);
}
multitable= true;
if (!table_list->is_multitable() &&
!processing_as_multitable_update_prohibited(thd))
multitable= true;
}
}