在原来的type_mode基础上,加上LOCK_REC

/*********************************************************************//**
Adds a record lock request in the record queue. The request is normally
added as the last in the queue, but if there are no waiting lock requests
on the record, and the request to be added is not a waiting request, we
can reuse a suitable record lock object already existing on the same page,
just setting the appropriate bit in its bitmap. This is a low-level function
which does NOT check for deadlocks or lock compatibility!
@return    lock where the bit was set */
static
lock_t*
lock_rec_add_to_queue(
/*==================*/
    ulint            type_mode,/*!< in: lock mode, wait, gap
                    etc. flags; type is ignored
                    and replaced by LOCK_REC */
    const buf_block_t*    block,    /*!< in: buffer block containing
                    the record */
    ulint            heap_no,/*!< in: heap number of the record */
    dict_index_t*        index,    /*!< in: index of record */
    trx_t*            trx)    /*!< in: transaction */
{
    lock_t*    lock;

    ut_ad(mutex_own(&kernel_mutex));
#ifdef UNIV_DEBUG
    switch (type_mode & LOCK_MODE_MASK) {
    case LOCK_X:
    case LOCK_S:
        break;
    default:
        ut_error;
    }

    if (!(type_mode & (LOCK_WAIT | LOCK_GAP))) {
        enum lock_mode    mode = (type_mode & LOCK_MODE_MASK) == LOCK_S
            ? LOCK_X
            : LOCK_S;
        lock_t*        other_lock
            = lock_rec_other_has_expl_req(mode, , LOCK_WAIT,
                              block, heap_no, trx);
        ut_a(!other_lock);
    }
#endif /* UNIV_DEBUG */
     
    type_mode |= LOCK_REC; //模式基础上 加上 LOCK_REC

    /* If rec is the supremum record, then we can reset the gap bit, as
    all locks on the supremum are automatically of the gap type, and we
    try to avoid unnecessary memory consumption of a new record lock
    struct for a gap type lock */

    if (UNIV_UNLIKELY(heap_no == PAGE_HEAP_NO_SUPREMUM)) {
/* There should never be LOCK_REC_NOT_GAP on a supremum
        record, but let us play safe */

        type_mode = type_mode & ~(LOCK_GAP | LOCK_REC_NOT_GAP);
    }

    /* Look for a waiting lock request on the same record or on a gap */

    lock = lock_rec_get_first_on_page(block);

    while (lock != NULL) {
        if (lock_get_wait(lock)
            && (lock_rec_get_nth_bit(lock, heap_no))) {

            goto somebody_waits;
        }

        lock = lock_rec_get_next_on_page(lock);
    }
        //以后再分析,貌似是为了节省空间
    if (UNIV_LIKELY(!(type_mode & LOCK_WAIT))) {

        /* Look for a similar record lock on the same page:
        if one is found and there are no waiting lock requests,
        we can just set the bit */

        lock = lock_rec_find_similar_on_page(
            type_mode, heap_no,
            lock_rec_get_first_on_page(block), trx);

        if (lock) {

            lock_rec_set_nth_bit(lock, heap_no);

            return(lock);
        }
    }

somebody_waits:
    return(lock_rec_create(type_mode, block, heap_no, index, trx));
}

