Debian Codegraph @

storage/innobase/dict/dict0load.cc

raw symbols SCIP
1 /*****************************************************************************
2
3 Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2016, 2023, MariaDB Corporation.
5
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free Software
8 Foundation; version 2 of the License.
9
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
17
18 *****************************************************************************/
19
20 /**************************************************//**
21 @file dict/dict0load.cc
22 Loads to the memory cache database object definitions
23 from dictionary tables
24
25 Created 4/24/1996 Heikki Tuuri
26 *******************************************************/
27
28 #include "dict0load.h"cxx . . $ `<file>/storage/innobase/include/dict0load.h`/
29
30 #include "log.h"cxx . . $ `<file>/sql/log.h`/
31 #include "btr0pcur.h"cxx . . $ `<file>/storage/innobase/include/btr0pcur.h`/
32 #include "btr0btr.h"cxx . . $ `<file>/storage/innobase/include/btr0btr.h`/
33 #include "dict0boot.h"cxx . . $ `<file>/storage/innobase/include/dict0boot.h`/
34 #include "dict0crea.h"cxx . . $ `<file>/storage/innobase/include/dict0crea.h`/
35 #include "dict0dict.h"cxx . . $ `<file>/storage/innobase/include/dict0dict.h`/
36 #include "dict0stats.h"cxx . . $ `<file>/storage/innobase/include/dict0stats.h`/
37 #include "ibuf0ibuf.h"cxx . . $ `<file>/storage/innobase/include/ibuf0ibuf.h`/
38 #include "fsp0file.h"cxx . . $ `<file>/storage/innobase/include/fsp0file.h`/
39 #include "fts0priv.h"cxx . . $ `<file>/storage/innobase/include/fts0priv.h`/
40 #include "mach0data.h"cxx . . $ `<file>/storage/innobase/include/mach0data.h`/
41 #include "page0page.h"cxx . . $ `<file>/storage/innobase/include/page0page.h`/
42 #include "rem0cmp.h"cxx . . $ `<file>/storage/innobase/include/rem0cmp.h`/
43 #include "srv0start.h"cxx . . $ `<file>/storage/innobase/include/srv0start.h`/
44 #include "srv0srv.h"cxx . . $ `<file>/storage/innobase/include/srv0srv.h`/
45 #include "fts0opt.h"cxx . . $ `<file>/storage/innobase/include/fts0opt.h`/
46 #include "row0vers.h"cxx . . $ `<file>/storage/innobase/include/row0vers.h`/
47
48 /** Loads a table definition and also all its index definitions.
49
50 Loads those foreign key constraints whose referenced table is already in
51 dictionary cache. If a foreign key constraint is not loaded, then the
52 referenced table is pushed into the output stack (fk_tables), if it is not
53 NULL. These tables must be subsequently loaded so that all the foreign
54 key constraints are loaded into memory.
55
56 @param[in,out] mtr mini-transaction
57 @param[in] name Table name in the db/tablename format
58 @param[in] ignore_err Error to be ignored when loading table
59 and its index definition
60 @param[out] fk_tables Related table names that must also be
61 loaded to ensure that all foreign key
62 constraints are loaded.
63 @return table, possibly with file_unreadable flag set
64 @retval nullptr if the table does not exist */
65 static dict_table_tcxx . . $ dict_table_t# *dict_load_table_onecxx . . $ dict_load_table_one(da3fe585bfe8f7fe).(mtr_tcxx . . $ mtr_t# &mtr,
66 const spancxx . . $ span#<const char> &name,
67 dict_err_ignore_tcxx . . $ dict_err_ignore_t# ignore_err,
68 dict_names_tcxx . . $ dict_names_t# &fk_tables);
69
70 /** Load an index definition from a SYS_INDEXES record to dict_index_t.
71 @return error message
72 @retval NULL on success */
73 static
74 const char*
75 dict_load_index_lowcxx . . $ dict_load_index_low(df34aa736bf7c68d).(
76 bytecxx . . $ byte#* table_id, /*!< in/out: table id (8 bytes),
77 an "in" value if mtr
78 and "out" when !mtr */
79 bool uncommitted, /*!< in: false=READ COMMITTED,
80 true=READ UNCOMMITTED */
81 mem_heap_tcxx . . $ mem_heap_t#* heap, /*!< in/out: temporary memory heap */
82 const rec_tcxx . . $ rec_t#* rec, /*!< in: SYS_INDEXES record */
83 mtr_tcxx . . $ mtr_t#* mtr, /*!< in/out: mini-transaction,
84 or nullptr if a pre-allocated
85 *index is to be filled in */
86 dict_table_tcxx . . $ dict_table_t#* table, /*!< in/out: table, or NULL */
87 dict_index_tcxx . . $ dict_index_t#** index); /*!< out,own: index, or NULL */
88
89 /** Load a table column definition from a SYS_COLUMNS record to dict_table_t.
90 @param table table, or nullptr if the output will be in column
91 @param use_uncommitted 0=READ COMMITTED, 1=detect, 2=READ UNCOMMITTED
92 @param heap memory heap for temporary storage
93 @param column pointer to output buffer, or nullptr if table!=nullptr
94 @param table_id table identifier
95 @param col_name column name
96 @param rec SYS_COLUMNS record
97 @param mtr mini-transaction
98 @param nth_v_col nullptr, or pointer to a counter of virtual columns
99 @return error message
100 @retval nullptr on success */
101 static const char *dict_load_column_lowcxx . . $ dict_load_column_low(6615616bea64e040).(dict_table_tcxx . . $ dict_table_t# *table,
102 unsigned use_uncommitted,
103 mem_heap_tcxx . . $ mem_heap_t# *heap, dict_col_tcxx . . $ dict_col_t# *column,
104 table_id_tcxx . . $ table_id_t# *table_id,
105 const char **col_name,
106 const rec_tcxx . . $ rec_t# *rec,
107 mtr_tcxx . . $ mtr_t# *mtr,
108 ulintcxx . . $ ulint# *nth_v_col);
109
110 /** Load a virtual column "mapping" (to base columns) information
111 from a SYS_VIRTUAL record
112 @param[in,out] table table
113 @param[in] uncommitted false=READ COMMITTED, true=READ UNCOMMITTED
114 @param[in,out] column mapped base column's dict_column_t
115 @param[in,out] table_id table id
116 @param[in,out] pos virtual column position
117 @param[in,out] base_pos base column position
118 @param[in] rec SYS_VIRTUAL record
119 @return error message
120 @retval NULL on success */
121 static
122 const char*
123 dict_load_virtual_lowcxx . . $ dict_load_virtual_low(a6dcee11bfcf3c3d).(
124 dict_table_tcxx . . $ dict_table_t#* table,
125 bool uncommitted,
126 dict_col_tcxx . . $ dict_col_t#** column,
127 table_id_tcxx . . $ table_id_t#* table_id,
128 ulintcxx . . $ ulint#* pos,
129 ulintcxx . . $ ulint#* base_pos,
130 const rec_tcxx . . $ rec_t#* rec);
131
132 /** Load an index field definition from a SYS_FIELDS record to dict_index_t.
133 @return error message
134 @retval NULL on success */
135 static
136 const char*
137 dict_load_field_lowcxx . . $ dict_load_field_low(e74a7aa1f259e4b2).(
138 bytecxx . . $ byte#* index_id, /*!< in/out: index id (8 bytes)
139 an "in" value if index != NULL
140 and "out" if index == NULL */
141 bool uncommitted, /*!< in: false=READ COMMITTED,
142 true=READ UNCOMMITTED */
143 dict_index_tcxx . . $ dict_index_t#* index, /*!< in/out: index, could be NULL
144 if we just populate a dict_field_t
145 struct with information from
146 a SYS_FIELDS record */
147 dict_field_tcxx . . $ dict_field_t#* sys_field, /*!< out: dict_field_t to be
148 filled */
149 ulintcxx . . $ ulint#* pos, /*!< out: Field position */
150 bytecxx . . $ byte#* last_index_id, /*!< in: last index id */
151 mem_heap_tcxx . . $ mem_heap_t#* heap, /*!< in/out: memory heap
152 for temporary storage */
153 mtr_tcxx . . $ mtr_t#* mtr, /*!< in/out: mini-transaction */
154 const rec_tcxx . . $ rec_t#* rec); /*!< in: SYS_FIELDS record */
155
156 #ifdef UNIV_DEBUG
157 /****************************************************************//**
158 Compare the name of an index column.
159 @return TRUE if the i'th column of index is 'name'. */
160 static
161 ibool
162 name_of_col_is(
163 /*===========*/
164 const dict_table_t* table, /*!< in: table */
165 const dict_index_t* index, /*!< in: index */
166 ulint i, /*!< in: index field offset */
167 const char* name) /*!< in: name to compare to */
168 {
169 ulint tmp = dict_col_get_no(dict_field_get_col(
170 dict_index_get_nth_field(
171 index, i)));
172
173 return(strcmp(name, dict_table_get_col_name(table, tmp).str) == 0);
174 }
175 #endif /* UNIV_DEBUG */
176
177 const rec_tcxx . . $ rec_t#*
178 dict_getnext_system_lowcxx . . $ dict_getnext_system_low(49cd3ce815400fce).(btr_pcur_tcxx . . $ btr_pcur_t# *pcur, mtr_tcxx . . $ mtr_t# *mtr)
179 {
180 rec_tcxx . . $ rec_t# *rec = nullptr;
181 while (!rec)
182 {
183 btr_pcur_move_to_next_user_reccxx . . $ btr_pcur_move_to_next_user_rec(db7b0b7a66db0c31).(pcur, mtr);
184 rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(pcur);
185 if (!btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(pcur))
186 {
187 /* end of index */
188 btr_pcur_closecxx . . $ btr_pcur_close(57c44ef9c177cfb0).(pcur);
189 return nullptr;
190 }
191 }
192 /* Get a record, let's save the position */
193 btr_pcur_store_positioncxx . . $ btr_pcur_store_position(f723d369374bc0bf).(pcur, mtr);
194 return rec;
195 }
196
197 /********************************************************************//**
198 This function opens a system table, and returns the first record.
199 @return first record of the system table */
200 const rec_tcxx . . $ rec_t#*
201 dict_startscan_systemcxx . . $ dict_startscan_system(595c38df12662632).(
202 /*==================*/
203 btr_pcur_tcxx . . $ btr_pcur_t#* pcur, /*!< out: persistent cursor to
204 the record */
205 mtr_tcxx . . $ mtr_t#* mtr, /*!< in: the mini-transaction */
206 dict_table_tcxx . . $ dict_table_t#* table) /*!< in: system table */
207 {
208 btr_pcur_initcxx . . $ btr_pcur_init(57c44ef9c177cfb0).(pcur);
209 if (pcur->open_leafcxx . . $ btr_pcur_t#open_leaf(1d074ecb69eae3b8).(true, table->indexescxx . . $ dict_table_t#indexes..startcxx . . $ ut_list_base#start., BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., mtr) !=
210 DB_SUCCESScxx . . $ DB_SUCCESS.)
211 return nullptr;
212 const rec_tcxx . . $ rec_t# *rec;
213 do
214 rec= dict_getnext_system_lowcxx . . $ dict_getnext_system_low(49cd3ce815400fce).(pcur, mtr);
215 while (rec && rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0));
216 return rec;
217 }
218
219 /********************************************************************//**
220 This function gets the next system table record as it scans the table.
221 @return the next record if found, NULL if end of scan */
222 const rec_tcxx . . $ rec_t#*
223 dict_getnext_systemcxx . . $ dict_getnext_system(49cd3ce815400fce).(
224 /*================*/
225 btr_pcur_tcxx . . $ btr_pcur_t#* pcur, /*!< in/out: persistent cursor
226 to the record */
227 mtr_tcxx . . $ mtr_t#* mtr) /*!< in: the mini-transaction */
228 {
229 const rec_tcxx . . $ rec_t# *rec=nullptr;
230 if (pcur->restore_positioncxx . . $ btr_pcur_t#restore_position(8c85f028503b2912).(BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., mtr) != btr_pcur_tcxx . . $ btr_pcur_t#::CORRUPTEDcxx . . $ btr_pcur_t#CORRUPTED.)
231 do
232 rec= dict_getnext_system_lowcxx . . $ dict_getnext_system_low(49cd3ce815400fce).(pcur, mtr);
233 while (rec && rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0));
234 return rec;
235 }
236
237 /********************************************************************//**
238 This function parses a SYS_INDEXES record and populate a dict_index_t
239 structure with the information from the record. For detail information
240 about SYS_INDEXES fields, please refer to dict_boot() function.
241 @return error message, or NULL on success */
242 const char*
243 dict_process_sys_indexes_reccxx . . $ dict_process_sys_indexes_rec(d161f4f7221e5479).(
244 /*=========================*/
245 mem_heap_tcxx . . $ mem_heap_t#* heap, /*!< in/out: heap memory */
246 const rec_tcxx . . $ rec_t#* rec, /*!< in: current SYS_INDEXES rec */
247 dict_index_tcxx . . $ dict_index_t#* index, /*!< out: index to be filled */
248 table_id_tcxx . . $ table_id_t#* table_id) /*!< out: index table id */
249 {
250 bytecxx . . $ byte# buf[8];
251
252 ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(index->is_dummy = true);
253 ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(index->in_instant_init = false);
254
255 /* Parse the record, and get "dict_index_t" struct filled */
256 const char *err_msg= dict_load_index_lowcxx . . $ dict_load_index_low(df34aa736bf7c68d).(buf, false, heap, rec,
257 nullptr, nullptr, &index);
258 *table_id= mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(buf);
259 return err_msg;
260 }
261
262 /********************************************************************//**
263 This function parses a SYS_COLUMNS record and populate a dict_column_t
264 structure with the information from the record.
265 @return error message, or NULL on success */
266 const char*
267 dict_process_sys_columns_reccxx . . $ dict_process_sys_columns_rec(75887d298df05190).(
268 /*=========================*/
269 mem_heap_tcxx . . $ mem_heap_t#* heap, /*!< in/out: heap memory */
270 const rec_tcxx . . $ rec_t#* rec, /*!< in: current SYS_COLUMNS rec */
271 dict_col_tcxx . . $ dict_col_t#* column, /*!< out: dict_col_t to be filled */
272 table_id_tcxx . . $ table_id_t#* table_id, /*!< out: table id */
273 const char** col_name, /*!< out: column name */
274 ulintcxx . . $ ulint#* nth_v_col) /*!< out: if virtual col, this is
275 record's sequence number */
276 {
277 const char* err_msg;
278
279 /* Parse the record, and get "dict_col_t" struct filled */
280 err_msg = dict_load_column_lowcxx . . $ dict_load_column_low(6615616bea64e040).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, heap, column,
281 table_id, col_name, rec, nullptr,
282 nth_v_col);
283
284 return(err_msg);
285 }
286
287 /** This function parses a SYS_VIRTUAL record and extracts virtual column
288 information
289 @param[in] rec current SYS_COLUMNS rec
290 @param[in,out] table_id table id
291 @param[in,out] pos virtual column position
292 @param[in,out] base_pos base column position
293 @return error message, or NULL on success */
294 const char*
295 dict_process_sys_virtual_reccxx . . $ dict_process_sys_virtual_rec(3fa846d2bf51dd8b).(
296 const rec_tcxx . . $ rec_t#* rec,
297 table_id_tcxx . . $ table_id_t#* table_id,
298 ulintcxx . . $ ulint#* pos,
299 ulintcxx . . $ ulint#* base_pos)
300 {
301 return dict_load_virtual_lowcxx . . $ dict_load_virtual_low(a6dcee11bfcf3c3d).(nullptr, false, nullptr, table_id,
302 pos, base_pos, rec);
303 }
304
305 /********************************************************************//**
306 This function parses a SYS_FIELDS record and populates a dict_field_t
307 structure with the information from the record.
308 @return error message, or NULL on success */
309 const char*
310 dict_process_sys_fields_reccxx . . $ dict_process_sys_fields_rec(66776805bc7225d1).(
311 /*========================*/
312 mem_heap_tcxx . . $ mem_heap_t#* heap, /*!< in/out: heap memory */
313 const rec_tcxx . . $ rec_t#* rec, /*!< in: current SYS_FIELDS rec */
314 dict_field_tcxx . . $ dict_field_t#* sys_field, /*!< out: dict_field_t to be
315 filled */
316 ulintcxx . . $ ulint#* pos, /*!< out: Field position */
317 index_id_tcxx . . $ index_id_t#* index_id, /*!< out: current index id */
318 index_id_tcxx . . $ index_id_t# last_id) /*!< in: previous index id */
319 {
320 bytecxx . . $ byte# buf[8];
321 bytecxx . . $ byte# last_index_id[8];
322 const char* err_msg;
323
324 mach_write_to_8cxx . . $ mach_write_to_8(5500c4293b1bbef0).(last_index_id, last_id);
325
326 err_msg = dict_load_field_lowcxx . . $ dict_load_field_low(e74a7aa1f259e4b2).(buf, false, nullptr, sys_field,
327 pos, last_index_id, heap, nullptr, rec);
328
329 *index_id = mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(buf);
330
331 return(err_msg);
332
333 }
334
335 /********************************************************************//**
336 This function parses a SYS_FOREIGN record and populate a dict_foreign_t
337 structure with the information from the record. For detail information
338 about SYS_FOREIGN fields, please refer to dict_load_foreign() function.
339 @return error message, or NULL on success */
340 const char*
341 dict_process_sys_foreign_reccxx . . $ dict_process_sys_foreign_rec(6be8c3f3fc81461d).(
342 /*=========================*/
343 mem_heap_tcxx . . $ mem_heap_t#* heap, /*!< in/out: heap memory */
344 const rec_tcxx . . $ rec_t#* rec, /*!< in: current SYS_FOREIGN rec */
345 dict_foreign_tcxx . . $ dict_foreign_t#* foreign) /*!< out: dict_foreign_t struct
346 to be filled */
347 {
348 ulintcxx . . $ ulint# len;
349 const bytecxx . . $ byte#* field;
350
351 if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
352 return("delete-marked record in SYS_FOREIGN");
353 }
354
355 if (rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec) != DICT_NUM_FIELDS__SYS_FOREIGNcxx . . $ DICT_NUM_FIELDS__SYS_FOREIGN.) {
356 return("wrong number of columns in SYS_FOREIGN record");
357 }
358
359 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
360 rec, DICT_FLD__SYS_FOREIGN__ID, &len);
361 if (len == 0 || len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
362 err_len:
363 return("incorrect column length in SYS_FOREIGN");
364 }
365
366 /* This receives a dict_foreign_t* that points to a stack variable.
367 So dict_foreign_free(foreign) is not used as elsewhere.
368 Since the heap used here is freed elsewhere, foreign->heap
369 is not assigned. */
370 foreign->idcxx . . $ dict_foreign_t#id. = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(heap, (const char*) field, len);
371
372 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
373 rec, DICT_FLD__SYS_FOREIGN__DB_TRX_IDcxx . . $ DICT_FLD__SYS_FOREIGN__DB_TRX_ID., &len);
374 if (len != DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
375 goto err_len;
376 }
377 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
378 rec, DICT_FLD__SYS_FOREIGN__DB_ROLL_PTRcxx . . $ DICT_FLD__SYS_FOREIGN__DB_ROLL_PTR., &len);
379 if (len != DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
380 goto err_len;
381 }
382
383 /* The _lookup versions of the referenced and foreign table names
384 are not assigned since they are not used in this dict_foreign_t */
385
386 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
387 rec, DICT_FLD__SYS_FOREIGN__FOR_NAME, &len);
388 if (len == 0 || len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
389 goto err_len;
390 }
391 foreign->foreign_table_namecxx . . $ dict_foreign_t#foreign_table_name. = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(
392 heap, (const char*) field, len);
393
394 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
395 rec, DICT_FLD__SYS_FOREIGN__REF_NAME, &len);
396 if (len == 0 || len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
397 goto err_len;
398 }
399 foreign->referenced_table_namecxx . . $ dict_foreign_t#referenced_table_name. = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(
400 heap, (const char*) field, len);
401
402 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
403 rec, DICT_FLD__SYS_FOREIGN__N_COLS, &len);
404 if (len != 4) {
405 goto err_len;
406 }
407 uint32_tcxx . . $ uint32_t# n_fields_and_type = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
408
409 foreign->typecxx . . $ dict_foreign_t#type. = n_fields_and_type >> 24 & ((1U << 6) - 1);
410 foreign->n_fieldscxx . . $ dict_foreign_t#n_fields. = n_fields_and_type & dict_index_tcxx . . $ dict_index_t#::MAX_N_FIELDScxx . . $ dict_index_t#MAX_N_FIELDS.;
411
412 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
413 }
414
415 /********************************************************************//**
416 This function parses a SYS_FOREIGN_COLS record and extract necessary
417 information from the record and return to caller.
418 @return error message, or NULL on success */
419 const char*
420 dict_process_sys_foreign_col_reccxx . . $ dict_process_sys_foreign_col_rec(45dad1421e3311c1).(
421 /*=============================*/
422 mem_heap_tcxx . . $ mem_heap_t#* heap, /*!< in/out: heap memory */
423 const rec_tcxx . . $ rec_t#* rec, /*!< in: current SYS_FOREIGN_COLS rec */
424 const char** name, /*!< out: foreign key constraint name */
425 const char** for_col_name, /*!< out: referencing column name */
426 const char** ref_col_name, /*!< out: referenced column name
427 in referenced table */
428 ulintcxx . . $ ulint#* pos) /*!< out: column position */
429 {
430 ulintcxx . . $ ulint# len;
431 const bytecxx . . $ byte#* field;
432
433 if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
434 return("delete-marked record in SYS_FOREIGN_COLS");
435 }
436
437 if (rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec) != DICT_NUM_FIELDS__SYS_FOREIGN_COLScxx . . $ DICT_NUM_FIELDS__SYS_FOREIGN_COLS.) {
438 return("wrong number of columns in SYS_FOREIGN_COLS record");
439 }
440
441 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
442 rec, DICT_FLD__SYS_FOREIGN_COLS__ID, &len);
443 if (len == 0 || len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
444 err_len:
445 return("incorrect column length in SYS_FOREIGN_COLS");
446 }
447 *name = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(heap, (char*) field, len);
448
449 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
450 rec, DICT_FLD__SYS_FOREIGN_COLS__POS, &len);
451 if (len != 4) {
452 goto err_len;
453 }
454 *pos = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
455
456 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
457 rec, DICT_FLD__SYS_FOREIGN_COLS__DB_TRX_IDcxx . . $ DICT_FLD__SYS_FOREIGN_COLS__DB_TRX_ID., &len);
458 if (len != DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
459 goto err_len;
460 }
461 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
462 rec, DICT_FLD__SYS_FOREIGN_COLS__DB_ROLL_PTRcxx . . $ DICT_FLD__SYS_FOREIGN_COLS__DB_ROLL_PTR., &len);
463 if (len != DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
464 goto err_len;
465 }
466
467 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
468 rec, DICT_FLD__SYS_FOREIGN_COLS__FOR_COL_NAME, &len);
469 if (len == 0 || len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
470 goto err_len;
471 }
472 *for_col_name = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(heap, (char*) field, len);
473
474 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
475 rec, DICT_FLD__SYS_FOREIGN_COLS__REF_COL_NAME, &len);
476 if (len == 0 || len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
477 goto err_len;
478 }
479 *ref_col_name = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(heap, (char*) field, len);
480
481 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
482 }
483
484 /** Check the validity of a SYS_TABLES record
485 Make sure the fields are the right length and that they
486 do not contain invalid contents.
487 @param[in] rec SYS_TABLES record
488 @return error message, or NULL on success */
489 static
490 const char*
491 dict_sys_tables_rec_checkcxx . . $ dict_sys_tables_rec_check(366f986dcc4a6ef).(
492 const rec_tcxx . . $ rec_t#* rec)
493 {
494 const bytecxx . . $ byte#* field;
495 ulintcxx . . $ ulint# len;
496
497 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys.locked());
498
499 if (rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec) != DICT_NUM_FIELDS__SYS_TABLEScxx . . $ DICT_NUM_FIELDS__SYS_TABLES.) {
500 return("wrong number of columns in SYS_TABLES record");
501 }
502
503 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
504 rec, DICT_FLD__SYS_TABLES__NAMEcxx . . $ DICT_FLD__SYS_TABLES__NAME., &len);
505 if (len == 0 || len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
506 err_len:
507 return("incorrect column length in SYS_TABLES");
508 }
509 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
510 rec, DICT_FLD__SYS_TABLES__DB_TRX_IDcxx . . $ DICT_FLD__SYS_TABLES__DB_TRX_ID., &len);
511 if (len != DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
512 goto err_len;
513 }
514 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
515 rec, DICT_FLD__SYS_TABLES__DB_ROLL_PTRcxx . . $ DICT_FLD__SYS_TABLES__DB_ROLL_PTR., &len);
516 if (len != DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
517 goto err_len;
518 }
519
520 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(rec, DICT_FLD__SYS_TABLES__IDcxx . . $ DICT_FLD__SYS_TABLES__ID., &len);
521 if (len != 8) {
522 goto err_len;
523 }
524
525 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
526 rec, DICT_FLD__SYS_TABLES__N_COLS, &len);
527 if (field == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! || len != 4) {
528 goto err_len;
529 }
530
531 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(rec, DICT_FLD__SYS_TABLES__TYPEcxx . . $ DICT_FLD__SYS_TABLES__TYPE., &len);
532 if (len != 4) {
533 goto err_len;
534 }
535
536 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
537 rec, DICT_FLD__SYS_TABLES__MIX_IDcxx . . $ DICT_FLD__SYS_TABLES__MIX_ID., &len);
538 if (len != 8) {
539 goto err_len;
540 }
541
542 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
543 rec, DICT_FLD__SYS_TABLES__MIX_LEN, &len);
544 if (field == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! || len != 4) {
545 goto err_len;
546 }
547
548 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
549 rec, DICT_FLD__SYS_TABLES__CLUSTER_IDcxx . . $ DICT_FLD__SYS_TABLES__CLUSTER_ID., &len);
550 if (len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
551 goto err_len;
552 }
553
554 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
555 rec, DICT_FLD__SYS_TABLES__SPACE, &len);
556 if (field == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! || len != 4) {
557 goto err_len;
558 }
559
560 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
561 }
562
563 /** Check if SYS_TABLES.TYPE is valid
564 @param[in] type SYS_TABLES.TYPE
565 @param[in] not_redundant whether ROW_FORMAT=REDUNDANT is not used
566 @return whether the SYS_TABLES.TYPE value is valid */
567 static
568 bool
569 dict_sys_tables_type_validcxx . . $ dict_sys_tables_type_valid(2a1b3e200b6293a).(ulintcxx . . $ ulint# type, bool not_redundant)
570 {
571 /* The DATA_DIRECTORY flag can be assigned fully independently
572 of all other persistent table flags. */
573 type &= ~DICT_TF_MASK_DATA_DIRcxx . . $ `storage/innobase/include/dict0mem.h:195:9`!;
574
575 if (type == 1) {
576 return(true); /* ROW_FORMAT=REDUNDANT or ROW_FORMAT=COMPACT */
577 }
578
579 if (!(type & 1)) {
580 /* For ROW_FORMAT=REDUNDANT and ROW_FORMAT=COMPACT,
581 SYS_TABLES.TYPE=1. Else, it is the same as
582 dict_table_t::flags, and the least significant bit
583 would be set. So, the bit never can be 0. */
584 return(false);
585 }
586
587 if (!not_redundant) {
588 /* SYS_TABLES.TYPE must be 1 or 1|DICT_TF_MASK_NO_ROLLBACK
589 for ROW_FORMAT=REDUNDANT. */
590 return !(type & ~(1U | DICT_TF_MASK_NO_ROLLBACKcxx . . $ `storage/innobase/include/dict0mem.h:207:9`!));
591 }
592
593 if (type >= 1U << DICT_TF_POS_UNUSEDcxx . . $ `storage/innobase/include/dict0mem.h:179:9`!) {
594 /* Some unknown bits are set. */
595 return(false);
596 }
597
598 return(dict_tf_is_valid_not_redundantcxx . . $ dict_tf_is_valid_not_redundant(31596a199e1d8a50).(type));
599 }
600
601 /** Convert SYS_TABLES.TYPE to dict_table_t::flags.
602 @param[in] type SYS_TABLES.TYPE
603 @param[in] not_redundant whether ROW_FORMAT=REDUNDANT is not used
604 @return table flags */
605 static
606 uint32_tcxx . . $ uint32_t# dict_sys_tables_type_to_tfcxx . . $ dict_sys_tables_type_to_tf(ba8ea5ca3157707b).(uint32_tcxx . . $ uint32_t# type, bool not_redundant)
607 {
608 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys_tables_type_valid(type, not_redundant));
609 uint32_tcxx . . $ uint32_t# flags = not_redundant ? 1 : 0;
610
611 /* ZIP_SSIZE, ATOMIC_BLOBS, DATA_DIR, PAGE_COMPRESSION,
612 PAGE_COMPRESSION_LEVEL are the same. */
613 flags |= type & (DICT_TF_MASK_ZIP_SSIZEcxx . . $ `storage/innobase/include/dict0mem.h:187:9`!
614 | DICT_TF_MASK_ATOMIC_BLOBScxx . . $ `storage/innobase/include/dict0mem.h:191:9`!
615 | DICT_TF_MASK_DATA_DIRcxx . . $ `storage/innobase/include/dict0mem.h:195:9`!
616 | DICT_TF_MASK_PAGE_COMPRESSIONcxx . . $ `storage/innobase/include/dict0mem.h:199:9`!
617 | DICT_TF_MASK_PAGE_COMPRESSION_LEVELcxx . . $ `storage/innobase/include/dict0mem.h:203:9`!
618 | DICT_TF_MASK_NO_ROLLBACKcxx . . $ `storage/innobase/include/dict0mem.h:207:9`!);
619
620 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_tf_is_valid(flags));
621 return(flags);
622 }
623
624 /** Outcome of dict_sys_tables_rec_read() */
625 enum table_read_statuscxx . . $ table_read_status# { READ_OKcxx . . $ READ_OK.= 0, READ_ERRORcxx . . $ READ_ERROR., READ_NOT_FOUNDcxx . . $ READ_NOT_FOUND. };
626
627 /** Read and return 5 integer fields from a SYS_TABLES record.
628 @param[in] rec A record of SYS_TABLES
629 @param[in] uncommitted true=use READ UNCOMMITTED, false=READ COMMITTED
630 @param[in] mtr mini-transaction
631 @param[out] table_id Pointer to the table_id for this table
632 @param[out] space_id Pointer to the space_id for this table
633 @param[out] n_cols Pointer to number of columns for this table.
634 @param[out] flags Pointer to table flags
635 @param[out] flags2 Pointer to table flags2
636 @param[out] trx_id DB_TRX_ID of the committed SYS_TABLES record,
637 or nullptr to perform READ UNCOMMITTED
638 @return whether the record was read correctly */
639 MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((warn_unused_result))
640 static
641 table_read_statuscxx . . $ table_read_status#
642 dict_sys_tables_rec_readcxx . . $ dict_sys_tables_rec_read(d1945c703ef817d).(
643 const rec_tcxx . . $ rec_t#* rec,
644 bool uncommitted,
645 mtr_tcxx . . $ mtr_t#* mtr,
646 table_id_tcxx . . $ table_id_t#* table_id,
647 uint32_tcxx . . $ uint32_t#* space_id,
648 uint32_tcxx . . $ uint32_t#* n_cols,
649 uint32_tcxx . . $ uint32_t#* flags,
650 uint32_tcxx . . $ uint32_t#* flags2,
651 trx_id_tcxx . . $ trx_id_t#* trx_id)
652 {
653 const bytecxx . . $ byte#* field;
654 ulintcxx . . $ ulint# len;
655 mem_heap_tcxx . . $ mem_heap_t#* heap = nullptr;
656
657 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
658 rec, DICT_FLD__SYS_TABLES__DB_TRX_ID, &len);
659 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len == 6 || len == UNIV_SQL_NULL);
660 trx_id_tcxx . . $ trx_id_t# id = len == 6 ? trx_read_trx_idcxx . . $ trx_read_trx_id(b191ace3c5bffbd9).(field) : 0;
661 if (id && !uncommitted && trx_syscxx . . $ trx_sys..findcxx . . $ trx_sys_t#find(2dd6004328198d46).(nullptr, id, false)) {
662 const auto savepoint = mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).();
663 heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(1024);
664 dict_index_tcxx . . $ dict_index_t#* index = UT_LIST_GET_FIRSTcxx . . $ `storage/innobase/include/ut0lst.h:421:9`!(
665 dict_sys.sys_tables->indexes);
666 rec_offscxx . . $ rec_offs#* offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(
667 rec, index, nullptr, true, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
668 const rec_tcxx . . $ rec_t#* old_vers;
669 row_vers_build_for_semi_consistent_readcxx . . $ row_vers_build_for_semi_consistent_read(554b1a302a674a14).(
670 rec, mtr, index, &offsets, &heap,
671 heap, &old_vers, nullptr);
672 mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(savepoint);
673 rec = old_vers;
674 if (!rec) {
675 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
676 return READ_NOT_FOUNDcxx . . $ READ_NOT_FOUND.;
677 }
678 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
679 rec, DICT_FLD__SYS_TABLES__DB_TRX_ID, &len);
680 if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(len != 6)) {
681 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
682 return READ_ERRORcxx . . $ READ_ERROR.;
683 }
684 id = trx_read_trx_idcxx . . $ trx_read_trx_id(b191ace3c5bffbd9).(field);
685 }
686
687 if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
688 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(id);
689 if (trx_id) {
690 return READ_NOT_FOUNDcxx . . $ READ_NOT_FOUND.;
691 }
692 }
693
694 if (trx_id) {
695 *trx_id = id;
696 }
697
698 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
699 rec, DICT_FLD__SYS_TABLES__ID, &len);
700 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len == 8);
701 *table_id = static_cast<table_id_tcxx . . $ table_id_t#>(mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(field));
702
703 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
704 rec, DICT_FLD__SYS_TABLES__SPACE, &len);
705 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len == 4);
706 *space_id = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
707
708 /* Read the 4 byte flags from the TYPE field */
709 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
710 rec, DICT_FLD__SYS_TABLES__TYPE, &len);
711 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(len == 4);
712 uint32_tcxx . . $ uint32_t# type = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
713
714 /* Handle MDEV-12873 InnoDB SYS_TABLES.TYPE incompatibility
715 for PAGE_COMPRESSED=YES in MariaDB 10.2.2 to 10.2.6.
716
717 MariaDB 10.2.2 introduced the SHARED_SPACE flag from MySQL 5.7,
718 shifting the flags PAGE_COMPRESSION, PAGE_COMPRESSION_LEVEL,
719 ATOMIC_WRITES (repurposed to NO_ROLLBACK in 10.3.1) by one bit.
720 The SHARED_SPACE flag would always
721 be written as 0 by MariaDB, because MariaDB does not support
722 CREATE TABLESPACE or CREATE TABLE...TABLESPACE for InnoDB.
723
724 So, instead of the bits AALLLLCxxxxxxx we would have
725 AALLLLC0xxxxxxx if the table was created with MariaDB 10.2.2
726 to 10.2.6. (AA=ATOMIC_WRITES, LLLL=PAGE_COMPRESSION_LEVEL,
727 C=PAGE_COMPRESSED, xxxxxxx=7 bits that were not moved.)
728
729 The case LLLLC=00000 is not a problem. The problem is the case
730 AALLLL10DB00001 where D is the (mostly ignored) DATA_DIRECTORY
731 flag and B is the ATOMIC_BLOBS flag (1 for ROW_FORMAT=DYNAMIC
732 and 0 for ROW_FORMAT=COMPACT in this case). Other low-order
733 bits must be so, because PAGE_COMPRESSED=YES is only allowed
734 for ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPACT, not for
735 ROW_FORMAT=REDUNDANT or ROW_FORMAT=COMPRESSED.
736
737 Starting with MariaDB 10.2.4, the flags would be
738 00LLLL10DB00001, because ATOMIC_WRITES is always written as 0.
739
740 We will concentrate on the PAGE_COMPRESSION_LEVEL and
741 PAGE_COMPRESSED=YES. PAGE_COMPRESSED=NO implies
742 PAGE_COMPRESSION_LEVEL=0, and in that case all the affected
743 bits will be 0. For PAGE_COMPRESSED=YES, the values 1..9 are
744 allowed for PAGE_COMPRESSION_LEVEL. That is, we must interpret
745 the bits AALLLL10DB00001 as AALLLL1DB00001.
746
747 If someone created a table in MariaDB 10.2.2 or 10.2.3 with
748 the attribute ATOMIC_WRITES=OFF (value 2) and without
749 PAGE_COMPRESSED=YES or PAGE_COMPRESSION_LEVEL, that should be
750 rejected. The value ATOMIC_WRITES=ON (1) would look like
751 ATOMIC_WRITES=OFF, but it would be ignored starting with
752 MariaDB 10.2.4. */
753 compile_time_assertcxx . . $ `include/my_global.h:377:9`!(DICT_TF_POS_PAGE_COMPRESSIONcxx . . $ `storage/innobase/include/dict0mem.h:171:9`! == 7);
754 compile_time_assertcxx . . $ `include/my_global.h:377:9`!(DICT_TF_POS_UNUSEDcxx . . $ `storage/innobase/include/dict0mem.h:179:9`! == 14);
755
756 if ((type & 0x19f) != 0x101) {
757 /* The table cannot have been created with MariaDB
758 10.2.2 to 10.2.6, because they would write the
759 low-order bits of SYS_TABLES.TYPE as 0b10xx00001 for
760 PAGE_COMPRESSED=YES. No adjustment is applicable. */
761 } else if (type >= 3 << 13) {
762 /* 10.2.2 and 10.2.3 write ATOMIC_WRITES less than 3,
763 and no other flags above that can be set for the
764 SYS_TABLES.TYPE to be in the 10.2.2..10.2.6 format.
765 This would in any case be invalid format for 10.2 and
766 earlier releases. */
767 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_sys_tables_type_valid(type, true));
768 } else {
769 /* SYS_TABLES.TYPE is of the form AALLLL10DB00001. We
770 must still validate that the LLLL bits are between 0
771 and 9 before we can discard the extraneous 0 bit. */
772 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!DICT_TF_GET_PAGE_COMPRESSION(type));
773
774 if ((((type >> 9) & 0xf) - 1) < 9) {
775 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(DICT_TF_GET_PAGE_COMPRESSION_LEVEL(type) & 1);
776
777 type = (type & 0x7fU) | (type >> 1 & ~0x7fU);
778
779 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(DICT_TF_GET_PAGE_COMPRESSION(type));
780 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(DICT_TF_GET_PAGE_COMPRESSION_LEVEL(type) >= 1);
781 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(DICT_TF_GET_PAGE_COMPRESSION_LEVEL(type) <= 9);
782 } else {
783 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_sys_tables_type_valid(type, true));
784 }
785 }
786
787 /* The low order bit of SYS_TABLES.TYPE is always set to 1. But in
788 dict_table_t::flags the low order bit is used to determine if the
789 ROW_FORMAT=REDUNDANT (0) or anything else (1).
790 Read the 4 byte N_COLS field and look at the high order bit. It
791 should be set for COMPACT and later. It should not be set for
792 REDUNDANT. */
793 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
794 rec, DICT_FLD__SYS_TABLES__N_COLS, &len);
795 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(len == 4);
796 *n_cols = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
797
798 const bool not_redundant = 0 != (*n_cols & DICT_N_COLS_COMPACTcxx . . $ DICT_N_COLS_COMPACT.);
799
800 if (!dict_sys_tables_type_validcxx . . $ dict_sys_tables_type_valid(2a1b3e200b6293a).(type, not_redundant)) {
801 sql_print_errorcxx . . $ sql_print_error(326aeb464d16410c).("InnoDB: Table %.*s in InnoDB"
802 " data dictionary contains invalid flags."
803 " SYS_TABLES.TYPE=" UINT32PFcxx . . $ `storage/innobase/include/univ.i:312:10`!
804 " SYS_TABLES.N_COLS=" UINT32PFcxx . . $ `storage/innobase/include/univ.i:312:10`!,
805 int(rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).(rec, 1)), rec,
806 type, *n_cols);
807 err_exit:
808 if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) {
809 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
810 }
811 return READ_ERRORcxx . . $ READ_ERROR.;
812 }
813
814 *flags = dict_sys_tables_type_to_tfcxx . . $ dict_sys_tables_type_to_tf(ba8ea5ca3157707b).(type, not_redundant);
815
816 /* For tables created before MySQL 4.1, there may be
817 garbage in SYS_TABLES.MIX_LEN where flags2 are found. Such tables
818 would always be in ROW_FORMAT=REDUNDANT which do not have the
819 high bit set in n_cols, and flags would be zero.
820 MySQL 4.1 was the first version to support innodb_file_per_table,
821 that is, *space_id != 0. */
822 if (not_redundant || *space_id != 0 || *n_cols & DICT_N_COLS_COMPACTcxx . . $ DICT_N_COLS_COMPACT.
823 || fil_systemcxx . . $ fil_system..sys_spacecxx . . $ fil_system_t#sys_space.->full_crc32cxx . . $ fil_space_t#full_crc32(3482b152b9333168).()) {
824
825 /* Get flags2 from SYS_TABLES.MIX_LEN */
826 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
827 rec, DICT_FLD__SYS_TABLES__MIX_LEN, &len);
828 *flags2 = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
829
830 if (!dict_tf2_is_validcxx . . $ dict_tf2_is_valid(7dc03904b9dbe7ff).(*flags, *flags2)) {
831 sql_print_errorcxx . . $ sql_print_error(326aeb464d16410c).("InnoDB: Table %.*s in InnoDB"
832 " data dictionary"
833 " contains invalid flags."
834 " SYS_TABLES.TYPE=" UINT32PFcxx . . $ `storage/innobase/include/univ.i:312:10`!
835 " SYS_TABLES.MIX_LEN=" UINT32PFcxx . . $ `storage/innobase/include/univ.i:312:10`!,
836 int(rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).(rec, 1)),
837 rec,
838 type, *flags2);
839 goto err_exit;
840 }
841
842 /* DICT_TF2_FTS will be set when indexes are being loaded */
843 *flags2 &= ~DICT_TF2_FTScxx . . $ `storage/innobase/include/dict0mem.h:258:9`!;
844
845 /* Now that we have used this bit, unset it. */
846 *n_cols &= ~DICT_N_COLS_COMPACTcxx . . $ DICT_N_COLS_COMPACT.;
847 } else {
848 *flags2 = 0;
849 }
850
851 if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) {
852 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
853 }
854
855 return READ_OKcxx . . $ READ_OK.;
856 }
857
858 /** @return SELECT MAX(space) FROM sys_tables */
859 static uint32_tcxx . . $ uint32_t# dict_find_max_space_idcxx . . $ dict_find_max_space_id(43d96db94a9226ac).(btr_pcur_tcxx . . $ btr_pcur_t# *pcur, mtr_tcxx . . $ mtr_t# *mtr)
860 {
861 uint32_tcxx . . $ uint32_t# max_space_id= 0;
862
863 for (const rec_tcxx . . $ rec_t# *rec= dict_startscan_systemcxx . . $ dict_startscan_system(595c38df12662632).(pcur, mtr, dict_syscxx . . $ dict_sys..sys_tablescxx . . $ dict_sys_t#sys_tables.);
864 rec; rec= dict_getnext_system_lowcxx . . $ dict_getnext_system_low(49cd3ce815400fce).(pcur, mtr))
865 if (!dict_sys_tables_rec_checkcxx . . $ dict_sys_tables_rec_check(366f986dcc4a6ef).(rec))
866 {
867 ulintcxx . . $ ulint# len;
868 const bytecxx . . $ byte# *field=
869 rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(rec, DICT_FLD__SYS_TABLES__SPACE, &len);
870 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len == 4);
871 max_space_id= stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(max_space_id, mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field));
872 }
873
874 return max_space_id;
875 }
876
877 /** Check MAX(SPACE) FROM SYS_TABLES and store it in fil_system.
878 Open each data file if an encryption plugin has been loaded.
879
880 @param spaces set of tablespace files to open
881 @param upgrade whether we need to invoke ibuf_upgrade() */
882 void dict_load_tablespacescxx . . $ dict_load_tablespaces(a5108321e3739a4b).(const stdcxx . . $ std/::setcxx . . $ std/set#<uint32_tcxx . . $ uint32_t#> *spaces, bool upgrade)
883 {
884 uint32_tcxx . . $ uint32_t# max_space_id = 0;
885 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
886 mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{nullptr};
887
888 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
889
890 dict_syscxx . . $ dict_sys..lockcxx . . $ dict_sys_t#lock(9bb8261ff8654062).(SRW_LOCK_CALLcxx . . $ `storage/innobase/include/srw_lock.h:44:10`!);
891
892 if (!spaces && !upgrade
893 && !encryption_key_id_exists(FIL_DEFAULT_ENCRYPTION_KEYcxx . . $ `storage/innobase/include/fil0crypt.h:41:9`!)) {
894 max_space_id = dict_find_max_space_idcxx . . $ dict_find_max_space_id(43d96db94a9226ac).(&pcur, &mtr);
895 goto done;
896 }
897
898 for (const rec_tcxx . . $ rec_t# *rec = dict_startscan_systemcxx . . $ dict_startscan_system(595c38df12662632).(&pcur, &mtr,
899 dict_syscxx . . $ dict_sys..sys_tablescxx . . $ dict_sys_t#sys_tables.);
900 rec; rec = dict_getnext_system_lowcxx . . $ dict_getnext_system_low(49cd3ce815400fce).(&pcur, &mtr)) {
901 ulintcxx . . $ ulint# len;
902 table_id_tcxx . . $ table_id_t# table_id;
903 uint32_tcxx . . $ uint32_t# space_id;
904 uint32_tcxx . . $ uint32_t# n_cols;
905 uint32_tcxx . . $ uint32_t# flags;
906 uint32_tcxx . . $ uint32_t# flags2;
907
908 /* If a table record is not useable, ignore it and continue
909 on to the next record. Error messages were logged. */
910 if (dict_sys_tables_rec_checkcxx . . $ dict_sys_tables_rec_check(366f986dcc4a6ef).(rec)) {
911 continue;
912 }
913
914 const char *field = reinterpret_cast<const char*>(
915 rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(rec, DICT_FLD__SYS_TABLES__NAME,
916 &len));
917
918 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("dict_check_sys_tables",
919 ("name: %*.s", static_cast<int>(len), field));
920
921 if (dict_sys_tables_rec_readcxx . . $ dict_sys_tables_rec_read(d1945c703ef817d).(rec, false,
922 &mtr, &table_id, &space_id,
923 &n_cols, &flags, &flags2, nullptr)
924 != READ_OKcxx . . $ READ_OK.
925 || space_id == TRX_SYS_SPACEcxx . . $ TRX_SYS_SPACE.) {
926 continue;
927 }
928
929 /* For tables or partitions using .ibd files, the flag
930 DICT_TF2_USE_FILE_PER_TABLE was not set in MIX_LEN
931 before MySQL 5.6.5. The flag should not have been
932 introduced in persistent storage. MariaDB will keep
933 setting the flag when writing SYS_TABLES entries for
934 newly created or rebuilt tables or partitions, but
935 will otherwise ignore the flag. */
936
937 if (fil_space_for_table_exists_in_memcxx . . $ fil_space_for_table_exists_in_mem(3a0fe4bc6ebddf1a).(space_id, flags)) {
938 continue;
939 }
940
941 if (spaces && spaces->findcxx . . $ std/set#find(5d7b472851d10a0f).(uint32_tcxx . . $ uint32_t#(space_id))
942 ==cxx . . $ std/`operator==`(a84eb84a7a5e8237). spaces->endcxx . . $ std/set#end(3220b82c0db6d2a1).()) {
943 continue;
944 }
945
946 if (flags2 & DICT_TF2_DISCARDEDcxx . . $ DICT_TF2_DISCARDED.) {
947 sql_print_informationcxx . . $ sql_print_information(326aeb464d16410c).("InnoDB: Ignoring tablespace"
948 " for %.*s because "
949 "the DISCARD flag is set",
950 static_cast<int>(len), field);
951 continue;
952 }
953
954 const spancxx . . $ span#<const char> namecxx . . $ st_/span#span(afd8256c216b84b2).{field, len};
955
956 char* filepath = fil_make_filepathcxx . . $ fil_make_filepath(3a9d6a37cf401fee).(nullptr, name,
957 IBDcxx . . $ IBD., false);
958
959 const bool not_dropped{!rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)};
960
961 /* Check that the .ibd file exists. */
962 if (fil_ibd_opencxx . . $ fil_ibd_open(94c58849d3046f4d).(space_id, dict_tf_to_fsp_flagscxx . . $ dict_tf_to_fsp_flags(2141b656ce2cc063).(flags),
963 not_dropped
964 ? fil_space_tcxx . . $ fil_space_t#::VALIDATE_NOTHINGcxx . . $ fil_space_t#VALIDATE_NOTHING.
965 : fil_space_tcxx . . $ fil_space_t#::MAYBE_MISSINGcxx . . $ fil_space_t#MAYBE_MISSING.,
966 namecxx . . $ st_/span#span(9cf43e240090718f)., filepath)) {
967 } else if (!not_dropped) {
968 } else if (srv_operationcxx . . $ srv_operation. == SRV_OPERATION_NORMALcxx . . $ SRV_OPERATION_NORMAL.
969 && srv_start_after_restorecxx . . $ srv_start_after_restore.
970 && srv_force_recoverycxx . . $ srv_force_recovery. < SRV_FORCE_NO_BACKGROUNDcxx . . $ SRV_FORCE_NO_BACKGROUND.
971 && dict_table_tcxx . . $ dict_table_t#::is_temporary_namecxx . . $ dict_table_t#is_temporary_name(c5f7da30cbc0f4e9).(filepath)) {
972 /* Mariabackup will not copy files whose
973 names start with #sql-. This table ought to
974 be dropped by drop_garbage_tables_after_restore()
975 a little later. */
976 } else {
977 sql_print_warningcxx . . $ sql_print_warning(326aeb464d16410c).("InnoDB: Ignoring tablespace for"
978 " %.*s because it"
979 " could not be opened.",
980 static_cast<int>(len), field);
981 }
982
983 max_space_id = ut_maxcxx . . $ `storage/innobase/include/ut0ut.h:53:9`!(max_space_id, space_id);
984
985 ut_freecxx . . $ `storage/innobase/include/ut0new.h:1044:9`!(filepath);
986 }
987
988 done:
989 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
990
991 fil_set_max_space_id_if_biggercxx . . $ fil_set_max_space_id_if_bigger(6bab9b75950d6f3).(max_space_id);
992
993 dict_syscxx . . $ dict_sys..unlockcxx . . $ dict_sys_t#unlock(ced63f7c635d850d).();
994 }
995
996 /** Error message for a delete-marked record in dict_load_column_low() */
997 static const char *dict_load_column_delcxx . . $ dict_load_column_del.= "delete-marked record in SYS_COLUMNS";
998 /** Error message for a missing record in dict_load_column_low() */
999 static const char *dict_load_column_nonecxx . . $ dict_load_column_none.= "SYS_COLUMNS record not found";
1000 /** Message for incomplete instant ADD/DROP in dict_load_column_low() */
1001 static const char *dict_load_column_instantcxx . . $ dict_load_column_instant.= "incomplete instant ADD/DROP";
1002
1003 /** Load a table column definition from a SYS_COLUMNS record to dict_table_t.
1004 @param table table, or nullptr if the output will be in column
1005 @param use_uncommitted 0=READ COMMITTED, 1=detect, 2=READ UNCOMMITTED
1006 @param heap memory heap for temporary storage
1007 @param column pointer to output buffer, or nullptr if table!=nullptr
1008 @param table_id table identifier
1009 @param col_name column name
1010 @param rec SYS_COLUMNS record
1011 @param mtr mini-transaction
1012 @param nth_v_col nullptr, or pointer to a counter of virtual columns
1013 @return error message
1014 @retval nullptr on success */
1015 static const char *dict_load_column_lowcxx . . $ dict_load_column_low(6615616bea64e040).(dict_table_tcxx . . $ dict_table_t# *table,
1016 unsigned use_uncommitted,
1017 mem_heap_tcxx . . $ mem_heap_t# *heap, dict_col_tcxx . . $ dict_col_t# *column,
1018 table_id_tcxx . . $ table_id_t# *table_id,
1019 const char **col_name,
1020 const rec_tcxx . . $ rec_t# *rec,
1021 mtr_tcxx . . $ mtr_t# *mtr,
1022 ulintcxx . . $ ulint# *nth_v_col)
1023 {
1024 char* name;
1025 const bytecxx . . $ byte#* field;
1026 ulintcxx . . $ ulint# len;
1027 ulintcxx . . $ ulint# mtype;
1028 ulintcxx . . $ ulint# prtype;
1029 ulintcxx . . $ ulint# col_len;
1030 ulintcxx . . $ ulint# pos;
1031 ulintcxx . . $ ulint# num_base;
1032
1033 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!table == !!column);
1034
1035 if (rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec) != DICT_NUM_FIELDS__SYS_COLUMNScxx . . $ DICT_NUM_FIELDS__SYS_COLUMNS.) {
1036 return("wrong number of columns in SYS_COLUMNS record");
1037 }
1038
1039 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1040 rec, DICT_FLD__SYS_COLUMNS__TABLE_ID, &len);
1041 if (len != 8) {
1042 err_len:
1043 return("incorrect column length in SYS_COLUMNS");
1044 }
1045
1046 if (table_id) {
1047 *table_id = mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(field);
1048 } else if (table->idcxx . . $ dict_table_t#id. != mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(field)) {
1049 return dict_load_column_nonecxx . . $ dict_load_column_none.;
1050 }
1051
1052 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1053 rec, DICT_FLD__SYS_COLUMNS__POS, &len);
1054 if (len != 4) {
1055 goto err_len;
1056 }
1057
1058 pos = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1059
1060 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1061 rec, DICT_FLD__SYS_COLUMNS__DB_TRX_ID, &len);
1062 if (len != DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1063 goto err_len;
1064 }
1065
1066 const trx_id_tcxx . . $ trx_id_t# trx_id = trx_read_trx_idcxx . . $ trx_read_trx_id(b191ace3c5bffbd9).(field);
1067
1068 if (trx_id && mtr && use_uncommitted < 2
1069 && trx_syscxx . . $ trx_sys..findcxx . . $ trx_sys_t#find(2dd6004328198d46).(nullptr, trx_id, false)) {
1070 if (use_uncommitted) {
1071 return dict_load_column_instantcxx . . $ dict_load_column_instant.;
1072 }
1073 const auto savepoint = mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).();
1074 dict_index_tcxx . . $ dict_index_t#* index = UT_LIST_GET_FIRSTcxx . . $ `storage/innobase/include/ut0lst.h:421:9`!(
1075 dict_sys.sys_columns->indexes);
1076 rec_offscxx . . $ rec_offs#* offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(
1077 rec, index, nullptr, true, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
1078 const rec_tcxx . . $ rec_t#* old_vers;
1079 row_vers_build_for_semi_consistent_readcxx . . $ row_vers_build_for_semi_consistent_read(554b1a302a674a14).(
1080 rec, mtr, index, &offsets, &heap,
1081 heap, &old_vers, nullptr);
1082 mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(savepoint);
1083 rec = old_vers;
1084 if (!old_vers) {
1085 return dict_load_column_nonecxx . . $ dict_load_column_none.;
1086 }
1087 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_get_deleted_flag(rec, 0));
1088 }
1089
1090 if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
1091 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(trx_id);
1092 return dict_load_column_delcxx . . $ dict_load_column_del.;
1093 }
1094
1095 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
1096 rec, DICT_FLD__SYS_COLUMNS__DB_ROLL_PTRcxx . . $ DICT_FLD__SYS_COLUMNS__DB_ROLL_PTR., &len);
1097 if (len != DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1098 goto err_len;
1099 }
1100
1101 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1102 rec, DICT_FLD__SYS_COLUMNS__NAME, &len);
1103 if (len == 0 || len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1104 goto err_len;
1105 }
1106
1107 *col_name = name = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(heap, (const char*) field, len);
1108
1109 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1110 rec, DICT_FLD__SYS_COLUMNS__MTYPE, &len);
1111 if (len != 4) {
1112 goto err_len;
1113 }
1114
1115 mtype = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1116
1117 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1118 rec, DICT_FLD__SYS_COLUMNS__PRTYPE, &len);
1119 if (len != 4) {
1120 goto err_len;
1121 }
1122 prtype = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1123
1124 if (dtype_get_charset_collcxx . . $ dtype_get_charset_coll(91f8ed6d6bcecca7).(prtype) == 0
1125 && dtype_is_string_typecxx . . $ dtype_is_string_type(31596a199e1d8a50).(mtype)) {
1126 /* The table was created with < 4.1.2. */
1127
1128 if (dtype_is_binary_string_typecxx . . $ dtype_is_binary_string_type(7dc03904b9dbe7ff).(mtype, prtype)) {
1129 /* Use the binary collation for
1130 string columns of binary type. */
1131
1132 prtype = dtype_form_prtypecxx . . $ dtype_form_prtype(747bb0b251b16f99).(
1133 prtype,
1134 DATA_MYSQL_BINARY_CHARSET_COLLcxx . . $ `storage/innobase/include/data0type.h:36:9`!);
1135 } else {
1136 /* Use the default charset for
1137 other than binary columns. */
1138
1139 prtype = dtype_form_prtypecxx . . $ dtype_form_prtype(747bb0b251b16f99).(
1140 prtype,
1141 default_charset_info->numbercxx . . $ charset_info_st#number.);
1142 }
1143 }
1144
1145 if (table && table->n_defcxx . . $ dict_table_t#n_def. != pos && !(prtype & DATA_VIRTUALcxx . . $ `storage/innobase/include/data0type.h:188:9`!)) {
1146 return("SYS_COLUMNS.POS mismatch");
1147 }
1148
1149 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1150 rec, DICT_FLD__SYS_COLUMNS__LEN, &len);
1151 if (len != 4) {
1152 goto err_len;
1153 }
1154 col_len = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1155 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1156 rec, DICT_FLD__SYS_COLUMNS__PREC, &len);
1157 if (len != 4) {
1158 goto err_len;
1159 }
1160 num_base = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1161
1162 if (table) {
1163 if (prtype & DATA_VIRTUALcxx . . $ `storage/innobase/include/data0type.h:188:9`!) {
1164 #ifdef UNIV_DEBUG
1165 dict_v_col_t* vcol =
1166 #endif
1167 dict_mem_table_add_v_colcxx . . $ dict_mem_table_add_v_col(1ecbc067b35b580e).(
1168 table, heap, name, mtype,
1169 prtype, col_len,
1170 dict_get_v_col_mysql_poscxx . . $ dict_get_v_col_mysql_pos(ecdaa1632f49f591).(pos), num_base);
1171 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(vcol->v_pos == dict_get_v_col_pos(pos));
1172 } else {
1173 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(num_base == 0);
1174 dict_mem_table_add_colcxx . . $ dict_mem_table_add_col(d1893c21bc74da17).(table, heap, name, mtype,
1175 prtype, col_len);
1176 }
1177
1178 if (trx_id > table->def_trx_idcxx . . $ dict_table_t#def_trx_id.) {
1179 table->def_trx_idcxx . . $ dict_table_t#def_trx_id. = trx_id;
1180 }
1181 } else {
1182 dict_mem_fill_column_structcxx . . $ dict_mem_fill_column_struct(ab1a87e77788f681).(column, pos, mtype,
1183 prtype, col_len);
1184 }
1185
1186 /* Report the virtual column number */
1187 if ((prtype & DATA_VIRTUALcxx . . $ `storage/innobase/include/data0type.h:188:9`!) && nth_v_col != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1188 *nth_v_col = dict_get_v_col_poscxx . . $ dict_get_v_col_pos(ecdaa1632f49f591).(pos);
1189 }
1190
1191 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
1192 }
1193
1194 /** Error message for a delete-marked record in dict_load_virtual_low() */
1195 static const char *dict_load_virtual_delcxx . . $ dict_load_virtual_del.= "delete-marked record in SYS_VIRTUAL";
1196 static const char *dict_load_virtual_nonecxx . . $ dict_load_virtual_none.= "SYS_VIRTUAL record not found";
1197
1198 /** Load a virtual column "mapping" (to base columns) information
1199 from a SYS_VIRTUAL record
1200 @param[in,out] table table
1201 @param[in] uncommitted false=READ COMMITTED, true=READ UNCOMMITTED
1202 @param[in,out] column mapped base column's dict_column_t
1203 @param[in,out] table_id table id
1204 @param[in,out] pos virtual column position
1205 @param[in,out] base_pos base column position
1206 @param[in] rec SYS_VIRTUAL record
1207 @return error message
1208 @retval NULL on success */
1209 static
1210 const char*
1211 dict_load_virtual_lowcxx . . $ dict_load_virtual_low(a6dcee11bfcf3c3d).(
1212 dict_table_tcxx . . $ dict_table_t#* table,
1213 bool uncommitted,
1214 dict_col_tcxx . . $ dict_col_t#** column,
1215 table_id_tcxx . . $ table_id_t#* table_id,
1216 ulintcxx . . $ ulint#* pos,
1217 ulintcxx . . $ ulint#* base_pos,
1218 const rec_tcxx . . $ rec_t#* rec)
1219 {
1220 const bytecxx . . $ byte#* field;
1221 ulintcxx . . $ ulint# len;
1222 ulintcxx . . $ ulint# base;
1223
1224 if (rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec) != DICT_NUM_FIELDS__SYS_VIRTUALcxx . . $ DICT_NUM_FIELDS__SYS_VIRTUAL.) {
1225 return("wrong number of columns in SYS_VIRTUAL record");
1226 }
1227
1228 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1229 rec, DICT_FLD__SYS_VIRTUAL__TABLE_ID, &len);
1230 if (len != 8) {
1231 err_len:
1232 return("incorrect column length in SYS_VIRTUAL");
1233 }
1234
1235 if (table_id != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1236 *table_id = mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(field);
1237 } else if (table->idcxx . . $ dict_table_t#id. != mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(field)) {
1238 return dict_load_virtual_nonecxx . . $ dict_load_virtual_none.;
1239 }
1240
1241 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1242 rec, DICT_FLD__SYS_VIRTUAL__POS, &len);
1243 if (len != 4) {
1244 goto err_len;
1245 }
1246
1247 if (pos != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1248 *pos = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1249 }
1250
1251 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1252 rec, DICT_FLD__SYS_VIRTUAL__BASE_POS, &len);
1253 if (len != 4) {
1254 goto err_len;
1255 }
1256
1257 base = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1258
1259 if (base_pos != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1260 *base_pos = base;
1261 }
1262
1263 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1264 rec, DICT_FLD__SYS_VIRTUAL__DB_TRX_ID, &len);
1265 if (len != DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1266 goto err_len;
1267 }
1268
1269 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
1270 rec, DICT_FLD__SYS_VIRTUAL__DB_ROLL_PTRcxx . . $ DICT_FLD__SYS_VIRTUAL__DB_ROLL_PTR., &len);
1271 if (len != DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1272 goto err_len;
1273 }
1274
1275 const trx_id_tcxx . . $ trx_id_t# trx_id = trx_read_trx_idcxx . . $ trx_read_trx_id(b191ace3c5bffbd9).(field);
1276
1277 if (trx_id && column && !uncommitted
1278 && trx_syscxx . . $ trx_sys..findcxx . . $ trx_sys_t#find(2dd6004328198d46).(nullptr, trx_id, false)) {
1279 if (!rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
1280 return dict_load_virtual_nonecxx . . $ dict_load_virtual_none.;
1281 }
1282 } else if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
1283 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(trx_id != 0);
1284 return dict_load_virtual_delcxx . . $ dict_load_virtual_del.;
1285 }
1286
1287 if (column != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1288 *column = dict_table_get_nth_colcxx . . $ `storage/innobase/include/dict0dict.h:737:9`!(table, base);
1289 }
1290
1291 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
1292 }
1293
1294 /** Load the definitions for table columns.
1295 @param mtr mini-transaction
1296 @param table table
1297 @param use_uncommitted 0=READ COMMITTED, 1=detect, 2=READ UNCOMMITTED
1298 @param heap memory heap for temporary storage
1299 @return error code
1300 @retval DB_SUCCESS on success
1301 @retval DB_SUCCESS_LOCKED_REC on success if use_uncommitted=1
1302 and instant ADD/DROP/reorder was detected */
1303 MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
1304 static dberr_tcxx . . $ dberr_t# dict_load_columnscxx . . $ dict_load_columns(fdd01f8df46eddce).(mtr_tcxx . . $ mtr_t# &mtr,
1305 dict_table_tcxx . . $ dict_table_t# *table, unsigned use_uncommitted,
1306 mem_heap_tcxx . . $ mem_heap_t# *heap)
1307 {
1308 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
1309 ulintcxx . . $ ulint# n_skipped = 0;
1310
1311 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys.locked());
1312
1313 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
1314
1315 dict_index_tcxx . . $ dict_index_t#* sys_index = dict_syscxx . . $ dict_sys..sys_columnscxx . . $ dict_sys_t#sys_columns.->indexescxx . . $ dict_table_t#indexes..startcxx . . $ ut_list_base#start.;
1316 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_sys.sys_columns->not_redundant());
1317
1318 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_columns, sys_index,
1319 DICT_FLD__SYS_COLUMNS__NAME, "NAME"));
1320 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_columns, sys_index,
1321 DICT_FLD__SYS_COLUMNS__PREC, "PREC"));
1322
1323 dfield_tcxx . . $ dfield_t# dfield;
1324 dtuple_tcxx . . $ dtuple_t# tuple{
1325 0,1,1,0,&dfield,nullptr
1326 #ifdef UNIV_DEBUG
1327 , DATA_TUPLE_MAGIC_N
1328 #endif
1329 };
1330 bytecxx . . $ byte# table_id[8];
1331 mach_write_to_8cxx . . $ mach_write_to_8(5500c4293b1bbef0).(table_id, table->idcxx . . $ dict_table_t#id.);
1332 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(&dfield, table_id, 8);
1333 dict_index_copy_typescxx . . $ dict_index_copy_types(9015429b5b64dc2b).(&tuple, sys_index, 1);
1334 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = sys_index;
1335
1336 dberr_tcxx . . $ dberr_t# err = btr_pcur_open_on_user_reccxx . . $ btr_pcur_open_on_user_rec(41267febe7c38db2).(&tuple,
1337 BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., &pcur, &mtr);
1338 if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) {
1339 goto func_exit;
1340 }
1341
1342 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(table->n_t_cols == static_cast<ulint>(
1343 table->n_cols) + static_cast<ulint>(table->n_v_cols));
1344
1345 for (ulintcxx . . $ ulint# i = 0;
1346 i + DATA_N_SYS_COLScxx . . $ `storage/innobase/include/data0type.h:161:9`! < table->n_t_colscxx . . $ dict_table_t#n_t_cols. + n_skipped;
1347 i++) {
1348 const char* err_msg;
1349 const char* name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1350 ulintcxx . . $ ulint# nth_v_col = ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!;
1351 const rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur);
1352
1353 err_msg = btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(&pcur)
1354 ? dict_load_column_lowcxx . . $ dict_load_column_low(6615616bea64e040).(table, use_uncommitted,
1355 heap, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!,
1356 &name, rec, &mtr, &nth_v_col)
1357 : dict_load_column_nonecxx . . $ dict_load_column_none.;
1358
1359 if (!err_msg) {
1360 } else if (err_msg == dict_load_column_delcxx . . $ dict_load_column_del.) {
1361 n_skipped++;
1362 goto next_rec;
1363 } else if (err_msg == dict_load_column_instantcxx . . $ dict_load_column_instant.) {
1364 err = DB_SUCCESS_LOCKED_RECcxx . . $ DB_SUCCESS_LOCKED_REC.;
1365 goto func_exit;
1366 } else if (err_msg == dict_load_column_nonecxx . . $ dict_load_column_none.
1367 && strstr(table->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name.,
1368 "/" TEMP_FILE_PREFIX_INNODBcxx . . $ `storage/innobase/include/dict0types.h:100:9`!)) {
1369 break;
1370 } else {
1371 ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). err_msg <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " for table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.;
1372 err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.;
1373 goto func_exit;
1374 }
1375
1376 /* Note: Currently we have one DOC_ID column that is
1377 shared by all FTS indexes on a table. And only non-virtual
1378 column can be used for FULLTEXT index */
1379 if (Lex_ident_columncxx . . $ Lex_ident_column#(Lex_cstring_strlencxx . . $ Lex_cstring_strlen#(name)).
1380 streqcxx . . $ Lex_ident#streq(5afebc4347f15c79).(FTS_DOC_IDcxx . . $ FTS_DOC_ID.)
1381 && nth_v_col == ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!) {
1382 dict_col_tcxx . . $ dict_col_t#* col;
1383 /* As part of normal loading of tables the
1384 table->flag is not set for tables with FTS
1385 till after the FTS indexes are loaded. So we
1386 create the fts_t instance here if there isn't
1387 one already created.
1388
1389 This case does not arise for table create as
1390 the flag is set before the table is created. */
1391 if (table->ftscxx . . $ dict_table_t#fts. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1392 table->ftscxx . . $ dict_table_t#fts. = fts_createcxx . . $ fts_create(fe68a4a1a2d26818).(table);
1393 table->ftscxx . . $ dict_table_t#fts.->cachecxx . . $ fts_t#cache. = fts_cache_createcxx . . $ fts_cache_create(c76bb1a6a133c9a9).(table);
1394 DICT_TF2_FLAG_SETcxx . . $ `storage/innobase/include/dict0mem.h:278:9`!(table, DICT_TF2_FTS_AUX_HEX_NAMEcxx . . $ `storage/innobase/include/dict0mem.h:274:9`!);
1395 }
1396
1397 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(table->fts->doc_col == ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!);
1398
1399 col = dict_table_get_nth_colcxx . . $ `storage/innobase/include/dict0dict.h:737:9`!(table, i - n_skipped);
1400
1401 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(col->len == sizeof(doc_id_t));
1402
1403 if (col->prtypecxx . . $ dict_col_t#prtype. & DATA_FTS_DOC_IDcxx . . $ `storage/innobase/include/data0type.h:163:9`!) {
1404 DICT_TF2_FLAG_SETcxx . . $ `storage/innobase/include/dict0mem.h:278:9`!(
1405 table, DICT_TF2_FTS_HAS_DOC_IDcxx . . $ `storage/innobase/include/dict0mem.h:255:9`!);
1406 DICT_TF2_FLAG_UNSETcxx . . $ `storage/innobase/include/dict0mem.h:284:9`!(
1407 table, DICT_TF2_FTS_ADD_DOC_IDcxx . . $ `storage/innobase/include/dict0mem.h:262:9`!);
1408 }
1409
1410 table->ftscxx . . $ dict_table_t#fts.->doc_colcxx . . $ fts_t#doc_col. = i - n_skipped;
1411 }
1412 next_rec:
1413 btr_pcur_move_to_next_user_reccxx . . $ btr_pcur_move_to_next_user_rec(db7b0b7a66db0c31).(&pcur, &mtr);
1414 }
1415
1416 func_exit:
1417 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
1418 return err;
1419 }
1420
1421 /** Loads SYS_VIRTUAL info for one virtual column
1422 @param mtr mini-transaction
1423 @param table table definition
1424 @param uncommitted false=READ COMMITTED, true=READ UNCOMMITTED
1425 @param nth_v_col virtual column position */
1426 MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
1427 static
1428 dberr_tcxx . . $ dberr_t#
1429 dict_load_virtual_colcxx . . $ dict_load_virtual_col(71ed16df01b1a930).(mtr_tcxx . . $ mtr_t# &mtr, dict_table_tcxx . . $ dict_table_t# *table, bool uncommitted,
1430 ulintcxx . . $ ulint# nth_v_col)
1431 {
1432 const dict_v_col_tcxx . . $ dict_v_col_t#* v_col = dict_table_get_nth_v_colcxx . . $ `storage/innobase/include/dict0dict.h:741:9`!(table, nth_v_col);
1433
1434 if (v_col->num_basecxx . . $ dict_v_col_t#num_base. == 0) {
1435 return DB_SUCCESScxx . . $ DB_SUCCESS.;
1436 }
1437
1438 dict_index_tcxx . . $ dict_index_t#* sys_virtual_index;
1439 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
1440
1441 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys.locked());
1442
1443 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
1444
1445 sys_virtual_index = dict_syscxx . . $ dict_sys..sys_virtualcxx . . $ dict_sys_t#sys_virtual.->indexescxx . . $ dict_table_t#indexes..startcxx . . $ ut_list_base#start.;
1446 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_sys.sys_virtual->not_redundant());
1447
1448 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_virtual, sys_virtual_index,
1449 DICT_FLD__SYS_VIRTUAL__POS, "POS"));
1450
1451 dfield_tcxx . . $ dfield_t# dfield[2];
1452 dtuple_tcxx . . $ dtuple_t# tuple{
1453 0,2,2,0,dfield,nullptr
1454 #ifdef UNIV_DEBUG
1455 , DATA_TUPLE_MAGIC_N
1456 #endif
1457 };
1458 bytecxx . . $ byte# table_id[8], vcol_pos[4];
1459 mach_write_to_8cxx . . $ mach_write_to_8(5500c4293b1bbef0).(table_id, table->idcxx . . $ dict_table_t#id.);
1460 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(&dfield[0], table_id, 8);
1461 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(vcol_pos,
1462 dict_create_v_col_poscxx . . $ dict_create_v_col_pos(80bad76eed2d2579).(nth_v_col, v_col->m_colcxx . . $ dict_v_col_t#m_col..indcxx . . $ dict_col_t#ind.));
1463 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(&dfield[1], vcol_pos, 4);
1464
1465 dict_index_copy_typescxx . . $ dict_index_copy_types(9015429b5b64dc2b).(&tuple, sys_virtual_index, 2);
1466 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = sys_virtual_index;
1467
1468 dberr_tcxx . . $ dberr_t# err = btr_pcur_open_on_user_reccxx . . $ btr_pcur_open_on_user_rec(41267febe7c38db2).(&tuple,
1469 BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., &pcur, &mtr);
1470 if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) {
1471 goto func_exit;
1472 }
1473
1474 for (ulintcxx . . $ ulint# i = 0, skipped = 0;
1475 i < unsigned{v_col->num_basecxx . . $ dict_v_col_t#num_base.} + skipped; i++) {
1476 ulintcxx . . $ ulint# pos;
1477 const char* err_msg
1478 = btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(&pcur)
1479 ? dict_load_virtual_lowcxx . . $ dict_load_virtual_low(a6dcee11bfcf3c3d).(table, uncommitted,
1480 &v_col->base_colcxx . . $ dict_v_col_t#base_col.[i - skipped],
1481 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!,
1482 &pos, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!,
1483 btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur))
1484 : dict_load_virtual_nonecxx . . $ dict_load_virtual_none.;
1485
1486 if (!err_msg) {
1487 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(pos == mach_read_from_4(vcol_pos));
1488 } else if (err_msg == dict_load_virtual_delcxx . . $ dict_load_virtual_del.) {
1489 skipped++;
1490 } else if (err_msg == dict_load_virtual_nonecxx . . $ dict_load_virtual_none.
1491 && strstr(table->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name.,
1492 "/" TEMP_FILE_PREFIX_INNODBcxx . . $ `storage/innobase/include/dict0types.h:100:9`!)) {
1493 break;
1494 } else {
1495 ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). err_msg <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " for table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.;
1496 err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.;
1497 break;
1498 }
1499
1500 btr_pcur_move_to_next_user_reccxx . . $ btr_pcur_move_to_next_user_rec(db7b0b7a66db0c31).(&pcur, &mtr);
1501 }
1502
1503 func_exit:
1504 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
1505 return err;
1506 }
1507
1508 /** Loads info from SYS_VIRTUAL for virtual columns.
1509 @param mtr mini-transaction
1510 @param table table definition
1511 @param uncommitted false=READ COMMITTED, true=READ UNCOMMITTED */
1512 MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
1513 static dberr_tcxx . . $ dberr_t# dict_load_virtualcxx . . $ dict_load_virtual(d8409e0ba2f11ba2).(mtr_tcxx . . $ mtr_t# &mtr, dict_table_tcxx . . $ dict_table_t# *table,
1514 bool uncommitted)
1515 {
1516 for (ulintcxx . . $ ulint# i= 0; i < table->n_v_colscxx . . $ dict_table_t#n_v_cols.; i++)
1517 if (dberr_tcxx . . $ dberr_t# err= dict_load_virtual_colcxx . . $ dict_load_virtual_col(71ed16df01b1a930).(mtr, table, uncommitted, i))
1518 return err;
1519 return DB_SUCCESScxx . . $ DB_SUCCESS.;
1520 }
1521
1522 /** Error message for a delete-marked record in dict_load_field_low() */
1523 static const char *dict_load_field_delcxx . . $ dict_load_field_del.= "delete-marked record in SYS_FIELDS";
1524
1525 static const char *dict_load_field_nonecxx . . $ dict_load_field_none.= "SYS_FIELDS record not found";
1526
1527 /** Load an index field definition from a SYS_FIELDS record to dict_index_t.
1528 @return error message
1529 @retval NULL on success */
1530 static
1531 const char*
1532 dict_load_field_lowcxx . . $ dict_load_field_low(e74a7aa1f259e4b2).(
1533 bytecxx . . $ byte#* index_id, /*!< in/out: index id (8 bytes)
1534 an "in" value if index != NULL
1535 and "out" if index == NULL */
1536 bool uncommitted, /*!< in: false=READ COMMITTED,
1537 true=READ UNCOMMITTED */
1538 dict_index_tcxx . . $ dict_index_t#* index, /*!< in/out: index, could be NULL
1539 if we just populate a dict_field_t
1540 struct with information from
1541 a SYS_FIELDS record */
1542 dict_field_tcxx . . $ dict_field_t#* sys_field, /*!< out: dict_field_t to be
1543 filled */
1544 ulintcxx . . $ ulint#* pos, /*!< out: Field position */
1545 bytecxx . . $ byte#* last_index_id, /*!< in: last index id */
1546 mem_heap_tcxx . . $ mem_heap_t#* heap, /*!< in/out: memory heap
1547 for temporary storage */
1548 mtr_tcxx . . $ mtr_t#* mtr, /*!< in/out: mini-transaction */
1549 const rec_tcxx . . $ rec_t#* rec) /*!< in: SYS_FIELDS record */
1550 {
1551 const bytecxx . . $ byte#* field;
1552 ulintcxx . . $ ulint# len;
1553 unsigned pos_and_prefix_len;
1554 unsigned prefix_len;
1555 bool descending;
1556 bool first_field;
1557 ulintcxx . . $ ulint# position;
1558
1559 /* Either index or sys_field is supplied, not both */
1560 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((!index) != (!sys_field));
1561 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((!index) == !mtr);
1562
1563 if (rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec) != DICT_NUM_FIELDS__SYS_FIELDScxx . . $ DICT_NUM_FIELDS__SYS_FIELDS.) {
1564 return("wrong number of columns in SYS_FIELDS record");
1565 }
1566
1567 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1568 rec, DICT_FLD__SYS_FIELDS__INDEX_ID, &len);
1569 if (len != 8) {
1570 err_len:
1571 return("incorrect column length in SYS_FIELDS");
1572 }
1573
1574 if (!index) {
1575 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(last_index_id);
1576 memcpy(index_id, (const char*) field, 8);
1577 first_field = memcmp(index_id, last_index_id, 8);
1578 } else {
1579 first_field = (index->n_defcxx . . $ dict_index_t#n_def. == 0);
1580 if (memcmp(field, index_id, 8)) {
1581 return dict_load_field_nonecxx . . $ dict_load_field_none.;
1582 }
1583 }
1584
1585 /* The next field stores the field position in the index and a
1586 possible column prefix length if the index field does not
1587 contain the whole column. The storage format is like this: if
1588 there is at least one prefix field in the index, then the HIGH
1589 2 bytes contain the field number (index->n_def) and the low 2
1590 bytes the prefix length for the field. Otherwise the field
1591 number (index->n_def) is contained in the 2 LOW bytes. */
1592
1593 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1594 rec, DICT_FLD__SYS_FIELDS__POS, &len);
1595 if (len != 4) {
1596 goto err_len;
1597 }
1598
1599 pos_and_prefix_len = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1600
1601 if (index && UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!
1602 ((pos_and_prefix_len & 0xFFFFUL) != index->n_def
1603 && (pos_and_prefix_len >> 16 & 0xFFFF) != index->n_def)) {
1604 return("SYS_FIELDS.POS mismatch");
1605 }
1606
1607 if (first_field || pos_and_prefix_len > 0xFFFFUL) {
1608 prefix_len = pos_and_prefix_len & 0x7FFFUL;
1609 descending = (pos_and_prefix_len & 0x8000UL);
1610 position = (pos_and_prefix_len & 0xFFFF0000UL) >> 16;
1611 } else {
1612 prefix_len = 0;
1613 descending = false;
1614 position = pos_and_prefix_len & 0xFFFFUL;
1615 }
1616
1617 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1618 rec, DICT_FLD__SYS_FIELDS__DB_TRX_ID, &len);
1619 if (len != DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1620 goto err_len;
1621 }
1622 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
1623 rec, DICT_FLD__SYS_FIELDS__DB_ROLL_PTRcxx . . $ DICT_FLD__SYS_FIELDS__DB_ROLL_PTR., &len);
1624 if (len != DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1625 goto err_len;
1626 }
1627
1628 const trx_id_tcxx . . $ trx_id_t# trx_id = trx_read_trx_idcxx . . $ trx_read_trx_id(b191ace3c5bffbd9).(field);
1629
1630 if (!trx_id) {
1631 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_get_deleted_flag(rec, 0));
1632 } else if (!mtr || uncommitted) {
1633 } else if (trx_syscxx . . $ trx_sys..findcxx . . $ trx_sys_t#find(2dd6004328198d46).(nullptr, trx_id, false)) {
1634 const auto savepoint = mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).();
1635 dict_index_tcxx . . $ dict_index_t#* sys_field = UT_LIST_GET_FIRSTcxx . . $ `storage/innobase/include/ut0lst.h:421:9`!(
1636 dict_sys.sys_fields->indexes);
1637 rec_offscxx . . $ rec_offs#* offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(
1638 rec, sys_field, nullptr, true, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
1639 const rec_tcxx . . $ rec_t#* old_vers;
1640 row_vers_build_for_semi_consistent_readcxx . . $ row_vers_build_for_semi_consistent_read(554b1a302a674a14).(
1641 rec, mtr, sys_field, &offsets, &heap,
1642 heap, &old_vers, nullptr);
1643 mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(savepoint);
1644 rec = old_vers;
1645 if (!old_vers || rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
1646 return dict_load_field_nonecxx . . $ dict_load_field_none.;
1647 }
1648 }
1649
1650 if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
1651 return(dict_load_field_delcxx . . $ dict_load_field_del.);
1652 }
1653
1654 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1655 rec, DICT_FLD__SYS_FIELDS__COL_NAME, &len);
1656 if (len == 0 || len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1657 goto err_len;
1658 }
1659
1660 if (index) {
1661 dict_mem_index_add_fieldcxx . . $ dict_mem_index_add_field(61ed6e1a807d1641).(
1662 index, mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(heap, (const char*) field, len),
1663 prefix_len, descending);
1664 } else {
1665 sys_field->namecxx . . $ dict_field_t#name. =cxx . . $ id_name_t#`operator=`(828bc1359dcaff23). mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(
1666 heap, (const char*) field, len);
1667 sys_field->prefix_lencxx . . $ dict_field_t#prefix_len. = prefix_len & ((1U << 12) - 1);
1668 sys_field->descendingcxx . . $ dict_field_t#descending. = descending;
1669 *pos = position;
1670 }
1671
1672 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
1673 }
1674
1675 /**
1676 Load definitions for index fields.
1677 @param mtr mini-transaction
1678 @param index index whose fields are to be loaded
1679 @param uncommitted false=READ COMMITTED, true=READ UNCOMMITTED
1680 @param heap memory heap for temporary storage
1681 @return error code
1682 @return DB_SUCCESS if the fields were loaded successfully */
1683 static dberr_tcxx . . $ dberr_t# dict_load_fieldscxx . . $ dict_load_fields(80deb3b188d952d5).(mtr_tcxx . . $ mtr_t# &mtr, dict_index_tcxx . . $ dict_index_t# *index,
1684 bool uncommitted, mem_heap_tcxx . . $ mem_heap_t# *heap)
1685 {
1686 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
1687
1688 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys.locked());
1689 auto sp = mtr.get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).();
1690
1691 dict_index_tcxx . . $ dict_index_t#* sys_index = dict_syscxx . . $ dict_sys..sys_fieldscxx . . $ dict_sys_t#sys_fields.->indexescxx . . $ dict_table_t#indexes..startcxx . . $ ut_list_base#start.;
1692 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_sys.sys_fields->not_redundant());
1693 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_fields, sys_index,
1694 DICT_FLD__SYS_FIELDS__COL_NAME, "COL_NAME"));
1695
1696 dfield_tcxx . . $ dfield_t# dfield;
1697 dtuple_tcxx . . $ dtuple_t# tuple{
1698 0,1,1,0,&dfield,nullptr
1699 #ifdef UNIV_DEBUG
1700 , DATA_TUPLE_MAGIC_N
1701 #endif
1702 };
1703 bytecxx . . $ byte# index_id[8];
1704 mach_write_to_8cxx . . $ mach_write_to_8(5500c4293b1bbef0).(index_id, index->idcxx . . $ dict_index_t#id.);
1705 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(&dfield, index_id, 8);
1706 dict_index_copy_typescxx . . $ dict_index_copy_types(9015429b5b64dc2b).(&tuple, sys_index, 1);
1707 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = sys_index;
1708
1709 dberr_tcxx . . $ dberr_t# error = btr_pcur_open_on_user_reccxx . . $ btr_pcur_open_on_user_rec(41267febe7c38db2).(&tuple, BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF.,
1710 &pcur, &mtr);
1711 if (error != DB_SUCCESScxx . . $ DB_SUCCESS.) {
1712 goto func_exit;
1713 }
1714
1715 for (ulintcxx . . $ ulint# i = 0; i < index->n_fieldscxx . . $ dict_index_t#n_fields.; i++) {
1716 const char *err_msg = btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(&pcur)
1717 ? dict_load_field_lowcxx . . $ dict_load_field_low(e74a7aa1f259e4b2).(index_id, uncommitted, index,
1718 nullptr, nullptr, nullptr,
1719 heap, &mtr,
1720 btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur))
1721 : dict_load_field_nonecxx . . $ dict_load_field_none.;
1722
1723 if (!err_msg) {
1724 } else if (err_msg == dict_load_field_delcxx . . $ dict_load_field_del.) {
1725 /* There could be delete marked records in
1726 SYS_FIELDS because SYS_FIELDS.INDEX_ID can be
1727 updated by ALTER TABLE ADD INDEX. */
1728 } else {
1729 if (err_msg != dict_load_field_nonecxx . . $ dict_load_field_none.
1730 || strstr(index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name.,
1731 "/" TEMP_FILE_PREFIX_INNODBcxx . . $ `storage/innobase/include/dict0types.h:100:9`!)) {
1732 ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). err_msg <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " for index "
1733 <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->namecxx . . $ dict_index_t#name.
1734 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " of table "
1735 <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name.;
1736 }
1737 error = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.;
1738 break;
1739 }
1740
1741 btr_pcur_move_to_next_user_reccxx . . $ btr_pcur_move_to_next_user_rec(db7b0b7a66db0c31).(&pcur, &mtr);
1742 }
1743
1744 func_exit:
1745 mtr.rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(sp);
1746 return error;
1747 }
1748
1749 /** Error message for a delete-marked record in dict_load_index_low() */
1750 static const char *dict_load_index_delcxx . . $ dict_load_index_del.= "delete-marked record in SYS_INDEXES";
1751 /** Error message for table->id mismatch in dict_load_index_low() */
1752 static const char *dict_load_index_nonecxx . . $ dict_load_index_none.= "SYS_INDEXES record not found";
1753 /** Error message for SYS_TABLES flags mismatch in dict_load_table_low() */
1754 static const char *dict_load_table_flagscxx . . $ dict_load_table_flags.= "incorrect flags in SYS_TABLES";
1755
1756 /** Load an index definition from a SYS_INDEXES record to dict_index_t.
1757 @return error message
1758 @retval NULL on success */
1759 static
1760 const char*
1761 dict_load_index_lowcxx . . $ dict_load_index_low(df34aa736bf7c68d).(
1762 bytecxx . . $ byte#* table_id, /*!< in/out: table id (8 bytes),
1763 an "in" value if mtr
1764 and "out" when !mtr */
1765 bool uncommitted, /*!< in: false=READ COMMITTED,
1766 true=READ UNCOMMITTED */
1767 mem_heap_tcxx . . $ mem_heap_t#* heap, /*!< in/out: temporary memory heap */
1768 const rec_tcxx . . $ rec_t#* rec, /*!< in: SYS_INDEXES record */
1769 mtr_tcxx . . $ mtr_t#* mtr, /*!< in/out: mini-transaction,
1770 or nullptr if a pre-allocated
1771 *index is to be filled in */
1772 dict_table_tcxx . . $ dict_table_t#* table, /*!< in/out: table, or NULL */
1773 dict_index_tcxx . . $ dict_index_t#** index) /*!< out,own: index, or NULL */
1774 {
1775 const bytecxx . . $ byte#* field;
1776 ulintcxx . . $ ulint# len;
1777 index_id_tcxx . . $ index_id_t# id;
1778 ulintcxx . . $ ulint# n_fields;
1779 ulintcxx . . $ ulint# type;
1780 unsigned merge_threshold;
1781
1782 if (mtr) {
1783 *index = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1784 }
1785
1786 if (rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec) == DICT_NUM_FIELDS__SYS_INDEXEScxx . . $ DICT_NUM_FIELDS__SYS_INDEXES.) {
1787 /* MERGE_THRESHOLD exists */
1788 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1789 rec, DICT_FLD__SYS_INDEXES__MERGE_THRESHOLD, &len);
1790 switch (len) {
1791 case 4:
1792 merge_threshold = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1793 break;
1794 case UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!:
1795 merge_threshold = DICT_INDEX_MERGE_THRESHOLD_DEFAULTcxx . . $ `storage/innobase/include/dict0mem.h:972:10`!;
1796 break;
1797 default:
1798 return("incorrect MERGE_THRESHOLD length"
1799 " in SYS_INDEXES");
1800 }
1801 } else if (rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec)
1802 == DICT_NUM_FIELDS__SYS_INDEXEScxx . . $ DICT_NUM_FIELDS__SYS_INDEXES. - 1) {
1803 /* MERGE_THRESHOLD doesn't exist */
1804
1805 merge_threshold = DICT_INDEX_MERGE_THRESHOLD_DEFAULTcxx . . $ `storage/innobase/include/dict0mem.h:972:10`!;
1806 } else {
1807 return("wrong number of columns in SYS_INDEXES record");
1808 }
1809
1810 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1811 rec, DICT_FLD__SYS_INDEXES__TABLE_ID, &len);
1812 if (len != 8) {
1813 err_len:
1814 return("incorrect column length in SYS_INDEXES");
1815 }
1816
1817 if (!mtr) {
1818 /* We are reading a SYS_INDEXES record. Copy the table_id */
1819 memcpy(table_id, (const char*) field, 8);
1820 } else if (memcmp(field, table_id, 8)) {
1821 /* Caller supplied table_id, verify it is the same
1822 id as on the index record */
1823 return dict_load_index_nonecxx . . $ dict_load_index_none.;
1824 }
1825
1826 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1827 rec, DICT_FLD__SYS_INDEXES__ID, &len);
1828 if (len != 8) {
1829 goto err_len;
1830 }
1831
1832 id = mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(field);
1833
1834 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1835 rec, DICT_FLD__SYS_INDEXES__DB_TRX_ID, &len);
1836 if (len != DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1837 goto err_len;
1838 }
1839 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(
1840 rec, DICT_FLD__SYS_INDEXES__DB_ROLL_PTRcxx . . $ DICT_FLD__SYS_INDEXES__DB_ROLL_PTR., &len);
1841 if (len != DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`! && len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1842 goto err_len;
1843 }
1844
1845 const trx_id_tcxx . . $ trx_id_t# trx_id = trx_read_trx_idcxx . . $ trx_read_trx_id(b191ace3c5bffbd9).(field);
1846 if (!trx_id) {
1847 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_get_deleted_flag(rec, 0));
1848 } else if (!mtr || uncommitted) {
1849 } else if (trx_syscxx . . $ trx_sys..findcxx . . $ trx_sys_t#find(2dd6004328198d46).(nullptr, trx_id, false)) {
1850 const auto savepoint = mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).();
1851 dict_index_tcxx . . $ dict_index_t#* sys_index = UT_LIST_GET_FIRSTcxx . . $ `storage/innobase/include/ut0lst.h:421:9`!(
1852 dict_sys.sys_indexes->indexes);
1853 rec_offscxx . . $ rec_offs#* offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(
1854 rec, sys_index, nullptr, true, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
1855 const rec_tcxx . . $ rec_t#* old_vers;
1856 row_vers_build_for_semi_consistent_readcxx . . $ row_vers_build_for_semi_consistent_read(554b1a302a674a14).(
1857 rec, mtr, sys_index, &offsets, &heap,
1858 heap, &old_vers, nullptr);
1859 mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(savepoint);
1860 rec = old_vers;
1861 if (!old_vers || rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
1862 return dict_load_index_nonecxx . . $ dict_load_index_none.;
1863 }
1864 } else if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)
1865 && rec[8 + 8 + DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! + DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`!]
1866 != static_cast<bytecxx . . $ byte#>(*TEMP_INDEX_PREFIX_STRcxx . . $ `storage/innobase/include/ut0ut.h:51:9`!)
1867 && table->def_trx_idcxx . . $ dict_table_t#def_trx_id. < trx_id) {
1868 table->def_trx_idcxx . . $ dict_table_t#def_trx_id. = trx_id;
1869 }
1870
1871 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1872 rec, DICT_FLD__SYS_INDEXES__N_FIELDS, &len);
1873 if (len != 4) {
1874 goto err_len;
1875 }
1876 n_fields = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1877
1878 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1879 rec, DICT_FLD__SYS_INDEXES__TYPE, &len);
1880 if (len != 4) {
1881 goto err_len;
1882 }
1883 type = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1884 if (type & (~0U << DICT_IT_BITScxx . . $ `storage/innobase/include/dict0mem.h:77:9`!)) {
1885 return("unknown SYS_INDEXES.TYPE bits");
1886 }
1887
1888 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1889 rec, DICT_FLD__SYS_INDEXES__PAGE_NO, &len);
1890 if (len != 4) {
1891 goto err_len;
1892 }
1893
1894 ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(const auto name_offs =)
1895 rec_get_nth_field_offs_oldcxx . . $ rec_get_nth_field_offs_old(f5d0f3a8e7d2af7b).(rec, DICT_FLD__SYS_INDEXES__NAMEcxx . . $ DICT_FLD__SYS_INDEXES__NAME., &len);
1896 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_offs == 8 + 8 + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
1897
1898 if (len == 0 || len == UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!) {
1899 goto err_len;
1900 }
1901
1902 if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
1903 return dict_load_index_delcxx . . $ dict_load_index_del.;
1904 }
1905
1906 char* name = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(heap, reinterpret_cast<const char*>(rec)
1907 + (8 + 8 + DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`!
1908 + DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`!),
1909 len);
1910
1911 if (mtr) {
1912 *index = dict_mem_index_createcxx . . $ dict_mem_index_create(e48d716bb01ae4e7).(table, name, type, n_fields);
1913 } else {
1914 dict_mem_fill_index_structcxx . . $ dict_mem_fill_index_struct(712dcaf71849f6c4).(*index, nullptr, name,
1915 type, n_fields);
1916 }
1917
1918 (*index)->idcxx . . $ dict_index_t#id. = id;
1919 (*index)->pagecxx . . $ dict_index_t#page. = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(field);
1920 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((*index)->page);
1921 (*index)->merge_thresholdcxx . . $ dict_index_t#merge_threshold. = merge_threshold & ((1U << 6) - 1);
1922
1923 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
1924 }
1925
1926 /** Load definitions for table indexes. Adds them to the data dictionary cache.
1927 @param mtr mini-transaction
1928 @param table table definition
1929 @param uncommitted false=READ COMMITTED, true=READ UNCOMMITTED
1930 @param heap memory heap for temporary storage
1931 @param ignore_err errors to be ignored when loading the index definition
1932 @return error code
1933 @retval DB_SUCCESS if all indexes were successfully loaded
1934 @retval DB_CORRUPTION if corruption of dictionary table
1935 @retval DB_UNSUPPORTED if table has unknown index type */
1936 dberr_tcxx . . $ dberr_t# dict_load_indexescxx . . $ dict_load_indexes(61d42a777c99396f).(mtr_tcxx . . $ mtr_t# *mtr, dict_table_tcxx . . $ dict_table_t# *table, bool uncommitted,
1937 mem_heap_tcxx . . $ mem_heap_t# *heap, dict_err_ignore_tcxx . . $ dict_err_ignore_t# ignore_err)
1938 {
1939 dict_index_tcxx . . $ dict_index_t#* sys_index;
1940 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
1941 bytecxx . . $ byte# table_id[8];
1942
1943 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys.locked());
1944
1945 mtr->startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
1946
1947 sys_index = dict_syscxx . . $ dict_sys..sys_indexescxx . . $ dict_sys_t#sys_indexes.->indexescxx . . $ dict_table_t#indexes..startcxx . . $ ut_list_base#start.;
1948 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_sys.sys_indexes->not_redundant());
1949 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_indexes, sys_index,
1950 DICT_FLD__SYS_INDEXES__NAME, "NAME"));
1951 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_indexes, sys_index,
1952 DICT_FLD__SYS_INDEXES__PAGE_NO, "PAGE_NO"));
1953
1954 dfield_tcxx . . $ dfield_t# dfield;
1955 dtuple_tcxx . . $ dtuple_t# tuple{
1956 0,1,1,0,&dfield,nullptr
1957 #ifdef UNIV_DEBUG
1958 , DATA_TUPLE_MAGIC_N
1959 #endif
1960 };
1961 mach_write_to_8cxx . . $ mach_write_to_8(5500c4293b1bbef0).(table_id, table->idcxx . . $ dict_table_t#id.);
1962 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(&dfield, table_id, 8);
1963 dict_index_copy_typescxx . . $ dict_index_copy_types(9015429b5b64dc2b).(&tuple, sys_index, 1);
1964 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = sys_index;
1965
1966 dberr_tcxx . . $ dberr_t# error = btr_pcur_open_on_user_reccxx . . $ btr_pcur_open_on_user_rec(41267febe7c38db2).(&tuple, BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF.,
1967 &pcur, mtr);
1968 if (error != DB_SUCCESScxx . . $ DB_SUCCESS.) {
1969 goto func_exit;
1970 }
1971
1972 while (btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(&pcur)) {
1973 dict_index_tcxx . . $ dict_index_t#* index = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1974 const char* err_msg;
1975 const rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur);
1976 if ((ignore_err & DICT_ERR_IGNORE_RECOVER_LOCKcxx . . $ DICT_ERR_IGNORE_RECOVER_LOCK.)
1977 && (rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec)
1978 == DICT_NUM_FIELDS__SYS_INDEXEScxx . . $ DICT_NUM_FIELDS__SYS_INDEXES.
1979 /* a record for older SYS_INDEXES table
1980 (missing merge_threshold column) is acceptable. */
1981 || rec_get_n_fields_oldcxx . . $ rec_get_n_fields_old(469dcb4e54b221a8).(rec)
1982 == DICT_NUM_FIELDS__SYS_INDEXEScxx . . $ DICT_NUM_FIELDS__SYS_INDEXES. - 1)) {
1983 const bytecxx . . $ byte#* field;
1984 ulintcxx . . $ ulint# len;
1985 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
1986 rec, DICT_FLD__SYS_INDEXES__NAME, &len);
1987
1988 if (len != UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!
1989 && static_cast<char>(*field)
1990 == static_cast<char>(*TEMP_INDEX_PREFIX_STRcxx . . $ `storage/innobase/include/ut0ut.h:51:9`!)) {
1991 /* Skip indexes whose name starts with
1992 TEMP_INDEX_PREFIX_STR, because they will
1993 be dropped by row_merge_drop_temp_indexes()
1994 during crash recovery. */
1995 goto next_rec;
1996 }
1997 }
1998
1999 err_msg = dict_load_index_lowcxx . . $ dict_load_index_low(df34aa736bf7c68d).(table_id, uncommitted, heap, rec,
2000 mtr, table, &index);
2001 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index == !!err_msg);
2002
2003 if (err_msg == dict_load_index_nonecxx . . $ dict_load_index_none.) {
2004 /* We have ran out of index definitions for
2005 the table. */
2006 break;
2007 }
2008
2009 if (err_msg == dict_load_index_delcxx . . $ dict_load_index_del.) {
2010 goto next_rec;
2011 } else if (err_msg) {
2012 ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). err_msg;
2013 if (ignore_err & DICT_ERR_IGNORE_INDEXcxx . . $ DICT_ERR_IGNORE_INDEX.) {
2014 goto next_rec;
2015 }
2016 error = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.;
2017 goto func_exit;
2018 } else if (rec[8 + 8 + DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! + DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`!]
2019 == static_cast<bytecxx . . $ byte#>(*TEMP_INDEX_PREFIX_STRcxx . . $ `storage/innobase/include/ut0ut.h:51:9`!)) {
2020 dict_mem_index_freecxx . . $ dict_mem_index_free(1c927c2eb82bd833).(index);
2021 goto next_rec;
2022 } else {
2023 const trx_id_tcxx . . $ trx_id_t# id = trx_read_trx_idcxx . . $ trx_read_trx_id(b191ace3c5bffbd9).(rec + 8 + 8);
2024 if (id > table->def_trx_idcxx . . $ dict_table_t#def_trx_id.) {
2025 table->def_trx_idcxx . . $ dict_table_t#def_trx_id. = id;
2026 }
2027 }
2028
2029 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index);
2030 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_index_is_online_ddl(index));
2031
2032 /* Check whether the index is corrupted */
2033 if (ignore_err != DICT_ERR_IGNORE_DROPcxx . . $ DICT_ERR_IGNORE_DROP.
2034 && index->is_corruptedcxx . . $ dict_index_t#is_corrupted(50ce9a9e25b4a850).() && index->is_clustcxx . . $ dict_index_t#is_clust(50ce9a9e25b4a850).()) {
2035 dict_mem_index_freecxx . . $ dict_mem_index_free(1c927c2eb82bd833).(index);
2036 error = DB_TABLE_CORRUPTcxx . . $ DB_TABLE_CORRUPT.;
2037 goto func_exit;
2038 }
2039
2040 if (index->typecxx . . $ dict_index_t#type. & DICT_FTScxx . . $ `storage/innobase/include/dict0mem.h:71:9`!
2041 && !dict_table_has_fts_indexcxx . . $ dict_table_has_fts_index(6d9bc5841bb2dc90).(table)) {
2042 /* This should have been created by now. */
2043 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(table->fts != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
2044 DICT_TF2_FLAG_SETcxx . . $ `storage/innobase/include/dict0mem.h:278:9`!(table, DICT_TF2_FTScxx . . $ `storage/innobase/include/dict0mem.h:258:9`!);
2045 }
2046
2047 /* We check for unsupported types first, so that the
2048 subsequent checks are relevant for the supported types. */
2049 if (index->typecxx . . $ dict_index_t#type. & ~(DICT_CLUSTEREDcxx . . $ `storage/innobase/include/dict0mem.h:65:9`! | DICT_UNIQUEcxx . . $ `storage/innobase/include/dict0mem.h:68:9`!
2050 | DICT_CORRUPTcxx . . $ `storage/innobase/include/dict0mem.h:69:9`! | DICT_FTScxx . . $ `storage/innobase/include/dict0mem.h:71:9`!
2051 | DICT_SPATIALcxx . . $ `storage/innobase/include/dict0mem.h:73:9`! | DICT_VIRTUALcxx . . $ `storage/innobase/include/dict0mem.h:75:9`!)) {
2052
2053 ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Unknown type " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->typecxx . . $ dict_index_t#type.
2054 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " of index " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->namecxx . . $ dict_index_t#name.
2055 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " of table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.;
2056
2057 error = DB_UNSUPPORTEDcxx . . $ DB_UNSUPPORTED.;
2058 dict_mem_index_freecxx . . $ dict_mem_index_free(1c927c2eb82bd833).(index);
2059 goto func_exit;
2060 } else if (index->pagecxx . . $ dict_index_t#page. == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!
2061 && table->is_readablecxx . . $ dict_table_t#is_readable(50ce9a9e25b4a850).()
2062 && (!(index->typecxx . . $ dict_index_t#type. & DICT_FTScxx . . $ `storage/innobase/include/dict0mem.h:71:9`!))) {
2063 if (!uncommitted
2064 && ignore_err != DICT_ERR_IGNORE_DROPcxx . . $ DICT_ERR_IGNORE_DROP.) {
2065 ibcxx . . $ ib/::error_or_warncxx . . $ ib/error_or_warn#(!(ignore_err
2066 & DICT_ERR_IGNORE_INDEXcxx . . $ DICT_ERR_IGNORE_INDEX.))
2067 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Index " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->namecxx . . $ dict_index_t#name.
2068 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " for table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.
2069 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " has been freed!";
2070 }
2071
2072 if (!(ignore_err & DICT_ERR_IGNORE_INDEXcxx . . $ DICT_ERR_IGNORE_INDEX.)) {
2073 corrupted:
2074 dict_mem_index_freecxx . . $ dict_mem_index_free(1c927c2eb82bd833).(index);
2075 error = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.;
2076 goto func_exit;
2077 }
2078 /* If caller can tolerate this error,
2079 we will continue to load the index and
2080 let caller deal with this error. However
2081 mark the index and table corrupted. We
2082 only need to mark such in the index
2083 dictionary cache for such metadata corruption,
2084 since we would always be able to set it
2085 when loading the dictionary cache */
2086 if (index->is_clustcxx . . $ dict_index_t#is_clust(50ce9a9e25b4a850).()) {
2087 index->tablecxx . . $ dict_index_t#table.->corruptedcxx . . $ dict_table_t#corrupted. = true;
2088 index->tablecxx . . $ dict_index_t#table.->file_unreadablecxx . . $ dict_table_t#file_unreadable. = true;
2089 }
2090 index->typecxx . . $ dict_index_t#type. |= DICT_CORRUPTcxx . . $ `storage/innobase/include/dict0mem.h:69:9`!;
2091 } else if (!dict_index_is_clustcxx . . $ `storage/innobase/include/dict0dict.h:617:9`!(index)
2092 && NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! == dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(table)) {
2093
2094 ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Trying to load index " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->namecxx . . $ dict_index_t#name.
2095 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " for table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.
2096 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). ", but the first index is not clustered!";
2097
2098 goto corrupted;
2099 } else if (dict_is_sys_tablecxx . . $ dict_is_sys_table(31596a199e1d8a50).(table->idcxx . . $ dict_table_t#id.)
2100 && (dict_index_is_clustcxx . . $ `storage/innobase/include/dict0dict.h:617:9`!(index)
2101 || ((table == dict_syscxx . . $ dict_sys..sys_tablescxx . . $ dict_sys_t#sys_tables.)
2102 && !strcmp("ID_IND", index->namecxx . . $ dict_index_t#name.)))) {
2103
2104 /* The index was created in memory already at booting
2105 of the database server */
2106 dict_mem_index_freecxx . . $ dict_mem_index_free(1c927c2eb82bd833).(index);
2107 } else {
2108 error = dict_load_fieldscxx . . $ dict_load_fields(80deb3b188d952d5).(*mtr, index, uncommitted,
2109 heap);
2110 if (error != DB_SUCCESScxx . . $ DB_SUCCESS.) {
2111 goto func_exit;
2112 }
2113
2114 /* The data dictionary tables should never contain
2115 invalid index definitions. If we ignored this error
2116 and simply did not load this index definition, the
2117 .frm file would disagree with the index definitions
2118 inside InnoDB. */
2119 if ((error = dict_index_add_to_cachecxx . . $ dict_index_add_to_cache(3d07a3b14c80f9f5).(index,
2120 index->pagecxx . . $ dict_index_t#page.))
2121 != DB_SUCCESScxx . . $ DB_SUCCESS.) {
2122 goto func_exit;
2123 }
2124
2125 #ifdef UNIV_DEBUG
2126 // The following assertion doesn't hold for FTS indexes
2127 // as it may have prefix_len=1 with any charset
2128 if (index->type != DICT_FTS) {
2129 for (uint i = 0; i < index->n_fields; i++) {
2130 dict_field_t &f = index->fields[i];
2131 ut_ad(f.col->mbmaxlen == 0
2132 || f.prefix_len
2133 % f.col->mbmaxlen == 0);
2134 }
2135 }
2136 #endif /* UNIV_DEBUG */
2137 }
2138 next_rec:
2139 btr_pcur_move_to_next_user_reccxx . . $ btr_pcur_move_to_next_user_rec(db7b0b7a66db0c31).(&pcur, mtr);
2140 }
2141
2142 if (!dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(table)
2143 && !(ignore_err & DICT_ERR_IGNORE_INDEXcxx . . $ DICT_ERR_IGNORE_INDEX.)) {
2144 ibcxx . . $ ib/::warncxx . . $ ib/warn#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "No indexes found for table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.;
2145 error = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.;
2146 goto func_exit;
2147 }
2148
2149 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(table->fts_doc_id_index == NULL);
2150
2151 if (table->ftscxx . . $ dict_table_t#fts. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
2152 dict_index_tcxx . . $ dict_index_t# *idx = dict_table_get_index_on_namecxx . . $ dict_table_get_index_on_name(6b93a012e10c5d73).(
2153 table, FTS_DOC_ID_INDEXcxx . . $ FTS_DOC_ID_INDEX..str);
2154 if (idx && dict_index_is_uniquecxx . . $ `storage/innobase/include/dict0dict.h:619:9`!(idx)) {
2155 table->fts_doc_id_indexcxx . . $ dict_table_t#fts_doc_id_index. = idx;
2156 }
2157 }
2158
2159 /* If the table contains FTS indexes, populate table->fts->indexes */
2160 if (dict_table_has_fts_indexcxx . . $ dict_table_has_fts_index(6d9bc5841bb2dc90).(table)) {
2161 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(table->fts_doc_id_index != NULL);
2162 /* table->fts->indexes should have been created. */
2163 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(table->fts->indexes != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
2164 dict_table_get_all_fts_indexescxx . . $ dict_table_get_all_fts_indexes(8bf9c764f11dc83a).(table, table->ftscxx . . $ dict_table_t#fts.->indexescxx . . $ fts_t#indexes.);
2165 }
2166
2167 func_exit:
2168 mtr->commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
2169 return error;
2170 }
2171
2172 /** Load a table definition from a SYS_TABLES record to dict_table_t.
2173 Do not load any columns or indexes.
2174 @param[in,out] mtr mini-transaction
2175 @param[in] uncommitted whether to use READ UNCOMMITTED isolation level
2176 @param[in] rec SYS_TABLES record
2177 @param[out,own] table table, or nullptr
2178 @return error message
2179 @retval nullptr on success */
2180 const char *dict_load_table_lowcxx . . $ dict_load_table_low(82199068c9db0ad2).(mtr_tcxx . . $ mtr_t# *mtr, bool uncommitted,
2181 const rec_tcxx . . $ rec_t# *rec, dict_table_tcxx . . $ dict_table_t# **table)
2182 {
2183 table_id_tcxx . . $ table_id_t# table_id;
2184 uint32_tcxx . . $ uint32_t# space_id, t_num, flags, flags2;
2185 ulintcxx . . $ ulint# n_cols, n_v_col;
2186 trx_id_tcxx . . $ trx_id_t# trx_id;
2187
2188 if (const char* error_text = dict_sys_tables_rec_checkcxx . . $ dict_sys_tables_rec_check(366f986dcc4a6ef).(rec)) {
2189 *table = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2190 return(error_text);
2191 }
2192
2193 if (auto r = dict_sys_tables_rec_readcxx . . $ dict_sys_tables_rec_read(d1945c703ef817d).(rec, uncommitted, mtr,
2194 &table_id, &space_id,
2195 &t_num, &flags, &flags2,
2196 &trx_id)) {
2197 *table = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2198 return r == READ_ERRORcxx . . $ READ_ERROR. ? dict_load_table_flagscxx . . $ dict_load_table_flags. : nullptr;
2199 }
2200
2201 dict_table_decode_n_colcxx . . $ dict_table_decode_n_col(c9f1a433d85a5e7c).(t_num, &n_cols, &n_v_col);
2202
2203 *table = dict_table_tcxx . . $ dict_table_t#::createcxx . . $ dict_table_t#create(3c27cf8a971d66c7).(
2204 spancxx . . $ st_/span#span(afd8256c216b84b2).<const char>(reinterpret_cast<const char*>(rec),
2205 rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).(rec, 1)),
2206 nullptr, n_cols + n_v_col, n_v_col, flags, flags2);
2207 (*table)->space_idcxx . . $ dict_table_t#space_id. = space_id;
2208 (*table)->idcxx . . $ dict_table_t#id. = table_id;
2209 (*table)->file_unreadablecxx . . $ dict_table_t#file_unreadable. = !!(flags2 & DICT_TF2_DISCARDEDcxx . . $ DICT_TF2_DISCARDED.);
2210 (*table)->def_trx_idcxx . . $ dict_table_t#def_trx_id. = trx_id;
2211 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
2212 }
2213
2214 /** Make sure the data_file_name is saved in dict_table_t if needed.
2215 @param[in,out] table Table object */
2216 void dict_get_and_save_data_dir_pathcxx . . $ dict_get_and_save_data_dir_path(48b6e9ea9d480c5b).(dict_table_tcxx . . $ dict_table_t# *table)
2217 {
2218 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!table->is_temporary());
2219 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!table->space || table->space->id == table->space_id);
2220
2221 if (!table->data_dir_pathcxx . . $ dict_table_t#data_dir_path. && table->space_idcxx . . $ dict_table_t#space_id. && table->spacecxx . . $ dict_table_t#space.)
2222 {
2223 const char *filepath= table->spacecxx . . $ dict_table_t#space.->chaincxx . . $ fil_space_t#chain..startcxx . . $ ut_list_base#start.->namecxx . . $ fil_node_t#name.;
2224 if (strncmp(fil_path_to_mysql_datadircxx . . $ fil_path_to_mysql_datadir., filepath,
2225 strlen(fil_path_to_mysql_datadircxx . . $ fil_path_to_mysql_datadir.)))
2226 {
2227 table->lock_mutex_lockcxx . . $ dict_table_t#lock_mutex_lock(49f6e7a06ebc5aa8).();
2228 table->flagscxx . . $ dict_table_t#flags.|= 1 << DICT_TF_POS_DATA_DIRcxx . . $ `storage/innobase/include/dict0mem.h:168:9`! & ((1U << DICT_TF_BITScxx . . $ `storage/innobase/include/dict0mem.h:151:9`!) - 1);
2229 table->data_dir_pathcxx . . $ dict_table_t#data_dir_path.= mem_heap_strdupcxx . . $ mem_heap_strdup(ccac314bc9d3d20f).(table->heapcxx . . $ dict_table_t#heap., filepath);
2230 os_file_make_data_dir_pathcxx . . $ os_file_make_data_dir_path(79dcf97cf68ec3dd).(table->data_dir_pathcxx . . $ dict_table_t#data_dir_path.);
2231 table->lock_mutex_unlockcxx . . $ dict_table_t#lock_mutex_unlock(49f6e7a06ebc5aa8).();
2232 }
2233 }
2234 }
2235
2236 /** Opens a tablespace for dict_load_table_one()
2237 @param[in,out] table A table that refers to the tablespace to open
2238 @param[in] ignore_err Whether to ignore an error. */
2239 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
2240 void
2241 dict_load_tablespacecxx . . $ dict_load_tablespace(3c9f9189aff6d60d).(
2242 dict_table_tcxx . . $ dict_table_t#* table,
2243 dict_err_ignore_tcxx . . $ dict_err_ignore_t# ignore_err)
2244 {
2245 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!table->is_temporary());
2246 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!table->space);
2247 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(table->space_id < SRV_SPACE_ID_UPPER_BOUND);
2248 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(fil_system.sys_space);
2249
2250 if (table->space_idcxx . . $ dict_table_t#space_id. == TRX_SYS_SPACEcxx . . $ TRX_SYS_SPACE.) {
2251 table->spacecxx . . $ dict_table_t#space. = fil_systemcxx . . $ fil_system..sys_spacecxx . . $ fil_system_t#sys_space.;
2252 return;
2253 }
2254
2255 if (table->flags2cxx . . $ dict_table_t#flags2. & DICT_TF2_DISCARDEDcxx . . $ DICT_TF2_DISCARDED.) {
2256 ibcxx . . $ ib/::warncxx . . $ ib/warn#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Tablespace for table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.
2257 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " is set as discarded.";
2258 table->file_unreadablecxx . . $ dict_table_t#file_unreadable. = true;
2259 return;
2260 }
2261
2262 /* The tablespace may already be open. */
2263 table->spacecxx . . $ dict_table_t#space. = fil_space_for_table_exists_in_memcxx . . $ fil_space_for_table_exists_in_mem(3a0fe4bc6ebddf1a).(table->space_idcxx . . $ dict_table_t#space_id.,
2264 table->flagscxx . . $ dict_table_t#flags.);
2265 if (table->spacecxx . . $ dict_table_t#space. || table->file_unreadablecxx . . $ dict_table_t#file_unreadable.) {
2266 return;
2267 }
2268
2269 /* Use the remote filepath if needed. This parameter is optional
2270 in the call to fil_ibd_open(). If not supplied, it will be built
2271 from the table->name. */
2272 char* filepath = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2273 if (DICT_TF_HAS_DATA_DIRcxx . . $ `storage/innobase/include/dict0mem.h:224:9`!(table->flags)) {
2274 /* This will set table->data_dir_path from fil_system */
2275 dict_get_and_save_data_dir_pathcxx . . $ dict_get_and_save_data_dir_path(48b6e9ea9d480c5b).(table);
2276
2277 if (table->data_dir_pathcxx . . $ dict_table_t#data_dir_path.) {
2278 filepath = fil_make_filepathcxx . . $ fil_make_filepath(8c662c98e388b103).(
2279 table->data_dir_pathcxx . . $ dict_table_t#data_dir_path., table->namecxx . . $ dict_table_t#name., IBDcxx . . $ IBD., true);
2280 }
2281 }
2282
2283 table->spacecxx . . $ dict_table_t#space. = fil_ibd_opencxx . . $ fil_ibd_open(94c58849d3046f4d).(
2284 table->space_idcxx . . $ dict_table_t#space_id., dict_tf_to_fsp_flagscxx . . $ dict_tf_to_fsp_flags(2141b656ce2cc063).(table->flagscxx . . $ dict_table_t#flags.),
2285 fil_space_tcxx . . $ fil_space_t#::VALIDATE_SPACE_IDcxx . . $ fil_space_t#VALIDATE_SPACE_ID.,
2286 {cxx . . $ st_/span#span(afd8256c216b84b2).table->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name., strlen(table->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name.)}, filepath);
2287
2288 if (!table->spacecxx . . $ dict_table_t#space.) {
2289 /* We failed to find a sensible tablespace file */
2290 table->file_unreadablecxx . . $ dict_table_t#file_unreadable. = true;
2291
2292 if (!(ignore_err & DICT_ERR_IGNORE_RECOVER_LOCKcxx . . $ DICT_ERR_IGNORE_RECOVER_LOCK.)) {
2293 sql_print_errorcxx . . $ sql_print_error(326aeb464d16410c).("InnoDB: Failed to load tablespace %"
2294 PRIu32cxx . . $ `<external>/15933738808807975373/inttypes.h:104:10`! " for table %s",
2295 table->space_idcxx . . $ dict_table_t#space_id., table->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name.);
2296 }
2297 }
2298
2299 ut_freecxx . . $ `storage/innobase/include/ut0new.h:1044:9`!(filepath);
2300 }
2301
2302 /** Loads a table definition and also all its index definitions.
2303
2304 Loads those foreign key constraints whose referenced table is already in
2305 dictionary cache. If a foreign key constraint is not loaded, then the
2306 referenced table is pushed into the output stack (fk_tables), if it is not
2307 NULL. These tables must be subsequently loaded so that all the foreign
2308 key constraints are loaded into memory.
2309
2310 @param[in,out] mtr mini-transaction
2311 @param[in] name Table name in the db/tablename format
2312 @param[in] ignore_err Error to be ignored when loading table
2313 and its index definition
2314 @param[out] fk_tables Related table names that must also be
2315 loaded to ensure that all foreign key
2316 constraints are loaded.
2317 @return table, possibly with file_unreadable flag set
2318 @retval nullptr if the table does not exist */
2319 static dict_table_tcxx . . $ dict_table_t# *dict_load_table_onecxx . . $ dict_load_table_one(da3fe585bfe8f7fe).(mtr_tcxx . . $ mtr_t# &mtr,
2320 const spancxx . . $ span#<const char> &name,
2321 dict_err_ignore_tcxx . . $ dict_err_ignore_t# ignore_err,
2322 dict_names_tcxx . . $ dict_names_t# &fk_tables)
2323 {
2324 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
2325
2326 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("dict_load_table_one");
2327 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("dict_load_table_one",
2328 ("table: %.*s", int(name.size()), name.data()));
2329
2330 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys.locked());
2331
2332 dict_index_tcxx . . $ dict_index_t# *sys_index = dict_syscxx . . $ dict_sys..sys_tablescxx . . $ dict_sys_t#sys_tables.->indexescxx . . $ dict_table_t#indexes..startcxx . . $ ut_list_base#start.;
2333 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_sys.sys_tables->not_redundant());
2334 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_tables, sys_index,
2335 DICT_FLD__SYS_TABLES__ID, "ID"));
2336 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_tables, sys_index,
2337 DICT_FLD__SYS_TABLES__N_COLS, "N_COLS"));
2338 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_tables, sys_index,
2339 DICT_FLD__SYS_TABLES__TYPE, "TYPE"));
2340 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_tables, sys_index,
2341 DICT_FLD__SYS_TABLES__MIX_LEN, "MIX_LEN"));
2342 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(name_of_col_is(dict_sys.sys_tables, sys_index,
2343 DICT_FLD__SYS_TABLES__SPACE, "SPACE"));
2344
2345 dfield_tcxx . . $ dfield_t# dfield;
2346 dtuple_tcxx . . $ dtuple_t# tuple{
2347 0,1,1,0,&dfield,nullptr
2348 #ifdef UNIV_DEBUG
2349 , DATA_TUPLE_MAGIC_N
2350 #endif
2351 };
2352 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(&dfield, name.datacxx . . $ st_/span#data(5a2a78a048fb49a8).(), name.sizecxx . . $ st_/span#size(fe4d2d262d4164a8).());
2353 dict_index_copy_typescxx . . $ dict_index_copy_types(9015429b5b64dc2b).(&tuple, sys_index, 1);
2354 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = sys_index;
2355
2356 bool uncommitted = false;
2357 reload:
2358 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
2359 dberr_tcxx . . $ dberr_t# err = btr_pcur_open_on_user_reccxx . . $ btr_pcur_open_on_user_rec(41267febe7c38db2).(&tuple,
2360 BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., &pcur, &mtr);
2361
2362 if (err != DB_SUCCESScxx . . $ DB_SUCCESS. || !btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(&pcur)) {
2363 /* Not found */
2364 err_exit:
2365 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
2366 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(nullptr);
2367 }
2368
2369 const rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur);
2370
2371 /* Check if the table name in record is the searched one */
2372 if (rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).(rec, 1) != name.sizecxx . . $ st_/span#size(fe4d2d262d4164a8).()
2373 || memcmp(name.datacxx . . $ st_/span#data(5a2a78a048fb49a8).(), rec, name.sizecxx . . $ st_/span#size(fe4d2d262d4164a8).())) {
2374 goto err_exit;
2375 }
2376
2377 dict_table_tcxx . . $ dict_table_t#* table;
2378 if (const char* err_msg =
2379 dict_load_table_lowcxx . . $ dict_load_table_low(82199068c9db0ad2).(&mtr, uncommitted, rec, &table)) {
2380 if (err_msg != dict_load_table_flagscxx . . $ dict_load_table_flags.) {
2381 ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). err_msg;
2382 }
2383 goto err_exit;
2384 }
2385 if (!table) {
2386 goto err_exit;
2387 }
2388
2389 const unsigned use_uncommitted = uncommitted
2390 ? 2
2391 : table->idcxx . . $ dict_table_t#id. == mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(
2392 rec + rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).(
2393 rec, DICT_FLD__SYS_TABLES__IDcxx . . $ DICT_FLD__SYS_TABLES__ID.));
2394
2395 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
2396
2397 mem_heap_tcxx . . $ mem_heap_t#* heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(32000);
2398
2399 dict_load_tablespacecxx . . $ dict_load_tablespace(3c9f9189aff6d60d).(table, ignore_err);
2400
2401 switch (dict_load_columnscxx . . $ dict_load_columns(fdd01f8df46eddce).(mtr, table, use_uncommitted, heap)) {
2402 case DB_SUCCESS_LOCKED_RECcxx . . $ DB_SUCCESS_LOCKED_REC.:
2403 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!uncommitted);
2404 uncommitted = true;
2405 dict_mem_table_freecxx . . $ dict_mem_table_free(48b6e9ea9d480c5b).(table);
2406 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
2407 goto reload;
2408 case DB_SUCCESScxx . . $ DB_SUCCESS.:
2409 if (!dict_load_virtualcxx . . $ dict_load_virtual(d8409e0ba2f11ba2).(mtr, table, uncommitted)) {
2410 break;
2411 }
2412 /* fall through */
2413 default:
2414 dict_mem_table_freecxx . . $ dict_mem_table_free(48b6e9ea9d480c5b).(table);
2415 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
2416 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(nullptr);
2417 }
2418
2419 dict_table_add_system_columnscxx . . $ dict_table_add_system_columns(f54c2afd6563a66e).(table, heap);
2420
2421 table->can_be_evictedcxx . . $ dict_table_t#can_be_evicted. = true;
2422 table->add_to_cachecxx . . $ dict_table_t#add_to_cache(49f6e7a06ebc5aa8).();
2423
2424 mem_heap_emptycxx . . $ mem_heap_empty(5231cf397463bfab).(heap);
2425
2426 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_tf2_is_valid(table->flags, table->flags2));
2427
2428 /* If there is no tablespace for the table then we only need to
2429 load the index definitions. So that we can IMPORT the tablespace
2430 later. When recovering table locks for resurrected incomplete
2431 transactions, the tablespace should exist, because DDL operations
2432 were not allowed while the table is being locked by a transaction. */
2433 dict_err_ignore_tcxx . . $ dict_err_ignore_t# index_load_err =
2434 !(ignore_err & DICT_ERR_IGNORE_RECOVER_LOCKcxx . . $ DICT_ERR_IGNORE_RECOVER_LOCK.)
2435 && !table->is_readablecxx . . $ dict_table_t#is_readable(50ce9a9e25b4a850).()
2436 ? DICT_ERR_IGNORE_ALLcxx . . $ DICT_ERR_IGNORE_ALL.
2437 : ignore_err;
2438
2439 err = dict_load_indexescxx . . $ dict_load_indexes(61d42a777c99396f).(&mtr, table, uncommitted, heap,
2440 index_load_err);
2441
2442 if (err == DB_TABLE_CORRUPTcxx . . $ DB_TABLE_CORRUPT.) {
2443 /* Refuse to load the table if the table has a corrupted
2444 cluster index */
2445 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index_load_err != DICT_ERR_IGNORE_DROP);
2446 ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Refusing to load corrupted table "
2447 <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.;
2448 evict:
2449 dict_syscxx . . $ dict_sys..removecxx . . $ dict_sys_t#remove(bc56845296a133e5).(table);
2450 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
2451 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(nullptr);
2452 }
2453
2454 if (err != DB_SUCCESScxx . . $ DB_SUCCESS. || !table->is_readablecxx . . $ dict_table_t#is_readable(50ce9a9e25b4a850).()) {
2455 } else if (dict_index_tcxx . . $ dict_index_t#* pk = dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(table)) {
2456 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(pk->is_primary());
2457 if (pk->is_corruptedcxx . . $ dict_index_t#is_corrupted(50ce9a9e25b4a850).()
2458 || pk->pagecxx . . $ dict_index_t#page. >= table->spacecxx . . $ dict_table_t#space.->get_sizecxx . . $ fil_space_t#get_size(2658d6455debfaef).()) {
2459 corrupted:
2460 table->corruptedcxx . . $ dict_table_t#corrupted. = true;
2461 table->file_unreadablecxx . . $ dict_table_t#file_unreadable. = true;
2462 err = DB_TABLE_CORRUPTcxx . . $ DB_TABLE_CORRUPT.;
2463 } else if (table->spacecxx . . $ dict_table_t#space.->idcxx . . $ fil_space_t#id.
2464 && ignore_err == DICT_ERR_IGNORE_DROPcxx . . $ DICT_ERR_IGNORE_DROP.) {
2465 /* Do not bother to load data from .ibd files
2466 only to delete the .ibd files. */
2467 goto corrupted;
2468 } else {
2469 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
2470 bool ok = false;
2471 if (buf_block_tcxx . . $ buf_block_t#* b = buf_page_getcxx . . $ `storage/innobase/include/buf0buf.h:149:10`!(
2472 page_id_t(table->space->id, pk->page),
2473 table->space->zip_size(),
2474 RW_S_LATCH, &mtr)) {
2475 switch (mach_read_from_2cxx . . $ mach_read_from_2(469dcb4e54b221a8).(FIL_PAGE_TYPEcxx . . $ `storage/innobase/include/fil0fil.h:1215:9`!
2476 + b->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.)) {
2477 case FIL_PAGE_INDEXcxx . . $ FIL_PAGE_INDEX.:
2478 case FIL_PAGE_TYPE_INSTANTcxx . . $ FIL_PAGE_TYPE_INSTANT.:
2479 ok = true;
2480 }
2481 }
2482 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
2483 if (!ok) {
2484 goto corrupted;
2485 }
2486
2487 err = btr_cur_instant_initcxx . . $ btr_cur_instant_init(2e0c606a2d65a22a).(&mtr, table);
2488 }
2489 } else {
2490 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(ignore_err & DICT_ERR_IGNORE_INDEX);
2491 if (ignore_err != DICT_ERR_IGNORE_DROPcxx . . $ DICT_ERR_IGNORE_DROP.) {
2492 err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.;
2493 goto evict;
2494 }
2495 }
2496
2497 /* We will load the foreign key information only if
2498 all indexes were loaded. */
2499 if (!table->is_readablecxx . . $ dict_table_t#is_readable(50ce9a9e25b4a850).()) {
2500 /* Don't attempt to load the indexes from disk. */
2501 } else if (err == DB_SUCCESScxx . . $ DB_SUCCESS.) {
2502 auto i = fk_tables.sizecxx . . $ std/deque#size(c9b1e749b64d5edc).();
2503 err = dict_load_foreignscxx . . $ dict_load_foreigns(9dda56b1e2a7829).(mtr, table->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name., nullptr,
2504 0, true, ignore_err, fk_tables);
2505
2506 if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) {
2507 fk_tables.erasecxx . . $ std/deque#erase(74a41bd00f332169).(fk_tablescxx . . $ std/_Deque_iterator#_Deque_iterator(5880d2d26bbc17a2)..begincxx . . $ std/deque#begin(3eee4dc5a9c66500).() +cxx . . $ std/operator+(7503db32ec856df1). i, fk_tablescxx . . $ std/_Deque_iterator#_Deque_iterator(5880d2d26bbc17a2)..endcxx . . $ std/deque#end(3eee4dc5a9c66500).());
2508 ibcxx . . $ ib/::warncxx . . $ ib/warn#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Load table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.
2509 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " failed, the table has missing"
2510 " foreign key indexes. Turn off"
2511 " 'foreign_key_checks' and try again.";
2512 goto evict;
2513 } else {
2514 dict_mem_table_fill_foreign_vcol_setcxx . . $ dict_mem_table_fill_foreign_vcol_set(48b6e9ea9d480c5b).(table);
2515 }
2516 }
2517
2518 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
2519
2520 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!table
2521 || (ignore_err & ~DICT_ERR_IGNORE_FK_NOKEY)
2522 || !table->is_readable()
2523 || !table->corrupted);
2524
2525 if (table && table->ftscxx . . $ dict_table_t#fts.) {
2526 if (!(dict_table_has_fts_indexcxx . . $ dict_table_has_fts_index(6d9bc5841bb2dc90).(table)
2527 || DICT_TF2_FLAG_IS_SETcxx . . $ `storage/innobase/include/dict0mem.h:281:9`!(table, DICT_TF2_FTS_HAS_DOC_IDcxx . . $ `storage/innobase/include/dict0mem.h:255:9`!)
2528 || DICT_TF2_FLAG_IS_SETcxx . . $ `storage/innobase/include/dict0mem.h:281:9`!(table, DICT_TF2_FTS_ADD_DOC_IDcxx . . $ `storage/innobase/include/dict0mem.h:262:9`!))) {
2529 /* the table->fts could be created in dict_load_column
2530 when a user defined FTS_DOC_ID is present, but no
2531 FTS */
2532 table->ftscxx . . $ dict_table_t#fts.->~fts_tcxx . . $ fts_t#();
2533 table->ftscxx . . $ dict_table_t#fts. = nullptr;
2534 } else if (fts_optimize_wqcxx . . $ fts_optimize_wq.) {
2535 fts_optimize_add_tablecxx . . $ fts_optimize_add_table(48b6e9ea9d480c5b).(table);
2536 } else if (table->can_be_evictedcxx . . $ dict_table_t#can_be_evicted.) {
2537 /* fts_optimize_thread is not started yet.
2538 So make the table as non-evictable from cache. */
2539 dict_syscxx . . $ dict_sys..prevent_evictioncxx . . $ dict_sys_t#prevent_eviction(48b6e9ea9d480c5b).(table);
2540 }
2541 }
2542
2543 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(err != DB_SUCCESS || dict_foreign_set_validate(*table));
2544
2545 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(table);
2546 }
2547
2548 dict_table_tcxx . . $ dict_table_t# *dict_sys_tcxx . . $ dict_sys_t#::load_tablecxx . . $ dict_sys_t#load_table(9f8a1681768f5609).(const spancxx . . $ span#<const char> &name,
2549 dict_err_ignore_tcxx . . $ dict_err_ignore_t# ignore) noexcept
2550 {
2551 if (dict_table_tcxx . . $ dict_table_t# *table= find_tablecxx . . $ dict_sys_t#find_table(25f651ffcaee7fcf).(name))
2552 return table;
2553 dict_names_tcxx . . $ dict_names_t# fk_listcxx . . $ std/deque#deque(49f6e7a06ebc5aa8).;
2554 THDcxx . . $ THD#* const thd{current_thdcxx . . $ `sql/mysqld.h:916:9`!};
2555 mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{thd ? thd_to_trxcxx . . $ thd_to_trx(76f0d80b3ea02926).(thd) : nullptr};
2556 dict_table_tcxx . . $ dict_table_t# *table= dict_load_table_onecxx . . $ dict_load_table_one(da3fe585bfe8f7fe).(mtr, name, ignore, fk_list);
2557 while (!fk_list.emptycxx . . $ std/deque#empty(3482b152b9333168).())
2558 {
2559 const char *f= fk_list.frontcxx . . $ std/deque#front(1c9784b1aa27a05e).();
2560 const spancxx . . $ span#<const char> namecxx . . $ st_/span#span(afd8256c216b84b2).{f, strlen(f)};
2561 if (!find_tablecxx . . $ dict_sys_t#find_table(25f651ffcaee7fcf).(name))
2562 dict_load_table_onecxx . . $ dict_load_table_one(da3fe585bfe8f7fe).(mtr, name, ignore, fk_list);
2563 fk_list.pop_frontcxx . . $ std/deque#pop_front(ced63f7c635d850d).();
2564 }
2565
2566 return table;
2567 }
2568
2569 /***********************************************************************//**
2570 Loads a table object based on the table id.
2571 @return table; NULL if table does not exist */
2572 dict_table_tcxx . . $ dict_table_t#*
2573 dict_load_table_on_idcxx . . $ dict_load_table_on_id(38493176723f9f58).(
2574 /*==================*/
2575 table_id_tcxx . . $ table_id_t# table_id, /*!< in: table id */
2576 dict_err_ignore_tcxx . . $ dict_err_ignore_t# ignore_err) /*!< in: errors to ignore
2577 when loading the table */
2578 {
2579 bytecxx . . $ byte# id_buf[8];
2580 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
2581 const bytecxx . . $ byte#* field;
2582 ulintcxx . . $ ulint# len;
2583 mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{nullptr};
2584
2585 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys.locked());
2586
2587 /* NOTE that the operation of this function is protected by
2588 dict_sys.latch, and therefore no deadlocks can occur
2589 with other dictionary operations. */
2590
2591 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
2592 /*---------------------------------------------------*/
2593 /* Get the secondary index based on ID for table SYS_TABLES */
2594 dict_index_tcxx . . $ dict_index_t# *sys_table_ids =
2595 dict_syscxx . . $ dict_sys..sys_tablescxx . . $ dict_sys_t#sys_tables.->indexescxx . . $ dict_table_t#indexes..startcxx . . $ ut_list_base#start.->indexescxx . . $ dict_index_t#indexes..nextcxx . . $ ut_list_node#next.;
2596
2597 dfield_tcxx . . $ dfield_t# dfield;
2598 dtuple_tcxx . . $ dtuple_t# tuple{
2599 0,1,1,0,&dfield,nullptr
2600 #ifdef UNIV_DEBUG
2601 , DATA_TUPLE_MAGIC_N
2602 #endif
2603 };
2604
2605 /* Write the table id in byte format to id_buf */
2606 mach_write_to_8cxx . . $ mach_write_to_8(5500c4293b1bbef0).(id_buf, table_id);
2607 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(&dfield, id_buf, 8);
2608 dict_index_copy_typescxx . . $ dict_index_copy_types(9015429b5b64dc2b).(&tuple, sys_table_ids, 1);
2609 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = sys_table_ids;
2610
2611 dict_table_tcxx . . $ dict_table_t#* table = nullptr;
2612
2613 if (btr_pcur_open_on_user_reccxx . . $ btr_pcur_open_on_user_rec(41267febe7c38db2).(&tuple, BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., &pcur, &mtr)
2614 == DB_SUCCESScxx . . $ DB_SUCCESS.
2615 && btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(&pcur)) {
2616 /*---------------------------------------------------*/
2617 /* Now we have the record in the secondary index
2618 containing the table ID and NAME */
2619 const rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur);
2620 check_rec:
2621 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2622 rec, DICT_FLD__SYS_TABLE_IDS__ID, &len);
2623 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len == 8);
2624
2625 /* Check if the table id in record is the one searched for */
2626 if (table_id == mach_read_from_8cxx . . $ mach_read_from_8(b191ace3c5bffbd9).(field)) {
2627 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(rec,
2628 DICT_FLD__SYS_TABLE_IDS__NAME, &len);
2629 table = dict_syscxx . . $ dict_sys..load_tablecxx . . $ dict_sys_t#load_table(9f8a1681768f5609).(
2630 {cxx . . $ st_/span#span(afd8256c216b84b2).reinterpret_cast<const char*>(field),
2631 len}, ignore_err);
2632 if (table && table->idcxx . . $ dict_table_t#id. != table_id) {
2633 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_get_deleted_flag(rec, 0));
2634 table = nullptr;
2635 }
2636 if (!table) {
2637 while (btr_pcur_move_to_nextcxx . . $ btr_pcur_move_to_next(db7b0b7a66db0c31).(&pcur, &mtr)) {
2638 rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur);
2639
2640 if (page_rec_is_user_reccxx . . $ page_rec_is_user_rec(190063cf6fb4afb1).(rec)) {
2641 goto check_rec;
2642 }
2643 }
2644 }
2645 }
2646 }
2647
2648 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
2649 return table;
2650 }
2651
2652 MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
2653 /********************************************************************//**
2654 Loads foreign key constraint col names (also for the referenced table).
2655 Members that must be set (and valid) in foreign:
2656 foreign->heap
2657 foreign->n_fields
2658 foreign->id ('\0'-terminated)
2659 Members that will be created and set by this function:
2660 foreign->foreign_col_names[i]
2661 foreign->referenced_col_names[i]
2662 (for i=0..foreign->n_fields-1) */
2663 static dberr_tcxx . . $ dberr_t# dict_load_foreign_colscxx . . $ dict_load_foreign_cols(36a73f0ada5bac9c).(mtr_tcxx . . $ mtr_t# &mtr, dict_foreign_tcxx . . $ dict_foreign_t# *foreign,
2664 trx_id_tcxx . . $ trx_id_t# trx_id)
2665 {
2666 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
2667 size_t id_len;
2668
2669 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys.locked());
2670
2671 id_len = strlen(foreign->idcxx . . $ dict_foreign_t#id.);
2672
2673 foreign->foreign_col_namescxx . . $ dict_foreign_t#foreign_col_names. = static_cast<const char**>(
2674 mem_heap_alloccxx . . $ mem_heap_alloc(3f50e4c8b9ca77c0).(foreign->heapcxx . . $ dict_foreign_t#heap.,
2675 foreign->n_fieldscxx . . $ dict_foreign_t#n_fields. * sizeof(void*)));
2676
2677 foreign->referenced_col_namescxx . . $ dict_foreign_t#referenced_col_names. = static_cast<const char**>(
2678 mem_heap_alloccxx . . $ mem_heap_alloc(3f50e4c8b9ca77c0).(foreign->heapcxx . . $ dict_foreign_t#heap.,
2679 foreign->n_fieldscxx . . $ dict_foreign_t#n_fields. * sizeof(void*)));
2680
2681 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
2682
2683 dict_index_tcxx . . $ dict_index_t#* sys_index = dict_syscxx . . $ dict_sys..sys_foreign_colscxx . . $ dict_sys_t#sys_foreign_cols.->indexescxx . . $ dict_table_t#indexes..startcxx . . $ ut_list_base#start.;
2684 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_sys.sys_foreign_cols->not_redundant());
2685
2686 dfield_tcxx . . $ dfield_t# dfield;
2687 dtuple_tcxx . . $ dtuple_t# tuple{
2688 0,1,1,0,&dfield,nullptr
2689 #ifdef UNIV_DEBUG
2690 , DATA_TUPLE_MAGIC_N
2691 #endif
2692 };
2693
2694 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(&dfield, foreign->idcxx . . $ dict_foreign_t#id., id_len);
2695 dict_index_copy_typescxx . . $ dict_index_copy_types(9015429b5b64dc2b).(&tuple, sys_index, 1);
2696 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = sys_index;
2697
2698 mem_heap_tcxx . . $ mem_heap_t#* heap = nullptr;
2699 dberr_tcxx . . $ dberr_t# err = btr_pcur_open_on_user_reccxx . . $ btr_pcur_open_on_user_rec(41267febe7c38db2).(&tuple,
2700 BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., &pcur, &mtr);
2701 if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) {
2702 goto func_exit;
2703 }
2704 for (ulintcxx . . $ ulint# i = 0; i < foreign->n_fieldscxx . . $ dict_foreign_t#n_fields.; i++) {
2705 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(btr_pcur_is_on_user_rec(&pcur));
2706
2707 const rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur);
2708 ulintcxx . . $ ulint# len;
2709 const bytecxx . . $ byte#* field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2710 rec, DICT_FLD__SYS_FOREIGN_COLS__DB_TRX_ID, &len);
2711 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(len == DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`!);
2712
2713 if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) {
2714 mem_heap_emptycxx . . $ mem_heap_empty(5231cf397463bfab).(heap);
2715 }
2716
2717 const trx_id_tcxx . . $ trx_id_t# id = trx_read_trx_idcxx . . $ trx_read_trx_id(b191ace3c5bffbd9).(field);
2718 if (!id) {
2719 } else if (id != trx_id && trx_syscxx . . $ trx_sys..findcxx . . $ trx_sys_t#find(2dd6004328198d46).(nullptr, id, false)) {
2720 const auto savepoint = mtr.get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).();
2721 rec_offscxx . . $ rec_offs#* offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(
2722 rec, sys_index, nullptr, true, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!,
2723 &heap);
2724 const rec_tcxx . . $ rec_t#* old_vers;
2725 row_vers_build_for_semi_consistent_readcxx . . $ row_vers_build_for_semi_consistent_read(554b1a302a674a14).(
2726 rec, &mtr, sys_index, &offsets, &heap,
2727 heap, &old_vers, nullptr);
2728 mtr.rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(savepoint);
2729 rec = old_vers;
2730 if (!rec || rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
2731 goto next;
2732 }
2733 }
2734
2735 if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
2736 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(id);
2737 goto next;
2738 }
2739
2740 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2741 rec, DICT_FLD__SYS_FOREIGN_COLS__ID, &len);
2742
2743 if (len != id_len || memcmp(foreign->idcxx . . $ dict_foreign_t#id., field, len)) {
2744 const rec_tcxx . . $ rec_t#* pos;
2745 ulintcxx . . $ ulint# pos_len;
2746 const rec_tcxx . . $ rec_t#* for_col_name;
2747 ulintcxx . . $ ulint# for_col_name_len;
2748 const rec_tcxx . . $ rec_t#* ref_col_name;
2749 ulintcxx . . $ ulint# ref_col_name_len;
2750
2751 pos = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2752 rec, DICT_FLD__SYS_FOREIGN_COLS__POS,
2753 &pos_len);
2754
2755 for_col_name = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2756 rec, DICT_FLD__SYS_FOREIGN_COLS__FOR_COL_NAME,
2757 &for_col_name_len);
2758
2759 ref_col_name = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2760 rec, DICT_FLD__SYS_FOREIGN_COLS__REF_COL_NAME,
2761 &ref_col_name_len);
2762
2763 ibcxx . . $ ib/::errorcxx . . $ ib/error# sout;
2764
2765 sout <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Unable to load column names for foreign"
2766 " key '" <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). foreign->idcxx . . $ dict_foreign_t#id.
2767 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "' because it was not found in"
2768 " InnoDB internal table SYS_FOREIGN_COLS. The"
2769 " closest entry we found is:"
2770 " (ID='";
2771 sout.writecxx . . $ ib/logger#write(defe42ee0ebd83a2).(field, len);
2772 sout <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "', POS=" <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(pos)
2773 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). ", FOR_COL_NAME='";
2774 sout.writecxx . . $ ib/logger#write(defe42ee0ebd83a2).(for_col_name, for_col_name_len);
2775 sout <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "', REF_COL_NAME='";
2776 sout.writecxx . . $ ib/logger#write(defe42ee0ebd83a2).(ref_col_name, ref_col_name_len);
2777 sout <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "')";
2778
2779 err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.;
2780 break;
2781 }
2782
2783 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2784 rec, DICT_FLD__SYS_FOREIGN_COLS__POS, &len);
2785 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(len == 4);
2786 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(i == mach_read_from_4(field));
2787
2788 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2789 rec, DICT_FLD__SYS_FOREIGN_COLS__FOR_COL_NAME, &len);
2790 foreign->foreign_col_namescxx . . $ dict_foreign_t#foreign_col_names.[i] = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(
2791 foreign->heapcxx . . $ dict_foreign_t#heap., (char*) field, len);
2792
2793 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2794 rec, DICT_FLD__SYS_FOREIGN_COLS__REF_COL_NAME, &len);
2795 foreign->referenced_col_namescxx . . $ dict_foreign_t#referenced_col_names.[i] = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(
2796 foreign->heapcxx . . $ dict_foreign_t#heap., (char*) field, len);
2797
2798 next:
2799 btr_pcur_move_to_next_user_reccxx . . $ btr_pcur_move_to_next_user_rec(db7b0b7a66db0c31).(&pcur, &mtr);
2800 }
2801 func_exit:
2802 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
2803 if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) {
2804 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
2805 }
2806 return err;
2807 }
2808
2809 /***********************************************************************//**
2810 Loads a foreign key constraint to the dictionary cache. If the referenced
2811 table is not yet loaded, it is added in the output parameter (fk_tables).
2812 @return DB_SUCCESS or error code */
2813 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((warn_unused_result))
2814 dberr_tcxx . . $ dberr_t#
2815 dict_load_foreigncxx . . $ dict_load_foreign(1d49bce8a07e5b4a).(
2816 /*==============*/
2817 mtr_tcxx . . $ mtr_t#& mtr, /*!< in/out: mini-transaction*/
2818 const char* table_name, /*!< in: table name */
2819 bool uncommitted, /*!< in: use READ UNCOMMITTED
2820 transaction isolation level */
2821 const char** col_names,
2822 /*!< in: column names, or NULL
2823 to use foreign->foreign_table->col_names */
2824 trx_id_tcxx . . $ trx_id_t# trx_id,
2825 /*!< in: current transaction id, or 0 */
2826 bool check_recursive,
2827 /*!< in: whether to record the foreign table
2828 parent count to avoid unlimited recursive
2829 load of chained foreign tables */
2830 bool check_charsets,
2831 /*!< in: whether to check charset
2832 compatibility */
2833 spancxx . . $ span#<const char> id,
2834 /*!< in: foreign constraint id */
2835 dict_err_ignore_tcxx . . $ dict_err_ignore_t# ignore_err,
2836 /*!< in: error to be ignored */
2837 dict_names_tcxx . . $ dict_names_t#& fk_tables)
2838 /*!< out: the foreign key constraint is added
2839 to the dictionary cache only if the referenced
2840 table is already in cache. Otherwise, the
2841 foreign key constraint is not added to cache,
2842 and the referenced table is added to this
2843 stack. */
2844 {
2845 dict_foreign_tcxx . . $ dict_foreign_t#* foreign;
2846 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
2847 const bytecxx . . $ byte#* field;
2848 ulintcxx . . $ ulint# len;
2849 dict_table_tcxx . . $ dict_table_t#* for_table;
2850 dict_table_tcxx . . $ dict_table_t#* ref_table;
2851
2852 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("dict_load_foreign");
2853 DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("dict_load_foreign",
2854 ("id: '%.*s', check_recursive: %d",
2855 int(id.size()), id.data(), check_recursive));
2856
2857 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys.locked());
2858
2859 dict_index_tcxx . . $ dict_index_t#* sys_index = dict_syscxx . . $ dict_sys..sys_foreigncxx . . $ dict_sys_t#sys_foreign.->indexescxx . . $ dict_table_t#indexes..startcxx . . $ ut_list_base#start.;
2860 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_sys.sys_foreign->not_redundant());
2861
2862 dfield_tcxx . . $ dfield_t# dfield;
2863 dtuple_tcxx . . $ dtuple_t# tuple{
2864 0,1,1,0,&dfield,nullptr
2865 #ifdef UNIV_DEBUG
2866 , DATA_TUPLE_MAGIC_N
2867 #endif
2868 };
2869 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(&dfield, id.datacxx . . $ st_/span#data(5a2a78a048fb49a8).(), id.sizecxx . . $ st_/span#size(fe4d2d262d4164a8).());
2870 dict_index_copy_typescxx . . $ dict_index_copy_types(9015429b5b64dc2b).(&tuple, sys_index, 1);
2871 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = sys_index;
2872
2873 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
2874
2875 mem_heap_tcxx . . $ mem_heap_t#* heap = nullptr;
2876 dberr_tcxx . . $ dberr_t# err = btr_pcur_open_on_user_reccxx . . $ btr_pcur_open_on_user_rec(41267febe7c38db2).(&tuple,
2877 BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., &pcur, &mtr);
2878 if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) {
2879 goto err_exit;
2880 }
2881
2882 if (!btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(&pcur)) {
2883 not_found:
2884 err = DB_NOT_FOUNDcxx . . $ DB_NOT_FOUND.;
2885 err_exit:
2886 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
2887 if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) {
2888 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
2889 }
2890 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(err);
2891 }
2892
2893 const rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur);
2894 static_assert(DICT_FLD__SYS_FOREIGN__IDcxx . . $ DICT_FLD__SYS_FOREIGN__ID. == 0, "compatibility");
2895 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(rec, DICT_FLD__SYS_FOREIGN__ID, &len);
2896
2897 /* Check if the id in record is the searched one */
2898 if (len != id.sizecxx . . $ st_/span#size(fe4d2d262d4164a8).() || memcmp(id.datacxx . . $ st_/span#data(5a2a78a048fb49a8).(), field, id.sizecxx . . $ st_/span#size(fe4d2d262d4164a8).())) {
2899 goto not_found;
2900 }
2901
2902 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2903 rec, DICT_FLD__SYS_FOREIGN__DB_TRX_ID, &len);
2904 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(len == DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`!);
2905
2906 const trx_id_tcxx . . $ trx_id_t# tid = trx_read_trx_idcxx . . $ trx_read_trx_id(b191ace3c5bffbd9).(field);
2907
2908 if (tid && tid != trx_id && !uncommitted
2909 && trx_syscxx . . $ trx_sys..findcxx . . $ trx_sys_t#find(2dd6004328198d46).(nullptr, tid, false)) {
2910 const auto savepoint = mtr.get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).();
2911 rec_offscxx . . $ rec_offs#* offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(
2912 rec, sys_index, nullptr, true, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
2913 const rec_tcxx . . $ rec_t#* old_vers;
2914 row_vers_build_for_semi_consistent_readcxx . . $ row_vers_build_for_semi_consistent_read(554b1a302a674a14).(
2915 rec, &mtr, sys_index, &offsets, &heap,
2916 heap, &old_vers, nullptr);
2917 mtr.rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(savepoint);
2918 rec = old_vers;
2919 if (!rec) {
2920 goto not_found;
2921 }
2922 }
2923
2924 if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0)) {
2925 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(tid);
2926 goto not_found;
2927 }
2928
2929 /* Read the table names and the number of columns associated
2930 with the constraint */
2931
2932 foreign = dict_mem_foreign_createcxx . . $ dict_mem_foreign_create(edf0a6212131030a).();
2933
2934 uint32_tcxx . . $ uint32_t# n_fields_and_type = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(
2935 rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2936 rec, DICT_FLD__SYS_FOREIGN__N_COLS, &len));
2937
2938 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(len == 4);
2939
2940 /* We store the type in the bits 24..29 of n_fields_and_type. */
2941
2942 foreign->typecxx . . $ dict_foreign_t#type. = (n_fields_and_type >> 24) & ((1U << 6) - 1);
2943 foreign->n_fieldscxx . . $ dict_foreign_t#n_fields. = n_fields_and_type & dict_index_tcxx . . $ dict_index_t#::MAX_N_FIELDScxx . . $ dict_index_t#MAX_N_FIELDS.;
2944
2945 foreign->idcxx . . $ dict_foreign_t#id. = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(foreign->heapcxx . . $ dict_foreign_t#heap., id.datacxx . . $ st_/span#data(5a2a78a048fb49a8).(), id.sizecxx . . $ st_/span#size(fe4d2d262d4164a8).());
2946
2947 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2948 rec, DICT_FLD__SYS_FOREIGN__FOR_NAME, &len);
2949
2950 foreign->foreign_table_namecxx . . $ dict_foreign_t#foreign_table_name. = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(
2951 foreign->heapcxx . . $ dict_foreign_t#heap., (char*) field, len);
2952 foreign->foreign_table_name_lookup_setcxx . . $ dict_foreign_t#foreign_table_name_lookup_set(49f6e7a06ebc5aa8).();
2953
2954 const size_t foreign_table_name_len = len;
2955 const size_t table_name_len = strlen(table_name);
2956
2957 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
2958 rec, DICT_FLD__SYS_FOREIGN__REF_NAME, &len);
2959
2960 if (!my_charset_latin1.strnncollcxx . . $ charset_info_st#strnncoll(62562a0dd7544c32).(table_name, table_name_len,
2961 foreign->foreign_table_namecxx . . $ dict_foreign_t#foreign_table_name.,
2962 foreign_table_name_len)) {
2963 } else if (!check_recursive
2964 && !my_charset_latin1.strnncollcxx . . $ charset_info_st#strnncoll(62562a0dd7544c32).(table_name, table_name_len,
2965 (const char*) field, len)) {
2966 } else {
2967 dict_foreign_freecxx . . $ dict_foreign_free(81b29ea77ca12b17).(foreign);
2968 goto not_found;
2969 }
2970
2971 foreign->referenced_table_namecxx . . $ dict_foreign_t#referenced_table_name. = mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(
2972 foreign->heapcxx . . $ dict_foreign_t#heap., (const char*) field, len);
2973 foreign->referenced_table_name_lookup_setcxx . . $ dict_foreign_t#referenced_table_name_lookup_set(49f6e7a06ebc5aa8).();
2974
2975 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
2976 if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) {
2977 mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap);
2978 }
2979
2980 err = dict_load_foreign_colscxx . . $ dict_load_foreign_cols(36a73f0ada5bac9c).(mtr, foreign, trx_id);
2981 if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) {
2982 goto load_error;
2983 }
2984
2985 ref_table = dict_syscxx . . $ dict_sys..find_tablecxx . . $ dict_sys_t#find_table(25f651ffcaee7fcf).(
2986 {cxx . . $ st_/span#span(afd8256c216b84b2).foreign->referenced_table_name_lookupcxx . . $ dict_foreign_t#referenced_table_name_lookup.,
2987 strlen(foreign->referenced_table_name_lookupcxx . . $ dict_foreign_t#referenced_table_name_lookup.)});
2988 for_table = dict_syscxx . . $ dict_sys..find_tablecxx . . $ dict_sys_t#find_table(25f651ffcaee7fcf).(
2989 {cxx . . $ st_/span#span(afd8256c216b84b2).foreign->foreign_table_name_lookupcxx . . $ dict_foreign_t#foreign_table_name_lookup.,
2990 strlen(foreign->foreign_table_name_lookupcxx . . $ dict_foreign_t#foreign_table_name_lookup.)});
2991
2992 if (!for_table) {
2993 /* To avoid recursively loading the tables related through
2994 the foreign key constraints, the child table name is saved
2995 here. The child table will be loaded later, along with its
2996 foreign key constraint. */
2997
2998 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(ref_table != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
2999 fk_tables.push_backcxx . . $ std/deque#push_back(fe7a8a4d1eddb70).(
3000 mem_heap_strduplcxx . . $ mem_heap_strdupl(c6c96d945e097123).(ref_table->heapcxx . . $ dict_table_t#heap.,
3001 foreign->foreign_table_name_lookupcxx . . $ dict_foreign_t#foreign_table_name_lookup.,
3002 foreign_table_name_len));
3003 load_error:
3004 dict_foreign_remove_from_cachecxx . . $ dict_foreign_remove_from_cache(81b29ea77ca12b17).(foreign);
3005 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(err);
3006 }
3007
3008 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(for_table || ref_table);
3009
3010 /* Note that there may already be a foreign constraint object in
3011 the dictionary cache for this constraint: then the following
3012 call only sets the pointers in it to point to the appropriate table
3013 and index objects and frees the newly created object foreign.
3014 Adding to the cache should always succeed since we are not creating
3015 a new foreign key constraint but loading one from the data
3016 dictionary. */
3017
3018 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(dict_foreign_add_to_cache(foreign, col_names,
3019 check_charsets,
3020 ignore_err));
3021 }
3022
3023 /***********************************************************************//**
3024 Loads foreign key constraints where the table is either the foreign key
3025 holder or where the table is referenced by a foreign key. Adds these
3026 constraints to the data dictionary.
3027
3028 The foreign key constraint is loaded only if the referenced table is also
3029 in the dictionary cache. If the referenced table is not in dictionary
3030 cache, then it is added to the output parameter (fk_tables).
3031
3032 @return DB_SUCCESS or error code */
3033 dberr_tcxx . . $ dberr_t#
3034 dict_load_foreignscxx . . $ dict_load_foreigns(9dda56b1e2a7829).(
3035 mtr_tcxx . . $ mtr_t#& mtr, /*!< in/out: mini-transaction*/
3036 const char* table_name, /*!< in: table name */
3037 const char** col_names, /*!< in: column names, or NULL
3038 to use table->col_names */
3039 trx_id_tcxx . . $ trx_id_t# trx_id, /*!< in: DDL transaction id,
3040 or 0 to check
3041 recursive load of tables
3042 chained by FK */
3043 bool check_charsets, /*!< in: whether to check
3044 charset compatibility */
3045 dict_err_ignore_tcxx . . $ dict_err_ignore_t# ignore_err, /*!< in: error to be ignored */
3046 dict_names_tcxx . . $ dict_names_t#& fk_tables)
3047 /*!< out: stack of table
3048 names which must be loaded
3049 subsequently to load all the
3050 foreign key constraints. */
3051 {
3052 btr_pcur_tcxx . . $ btr_pcur_t# pcur;
3053
3054 DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("dict_load_foreigns");
3055
3056 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_sys.locked());
3057
3058 if (!dict_syscxx . . $ dict_sys..sys_foreigncxx . . $ dict_sys_t#sys_foreign. || !dict_syscxx . . $ dict_sys..sys_foreign_colscxx . . $ dict_sys_t#sys_foreign_cols.) {
3059 if (ignore_err & DICT_ERR_IGNORE_FK_NOKEYcxx . . $ DICT_ERR_IGNORE_FK_NOKEY.) {
3060 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(DB_SUCCESS);
3061 }
3062 sql_print_informationcxx . . $ sql_print_information(326aeb464d16410c).("InnoDB: No foreign key system tables"
3063 " in the database");
3064 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(DB_ERROR);
3065 }
3066
3067 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_sys.sys_foreign->not_redundant());
3068
3069 dict_index_tcxx . . $ dict_index_t# *sec_index = dict_table_get_next_indexcxx . . $ `storage/innobase/include/dict0dict.h:614:10`!(
3070 dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(dict_sys.sys_foreign));
3071 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!strcmp(sec_index->fields[0].name, "FOR_NAME"));
3072 bool check_recursive = !trx_id;
3073 dfield_tcxx . . $ dfield_t# dfield;
3074 dtuple_tcxx . . $ dtuple_t# tuple{
3075 0,1,1,0,&dfield,nullptr
3076 #ifdef UNIV_DEBUG
3077 , DATA_TUPLE_MAGIC_N
3078 #endif
3079 };
3080
3081 start_load:
3082 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
3083 dfield_set_datacxx . . $ dfield_set_data(c3b230cbf9e02f9f).(&dfield, table_name, strlen(table_name));
3084 dict_index_copy_typescxx . . $ dict_index_copy_types(9015429b5b64dc2b).(&tuple, sec_index, 1);
3085 pcur.btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = sec_index;
3086
3087 dberr_tcxx . . $ dberr_t# err = btr_pcur_open_on_user_reccxx . . $ btr_pcur_open_on_user_rec(41267febe7c38db2).(&tuple,
3088 BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., &pcur, &mtr);
3089 if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) {
3090 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(err);
3091 }
3092 loop:
3093 const rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(&pcur);
3094 const bytecxx . . $ byte#* field;
3095 const auto maybe_deleted = rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, 0);
3096
3097 if (!btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(&pcur)) {
3098 /* End of index */
3099
3100 goto load_next_index;
3101 }
3102
3103 /* Now we have the record in the secondary index containing a table
3104 name and a foreign constraint ID */
3105
3106 ulintcxx . . $ ulint# len;
3107 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
3108 rec, DICT_FLD__SYS_FOREIGN_FOR_NAME__NAME, &len);
3109
3110 /* Check if the table name in the record is the one searched for; the
3111 following call does the comparison in the latin1_swedish_ci
3112 charset-collation, in a case-insensitive way. */
3113
3114 if (cmp_datacxx . . $ cmp_data(4b1843bef49e4d58).(dfield_get_typecxx . . $ dfield_get_type(c1d58f3834c4404a).(&dfield)->mtypecxx . . $ dtype_t#mtype.,
3115 dfield_get_typecxx . . $ dfield_get_type(c1d58f3834c4404a).(&dfield)->prtypecxx . . $ dtype_t#prtype.,
3116 false,
3117 reinterpret_cast<const bytecxx . . $ byte#*>(table_name),
3118 dfield_get_lencxx . . $ dfield_get_len(61c431dfc6825316).(&dfield),
3119 field, len)) {
3120 goto load_next_index;
3121 }
3122
3123 /* Since table names in SYS_FOREIGN are stored in a case-insensitive
3124 order, we have to check that the table name matches also in a binary
3125 string comparison. On Unix, MySQL allows table names that only differ
3126 in character case. If lower_case_table_names=2 then what is stored
3127 may not be the same case, but the previous comparison showed that they
3128 match with no-case. */
3129
3130 if (lower_case_table_namescxx . . $ lower_case_table_names. != 2 && memcmp(field, table_name, len)) {
3131 goto next_rec;
3132 }
3133
3134 /* Now we get a foreign key constraint id */
3135 field = rec_get_nth_field_oldcxx . . $ `storage/innobase/include/rem0rec.h:535:9`!(
3136 rec, DICT_FLD__SYS_FOREIGN_FOR_NAME__ID, &len);
3137
3138 /* Copy the string because the page may be modified or evicted
3139 after mtr.commit() below. */
3140 char fk_id[MAX_TABLE_NAME_LENcxx . . $ `storage/innobase/include/univ.i:249:9`! + NAME_LENcxx . . $ `include/mysql_com.h:33:9`!];
3141 err = DB_SUCCESScxx . . $ DB_SUCCESS.;
3142 if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(len < sizeof fk_id)) {
3143 memcpy(fk_id, field, len);
3144 }
3145
3146 btr_pcur_store_positioncxx . . $ btr_pcur_store_position(f723d369374bc0bf).(&pcur, &mtr);
3147
3148 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
3149
3150 /* Load the foreign constraint definition to the dictionary cache */
3151
3152 err = len < sizeof fk_id
3153 ? dict_load_foreigncxx . . $ dict_load_foreign(1d49bce8a07e5b4a).(mtr, table_name, false, col_names, trx_id,
3154 check_recursive, check_charsets,
3155 {cxx . . $ st_/span#span(afd8256c216b84b2).fk_id, len}, ignore_err, fk_tables)
3156 : DB_CORRUPTIONcxx . . $ DB_CORRUPTION.;
3157
3158 switch (err) {
3159 case DB_SUCCESScxx . . $ DB_SUCCESS.:
3160 break;
3161 case DB_NOT_FOUNDcxx . . $ DB_NOT_FOUND.:
3162 if (maybe_deleted) {
3163 break;
3164 }
3165 sql_print_errorcxx . . $ sql_print_error(326aeb464d16410c).("InnoDB: Cannot load foreign constraint %.*s:"
3166 " could not find the relevant record in "
3167 "SYS_FOREIGN", int(len), fk_id);
3168 /* fall through */
3169 default:
3170 corrupted:
3171 ut_freecxx . . $ `storage/innobase/include/ut0new.h:1044:9`!(pcur.old_rec_buf);
3172 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(err);
3173 }
3174
3175 mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).();
3176 if (pcur.restore_positioncxx . . $ btr_pcur_t#restore_position(8c85f028503b2912).(BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., &mtr)
3177 == btr_pcur_tcxx . . $ btr_pcur_t#::CORRUPTEDcxx . . $ btr_pcur_t#CORRUPTED.) {
3178 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
3179 goto corrupted;
3180 }
3181 next_rec:
3182 btr_pcur_move_to_next_user_reccxx . . $ btr_pcur_move_to_next_user_rec(db7b0b7a66db0c31).(&pcur, &mtr);
3183
3184 goto loop;
3185
3186 load_next_index:
3187 mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).();
3188
3189 if ((sec_index = dict_table_get_next_indexcxx . . $ `storage/innobase/include/dict0dict.h:614:10`!(sec_index))) {
3190 /* Switch to scan index on REF_NAME */
3191 check_recursive = false;
3192 goto start_load;
3193 }
3194
3195 ut_freecxx . . $ `storage/innobase/include/ut0new.h:1044:9`!(pcur.old_rec_buf);
3196 DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(DB_SUCCESS);
3197 }