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