1 /***************************************************************************** 2 3 Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. 4 5 This program is free software; you can redistribute it and/or modify it under 6 the terms of the GNU General Public License, version 2.0, as published by the 7 Free Software Foundation. 8 9 This program is also distributed with certain software (including but not 10 limited to OpenSSL) that is licensed under separate terms, as designated in a 11 particular file or component or in included license documentation. The authors 12 of MySQL hereby grant you an additional permission to link the program and 13 your derivative works with the separately licensed software that they have 14 included with MySQL. 15 16 This program is distributed in the hope that it will be useful, but WITHOUT 17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, 19 for more details. 20 21 You should have received a copy of the GNU General Public License along with 22 this program; if not, write to the Free Software Foundation, Inc., 23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 25 *****************************************************************************/ 26 27 /** @file include/fil0types.h 28 The low-level file system page header & trailer offsets 29 30 Created 10/25/1995 Heikki Tuuri 31 *******************************************************/ 32 33 #ifndef fil0types_h 34 #define fil0types_h 35 36 #include "univ.i" 37 38 /** The byte offsets on a file page for various variables. */ 39 40 /** MySQL-4.0.14 space id the page belongs to (== 0) but in later 41 versions the 'new' checksum of the page */ 42 #define FIL_PAGE_SPACE_OR_CHKSUM 0 43 44 /** page offset inside space */ 45 #define FIL_PAGE_OFFSET 4 46 47 /** if there is a 'natural' predecessor of the page, its offset. 48 Otherwise FIL_NULL. This field is not set on BLOB pages, which are stored as a 49 singly-linked list. See also FIL_PAGE_NEXT. */ 50 #define FIL_PAGE_PREV 8 51 52 /** On page 0 of the tablespace, this is the server version ID */ 53 #define FIL_PAGE_SRV_VERSION 8 54 55 /** if there is a 'natural' successor of the page, its offset. Otherwise 56 FIL_NULL. B-tree index pages(FIL_PAGE_TYPE contains FIL_PAGE_INDEX) on the 57 same PAGE_LEVEL are maintained as a doubly linked list via FIL_PAGE_PREV and 58 FIL_PAGE_NEXT in the collation order of the smallest user record on each 59 page. */ 60 #define FIL_PAGE_NEXT 12 61 62 /** On page 0 of the tablespace, this is the server version ID */ 63 #define FIL_PAGE_SPACE_VERSION 12 64 65 /** lsn of the end of the newest modification log record to the page */ 66 #define FIL_PAGE_LSN 16 67 68 /** file page type: FIL_PAGE_INDEX,..., 2 bytes. The contents of this field 69 can only be trusted in the following case: if the page is an uncompressed 70 B-tree index page, then it is guaranteed that the value is FIL_PAGE_INDEX. 71 The opposite does not hold. 72 73 In tablespaces created by MySQL/InnoDB 5.1.7 or later, the contents of this 74 field is valid for all uncompressed pages. */ 75 #define FIL_PAGE_TYPE 24 76 77 /** this is only defined for the first page of the system tablespace: the file 78 has been flushed to disk at least up to this LSN. For FIL_PAGE_COMPRESSED 79 pages, we store the compressed page control information in these 8 bytes. */ 80 #define FIL_PAGE_FILE_FLUSH_LSN 26 81 82 /** If page type is FIL_PAGE_COMPRESSED then the 8 bytes starting at 83 FIL_PAGE_FILE_FLUSH_LSN are broken down as follows: */ 84 85 /** Control information version format (u8) */ 86 constexpr ulint FIL_PAGE_VERSION = FIL_PAGE_FILE_FLUSH_LSN; 87 88 /** Compression algorithm (u8) */ 89 constexpr ulint FIL_PAGE_ALGORITHM_V1 = FIL_PAGE_VERSION + 1; 90 91 /** Original page type (u16) */ 92 constexpr ulint FIL_PAGE_ORIGINAL_TYPE_V1 = FIL_PAGE_ALGORITHM_V1 + 1; 93 94 /** Original data size in bytes (u16)*/ 95 constexpr ulint FIL_PAGE_ORIGINAL_SIZE_V1 = FIL_PAGE_ORIGINAL_TYPE_V1 + 2; 96 97 /** Size after compression (u16) */ 98 constexpr ulint FIL_PAGE_COMPRESS_SIZE_V1 = FIL_PAGE_ORIGINAL_SIZE_V1 + 2; 99 100 /** This overloads FIL_PAGE_FILE_FLUSH_LSN for RTREE Split Sequence Number */ 101 constexpr ulint FIL_RTREE_SPLIT_SEQ_NUM = FIL_PAGE_FILE_FLUSH_LSN; 102 103 /** starting from 4.1.x this contains the space id of the page */ 104 constexpr ulint FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID = 34; 105 106 /** alias for space id */ 107 #define FIL_PAGE_SPACE_ID FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 108 109 /** start of the data on the page */ 110 constexpr ulint FIL_PAGE_DATA = 38; 111 112 /** File page trailer */ 113 /** the low 4 bytes of this are used to store the page checksum, the 114 last 4 bytes should be identical to the last 4 bytes of FIL_PAGE_LSN */ 115 constexpr ulint FIL_PAGE_END_LSN_OLD_CHKSUM = 8; 116 117 /** size of the page trailer */ 118 constexpr ulint FIL_PAGE_DATA_END = 8; 119 120 /** First in address is the page offset. */ 121 constexpr size_t FIL_ADDR_PAGE = 0; 122 123 /** Then comes 2-byte byte offset within page.*/ 124 constexpr size_t FIL_ADDR_BYTE = 4; 125 126 /** Address size is 6 bytes. */ 127 constexpr size_t FIL_ADDR_SIZE = 6; 128 129 /** Path separator e.g., 'dir;...;dirN' */ 130 constexpr char FIL_PATH_SEPARATOR = ';'; 131 132 #endif /* fil0types_h */ 133