mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-30046 wrong row targeted with "insert ... on duplicate" and "replace"
When HA_DUPLICATE_POS is not supported, the row to replace was navigated by ha_index_read_idx_map, which uses only hash to navigate. Suchwise, given a hash collision it may choose an incorrect row. handler::position would be correct and very convenient to use here. dup_ref is already set by handler independently of the engine capabilities, when an extra lookup is made (for long unique or something else, for example WITHOUT OVERLAPS) such error will be indicated by file->lookup_errkey != -1.
This commit is contained in:
@ -4569,6 +4569,12 @@ uint handler::get_dup_key(int error)
|
||||
DBUG_RETURN(errkey);
|
||||
}
|
||||
|
||||
bool handler::has_dup_ref() const
|
||||
{
|
||||
DBUG_ASSERT(lookup_errkey != (uint)-1 || errkey != (uint)-1);
|
||||
return ha_table_flags() & HA_DUPLICATE_POS || lookup_errkey != (uint)-1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Delete all files with extension from bas_ext().
|
||||
@ -6996,11 +7002,8 @@ exit:
|
||||
if (error == HA_ERR_FOUND_DUPP_KEY)
|
||||
{
|
||||
table->file->lookup_errkey= key_no;
|
||||
if (ha_table_flags() & HA_DUPLICATE_POS)
|
||||
{
|
||||
lookup_handler->position(table->record[0]);
|
||||
memcpy(table->file->dup_ref, lookup_handler->ref, ref_length);
|
||||
}
|
||||
lookup_handler->position(table->record[0]);
|
||||
memcpy(table->file->dup_ref, lookup_handler->ref, ref_length);
|
||||
}
|
||||
restore_record(table, file->lookup_buffer);
|
||||
table->restore_blob_values(blob_storage);
|
||||
|
Reference in New Issue
Block a user