mariadb/mysql-test/suite/rpl/t/rpl_mdev38731.test
Kristian Nielsen ba305095ff MDEV-38731: Wrong index usage when row-based replication and no PK
This affects row-based replication for UPDATE/DELETE on tables with no
primary key (and no non-NULL unique index).

There was a typo / incorrect merge from the following commit:

commit 3abce27e9d
Author: unknown <knielsen@knielsen-hq.org>
Date:   Mon Dec 27 22:37:37 2010 +0100

    Merge Percona patch row_based_replication_without_primary_key.patch into MariaDB.

Instead of referencing the index selected for applying the event, part
of the code was referencing the first index (in internal order) in the
table. This is code that checks if an index lookup is unique, or if it
requires a range scan. This could lead the code to incorrectly do a
unique lookup instead of comparing the pre-image against each row in a
range scan, thus applying the event to the wrong row and causing
replication to diverge.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2026-03-11 08:35:55 +01:00

21 lines
541 B
Text

--source include/have_innodb.inc
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
CREATE TABLE t (a int, b int, c int, d int, KEY (d)) ENGINE=InnoDB;
INSERT INTO t (a,b,d) VALUES
(1,NULL,4),(2,NULL,1),(3,NULL,1),
(4,NULL,1),(5,NULL,1),(6,NULL,1),
(7,0,NULL),(8,NULL,NULL);
ALTER TABLE t ADD UNIQUE (b);
--sync_slave_with_master
ANALYZE TABLE t;
--connection master
UPDATE t SET c = 1;
ALTER TABLE t ADD UNIQUE (a);
--sync_slave_with_master
--connection master
DROP TABLE t;
--source include/rpl_end.inc