mysql源码阅读笔记 (1) 底层物理页面的数据结构

Innodb数据页结构

单个页面的数据结构如下图所示:
这里写图片描述

1.1 文件头(fil0fil.h)
    /** The byte offsets on a file page for various variables @{ */
#define FIL_PAGE_SPACE_OR_CHKSUM 0  /*!< in < MySQL-4.0.14 space id the
                    page belongs to (== 0) but in later
                    versions the 'new' checksum of the
                    page */
#define FIL_PAGE_OFFSET     4   /*!< page offset inside space */
#define FIL_PAGE_PREV       8   /*!< if there is a 'natural'
                    predecessor of the page, its
                    offset.  Otherwise FIL_NULL.
                    This field is not set on BLOB
                    pages, which are stored as a
                    singly-linked list.  See also
                    FIL_PAGE_NEXT. */
#define FIL_PAGE_NEXT       12  /*!< if there is a 'natural' successor
                    of the page, its offset.
                    Otherwise FIL_NULL.
                    B-tree index pages
                    (FIL_PAGE_TYPE contains FIL_PAGE_INDEX)
                    on the same PAGE_LEVEL are maintained
                    as a doubly linked list via
                    FIL_PAGE_PREV and FIL_PAGE_NEXT
                    in the collation order of the
                    smallest user record on each page. */
#define FIL_PAGE_LSN        16  /*!< lsn of the end of the newest
                    modification log record to the page */
#define FIL_PAGE_TYPE       24  /*!< file page type: FIL_PAGE_INDEX,...,
                    2 bytes.

                    The contents of this field can only
                    be trusted in the following case:
                    if the page is an uncompressed
                    B-tree index page, then it is
                    guaranteed that the value is
                    FIL_PAGE_INDEX.
                    The opposite does not hold.

                    In tablespaces created by
                    MySQL/InnoDB 5.1.7 or later, the
                    contents of this field is valid
                    for all uncompressed pages. */
#define FIL_PAGE_FILE_FLUSH_LSN 26  /*!< this is only defined for the
                    first page in a system tablespace
                    data file (ibdata*, not *.ibd):
                    the file has been flushed to disk
                    at least up to this lsn */
#define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID  34 /*!< starting from 4.1.x this
                    contains the space id of the page */
#define FIL_PAGE_SPACE_ID  FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID

各个字段的说明:

名称大小(字节)说明
FIL_PAGE_SPACE_OR_CHKSUM4页的checksum
FIL_PAGE_OFFSET4表空间中页的偏移值
FIL_PAGE_PREV4B+树的链接,上一个叶子节点
FIL_PAGE_NEXT4B+树的链接 下一个叶子节点
FIL_PAGE_LSN8该页最后被修改的日志序列位置LSN;
(Log Sequence Number)
FIL_PAGE_TYPE2页的类型
FIL_PAGE_FILE_FLUSH_LSN8代表文件至少被更新到了改LSN
FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID4version > 4.1开始,代表该页属于哪个表空间
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值