---TRANSACTION 771, ACTIVE 403 sec
4 lock struct(s), heap size 1248, 5 row lock(s)
MySQL thread id 6, OS thread handle 0x415fa960, query id 423 localhost root
TABLE LOCK table `test`.`transfer` trx id 771 lock mode IX
RECORD LOCKS space id 22 page no 4 n bits 72 index `trans_id` of table `test`.`transfer` trx id 771 lock_mode X
Record lock, heap no 2 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
0: len 4; hex 80000065; asc e;;
1: len 4; hex 80000001; asc ;;
Record lock, heap no 3 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
0: len 4; hex 80000067; asc g;;
1: len 4; hex 80000004; asc ;;
RECORD LOCKS space id 22 page no 3 n bits 72 index `PRIMARY` of table `test`.`transfer` trx id 771 lock_mode X locks rec but not gap
Record lock, heap no 2 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
0: len 4; hex 80000001; asc ;;
1: len 6; hex 0000000005d3; asc ;;
2: len 7; hex ac000001910110; asc ;;
3: len 4; hex 80000065; asc e;;
4: len 3; hex 616161; asc aaa;;
Record lock, heap no 3 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
0: len 4; hex 80000004; asc ;;
1: len 6; hex 0000000005e0; asc ;;
2: len 7; hex b8000001930110; asc ;;
3: len 4; hex 80000067; asc g;;
4: len 3; hex 626262; asc bbb;;
RECORD LOCKS space id 22 page no 4 n bits 72 index `trans_id` of table `test`.`transfer` trx id 771 lock_mode X locks gap before rec
Record lock, heap no 4 PHYSICAL RECORD: n_fields 2; compact format; info bits 0
0: len 4; hex 80000068; asc h;;
1: len 4; hex 8000000a; asc ;;
没有!因为103上已经有N锁了,而N锁比G锁级别高,所以没有必要再加个G锁了。
所以如果是单独给101加锁,就肯定会给103加gap锁了,验证一下:
来源: http://www.bubuko.com/infodetail-1860998.html