MySQL 9.6.0
Source Code Documentation
dict0boot.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1996, 2025, 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/dict0boot.h
29 Data dictionary creation and booting
30
31 Created 4/18/1996 Heikki Tuuri
32 *******************************************************/
33
34#ifndef dict0boot_h
35#define dict0boot_h
36
37#include "univ.i"
38
39#include "buf0buf.h"
40#include "dict0dict.h"
41#include "fsp0fsp.h"
42#include "mtr0log.h"
43#include "mtr0mtr.h"
44#include "ut0byte.h"
45
46typedef byte dict_hdr_t;
47
48/** Gets a pointer to the dictionary header and x-latches its page.
49 @return pointer to the dictionary header, page x-latched */
50dict_hdr_t *dict_hdr_get(mtr_t *mtr); /*!< in: mtr */
51
52/** Returns a new table, index, or space id.
53@param[out] table_id Table id (not assigned if null)
54@param[out] index_id Index id (not assigned if null)
55@param[out] space_id Space id (not assigned if null)
56@param[in] table Table
57@param[in] disable_redo If true and table object is null then disable-redo */
58void dict_hdr_get_new_id(table_id_t *table_id, space_index_t *index_id,
59 space_id_t *space_id, const dict_table_t *table,
60 bool disable_redo);
61#ifndef UNIV_HOTBACKUP
62/** Returns a new row id.
63 @return the new id */
65/** Reads a row id from a record or other 6-byte stored form.
66 @return row id */
68 const byte *field); /*!< in: record field */
69
70/** Writes a row id to a record or other 6-byte stored form.
71@param[in] field record field
72@param[in] row_id row id */
73static inline void dict_sys_write_row_id(byte *field, row_id_t row_id);
74
75#endif /* !UNIV_HOTBACKUP */
76
77/** Initializes the data dictionary memory structures when the database is
78 started. This function is also called when the data dictionary is created.
79 @return DB_SUCCESS or error code. */
80[[nodiscard]] dberr_t dict_boot();
81
82/** Creates and initializes the data dictionary at the server bootstrap.
83 @return DB_SUCCESS or error code. */
84[[nodiscard]] dberr_t dict_create();
85
86/** the ids for tables etc. start from this number, except for basic system
87 tables and their above defined indexes; ibuf tables and indexes are assigned
88 as the id the number DICT_IBUF_ID_MIN plus the space id */
89constexpr uint32_t DICT_HDR_FIRST_ID = 10;
90
91/* The offset of the dictionary header on the page */
92constexpr uint32_t DICT_HDR = FSEG_PAGE_DATA;
93
94/*-------------------------------------------------------------*/
95/* Dictionary header offsets */
96/** The latest assigned row id */
97constexpr uint32_t DICT_HDR_ROW_ID = 0;
98/** The latest assigned table id */
99constexpr uint32_t DICT_HDR_TABLE_ID = 8;
100/** The latest assigned index id */
101constexpr uint32_t DICT_HDR_INDEX_ID = 16;
102/** The latest assigned space id,or 0*/
103constexpr uint32_t DICT_HDR_MAX_SPACE_ID = 24;
104/** Obsolete,always DICT_HDR_FIRST_ID*/
105constexpr uint32_t DICT_HDR_MIX_ID_LOW = 28;
106
107/* Segment header for the tablespace segment into which the dictionary header is
108 created */
109constexpr uint32_t DICT_HDR_FSEG_HEADER = 56;
110/*-------------------------------------------------------------*/
111
112/* When a row id which is zero modulo this number (which must be a power of
113two) is assigned, the field DICT_HDR_ROW_ID on the dictionary header page is
114updated */
115constexpr uint32_t DICT_HDR_ROW_ID_WRITE_MARGIN = 256;
116
117#ifndef UNIV_HOTBACKUP
118#include "dict0boot.ic"
119#endif /* !UNIV_HOTBACKUP */
120
121#endif
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:49
The database buffer pool high-level routines.
dberr_t
Definition: db0err.h:39
constexpr uint32_t DICT_HDR
Definition: dict0boot.h:92
static void dict_sys_write_row_id(byte *field, row_id_t row_id)
Writes a row id to a record or other 6-byte stored form.
static row_id_t dict_sys_read_row_id(const byte *field)
Reads a row id from a record or other 6-byte stored form.
byte dict_hdr_t
Definition: dict0boot.h:46
constexpr uint32_t DICT_HDR_INDEX_ID
The latest assigned index id.
Definition: dict0boot.h:101
constexpr uint32_t DICT_HDR_FIRST_ID
the ids for tables etc.
Definition: dict0boot.h:89
constexpr uint32_t DICT_HDR_TABLE_ID
The latest assigned table id.
Definition: dict0boot.h:99
dict_hdr_t * dict_hdr_get(mtr_t *mtr)
Gets a pointer to the dictionary header and x-latches its page.
Definition: dict0boot.cc:50
void dict_hdr_get_new_id(table_id_t *table_id, space_index_t *index_id, space_id_t *space_id, const dict_table_t *table, bool disable_redo)
Returns a new table, index, or space id.
Definition: dict0boot.cc:70
constexpr uint32_t DICT_HDR_FSEG_HEADER
Definition: dict0boot.h:109
constexpr uint32_t DICT_HDR_MAX_SPACE_ID
The latest assigned space id,or 0.
Definition: dict0boot.h:103
static row_id_t dict_sys_get_new_row_id()
Returns a new row id.
dberr_t dict_boot()
Initializes the data dictionary memory structures when the database is started.
Definition: dict0boot.cc:209
constexpr uint32_t DICT_HDR_ROW_ID_WRITE_MARGIN
Definition: dict0boot.h:115
constexpr uint32_t DICT_HDR_ROW_ID
The latest assigned row id.
Definition: dict0boot.h:97
constexpr uint32_t DICT_HDR_MIX_ID_LOW
Obsolete,always DICT_HDR_FIRST_ID.
Definition: dict0boot.h:105
dberr_t dict_create()
Creates and initializes the data dictionary at the server bootstrap.
Definition: dict0boot.cc:258
Data dictionary creation and booting.
Data dictionary system.
ib_id_t space_index_t
Index identifier (unique within a tablespace).
Definition: dict0types.h:223
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:221
File space management.
constexpr uint32_t FSEG_PAGE_DATA
On a page of any file segment, data may be put starting from this offset.
Definition: fsp0types.h:79
Mini-transaction logging routines.
Mini-transaction buffer.
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Data structure for a database table.
Definition: dict0mem.h:1925
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:177
ib_id_t row_id_t
Row identifier (DB_ROW_ID, DATA_ROW_ID)
Definition: trx0types.h:132
Version control for database, common definitions, and include files.
Utilities for byte operations.