MySQL  8.0.18
Source Code Documentation
dict0boot.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 *****************************************************************************/
26 
27 /** @file include/dict0boot.h
28  Data dictionary creation and booting
29 
30  Created 4/18/1996 Heikki Tuuri
31  *******************************************************/
32 
33 #ifndef dict0boot_h
34 #define dict0boot_h
35 
36 #include "univ.i"
37 
38 #include "buf0buf.h"
39 #include "dict0dict.h"
40 #include "fsp0fsp.h"
41 #include "mtr0log.h"
42 #include "mtr0mtr.h"
43 #include "ut0byte.h"
44 
45 typedef byte dict_hdr_t;
46 
47 /** Gets a pointer to the dictionary header and x-latches its page.
48  @return pointer to the dictionary header, page x-latched */
49 dict_hdr_t *dict_hdr_get(mtr_t *mtr); /*!< in: mtr */
50 /** Returns a new table, index, or space id. */
51 void dict_hdr_get_new_id(table_id_t *table_id, /*!< out: table id
52  (not assigned if NULL) */
53  space_index_t *index_id, /*!< out: index id
54  (not assigned if NULL) */
55  space_id_t *space_id, /*!< out: space id
56  (not assigned if NULL) */
57  const dict_table_t *table, /*!< in: table */
58  bool disable_redo); /*!< in: if true and table
59  object is NULL
60  then disable-redo */
61 /** Writes the current value of the row id counter to the dictionary header file
62  page. */
63 void dict_hdr_flush_row_id(void);
64 /** Returns a new row id.
65  @return the new id */
66 UNIV_INLINE
68 /** Reads a row id from a record or other 6-byte stored form.
69  @return row id */
70 UNIV_INLINE
71 row_id_t dict_sys_read_row_id(const byte *field); /*!< in: record field */
72 
73 /** Writes a row id to a record or other 6-byte stored form.
74 @param[in] field record field
75 @param[in] row_id row id */
76 UNIV_INLINE
77 void dict_sys_write_row_id(byte *field, row_id_t row_id);
78 
79 /** Initializes the data dictionary memory structures when the database is
80  started. This function is also called when the data dictionary is created.
81  @return DB_SUCCESS or error code. */
82 dberr_t dict_boot(void) MY_ATTRIBUTE((warn_unused_result));
83 
84 /** Creates and initializes the data dictionary at the server bootstrap.
85  @return DB_SUCCESS or error code. */
86 dberr_t dict_create(void) MY_ATTRIBUTE((warn_unused_result));
87 
88 /** Check if a table id belongs to old innodb internal system table.
89 @param[in] id table id
90 @return true if the table id belongs to a system table. */
91 UNIV_INLINE
92 bool dict_is_old_sys_table(table_id_t id) MY_ATTRIBUTE((warn_unused_result));
93 
94 /* Space id and page no where the dictionary header resides */
95 #define DICT_HDR_SPACE 0 /* the SYSTEM tablespace */
96 #define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO
97 
98 /* The ids for the basic system tables and their indexes */
99 #define DICT_TABLES_ID 1
100 #define DICT_COLUMNS_ID 2
101 #define DICT_INDEXES_ID 3
102 #define DICT_FIELDS_ID 4
103 /* The following is a secondary index on SYS_TABLES */
104 #define DICT_TABLE_IDS_ID 5
105 
106 #define DICT_HDR_FIRST_ID \
107  10 /* the ids for tables etc. start \
108  from this number, except for basic \
109  system tables and their above defined \
110  indexes; ibuf tables and indexes are \
111  assigned as the id the number \
112  DICT_IBUF_ID_MIN plus the space id */
113 
114 /* The offset of the dictionary header on the page */
115 #define DICT_HDR FSEG_PAGE_DATA
116 
117 /*-------------------------------------------------------------*/
118 /* Dictionary header offsets */
119 #define DICT_HDR_ROW_ID 0 /* The latest assigned row id */
120 #define DICT_HDR_TABLE_ID 8 /* The latest assigned table id */
121 #define DICT_HDR_INDEX_ID 16 /* The latest assigned index id */
122 #define DICT_HDR_MAX_SPACE_ID 24 /* The latest assigned space id,or 0*/
123 #define DICT_HDR_MIX_ID_LOW 28 /* Obsolete,always DICT_HDR_FIRST_ID*/
124 #define DICT_HDR_TABLES 32 /* Root of SYS_TABLES clust index */
125 #define DICT_HDR_TABLE_IDS 36 /* Root of SYS_TABLE_IDS sec index */
126 #define DICT_HDR_COLUMNS 40 /* Root of SYS_COLUMNS clust index */
127 #define DICT_HDR_INDEXES 44 /* Root of SYS_INDEXES clust index */
128 #define DICT_HDR_FIELDS 48 /* Root of SYS_FIELDS clust index */
129 
130 #define DICT_HDR_FSEG_HEADER \
131  56 /* Segment header for the tablespace \
132  segment into which the dictionary \
133  header is created */
134 /*-------------------------------------------------------------*/
135 
136 /* The columns in SYS_TABLES */
147 };
148 /* The field numbers in the SYS_TABLES clustered index */
161 };
162 /* The field numbers in the SYS_TABLE_IDS index */
167 };
168 /* The columns in SYS_COLUMNS */
178 };
179 /* The field numbers in the SYS_COLUMNS clustered index */
191 };
192 /* The columns in SYS_INDEXES */
203 };
204 /* The field numbers in the SYS_INDEXES clustered index */
217 };
218 /* The columns in SYS_FIELDS */
224 };
225 /* The field numbers in the SYS_FIELDS clustered index */
233 };
234 /* The columns in SYS_FOREIGN */
241 };
242 /* The field numbers in the SYS_FOREIGN clustered index */
251 };
252 /* The field numbers in the SYS_FOREIGN_FOR_NAME secondary index */
257 };
258 /* The columns in SYS_FOREIGN_COLS */
265 };
266 /* The field numbers in the SYS_FOREIGN_COLS clustered index */
275 };
276 /* The columns in SYS_TABLESPACES */
282 };
283 /* The field numbers in the SYS_TABLESPACES clustered index */
291 };
292 /* The columns in SYS_DATAFILES */
297 };
298 /* The field numbers in the SYS_DATAFILES clustered index */
305 };
306 
307 /* The columns in SYS_VIRTUAL */
313 };
314 /* The field numbers in the SYS_VIRTUAL clustered index */
322 };
323 
324 /* A number of the columns above occur in multiple tables. These are the
325 length of thos fields. */
326 #define DICT_FLD_LEN_SPACE 4
327 #define DICT_FLD_LEN_FLAGS 4
328 
329 /* When a row id which is zero modulo this number (which must be a power of
330 two) is assigned, the field DICT_HDR_ROW_ID on the dictionary header page is
331 updated */
332 #define DICT_HDR_ROW_ID_WRITE_MARGIN 256
333 
334 #ifndef UNIV_HOTBACKUP
335 #include "dict0boot.ic"
336 #endif /* !UNIV_HOTBACKUP */
337 
338 #endif
Definition: dict0boot.h:286
Definition: dict0boot.h:304
UNIV_INLINE row_id_t dict_sys_read_row_id(const byte *field)
Reads a row id from a record or other 6-byte stored form.
Definition: dict0boot.h:141
Definition: dict0boot.h:230
Definition: dict0boot.h:213
dict_col_sys_indexes_enum
Definition: dict0boot.h:193
Definition: dict0boot.h:189
Definition: dict0boot.h:229
dict_fld_sys_datafiles_enum
Definition: dict0boot.h:299
Definition: dict0boot.h:248
Definition: dict0boot.h:170
Definition: dict0boot.h:201
Definition: dict0boot.h:166
Definition: dict0boot.h:190
Definition: dict0boot.h:174
Definition: dict0boot.h:294
dberr_t dict_create(void)
Creates and initializes the data dictionary at the server bootstrap.
Definition: dict0boot.cc:440
Definition: dict0boot.h:215
dict_col_sys_tables_enum
Definition: dict0boot.h:137
Definition: dict0boot.h:310
Definition: dict0boot.h:160
Definition: dict0boot.h:262
dict_col_sys_fields_enum
Definition: dict0boot.h:219
Definition: dict0boot.h:194
Definition: dict0boot.h:309
Definition: dict0boot.h:216
Definition: dict0boot.h:269
Definition: dict0boot.h:152
Definition: dict0boot.h:200
void dict_hdr_flush_row_id(void)
Writes the current value of the row id counter to the dictionary header file page.
Definition: dict0boot.cc:152
Definition: dict0boot.h:199
dict_fld_sys_virtual_enum
Definition: dict0boot.h:315
Definition: dict0boot.h:222
Definition: dict0boot.h:154
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:64
dict_col_sys_columns_enum
Definition: dict0boot.h:169
Definition: dict0boot.h:264
Data structure for a database table.
Definition: dict0mem.h:1529
Definition: dict0boot.h:281
Definition: dict0boot.h:183
Definition: dict0boot.h:186
dict_fld_sys_foreign_enum
Definition: dict0boot.h:243
Definition: dict0boot.h:316
File space management.
dict_fld_sys_table_ids_enum
Definition: dict0boot.h:163
Definition: dict0boot.h:287
Definition: dict0boot.h:249
ib_id_t row_id_t
Row identifier (DB_ROW_ID, DATA_ROW_ID)
Definition: trx0types.h:142
Definition: dict0boot.h:255
Definition: dict0boot.h:312
Definition: dict0boot.h:195
Definition: dict0boot.h:245
Definition: dict0boot.h:247
Definition: dict0boot.h:263
Definition: dict0boot.h:300
Definition: dict0boot.h:246
Definition: dict0boot.h:270
Mini-transaction logging routines.
dict_col_sys_tablespaces_enum
Definition: dict0boot.h:277
Definition: dict0boot.h:151
Definition: dict0boot.h:157
UNIV_INLINE row_id_t dict_sys_get_new_row_id(void)
Returns a new row id.
Definition: dict0boot.h:165
Definition: dict0boot.h:317
Data dictionary system.
Definition: dict0boot.h:320
Definition: dict0boot.h:181
Definition: dict0boot.h:321
Definition: dict0boot.h:250
Definition: dict0boot.h:211
Definition: dict0boot.h:221
Definition: dict0boot.h:139
Definition: dict0boot.h:188
dict_hdr_t * dict_hdr_get(mtr_t *mtr)
Gets a pointer to the dictionary header and x-latches its page.
Definition: dict0boot.cc:49
Definition: dict0boot.h:232
UNIV_INLINE 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.
Definition: dict0boot.h:202
dberr_t
Definition: db0err.h:38
Definition: dict0boot.h:256
Definition: dict0boot.h:274
Definition: dict0boot.h:197
Definition: dict0boot.h:176
Definition: dict0boot.h:158
Definition: dict0boot.h:156
Definition: dict0boot.h:301
Definition: dict0boot.h:280
Definition: dict0boot.h:187
Definition: dict0boot.h:172
dict_col_sys_datafiles_enum
Definition: dict0boot.h:293
Definition: dict0boot.h:196
byte dict_hdr_t
Definition: dict0boot.h:45
Definition: dict0boot.h:288
Definition: dict0boot.h:209
dberr_t dict_boot(void)
Initializes the data dictionary memory structures when the database is started.
Definition: dict0boot.cc:206
dict_col_sys_virtual_enum
Definition: dict0boot.h:308
Definition: dict0boot.h:138
Utilities for byte operations.
Definition: dict0boot.h:319
dict_fld_sys_indexes_enum
Definition: dict0boot.h:205
Definition: dict0boot.h:153
Definition: dict0boot.h:228
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:61
dict_fld_sys_fields_enum
Definition: dict0boot.h:226
Definition: dict0boot.h:185
Definition: dict0boot.h:240
Definition: dict0boot.h:173
Definition: dict0boot.h:289
dict_fld_sys_foreign_for_name_enum
Definition: dict0boot.h:253
Definition: dict0boot.h:295
Definition: dict0boot.h:198
uint32 space_id_t
Tablespace identifier.
Definition: api0api.h:59
Definition: dict0boot.h:311
Definition: dict0boot.h:303
dict_fld_sys_columns_enum
Definition: dict0boot.h:180
Definition: dict0boot.h:206
Definition: dict0boot.h:208
Definition: dict0boot.h:220
ib_id_t space_index_t
Index identifier (unique within a tablespace).
Definition: dict0types.h:63
Definition: dict0boot.h:268
dict_col_sys_foreign_cols_enum
Definition: dict0boot.h:259
Definition: dict0boot.h:285
Definition: dict0boot.h:171
Definition: dict0boot.h:290
Definition: dict0boot.h:244
Definition: dict0boot.h:184
Definition: dict0boot.h:231
Definition: dict0boot.h:278
Definition: dict0boot.h:272
Definition: dict0boot.h:302
Mini-transaction buffer.
Definition: dict0boot.h:207
Definition: dict0boot.h:223
Definition: dict0boot.h:271
Definition: dict0boot.h:239
Definition: dict0boot.h:175
dict_col_sys_foreign_enum
Definition: dict0boot.h:235
Definition: dict0boot.h:142
Definition: dict0boot.h:164
Definition: dict0boot.h:210
dict_fld_sys_tablespaces_enum
Definition: dict0boot.h:284
Definition: dict0boot.h:150
Definition: dict0boot.h:144
Definition: dict0boot.h:143
Definition: dict0boot.h:145
Definition: dict0boot.h:155
Definition: dict0boot.h:177
Definition: dict0boot.h:236
unsigned char byte
Blob class.
Definition: common.h:159
Definition: dict0boot.h:182
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:169
UNIV_INLINE bool dict_is_old_sys_table(table_id_t id)
Check if a table id belongs to old innodb internal system table.
Definition: dict0boot.h:296
Definition: dict0boot.h:227
Definition: dict0boot.h:140
The database buffer pool high-level routines.
Definition: dict0boot.h:238
dict_fld_sys_foreign_cols_enum
Definition: dict0boot.h:267
Definition: dict0boot.h:318
Definition: dict0boot.h:261
dict_fld_sys_tables_enum
Definition: dict0boot.h:149
Definition: dict0boot.h:214
Definition: dict0boot.h:237
Definition: dict0boot.h:260
Definition: dict0boot.h:159
Definition: dict0boot.h:273
Definition: dict0boot.h:279
Definition: dict0boot.h:146
Definition: dict0boot.h:212
Definition: dict0boot.h:254