标签:
判断是否预加锁的模式 要强壮于 已添加的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); }
标签:
原文地址:http://www.cnblogs.com/taek/p/4943052.html