1
by brian
clean slate |
1 |
drop table if exists t1;
|
2 |
set session transaction isolation level read committed;
|
|
3 |
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1;
|
|
4 |
insert into t1 values (1),(2),(3),(4),(5),(6),(7);
|
|
5 |
set autocommit=0;
|
|
6 |
select * from t1 where a=3 lock in share mode;
|
|
7 |
a
|
|
8 |
3
|
|
9 |
set session transaction isolation level read committed;
|
|
10 |
set autocommit=0;
|
|
11 |
update t1 set a=10 where a=5;
|
|
12 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
13 |
commit;
|
|
14 |
update t1 set a=10 where a=5;
|
|
15 |
select * from t1 where a=2 for update;
|
|
16 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
17 |
select * from t1 where a=2 limit 1 for update;
|
|
18 |
a
|
|
19 |
2
|
|
20 |
update t1 set a=11 where a=6;
|
|
21 |
update t1 set a=12 where a=2;
|
|
22 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
23 |
update t1 set a=13 where a=1;
|
|
24 |
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
25 |
commit;
|
|
26 |
update t1 set a=14 where a=1;
|
|
27 |
commit;
|
|
28 |
select * from t1;
|
|
29 |
a
|
|
30 |
14
|
|
31 |
2
|
|
32 |
3
|
|
33 |
4
|
|
34 |
10
|
|
35 |
11
|
|
36 |
7
|
|
37 |
drop table t1;
|