Skip to content

Commit 9fee640

Browse files
committed
Add test for updating pk with duplicate
1 parent a095177 commit 9fee640

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
drop table if exists gh_ost_test;
2+
create table gh_ost_test (
3+
id int auto_increment,
4+
email varchar(100) not null,
5+
primary key (id)
6+
) auto_increment=1;
7+
8+
insert into gh_ost_test (email) values ('alice@example.com');
9+
insert into gh_ost_test (email) values ('bob@example.com');
10+
insert into gh_ost_test (email) values ('charlie@example.com');
11+
12+
drop event if exists gh_ost_test;
13+
delimiter ;;
14+
create event gh_ost_test
15+
on schedule every 1 second
16+
starts current_timestamp + interval 3 second
17+
ends current_timestamp + interval 60 second
18+
on completion not preserve
19+
enable
20+
do
21+
begin
22+
-- This UPDATE modifies the primary key, so it will be converted to DELETE + INSERT
23+
-- The INSERT will attempt to insert email='alice@example.com' (duplicate)
24+
-- which violates the new unique index being added by the migration
25+
-- Delay ensures this fires during binlog apply phase, not bulk copy
26+
update gh_ost_test set id=10, email='alice@example.com' where id=2;
27+
end ;;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Warnings detected during DML event application
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--panic-on-warnings --alter "ADD UNIQUE KEY email_unique (email)"

0 commit comments

Comments
 (0)