函数lock_rec_get_first_on_page

时间:2023-03-09 08:37:29
函数lock_rec_get_first_on_page

lock结构体 详见

/*********************************************************************//**
Gets the first record lock on a page, where the page is identified by a
pointer to it.
@return    first lock, NULL if none exists */
UNIV_INLINE
lock_t*
lock_rec_get_first_on_page(
/*=======================*/
    const buf_block_t*    block)    /*!< in: buffer block */
{
    ulint    hash;
    lock_t*    lock;
    ulint    space    = buf_block_get_space(block);
    ulint    page_no    = buf_block_get_page_no(block);

    ut_ad(mutex_own(&kernel_mutex));

    hash = buf_block_get_lock_hash_val(block);

    lock = HASH_GET_FIRST(lock_sys->rec_hash, hash); //详见    while (lock) {
        if ((lock->un_member.rec_lock.space == space)
            && (lock->un_member.rec_lock.page_no == page_no)) {

            break;
        }

        lock = HASH_GET_NEXT(hash, lock);//详见
    }

    return(lock);
}