1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +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:
Nikita Malyavin
2022-12-28 23:05:46 +03:00
parent 7f161a5c58
commit 72429cad7f
5 changed files with 63 additions and 8 deletions

View File

@ -674,6 +674,25 @@ SELECT * FROM t1;
a b c
3 2 2
DROP TABLE t1;
# MDEV-30046 wrong row targeted with "insert ... on duplicate" and
# "replace", leading to data corruption
create table t (s blob, n int, unique (s)) engine=innodb;
insert into t values ('Hrecvx_0004ln-00',1), ('Hrecvx_0004mm-00',1);
replace into t values ('Hrecvx_0004mm-00',2);
select * from t;
s n
Hrecvx_0004ln-00 1
Hrecvx_0004mm-00 2
drop table t;
create table t (s blob, n int, unique (s)) engine=innodb;
insert into t values ('Hrecvx_0004ln-00',1), ('Hrecvx_0004mm-00',1);
insert into t values ('Hrecvx_0004mm-00',2)
on duplicate key update n = values (n);
select * from t;
s n
Hrecvx_0004ln-00 1
Hrecvx_0004mm-00 2
drop table t;
#
# End of 10.5 tests
#