MySQL 26.7.0
Source Code Documentation
fsp0sysspace.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2013, 2026, 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/fsp0sysspace.h
29 Multi file, shared, system tablespace implementation.
30
31 Created 2013-7-26 by Kevin Lewis
32 *******************************************************/
33
34#ifndef fsp0sysspace_h
35#define fsp0sysspace_h
36
39#include "fsp0space.h"
40#include "univ.i"
41#include "ut0expected.h" /* ut::Expected */
42
43#ifdef UNIV_HOTBACKUP
44#include "srv0srv.h"
45#endif
46
47/** If the last data file is auto-extended, we add this many pages to it
48at a time. We have to make this public because it is a config variable. */
50
51#ifdef UNIV_DEBUG
52/** Control if extra debug checks need to be done for temporary tablespace.
53Default = true that is disable such checks.
54This variable is not exposed to end-user but still kept as variable for
55developer to enable it during debug. */
57#endif /* UNIV_DEBUG */
58
59namespace ib::fsp {
60
61/** Stores information about a single system tablespace node parsed out from the
62param string. It represents a "const" config part of the node. */
64 public:
65 /** Constructor with all information that could be parsed out of the param
66 string. */
70
72
73 private:
74 /** Type of the node's device. */
76};
77
78/** Represents a tablespace node, including runtime info acquired and changed
79after the node is parsed out of the param string. */
81 public:
82 SysTablespace_node(const std::string &name, page_no_t size, size_t order,
85
89 }
90
91 [[nodiscard]] bool node_storage_exists() const {
93 }
94
95 private:
96 /** Specifies if the storage node exists. This is populated only after
97 checking the actual nodes' storage. */
99};
100
101/** Data structure that contains the information about shared tablespaces.
102Currently this can be the system tablespace or a temporary table tablespace */
103class SysTablespace : public Tablespace<SysTablespace_node> {
104 private:
106 public:
110 storage) noexcept
111 : m_node(node), m_storage(std::move(storage)) {}
112
115 };
116
117 public:
119 : Tablespace(space_id, space_type) { /* No op */
120 }
121
122#ifdef UNIV_HOTBACKUP
123 void reset() override {
126 m_is_tablespace_full = false;
129 }
130#endif
131
132 /** Set tablespace full status
133 @param[in] is_full true if full */
134 void set_tablespace_full_status(bool is_full) {
135 m_is_tablespace_full = is_full;
136 }
137
138 /** Get tablespace full status
139 @return true if table is full */
140 [[nodiscard]] bool get_tablespace_full_status() {
142 }
143
144 /** Parse the input params and populate member variables.
145 @param[in] filepath_spec path to data files
146 @return true on success parse */
147 [[nodiscard]] bool parse_params(const char *filepath_spec);
148
149 /** Check the data file specification.
150 @param[in] create_new_tablespace True if a new tablespace is to be created
151 @param[in] min_expected_size Minimum expected tablespace size in bytes
152 @param[in] supports_raw_devices True if the tablespace supports raw devices.
153 @return DB_SUCCESS if all OK else error code */
154 [[nodiscard]] dberr_t check_file_spec(bool create_new_tablespace,
155 uint64_t min_expected_size,
156 bool supports_raw_devices);
157
158 /**
159 @return auto_extend value setting */
160 [[nodiscard]] ulint can_auto_extend_last_file() const {
162 }
163
164 /**
165 @return the autoextend increment in pages. */
166 [[nodiscard]] static page_no_t get_autoextend_increment() {
168 ((1024 * 1024) / UNIV_PAGE_SIZE);
169 }
170
171 /** Open or create the data files, register the tablespace and its nodes in
172 the `fil`'s tablespace registry.
173 @return DB_SUCCESS or error code */
174 [[nodiscard]] dberr_t prepare_nodes();
175
176 /** Check the tablespace header for this tablespace and read the flush LSN.
177 @return value stored at offset FIL_PAGE_FILE_FLUSH_LSN or error code */
179
180 /** @return the sum of the node sizes that were created, in pages. */
183 }
184
185 private:
186 /** Create storage for the specified data node.
187 @param[in,out] node data node object. May change value of the
188 m_node_storage_exists member.
189 @return Opened storage node or error code */
192
193 /** Open storage of the specified data node.
194 @param[in] node data node object
195 @return Opened storage node or error code */
197 const SysTablespace_node &node);
198
199 private:
200 /* Put the pointer to the next byte after a valid file name.
201 Note that we must step over the ':' in a Windows filepath.
202 A Windows path normally looks like C:\ibdata\ibdata1:1G, but
203 a Windows raw partition may have a specification like
204 \\.\C::1Gnewraw or \\.\PHYSICALDRIVE2:1Gnewraw.
205 @param[in] str system tablespace file path spec
206 @return next character in string after the file name */
207 [[nodiscard]] static char *parse_file_name(char *ptr);
208
209 /** Convert a numeric string representing a number of bytes optionally ending
210 in upper or lower case G, M, or K, to a number of megabytes, rounding down to
211 the nearest megabyte. Then return the number of pages in the file.
212 @param[in,out] ptr Pointer to a numeric string
213 @return the number of pages in the file. */
214 [[nodiscard]] page_no_t parse_suffixed_page_count(char *&ptr);
215
216 enum class file_status_t_ {
217 FILE_STATUS_VOID = 0, /** status not set */
218 FILE_STATUS_RW_PERMISSION_ERROR, /** permission error */
219 FILE_STATUS_READ_WRITE_ERROR, /** not readable/writable */
220 FILE_STATUS_NOT_REGULAR_FILE_ERROR /** not a regular file */
221 };
222
223 /** Verify the size of the node storage
224 @param[in] node data node object
225 @param[in] node_info Information about the node storage specified.
226 @return DB_SUCCESS if OK else error code. */
227 [[nodiscard]] dberr_t check_size(
230
231 /* DATA MEMBERS */
232
233 /** if true, then we auto-extend the last data file */
235
236 /** if != 0, this tells the max size auto-extending may increase the
237 last data file size */
239
240 /** Tablespace full status */
242
243 /** Sum of sizes of all nodes, in pages, that had the storage created during
244 this instance lifetime. */
246};
247
248} // namespace ib::fsp
249
250/** The control info of the system tablespace. */
252
253/** The control info of a temporary table shared tablespace. */
255#endif /* fsp0sysspace_h */
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:49
uint32_t page_no_t
Page number.
Definition: api0api.h:47
Definition: fsp0sysspace.h:105
ut::unique_ptr< ib::fil::Tablespace_node_handle_interface > m_storage
Definition: fsp0sysspace.h:114
Opened_storage_node(const SysTablespace_node &node, ut::unique_ptr< ib::fil::Tablespace_node_handle_interface > storage) noexcept
Definition: fsp0sysspace.h:107
const SysTablespace_node & m_node
Definition: fsp0sysspace.h:113
Data structure that contains the information about shared tablespaces.
Definition: fsp0sysspace.h:103
ut::Expected< lsn_t > read_lsn_and_check_flags()
Check the tablespace header for this tablespace and read the flush LSN.
Definition: fsp0sysspace.cc:433
dberr_t prepare_nodes()
Open or create the data files, register the tablespace and its nodes in the fil's tablespace registry...
Definition: fsp0sysspace.cc:639
void set_tablespace_full_status(bool is_full)
Set tablespace full status.
Definition: fsp0sysspace.h:134
SysTablespace(space_id_t space_id, fil_type_t space_type)
Definition: fsp0sysspace.h:118
bool get_tablespace_full_status()
Get tablespace full status.
Definition: fsp0sysspace.h:140
ut::Expected< SysTablespace::Opened_storage_node > create_node(SysTablespace_node &node)
Create storage for the specified data node.
Definition: fsp0sysspace.cc:315
page_no_t parse_suffixed_page_count(char *&ptr)
Convert a numeric string representing a number of bytes optionally ending in upper or lower case G,...
Definition: fsp0sysspace.cc:88
static page_no_t get_autoextend_increment()
Definition: fsp0sysspace.h:166
dberr_t check_file_spec(bool create_new_tablespace, uint64_t min_expected_size, bool supports_raw_devices)
Check the data file specification.
Definition: fsp0sysspace.cc:491
page_no_t m_last_file_size_in_pages_max
if != 0, this tells the max size auto-extending may increase the last data file size
Definition: fsp0sysspace.h:238
bool m_auto_extend_last_file
if true, then we auto-extend the last data file
Definition: fsp0sysspace.h:234
file_status_t_
Definition: fsp0sysspace.h:216
@ FILE_STATUS_NOT_REGULAR_FILE_ERROR
not readable/writable
@ FILE_STATUS_READ_WRITE_ERROR
permission error
ut::Expected< SysTablespace::Opened_storage_node > open_node(const SysTablespace_node &node)
Open storage of the specified data node.
Definition: fsp0sysspace.cc:391
bool parse_params(const char *filepath_spec)
Parse the input params and populate member variables.
Definition: fsp0sysspace.cc:120
bool m_is_tablespace_full
Tablespace full status.
Definition: fsp0sysspace.h:241
dberr_t check_size(SysTablespace_node &node, const ib::fil::Tablespaces_nodes_interface::Node_info &node_info)
Verify the size of the node storage.
Definition: fsp0sysspace.cc:289
page_no_t m_sum_of_new_sizes_in_pages
Sum of sizes of all nodes, in pages, that had the storage created during this instance lifetime.
Definition: fsp0sysspace.h:245
static char * parse_file_name(char *ptr)
Definition: fsp0sysspace.cc:76
ulint can_auto_extend_last_file() const
Definition: fsp0sysspace.h:160
page_no_t get_sum_of_new_sizes_in_pages() const
Definition: fsp0sysspace.h:181
Data structure that contains the information about an InnoDB tablespace.
Definition: fsp0space.h:82
fil_type_t space_type() const
Get tablespace type.
Definition: fsp0space.h:126
space_id_t space_id() const
Get the space id of the tablespace.
Definition: fsp0space.h:161
const SysTablespace_node & node(size_t order) const
Definition: fsp0space.h:117
C++23 std::expected.
Definition: ut0expected.h:74
dberr_t
Definition: db0err.h:39
fil_type_t
File types.
Definition: fil0types.h:180
node_device_type_t
Types of nodes specifed in innodb_data_file_path.
Definition: fsp0file.h:59
General shared tablespace implementation.
ib::fsp::SysTablespace srv_tmp_space
The control info of a temporary table shared tablespace.
ib::fsp::SysTablespace srv_sys_space
The control info of the system tablespace.
ulong sys_tablespace_auto_extend_increment
If the last data file is auto-extended, we add this many pages to it at a time.
Definition: fsp0sysspace.cc:68
bool srv_skip_temp_table_checks_debug
Control if extra debug checks need to be done for temporary tablespace.
Definition: fsp0sysspace.cc:71
std::string HARNESS_EXPORT reset()
get 'reset attributes' ESC sequence.
Definition: vt100.cc:37
Definition: fsp0sysspace.cc:74
noexcept
The return type for any call_and_catch(f, args...) call where f(args...) returns Type.
Definition: call_and_catch.h:76
size_t size(const char *const c)
Definition: base64.h:46
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > > >, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2284
The server main program.
Stored general information about the storage node at the time of calling the get_node_info().
Definition: fil0tablespaces_nodes_interface.h:173
Stores information about a single system tablespace node parsed out from the param string.
Definition: fsp0sysspace.h:63
const node_device_type_t m_device_type
Type of the node's device.
Definition: fsp0sysspace.h:75
node_device_type_t device_type() const
Definition: fsp0sysspace.h:71
SysTablespace_node_config(const std::string &name, page_no_t size, size_t order, node_device_type_t device_type)
Constructor with all information that could be parsed out of the param string.
Definition: fsp0sysspace.h:67
Represents a tablespace node, including runtime info acquired and changed after the node is parsed ou...
Definition: fsp0sysspace.h:80
void set_node_storage_exists()
Definition: fsp0sysspace.h:86
SysTablespace_node(const std::string &name, page_no_t size, size_t order, node_device_type_t device_type)
Definition: fsp0sysspace.h:82
bool m_node_storage_exists
Specifies if the storage node exists.
Definition: fsp0sysspace.h:98
bool node_storage_exists() const
Definition: fsp0sysspace.h:91
Stores information about a single tablespace node.
Definition: fsp0space.h:50
const std::string & name() const
Definition: fsp0space.h:62
size_t order() const
Definition: fsp0space.h:64
Version control for database, common definitions, and include files.
#define UNIV_PAGE_SIZE
The universal page size of the database.
Definition: univ.i:291
unsigned long int ulint
Definition: univ.i:403
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:97
Minimal implementation of C++23 std::expected.