1
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
2
create table t1 (id int not null, f_id int not null, f int not null,
3
primary key(f_id, id)) engine = InnoDB;
4
create table t2 (id int not null,s_id int not null,s varchar(200),
5
primary key(id)) engine = InnoDB;
6
INSERT INTO t1 VALUES (8, 1, 3);
7
INSERT INTO t1 VALUES (1, 2, 1);
8
INSERT INTO t2 VALUES (1, 0, '');
9
INSERT INTO t2 VALUES (8, 1, '');
11
DELETE ml.* FROM t1 AS ml LEFT JOIN t2 AS mm ON (mm.id=ml.id)
13
select ml.* from t1 as ml left join t2 as mm on (mm.id=ml.id)
14
where mm.id is null lock in share mode;
17
create table t1(a int not null, b int, primary key(a)) engine = InnoDB;
18
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
21
select * from t1 lock in share mode;
30
update t1 set b = 5 where b = 1;
32
select * from t1 where a = 2 and b = 2 for update;
33
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
37
create table t1(a int not null, b int, primary key(a)) engine = InnoDB;
38
insert into t1 values(1,1),(2,2),(3,1),(4,2),(5,1),(6,2),(7,3);
41
update t1 set b = 5 where b = 1;
43
select * from t1 where a = 7 and b = 3 for update;
49
create table t1(a int not null, b int, primary key(a)) engine = InnoDB;
50
insert into t1 values (1,2),(5,3),(4,2);
51
create table t2(d int not null, e int, primary key(d)) engine = InnoDB;
52
insert into t2 values (8,6),(12,1),(3,1);
55
select * from t2 for update;
61
insert into t1 select * from t2;
62
update t1 set b = (select e from t2 where a = d);
63
create table t3(d int not null, e int, primary key(d)) engine = InnoDB
67
drop table t1, t2, t3;
68
SET SESSION STORAGE_ENGINE = InnoDB;
69
SET SESSION STORAGE_ENGINE = InnoDB;
70
SET SESSION STORAGE_ENGINE = InnoDB;
71
create table t1(a int not null, b int, primary key(a)) engine = InnoDB;
72
insert into t1 values (1,2),(5,3),(4,2);
73
create table t2(a int not null, b int, primary key(a)) engine = InnoDB;
74
insert into t2 values (8,6),(12,1),(3,1);
75
create table t3(d int not null, b int, primary key(d)) engine = InnoDB;
76
insert into t3 values (8,6),(12,1),(3,1);
77
create table t5(a int not null, b int, primary key(a)) engine = InnoDB;
78
insert into t5 values (1,2),(5,3),(4,2);
79
create table t6(d int not null, e int, primary key(d)) engine = InnoDB;
80
insert into t6 values (8,6),(12,1),(3,1);
81
create table t8(a int not null, b int, primary key(a)) engine = InnoDB;
82
insert into t8 values (1,2),(5,3),(4,2);
83
create table t9(d int not null, e int, primary key(d)) engine = InnoDB;
84
insert into t9 values (8,6),(12,1),(3,1);
87
select * from t2 for update;
93
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
94
insert into t1 select * from t2;
96
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
97
update t3 set b = (select b from t2 where a = d);
99
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
100
create table t4(a int not null, b int, primary key(a)) select * from t2;
102
insert into t5 (select * from t2 lock in share mode);
104
update t6 set e = (select b from t2 where a = d lock in share mode);
106
create table t7(a int not null, b int, primary key(a)) select * from t2 lock in share mode;
108
insert into t8 (select * from t2 for update);
110
update t9 set e = (select b from t2 where a = d for update);
112
create table t10(a int not null, b int, primary key(a)) select * from t2 for update;
113
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
114
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
115
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
116
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
117
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
118
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
119
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
120
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
121
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
123
drop table t1, t2, t3, t5, t6, t8, t9;