forked from arthur-zhang/innodb-file-parser-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_03.bt
57 lines (51 loc) · 2.35 KB
/
test_03.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
BigEndian();
#define PAGE_SIZE (16 * 1024)
typedef ubyte u1;
typedef uint16 u2;
typedef uint32 u4;
typedef uint64 u8;
typedef byte i1;
typedef int16 i2;
typedef int32 i4;
enum <u2> PAGE_TYPE {
FIL_PAGE_INDEX = 17855, /*!< B-tree node */
FIL_PAGE_RTREE = 17854, /*!< B-tree node */
FIL_PAGE_UNDO_LOG =2, /*!< Undo log page */
FIL_PAGE_INODE =3 ,/*!< Index node */
FIL_PAGE_IBUF_FREE_LIST =4, /*!< Insert buffer free list */ /* File page types introduced in MySQL/InnoDB 5.1.7 */
FIL_PAGE_TYPE_ALLOCATED =0 ,/*!< Freshly allocated page */
FIL_PAGE_IBUF_BITMAP =5 , /*!< Insert buffer bitmap */
FIL_PAGE_TYPE_SYS =6 ,/*!< System page */
FIL_PAGE_TYPE_TRX_SYS =7, /*!< Transaction system data */
FIL_PAGE_TYPE_FSP_HDR =8 ,/*!< File space header */
FIL_PAGE_TYPE_XDES =9 ,/*!< Extent descriptor page */
FIL_PAGE_TYPE_BLOB =10 ,/*!< Uncompressed BLOB page */
FIL_PAGE_TYPE_ZBLOB =11 ,/*!< First compressed BLOB page */
FIL_PAGE_TYPE_ZBLOB2 =12 ,/*!< Subsequent compressed BLOB page */
FIL_PAGE_TYPE_UNKNOWN =13 ,/*!< In old tablespaces, garbage in FIL_PAGE_TYPE is replaced with this value when flushing pages. */
FIL_PAGE_COMPRESSED =14 ,/*!< Compressed page */
FIL_PAGE_ENCRYPTED =15 ,/*!< Encrypted page */
FIL_PAGE_COMPRESSED_AND_ENCRYPTED =16 , /*!< Compressed and Encrypted page */
FIL_PAGE_ENCRYPTED_RTREE =17, /*!< Encrypted R-tree page */
};
// 38 字节的 File Header,存储了页的一些通用信息
typedef struct FilHeader {
u4 FIL_PAGE_SPACE_OR_CHKSUM<format=hex,comment="页的校验和(checksum值)">;
u4 FIL_PAGE_OFFSET<fgcolor=0xFF0000,comment="页号">;
u4 FIL_PAGE_PREV<comment="上一个页的页号">;
u4 FIL_PAGE_NEXT<comment="下一个页的页号">;
u8 FIL_PAGE_LSN<comment="页面被最后修改时对应的日志序列位置(英文名是:Log Sequence Number)">;
PAGE_TYPE FIL_PAGE_TYPE;
u8 FIL_PAGE_FILE_FLUSH_LSN<comment="仅在系统表空间的一个页中定义,代表文件至少被刷新到了对应的LSN值">;
u4 FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID<comment="页属于哪个表空间">;
};
// 定义一个 Page 结构体
typedef struct Page(int index) {
FilHeader file_header;
byte unparsed[PAGE_SIZE - sizeof(file_header)];
};
local int file_size = FileSize();
local int i;
for (i = 0; i < file_size / PAGE_SIZE; ++i) {
Page page(i); // 读取 16KB 的内容映射到 Page 结构体中
}