MySQL 8.0.31
Source Code Documentation
fil0types.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1995, 2022, 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 page type from the page header.
147 @return the page type. */
148 [[nodiscard]] uint16_t get_page_type() const noexcept;
149
150 /** Print the page header to the given output stream.
151 @param[in] out the output stream.
152 @return the output stream. */
153 std::ostream &print(std::ostream &out) const noexcept;
154
155 private:
156 /** Pointer to the page header. */
157 const byte *m_frame{};
158};
159
160/** Overload the global output operator to handle an object of type
161Fil_page_header.
162@param[in] out the output stream.
163@param[in] header an object of type Fil_page_header.
164@return the output stream. */
165inline std::ostream &operator<<(std::ostream &out,
166 const Fil_page_header &header) noexcept {
167 return (header.print(out));
168}
169
170#endif /* fil0types_h */
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:50
uint32_t page_no_t
Page number.
Definition: api0api.h:48
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:165
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:183
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:157
Fil_page_header(const byte *frame)
The constructor that takes a pointer to page header as argument.
Definition: fil0types.h:136
space_id_t get_space_id() const noexcept
Get the space id from the page header.
Definition: fil0fil.cc:11699
uint16_t get_page_type() const noexcept
Get the page type from the page header.
Definition: fil0fil.cc:11707
page_no_t get_page_no() const noexcept
Get the page number from the page header.
Definition: fil0fil.cc:11703
std::ostream & print(std::ostream &out) const noexcept
Print the page header to the given output stream.
Definition: fil0fil.cc:11691
Version control for database, common definitions, and include files.