检查锁与锁之间的兼容性
路径:/mysql-5.5.43/storage/innobase/lock/lock0lock.c
实现:见锁的强度比较
/* LOCK COMPATIBILITY MATRIX * IS IX S X AI * IS + + + - + * IX + + - - + * S + - + - - * X - - - - - * AI + + - - - * * Note that for rows, InnoDB only acquires S or X locks. * For tables, InnoDB normally acquires IS or IX locks. * S or X table locks are only acquired for LOCK TABLES. * Auto-increment (AI) locks are needed because of * statement-level MySQL binlog. * See also lock_mode_compatible(). */ /*********************************************************************//** Calculates if lock mode 1 is compatible with lock mode 2. @return nonzero if mode1 compatible with mode2 */ UNIV_INLINE ulint lock_mode_compatible( /*=================*/ enum lock_mode mode1, /*!< in: lock mode */ enum lock_mode mode2) /*!< in: lock mode */ { ut_ad(mode1 == LOCK_X || mode1 == LOCK_S || mode1 == LOCK_IX || mode1 == LOCK_IS || mode1 == LOCK_AUTO_INC); ut_ad(mode2 == LOCK_X || mode2 == LOCK_S || mode2 == LOCK_IX || mode2 == LOCK_IS || mode2 == LOCK_AUTO_INC); return((LOCK_MODE_COMPATIBILITY) & LK(mode1, mode2)); }
时间: 2024-11-06 13:09:09