在原来的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. AJAX实现仿Google Suggest效果

    修复了一些细节代码(支持持续按键事件) *项目名称:AJAX实现类Google Suggest效果*作者:草履虫(也就是蓝色的ecma)*联系:caolvchong@gmail.com*时间:2007 ...

  2. IDA 在string窗口中显示中文字符串

    打开ida61\cfg中的ida.cfg文件找到 // (cp866 version)AsciiStringChars = "\r\n\a\v\b\t\x1B" " !\ ...

  3. php中用于接受表单数据的$_request与$_post、$_get

    一.$_request与$_post.$_get的区别和特点 $_REQUEST[]具用$_POST[] $_GET[]的功能,但是$_REQUEST[]比较慢.通过post和get方法提交的所有数据 ...

  4. DevSecOps 简介(一)

    DevOps,或者说企业应用开发团队和系统运营团队的合作,已经成为一个时髦的 IT 话题.这一新的运营模式往往与敏捷式软件开发方法并举,同时还会利用云计算的可扩展性--这一切,都是为了使企业更加灵活, ...

  5. POJ 2482 Stars in Your Window (线段树+扫描线+区间最值,思路太妙了)

    该题和 黑书 P102 采矿 类似 参考链接:http://blog.csdn.net/shiqi_614/article/details/7819232http://blog.csdn.net/ts ...

  6. iOS生成本地随机验证码

    原文链接:http://www.cnblogs.com/jerehedu/p/4527707.html 效果图:

  7. CSS Ruler 前端工具

    CSS Ruler是一款在线的CSS单位工具. CSS Ruler 彩蛋爆料直击现场 http://katydecorah.com/css-ruler/

  8. POJ 1477

    #include <iostream> #define MAXN 100 using namespace std; int _[MAXN]; int main() { //freopen( ...

  9. Linux之select系统调用_1

    SYNOPSIS /* According to POSIX.1-2001 */ #include <sys/select.h> /* According to earlier stand ...

  10. [转载] Linux poll机制

    原地址:http://hongwazi.blog.163.com/blog/#m=0&t=3&c=poll poll的是一种查询的方式,英文解释 :民意调查 函数原型:int poll ...