码迷,mamicode.com
首页 > 其他好文 > 详细

函数lock_rec_has_expl

时间:2015-11-06 17:44:00      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:

判断是否预加锁的模式 要强壮于 已添加的lock锁模式

/*********************************************************************//**
Checks if a transaction has a GRANTED explicit lock on rec stronger or equal
to precise_mode.
@return    lock or NULL */
UNIV_INLINE
lock_t*
lock_rec_has_expl(
/*==============*/
    ulint            precise_mode,/*!< in: LOCK_S or LOCK_X
                    possibly ORed to LOCK_GAP or
                    LOCK_REC_NOT_GAP, for a
                    supremum record we regard this
                    always a gap type request */
    const buf_block_t*    block,    /*!< in: buffer block containing
                    the record */
    ulint            heap_no,/*!< in: heap number of the record */
    trx_t*            trx)    /*!< in: transaction */
{
    lock_t*    lock;

    ut_ad(mutex_own(&kernel_mutex));
    ut_ad((precise_mode & LOCK_MODE_MASK) == LOCK_S
          || (precise_mode & LOCK_MODE_MASK) == LOCK_X);
    ut_ad(!(precise_mode & LOCK_INSERT_INTENTION));

    lock = lock_rec_get_first(block, heap_no); //函数实现

while (lock) {
        if (lock->trx == trx
            && !lock_is_wait_not_by_other(lock->type_mode)
            && lock_mode_stronger_or_eq(lock_get_mode(lock),
                        precise_mode & LOCK_MODE_MASK)
            && (!lock_rec_get_rec_not_gap(lock)
            || (precise_mode & LOCK_REC_NOT_GAP)
            || heap_no == PAGE_HEAP_NO_SUPREMUM)
            && (!lock_rec_get_gap(lock)
            || (precise_mode & LOCK_GAP)
            || heap_no == PAGE_HEAP_NO_SUPREMUM)
            && (!lock_rec_get_insert_intention(lock))) {

            return(lock);
        }

        lock = lock_rec_get_next(heap_no, lock);
    }

    return(NULL);
}

 

函数lock_rec_has_expl

标签:

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

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