函数lock_rec_add_to_queue的更多相关文章

  1. Python 小而美的函数

    python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况   any any(iterable) ...

  2. 探究javascript对象和数组的异同,及函数变量缓存技巧

    javascript中最经典也最受非议的一句话就是:javascript中一切皆是对象.这篇重点要提到的,就是任何jser都不陌生的Object和Array. 有段时间曾经很诧异,到底两种数据类型用来 ...

  3. JavaScript权威指南 - 函数

    函数本身就是一段JavaScript代码,定义一次但可能被调用任意次.如果函数挂载在一个对象上,作为对象的一个属性,通常这种函数被称作对象的方法.用于初始化一个新创建的对象的函数被称作构造函数. 相对 ...

  4. C++对C的函数拓展

    一,内联函数 1.内联函数的概念 C++中的const常量可以用来代替宏常数的定义,例如:用const int a = 10来替换# define a 10.那么C++中是否有什么解决方案来替代宏代码 ...

  5. 菜鸟Python学习笔记第一天:关于一些函数库的使用

    2017年1月3日 星期二 大一学习一门新的计算机语言真的很难,有时候连函数拼写出错查错都能查半天,没办法,谁让我英语太渣. 关于计算机语言的学习我想还是从C语言学习开始为好,Python有很多语言的 ...

  6. javascript中的this与函数讲解

    前言 javascript中没有块级作用域(es6以前),javascript中作用域分为函数作用域和全局作用域.并且,大家可以认为全局作用域其实就是Window函数的函数作用域,我们编写的js代码, ...

  7. 复杂的 Hash 函数组合有意义吗?

    很久以前看到一篇文章,讲某个大网站储存用户口令时,会经过十分复杂的处理.怎么个复杂记不得了,大概就是先 Hash,结果加上一些特殊字符再 Hash,结果再加上些字符.再倒序.再怎么怎么的.再 Hash ...

  8. JS核心系列:浅谈函数的作用域

    一.作用域(scope) 所谓作用域就是:变量在声明它们的函数体以及这个函数体嵌套的任意函数体内都是有定义的. function scope(){ var foo = "global&quo ...

  9. C++中的时间函数

    C++获取时间函数众多,何时该用什么函数,拿到的是什么时间?该怎么用?很多人都会混淆. 本文是本人经历了几款游戏客户端和服务器开发后,对游戏中时间获取的一点总结. 最早学习游戏客户端时,为了获取最精确 ...

随机推荐

  1. 用c语言产生随机数的方法

    用c语言产生随机数的方法 在C语言中,rand()函数可以用来产生随机数,但是这不是真正意义上的随机数,是一个伪随机数,是根据一个数,我们可以称它为种子,为基准以某个递推公式推算出来的一系数,当这系列 ...

  2. 如何让360、遨游、猎豹等双核浏览器默认以webkit内核渲染网页?

    众知目前国内不少浏览器都自称双核,一般是 IE(Trident)+Webkit.因为 webkit 急速的体验和对 HTML5 的支持,有些情况下开发者可能希望用户优先甚至只使用 webkit 内核渲 ...

  3. Tomcat server分端口部署web项目

    <?xml version='1.0' encoding='utf-8'?> <Server port="8006" shutdown="SHUTDOW ...

  4. Sqli-labs less 19

    Less-19 从源代码中我们可以看到我们获取到的是HTTP_REFERER 那和less18是基本一致的,我们从referer进行修改. 还是像less18一样,我们只给出一个示例 将referer ...

  5. iOS警告-Warning: Error creating LLDB target at path(模拟器警告)

    Warning: Error creating LLDB target at path '/Users/apple/Library/Developer/Xcode/DerivedData/Observ ...

  6. Android屏幕适应详解(一)

    一.关于布局适配 1.不要使用绝对布局 2.尽量使用match_parent 而不是fill_parent . 3.能够使用权重的地方尽量使用权重(android:layout_weight) 4.如 ...

  7. 传说中的WCF(11):会话(Session)

    在标题中我加了一个大家都很熟悉的单词——Session,熟吧?玩过Web开发的朋友肯定在梦中都会见到她. 在Web中为什么要会话呢?毕竟每个用户在一个Web应用中可能不止进行一次操作,比如,某二手飞机 ...

  8. 关于SIGPIPE导致的程序退出

    http://www.cppblog.com/elva/archive/2008/09/10/61544.html 收集一些网上的资料,以便参考: http://blog.chinaunix.net/ ...

  9. Android基础之Activity launchMode详解

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! Activity的lauchmode,是基础的属性,但也是App优化必须掌握的知识,它约束了Acti ...

  10. 280. Wiggle Sort

    题目: Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] ...