1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-22714 Assertion failed upon multi-update on table WITHOUT OVERLAPS

The problem here was that ha_check_overlaps internally uses ha_index_read,
which in case of fail overwrites table->status. Even though the handlers
are different, they share a common table, so the value is anyway spoiled.
This is bad, and table->status is badly designed and overweighted by
functionality, but nothing can be done with it, since the code related to
this logic is ancient and it's impossible to extract it with normal effort.

So let's just save and restore the value in ha_update_row before and after
the checks.

Other operations like INSERT and simple UPDATE are not in risk, since they
don't use this table->status approach.
DELETE does not do any unique checks, so it's also safe.
This commit is contained in:
Nikita Malyavin
2020-09-24 21:59:28 +10:00
parent 30894fe9a9
commit d543363f25
3 changed files with 32 additions and 6 deletions

View File

@ -7182,17 +7182,20 @@ int handler::ha_update_row(const uchar *old_data, const uchar *new_data)
DBUG_ASSERT(new_data == table->record[0]);
DBUG_ASSERT(old_data == table->record[1]);
if ((error= ha_check_overlaps(old_data, new_data)))
return error;
uint saved_status= table->status;
error= ha_check_overlaps(old_data, new_data);
MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write();
increment_statistics(&SSV::ha_update_count);
if (table->s->long_unique_table && this == table->file &&
(error= check_duplicate_long_entries_update(new_data)))
{
if (!error && table->s->long_unique_table && this == table->file)
error= check_duplicate_long_entries_update(new_data);
table->status= saved_status;
if (error)
return error;
}
TABLE_IO_WAIT(tracker, PSI_TABLE_UPDATE_ROW, active_index, 0,
{ error= update_row(old_data, new_data);})