MySQL 8.0.39
Source Code Documentation
fil0types.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1995, 2024, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is designed to work with certain software (including
10but not limited to OpenSSL) that is licensed under separate terms,
11as designated in a particular file or component or in included license
12documentation. The authors of MySQL hereby grant you an additional
13permission to link the program and your derivative works with the
14separately licensed software that they have either included with
15the program or referenced in the documentation.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/** @file include/fil0types.h
29 The low-level file system page header & trailer offsets
30
31 Created 10/25/1995 Heikki Tuuri
32 *******************************************************/
33
34#ifndef fil0types_h
35#define fil0types_h
36
37#include "univ.i"
38
39/** The byte offsets on a file page for various variables. */
40
41/** MySQL-4.0.14 space id the page belongs to (== 0) but in later
42versions the 'new' checksum of the page */
43constexpr uint32_t FIL_PAGE_SPACE_OR_CHKSUM = 0;
44
45/** page offset inside space */
46constexpr uint32_t FIL_PAGE_OFFSET = 4;
47
48/** if there is a 'natural' predecessor of the page, its offset.
49Otherwise FIL_NULL. This field is not set on BLOB pages, which are stored as a
50singly-linked list. See also FIL_PAGE_NEXT. */
51constexpr uint32_t FIL_PAGE_PREV = 8;
52
53/** On page 0 of the tablespace, this is the server version ID */
54constexpr uint32_t FIL_PAGE_SRV_VERSION = 8;
55
56/** if there is a 'natural' successor of the page, its offset. Otherwise
57FIL_NULL. B-tree index pages(FIL_PAGE_TYPE contains FIL_PAGE_INDEX) on the
58same PAGE_LEVEL are maintained as a doubly linked list via FIL_PAGE_PREV and
59FIL_PAGE_NEXT in the collation order of the smallest user record on each
60page. */
61constexpr uint32_t FIL_PAGE_NEXT = 12;
62
63/** On page 0 of the tablespace, this is the server version ID */
64constexpr uint32_t FIL_PAGE_SPACE_VERSION = 12;
65
66/** lsn of the end of the newest modification log record to the page */
67constexpr uint32_t FIL_PAGE_LSN = 16;
68
69/** file page type: FIL_PAGE_INDEX,..., 2 bytes. The contents of this field
70can only be trusted in the following case: if the page is an uncompressed
71B-tree index page, then it is guaranteed that the value is FIL_PAGE_INDEX.
72The opposite does not hold.
73
74In tablespaces created by MySQL/InnoDB 5.1.7 or later, the contents of this
75field is valid for all uncompressed pages. */
76constexpr uint32_t FIL_PAGE_TYPE = 24;
77
78/** this is only defined for the first page of the system tablespace: the file
79has been flushed to disk at least up to this LSN. For FIL_PAGE_COMPRESSED
80pages, we store the compressed page control information in these 8 bytes. */
81constexpr uint32_t FIL_PAGE_FILE_FLUSH_LSN = 26;
82
83/** If page type is FIL_PAGE_COMPRESSED then the 8 bytes starting at
84FIL_PAGE_FILE_FLUSH_LSN are broken down as follows: */
85
86/** Control information version format (u8) */
88
89/** Compression algorithm (u8) */
90constexpr uint32_t FIL_PAGE_ALGORITHM_V1 = FIL_PAGE_VERSION + 1;
91
92/** Original page type (u16) */
94
95/** Original data size in bytes (u16)*/
97
98/** Size after compression (u16) */
100
101/** This overloads FIL_PAGE_FILE_FLUSH_LSN for RTREE Split Sequence Number */
103
104/** starting from 4.1.x this contains the space id of the page */
105constexpr uint32_t FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID = 34;
106
107/** alias for space id */
109
110/** start of the data on the page */
111constexpr uint32_t FIL_PAGE_DATA = 38;
112
113/** File page trailer */
114/** the low 4 bytes of this are used to store the page checksum, the
115last 4 bytes should be identical to the last 4 bytes of FIL_PAGE_LSN */
116constexpr uint32_t FIL_PAGE_END_LSN_OLD_CHKSUM = 8;
117
118/** size of the page trailer */
119constexpr uint32_t FIL_PAGE_DATA_END = 8;
120
121/** First in address is the page offset. */
122constexpr size_t FIL_ADDR_PAGE = 0;
123
124/** Then comes 2-byte byte offset within page.*/
125constexpr size_t FIL_ADDR_BYTE = 4;
126
127/** Address size is 6 bytes. */
128constexpr size_t FIL_ADDR_SIZE = 6;
129
130/** Path separator e.g., 'dir;...;dirN' */
131constexpr char FIL_PATH_SEPARATOR = ';';
132
133/** A wrapper class to help print and inspect the file page header. */
135 /** The constructor that takes a pointer to page header as argument.
136 @param[in] frame the pointer to the page header. */
137 explicit Fil_page_header(const byte *frame) : m_frame(frame) {}
138
139 /** Get the space id from the page header.
140 @return the space identifier. */
141 [[nodiscard]] space_id_t get_space_id() const noexcept;
142
143 /** Get the page number from the page header.
144 @return the page number. */
145 [[nodiscard]] page_no_t get_page_no() const noexcept;
146
147 /** Get the page type from the page header.
148 @return the page type. */
149 [[nodiscard]] uint16_t get_page_type() const noexcept;
150
151 /** Print the page header to the given output stream.
152 @param[in] out the output stream.
153 @return the output stream. */
154 std::ostream &print(std::ostream &out) const noexcept;
155
156 private:
157 /** Pointer to the page header. */
158 const byte *m_frame{};
159};
160
161/** Overload the global output operator to handle an object of type
162Fil_page_header.
163@param[in] out the output stream.
164@param[in] header an object of type Fil_page_header.
165@return the output stream. */
166inline std::ostream &operator<<(std::ostream &out,
167 const Fil_page_header &header) noexcept {
168 return (header.print(out));
169}
170
171#endif /* fil0types_h */
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:51
uint32_t page_no_t
Page number.
Definition: api0api.h:49
std::ostream & operator<<(std::ostream &out, const Fil_page_header &header) noexcept
Overload the global output operator to handle an object of type Fil_page_header.
Definition: fil0types.h:166
constexpr uint32_t FIL_PAGE_VERSION
If page type is FIL_PAGE_COMPRESSED then the 8 bytes starting at FIL_PAGE_FILE_FLUSH_LSN are broken d...
Definition: fil0types.h:87
constexpr uint32_t FIL_PAGE_COMPRESS_SIZE_V1
Size after compression (u16)
Definition: fil0types.h:99
constexpr uint32_t FIL_PAGE_TYPE
file page type: FIL_PAGE_INDEX,..., 2 bytes.
Definition: fil0types.h:76
constexpr size_t FIL_ADDR_PAGE
First in address is the page offset.
Definition: fil0types.h:122
constexpr uint32_t FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID
starting from 4.1.x this contains the space id of the page
Definition: fil0types.h:105
constexpr uint32_t FIL_PAGE_OFFSET
page offset inside space
Definition: fil0types.h:46
constexpr uint32_t FIL_PAGE_DATA
start of the data on the page
Definition: fil0types.h:111
constexpr size_t FIL_ADDR_SIZE
Address size is 6 bytes.
Definition: fil0types.h:128
constexpr uint32_t FIL_PAGE_FILE_FLUSH_LSN
this is only defined for the first page of the system tablespace: the file has been flushed to disk a...
Definition: fil0types.h:81
constexpr uint32_t FIL_PAGE_ORIGINAL_TYPE_V1
Original page type (u16)
Definition: fil0types.h:93
constexpr uint32_t FIL_PAGE_LSN
lsn of the end of the newest modification log record to the page
Definition: fil0types.h:67
constexpr uint32_t FIL_PAGE_SPACE_ID
alias for space id
Definition: fil0types.h:108
constexpr uint32_t FIL_PAGE_ALGORITHM_V1
Compression algorithm (u8)
Definition: fil0types.h:90
constexpr uint32_t FIL_PAGE_NEXT
if there is a 'natural' successor of the page, its offset.
Definition: fil0types.h:61
constexpr uint32_t FIL_PAGE_SPACE_OR_CHKSUM
The byte offsets on a file page for various variables.
Definition: fil0types.h:43
constexpr uint32_t FIL_PAGE_END_LSN_OLD_CHKSUM
File page trailer.
Definition: fil0types.h:116
constexpr uint32_t FIL_PAGE_PREV
if there is a 'natural' predecessor of the page, its offset.
Definition: fil0types.h:51
constexpr uint32_t FIL_PAGE_SPACE_VERSION
On page 0 of the tablespace, this is the server version ID.
Definition: fil0types.h:64
constexpr uint32_t FIL_PAGE_SRV_VERSION
On page 0 of the tablespace, this is the server version ID.
Definition: fil0types.h:54
constexpr uint32_t FIL_RTREE_SPLIT_SEQ_NUM
This overloads FIL_PAGE_FILE_FLUSH_LSN for RTREE Split Sequence Number.
Definition: fil0types.h:102
constexpr uint32_t FIL_PAGE_DATA_END
size of the page trailer
Definition: fil0types.h:119
constexpr char FIL_PATH_SEPARATOR
Path separator e.g., 'dir;...;dirN'.
Definition: fil0types.h:131
constexpr uint32_t FIL_PAGE_ORIGINAL_SIZE_V1
Original data size in bytes (u16)
Definition: fil0types.h:96
constexpr size_t FIL_ADDR_BYTE
Then comes 2-byte byte offset within page.
Definition: fil0types.h:125
Definition: gcs_xcom_synode.h:64
A wrapper class to help print and inspect the file page header.
Definition: fil0types.h:134
const byte * m_frame
Pointer to the page header.
Definition: fil0types.h:158
Fil_page_header(const byte *frame)
The constructor that takes a pointer to page header as argument.
Definition: fil0types.h:137
space_id_t get_space_id() const noexcept
Get the space id from the page header.
Definition: fil0fil.cc:11753
uint16_t get_page_type() const noexcept
Get the page type from the page header.
Definition: fil0fil.cc:11761
page_no_t get_page_no() const noexcept
Get the page number from the page header.
Definition: fil0fil.cc:11757
std::ostream & print(std::ostream &out) const noexcept
Print the page header to the given output stream.
Definition: fil0fil.cc:11745
Version control for database, common definitions, and include files.