2016-03-25 20:51:22 +04:00
|
|
|
connect con1,localhost,root,,;
|
|
|
|
connect con2,localhost,root,,;
|
|
|
|
connect con3,localhost,root,,;
|
2010-08-03 12:54:05 +02:00
|
|
|
# Drop test table
|
|
|
|
drop table if exists t;
|
|
|
|
# Create test table
|
|
|
|
create table t(a INT PRIMARY KEY, b INT) engine=InnoDB;
|
|
|
|
# Insert two rows to test table
|
|
|
|
insert into t values(2,1);
|
|
|
|
insert into t values(1,2);
|
2016-03-25 20:51:22 +04:00
|
|
|
connection con1;
|
2010-08-03 12:54:05 +02:00
|
|
|
BEGIN;
|
|
|
|
SELECT b FROM t WHERE a=1 FOR UPDATE;
|
2016-03-25 20:51:22 +04:00
|
|
|
connection con2;
|
2010-08-03 12:54:05 +02:00
|
|
|
BEGIN;
|
|
|
|
SELECT b FROM t WHERE a=2 FOR UPDATE;
|
2016-03-25 20:51:22 +04:00
|
|
|
connection con1;
|
2010-08-03 12:54:05 +02:00
|
|
|
SELECT b FROM t WHERE a=2 FOR UPDATE;
|
2016-03-25 20:51:22 +04:00
|
|
|
connection con2;
|
2010-08-03 12:54:05 +02:00
|
|
|
SELECT b FROM t WHERE a=1 FOR UPDATE;
|
2016-03-25 20:51:22 +04:00
|
|
|
connection con1;
|
2011-07-14 21:22:41 +02:00
|
|
|
ROLLBACK;
|
2016-03-25 20:51:22 +04:00
|
|
|
connection con2;
|
2011-07-14 21:22:41 +02:00
|
|
|
ROLLBACK;
|
2016-03-25 20:51:22 +04:00
|
|
|
connection con3;
|
2011-07-14 21:22:41 +02:00
|
|
|
Deadlocks: 1
|
2010-08-03 12:54:05 +02:00
|
|
|
# Drop test table
|
|
|
|
drop table t;
|