扩展表空间

/***********************************************************************//**
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. 【转】 java自定义注解

    java注解是附加在代码中的一些元信息,用于一些工具在编译.运行时进行解析和使用,起到说明.配置的功能. 注解不会也不能影响代码的实际逻辑,仅仅起到辅助性的作用.包含在 java.lang.annot ...

  2. OC面向对象多态笔记

    面向对象的多态是建立在继承上,可以说没有继承就没有多态: 多态:父类指针指向了子类的对象: int main() { //假设已定义了Animal类和它的子类Dog,那么多态的代码体现就是 Anima ...

  3. .Net webservice动态调用

    直接贴代码吧 public class PmsService { /// <summary> /// pms接口 /// </summary> /// <param na ...

  4. 【SharePoint 文档管理解决方案设计系列一】文档使用分析

    在我们在 SharePoint 端设计文档管理解决方案之前我们要了解目前客户在他们已有的系统里是怎么对文档进行使用和管理的.只有了解了当前的使用情况才能根据客户的需求量身定做一套适合他们的有效的解决方 ...

  5. Android 问题流水总结

    先来一篇环境搭建的博客 这些都是大同小异. http://blog.csdn.net/yzhj2005/article/details/6980676 http://blog.csdn.net/wan ...

  6. 消除SDK更新时的“https://dl-ssl.google.com refused”异常

    原地址:http://blog.csdn.net/x605940745/article/details/17911115 消除SDK更新时的“https://dl-ssl.google.com ref ...

  7. Nginx配置一个自签名的SSL证书

    http://www.liaoxuefeng.com/article/0014189023237367e8d42829de24b6eaf893ca47df4fb5e000 要保证Web浏览器到服务器的 ...

  8. SDUT 1220 完美数

    完美数 Time Limit: 1000ms   Memory limit: 65536K 题目描述 任何一个自然数的约数中都有1和它本身,我们把小于它本身的因数叫做这个自然数的真约数. 如6的所有真 ...

  9. [SQL Server系] -- 约束

    什么是约束? 约束(Constraint)是SQL Server中提供的 自动保存数据库完整性 的一种方法,定义了可输入表或表的列中的数据限制条件. SQL Server中共有5中约束 PRIMARY ...

  10. sqlserver 空间数据类型

    --.建立有空间数据的表 create table x ( v ,) primary key, geog geography not null, geogWKT as geog.STAsText() ...