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

MDEV-31150 Crash on 2nd execution of update using mergeable derived table

This bug caused crashes of the server on the second execution of update
statements that used mergeable derived tables. The crashes happened in
the function multi_update_check_table_access() when the code tried to
dereference the pointer stored in field TABLE_LIST::TABLE for a mergeable
derived table. The fact is this field is set to NULL after the first
execution of the query. At the same any action performed by the function
is actually not needed for derived tables.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
This commit is contained in:
Igor Babaev
2023-07-26 22:59:25 -07:00
parent c6ac1e39b6
commit adc13e2c16
3 changed files with 421 additions and 0 deletions

View File

@ -1497,6 +1497,14 @@ static bool multi_update_check_table_access(THD *thd, TABLE_LIST *table,
else
{
/* Must be a base or derived table. */
/*
Derived tables do not need the check below.
Besides one have take into account that for mergeable derived tables
TABLE_LIST::TABLE is set to NULL after the first execution of the query.
*/
if (table->is_derived())
return false;
const bool updated= table->table->map & tables_for_update;
if (check_table_access(thd, updated ? UPDATE_ACL : SELECT_ACL, table,
FALSE, 1, FALSE))