1
by brian
clean slate |
1 |
-- source include/have_innodb.inc
|
2 |
||
3 |
--disable_warnings
|
|
4 |
drop table if exists t1; |
|
5 |
--enable_warnings
|
|
6 |
||
7 |
# basic tests of semi-consistent reads |
|
8 |
||
9 |
connect (a,localhost,root,,); |
|
10 |
connect (b,localhost,root,,); |
|
11 |
connection a; |
|
12 |
set session transaction isolation level read committed; |
|
13 |
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; |
|
14 |
insert into t1 values (1),(2),(3),(4),(5),(6),(7); |
|
15 |
set autocommit=0; |
|
16 |
# this should lock the entire table |
|
17 |
select * from t1 where a=3 lock in share mode; |
|
18 |
connection b; |
|
19 |
set session transaction isolation level read committed; |
|
20 |
set autocommit=0; |
|
21 |
-- error ER_LOCK_WAIT_TIMEOUT
|
|
22 |
update t1 set a=10 where a=5; |
|
23 |
connection a; |
|
24 |
commit; |
|
25 |
connection b; |
|
26 |
update t1 set a=10 where a=5; |
|
27 |
connection a; |
|
28 |
-- error ER_LOCK_WAIT_TIMEOUT
|
|
29 |
select * from t1 where a=2 for update; |
|
30 |
# this should lock the records (1),(2) |
|
31 |
select * from t1 where a=2 limit 1 for update; |
|
32 |
connection b; |
|
33 |
update t1 set a=11 where a=6; |
|
34 |
-- error ER_LOCK_WAIT_TIMEOUT
|
|
35 |
update t1 set a=12 where a=2; |
|
36 |
-- error ER_LOCK_WAIT_TIMEOUT
|
|
37 |
update t1 set a=13 where a=1; |
|
38 |
connection a; |
|
39 |
commit; |
|
40 |
connection b; |
|
41 |
update t1 set a=14 where a=1; |
|
42 |
commit; |
|
43 |
connection a; |
|
44 |
select * from t1; |
|
45 |
drop table t1; |
|
46 |
||
47 |
connection default; |
|
48 |
disconnect a; |
|
49 |
disconnect b; |