扩展表空间

/***********************************************************************//**
Tries to extend the last data file of a tablespace if it is auto-extending.
@return    FALSE if not auto-extending */
static __attribute__((nonnull))
ibool
fsp_try_extend_data_file(
/*=====================*/
    ulint*        actual_increase,/*!< out: actual increase in pages, where
                    we measure the tablespace size from
                    what the header field says; it may be
                    the actual file size rounded down to
                    megabyte */
    ulint        space,        /*!< in: space */
    fsp_header_t*    header,        /*!< in/out: space header */
    mtr_t*        mtr)        /*!< in/out: mini-transaction */
{
    ulint    size;
    ulint    zip_size;
    ulint    new_size;
    ulint    old_size;
    ulint    size_increase;
    ulint    actual_size;
    ibool    success;

    *actual_increase = ;
    //UNIV_INTERN ibool    srv_auto_extend_last_data_file    = FALSE;
     && !srv_auto_extend_last_data_file) {

        /* We print the error message only once to avoid
        spamming the error log. Note that we don't need
        to reset the flag to FALSE as dealing with this
        error requires server restart. */
        if (fsp_tbs_full_error_printed == FALSE) {
            fprintf(stderr,
                "InnoDB: Error: Data file(s) ran"
                " out of space.\n"
                "Please add another data file or"
                " use \'autoextend\' for the last"
                " data file.\n");
            fsp_tbs_full_error_printed = TRUE;
        }
        return(FALSE);
    }

    size = mtr_read_ulint(header + FSP_SIZE, MLOG_4BYTES, mtr);
    zip_size = dict_table_flags_to_zip_size(
        mach_read_from_4(header + FSP_SPACE_FLAGS));

    old_size = size;

    ) {
        /**
         * if != 0, this tells the max size auto-extending may increase the last data file size
         * UNIV_INTERN ulint    srv_last_file_size_max    = 0;
         *
         *#define SRV_AUTO_EXTEND_INCREMENT    \
            (srv_auto_extend_increment * ((1024 * 1024) / UNIV_PAGE_SIZE))
            ====> 8*((1024*1024)/16k) 为512个page,共计8M (默认为8M)
         */
        if (!srv_last_file_size_max) {
            size_increase = SRV_AUTO_EXTEND_INCREMENT;
        } else {
            ...
        }
    } else {
        /* We extend single-table tablespaces first one extent
        at a time, but for bigger tablespaces more. It is not
        enough to extend always by one extent, because some
        extents are frag page extents. */
        ulint    extent_size;    /*!< one megabyte, in pages */

        if (!zip_size) {
            extent_size = FSP_EXTENT_SIZE;
        } else {
            extent_size = FSP_EXTENT_SIZE
                * UNIV_PAGE_SIZE / zip_size;
        }

        if (size < extent_size) {
            /* Let us first extend the file to extent_size */
            success = fsp_try_extend_data_file_with_pages(
                space, extent_size - , header, mtr);
            if (!success) {
                new_size = mtr_read_ulint(header + FSP_SIZE,
                              MLOG_4BYTES, mtr);

                *actual_increase = new_size - old_size;

                return(FALSE);
            }

            size = extent_size;
        }

         * extent_size) {
            size_increase = extent_size;
        } else {
            /* Below in fsp_fill_free_list() we assume
            that we add at most FSP_FREE_ADD extents at
            a time */
            size_increase = FSP_FREE_ADD * extent_size;
        }
    }

    ) {

        return(TRUE);
    }
    //当前size+512个page
    success = fil_extend_space_to_desired_size(&actual_size, space,size + size_increase);//详见    /* We ignore any fragments of a full megabyte when storing the size
    to the space header */

    if (!zip_size) {
        new_size = ut_calc_align_down(actual_size,
                          ( * ) / UNIV_PAGE_SIZE);
    } else {
        new_size = ut_calc_align_down(actual_size,
                          ( * ) / zip_size);
    }
    mlog_write_ulint(header + FSP_SIZE, new_size, MLOG_4BYTES, mtr);

    *actual_increase = new_size - old_size;

    return(TRUE);
}

函数fsp_try_extend_data_file的更多相关文章

  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. Careercup - Facebook面试题 - 5761467236220928

    2014-05-02 07:06 题目链接 原题: Given an array of randomly sorted integers and an integer k, write a funct ...

  2. MVC3 ModelBinder

    1.Model Binder从哪些地方获取数据(找到数据后会停止继续寻找) MVC 框架内置默认的 Model Binder 是 DefaultModelBinder 类.当 Action Invok ...

  3. 【BZOJ】【2820】YY的GCD

    莫比乌斯反演 PoPoQQQ讲义第二题. 暴力枚举每个质数,然后去更新它的倍数即可,那个g[x]看不懂就算了…… 为什么去掉了一个memset就不T了→_→…… /****************** ...

  4. uva 10912

    dp 记忆化搜索 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> ...

  5. C语言关键字register、extern、static

    C语言中: 一.register变量 关键字regiter请求编译器尽可能的将变量存在CPU的寄存器中.有以下几点注意的地方. register变量必须是能被CPU寄存器所接受的类型,这通常意味着re ...

  6. mahout安装配置

    1.下载mahout 下载地址:http://mahout.apache.org 我下载的最新版:mahout-distribution-0.9 2.把mahout解压到你想存放的文档,我是放在/Us ...

  7. 无法解析指定的连接标识符 oracle错误12154

    导出的时候老是报这个错,exp userid=c##yh/yh@MyOracle tables=(stu3) file=d:\e.dmp; 解决了好久,最后都失败了,后来加了127.0.0.1:152 ...

  8. lintcode : 空格替换

    题目: 空格替换 设计一种方法,将一个字符串中的所有空格替换成 %20 .你可以假设该字符串有足够的空间来加入新的字符,且你得到的是“真实的”字符长度. 样例 对于字符串"Mr John S ...

  9. 再谈PCA

        其实之前写过PCA相关的博文,但是由于之前掌握的理论知识有限,所以理解也比较浅.这篇博文,我们以另外一种角度来理解PCA看,这里我假设大家对PCA都有一个初步的了解.首先,我们举一个二维空间中 ...

  10. *[topcoder]TheMatrix

    http://community.topcoder.com/stat?c=problem_statement&pm=13035 矩阵棋盘的题,比较典型.可以定两条column夹住,然后上下扫, ...