MDEV-33470 Unique hash index is broken on DML for system-versioned table

Hash index is vcol-based wrapper (MDEV-371). row_end is added to
unique index. So when row_end is updated unique hash index must be
recalculated via vcol_update_fields(). DELETE did not update virtual
fields, so DELETE HISTORY was getting wrong hash value.

The fix does update_virtual_fields() on vers_update_end() so in every
case row_end is updated virtual fields are updated as well.
This commit is contained in:
Aleksey Midenkov 2024-10-08 13:08:10 +03:00
parent d37bb140b1
commit 706a8bcb5b
4 changed files with 26 additions and 4 deletions

View file

@ -224,3 +224,14 @@ ERROR HY000: The target table v1 of the DELETE is not updatable
DROP VIEW v1;
DROP TABLE t1;
# End of 10.4 tests
#
# MDEV-33470 Unique hash index is broken on DML for system-versioned table
#
create or replace table t (
c int, unique (c) using hash)
with system versioning;
insert into t values (0);
delete from t;
delete history from t;
drop table t;
# End of 10.5 tests

View file

@ -232,4 +232,17 @@ DROP TABLE t1;
--echo # End of 10.4 tests
--echo #
--echo # MDEV-33470 Unique hash index is broken on DML for system-versioned table
--echo #
create or replace table t (
c int, unique (c) using hash)
with system versioning;
insert into t values (0);
delete from t;
delete history from t;
drop table t;
--echo # End of 10.5 tests
--source suite/versioning/common_finish.inc

View file

@ -1810,10 +1810,6 @@ int vers_insert_history_row(TABLE *table)
if (row_start->cmp(row_start->ptr, row_end->ptr) >= 0)
return 0;
if (table->vfield &&
table->update_virtual_fields(table->file, VCOL_UPDATE_FOR_READ))
return HA_ERR_GENERIC;
return table->file->ha_write_row(table->record[0]);
}

View file

@ -9078,6 +9078,8 @@ void TABLE::vers_update_end()
in_use->query_start_sec_part()))
DBUG_ASSERT(0);
vers_end_field()->set_has_explicit_value();
if (vfield)
update_virtual_fields(file, VCOL_UPDATE_FOR_WRITE);
}
/**