1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#Test for Exclusive, GAP locks
drop table if exists t1_x_gap;
use test;
create table t1_x_gap (id int(10) primary key, x int(10)) engine=INNODB;
Warnings:
Warning 1681 Integer display width is deprecated and will be removed in a future release.
Warning 1681 Integer display width is deprecated and will be removed in a future release.
insert into t1_x_gap values (1,10),(2,20),(3,30),(4,40),(5,50);
start transaction;
select * from t1_x_gap where id<5 for update;
id x
1 10
2 20
3 30
4 40
select object_schema, object_name, lock_type, lock_mode, lock_status, lock_data
from performance_schema.data_locks
where object_name="t1_x_gap"
order by lock_type, lock_mode, lock_status, lock_data;
object_schema object_name lock_type lock_mode lock_status lock_data
test t1_x_gap RECORD X GRANTED 1
test t1_x_gap RECORD X GRANTED 2
test t1_x_gap RECORD X GRANTED 3
test t1_x_gap RECORD X GRANTED 4
test t1_x_gap RECORD X,GAP GRANTED 5
test t1_x_gap TABLE IX GRANTED NULL
start transaction;
insert into t1_x_gap values (0,0);
select object_schema, object_name, lock_type, lock_mode, lock_status
from performance_schema.data_locks
where object_name="t1_x_gap"
order by lock_type, lock_mode, lock_status;
object_schema object_name lock_type lock_mode lock_status
test t1_x_gap RECORD X GRANTED
test t1_x_gap RECORD X GRANTED
test t1_x_gap RECORD X GRANTED
test t1_x_gap RECORD X GRANTED
test t1_x_gap RECORD X,GAP GRANTED
test t1_x_gap RECORD X,GAP,INSERT_INTENTION WAITING
test t1_x_gap TABLE IX GRANTED
test t1_x_gap TABLE IX GRANTED
commit;
select object_schema, object_name, lock_type, lock_mode, lock_status
from performance_schema.data_locks
where object_name="t1_x_gap";
object_schema object_name lock_type lock_mode lock_status
test t1_x_gap TABLE IX GRANTED
test t1_x_gap RECORD X,GAP,INSERT_INTENTION GRANTED
commit;
drop table t1_x_gap;
|