set sql_mode=""; drop table if exists a,b,c,d,e; create table a(a int, b int, c int, key(a),key(b),key(c),key(a,b,c), unique key(b,c),key(c,a,b))engine=innodb; create table b like a; create table c like a; create table d like a; create table e like a; drop procedure if exists p; delimiter $ create procedure p() begin -- declare continue handler for sqlexception begin end; repeat if rand()>0.5 then start transaction; end if; if rand()>0.1 then set @a:=floor(rand()*10); end if; if rand()>0.1 then set @b:=floor(rand()*10); end if; if rand()>0.1 then set @c:=floor(rand()*10); end if; if rand()>0.5 then replace into a(a,b,c) values(@a,@b,@c); end if; if rand()>0.5 then replace into b(a,b,c) values(@a,@b,@c); end if; if rand()>0.5 then replace into c(a,b,c) values(@a,@b,@c); end if; if rand()>0.5 then replace into d(a,b,c) values(@a,@b,@c); end if; if rand()>0.5 then replace into e(a,b,c) values(@a,@b,@c); end if; if rand()>0.1 then set @a:=floor(rand()*10); end if; if rand()>0.1 then set @b:=floor(rand()*10); end if; if rand()>0.1 then set @c:=floor(rand()*10); end if; if rand()>0.5 then update ignore a set b=@a where c=@a; end if; if rand()>0.5 then update ignore b set c=@b where a=@b; end if; if rand()>0.5 then update ignore c set c=@c where b=@c; end if; if rand()>0.5 then update ignore d set a=@d where c=@d; end if; if rand()>0.5 then update ignore e set a=@e where a=@e; end if; if rand()>0.1 then set @a:=floor(rand()*10); end if; if rand()>0.1 then set @b:=floor(rand()*10); end if; if rand()>0.1 then set @c:=floor(rand()*10); end if; if rand()>0.5 then delete from a where a=@a; end if; if rand()>0.5 then delete from b where b=@b; end if; if rand()>0.5 then delete from c where c=@c; end if; if rand()>0.5 then delete from d where a=@d; end if; if rand()>0.5 then delete from e where b=@c; end if; if rand()>0.5 then commit; end if; until rand()>0.2 end repeat; end $ delimiter ; call p(); -- in 5 threads