1
-- source include/have_innodb.inc
4
# Check and select innodb lock type
7
set global innodb_table_locks=1;
9
select @@innodb_table_locks;
12
# Testing of explicit table locks with enforced table locks
15
connect (con1,localhost,root,,);
16
connect (con2,localhost,root,,);
19
drop table if exists t1;
23
# Testing of explicit table locks with enforced table locks
26
set @@innodb_table_locks=1;
29
create table t1 (id integer, x integer) engine=INNODB;
30
insert into t1 values(0, 0);
32
SELECT * from t1 where id = 0 FOR UPDATE;
37
# The following statement should hang because con1 is locking the page
43
update t1 set x=1 where id = 0;
49
update t1 set x=2 where id = 0;
60
# Try with old lock method (where LOCK TABLE is ignored by InnoDB)
63
set @@innodb_table_locks=0;
65
create table t1 (id integer primary key, x integer) engine=INNODB;
66
insert into t1 values(0, 0),(1,1),(2,2);
68
SELECT * from t1 where id = 0 FOR UPDATE;
72
set @@innodb_table_locks=0;
74
# The following statement should work becase innodb doesn't check table locks
79
# This will be locked by MySQL
81
update t1 set x=10 where id = 2;
86
# Note that we will get a deadlock if we try to select any rows marked
87
# for update by con1 !
89
SELECT * from t1 where id = 2;
90
UPDATE t1 set x=3 where id = 2;