码迷,mamicode.com
首页 > 数据库 > 详细

innodb锁之间的兼容性判断

时间:2015-11-05 11:52:37      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:

检查锁与锁之间的兼容性

路径:/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));
}

 

innodb锁之间的兼容性判断

标签:

原文地址:http://www.cnblogs.com/taek/p/4938901.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!