| 1 |
-- source include/not_embedded.inc |
| 2 |
-- source include/have_innodb.inc |
| 3 |
|
| 4 |
--disable_warnings |
| 5 |
drop table if exists t1,t2; |
| 6 |
--enable_warnings |
| 7 |
|
| 8 |
# basic tests of semi-consistent reads |
| 9 |
|
| 10 |
connect (a,localhost,root,,); |
| 11 |
connect (b,localhost,root,,); |
| 12 |
connection a; |
| 13 |
set binlog_format=mixed; |
| 14 |
set session transaction isolation level repeatable read; |
| 15 |
create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; |
| 16 |
insert into t1 values (1),(2),(3),(4),(5),(6),(7); |
| 17 |
set autocommit=0; |
| 18 |
# this should lock the entire table |
| 19 |
select * from t1 where a=3 lock in share mode; |
| 20 |
connection b; |
| 21 |
set binlog_format=mixed; |
| 22 |
set session transaction isolation level repeatable read; |
| 23 |
set autocommit=0; |
| 24 |
-- error ER_LOCK_WAIT_TIMEOUT |
| 25 |
update t1 set a=10 where a=5; |
| 26 |
commit; |
| 27 |
connection a; |
| 28 |
commit; |
| 29 |
connection b; |
| 30 |
# perform a semi-consisent read (and unlock non-matching rows) |
| 31 |
set innodb_snapshot_isolation=off; |
| 32 |
set session transaction isolation level read committed; |
| 33 |
update t1 set a=10 where a=5; |
| 34 |
connection a; |
| 35 |
-- error ER_LOCK_WAIT_TIMEOUT |
| 36 |
select * from t1 where a=2 for update; |
| 37 |
# this should lock the records (1),(2) |
| 38 |
select * from t1 where a=2 limit 1 for update; |
| 39 |
connection b; |
| 40 |
# semi-consistent read will skip non-matching locked rows a=1, a=2 |
| 41 |
update t1 set a=11 where a=6; |
| 42 |
-- error ER_LOCK_WAIT_TIMEOUT |
| 43 |
update t1 set a=12 where a=2; |
| 44 |
-- error ER_LOCK_WAIT_TIMEOUT |
| 45 |
update t1 set a=13 where a=1; |
| 46 |
connection a; |
| 47 |
commit; |
| 48 |
connection b; |
| 49 |
update t1 set a=14 where a=1; |
| 50 |
commit; |
| 51 |
connection a; |
| 52 |
select * from t1; |
| 53 |
drop table t1; |
| 54 |
|
| 55 |
connection default; |
| 56 |
disconnect a; |
| 57 |
disconnect b; |
| 58 |
|
| 59 |
# Bug 39320 |
| 60 |
create table t1 (a int, b int) engine=myisam; |
| 61 |
create table t2 (c int, d int, key (c)) engine=innodb; |
| 62 |
insert into t1 values (1,1); |
| 63 |
insert into t2 values (1,2); |
| 64 |
connect (a,localhost,root,,); |
| 65 |
connection a; |
| 66 |
set session transaction isolation level read committed; |
| 67 |
delete from t1 using t1 join t2 on t1.a = t2.c where t2.d in (1); |
| 68 |
connection default; |
| 69 |
disconnect a; |
| 70 |
drop table t1, t2; |