Debian Codegraph @

storage/innobase/row/row0quiesce.cc

raw symbols SCIP
1 /*****************************************************************************
2
3 Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2017, 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 row/row0quiesce.cc
22 Quiesce a tablespace.
23
24 Created 2012-02-08 by Sunny Bains.
25 *******************************************************/
26
27 #include "row0quiesce.h"cxx . . $ `<file>/storage/innobase/include/row0quiesce.h`/
28 #include "row0mysql.h"cxx . . $ `<file>/storage/innobase/include/row0mysql.h`/
29 #include "buf0flu.h"cxx . . $ `<file>/storage/innobase/include/buf0flu.h`/
30 #include "srv0start.h"cxx . . $ `<file>/storage/innobase/include/srv0start.h`/
31 #include "trx0purge.h"cxx . . $ `<file>/storage/innobase/include/trx0purge.h`/
32
33 #ifdef HAVE_MY_AES_H
34 #include <my_aes.h>
35 #endif
36
37 /*********************************************************************//**
38 Write the meta data (index user fields) config file.
39 @return DB_SUCCESS or error code. */
40 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
41 dberr_tcxx . . $ dberr_t#
42 row_quiesce_write_index_fieldscxx . . $ row_quiesce_write_index_fields(c65ab6038b9bb558).(
43 /*===========================*/
44 const dict_index_tcxx . . $ dict_index_t#* index, /*!< in: write the meta data for
45 this index */
46 FILE* file, /*!< in: file to write to */
47 THDcxx . . $ THD#* thd) /*!< in/out: session */
48 {
49 bytecxx . . $ byte# row[sizeof(ib_uint32_tcxx . . $ ib_uint32_t#) * 3];
50
51 for (ulintcxx . . $ ulint# i = 0; i < index->n_fieldscxx . . $ dict_index_t#n_fields.; ++i) {
52 bytecxx . . $ byte#* ptr = row;
53 const dict_field_tcxx . . $ dict_field_t#* field = &index->fieldscxx . . $ dict_index_t#fields.[i];
54
55 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, field->prefix_lencxx . . $ dict_field_t#prefix_len.);
56 ptr += 4;
57
58 /* Since maximum fixed length can be
59 DICT_ANTELOPE_MAX_INDEX_COL_LEN, InnoDB
60 can use the 0th bit to store the
61 field descending information */
62 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, field->fixed_lencxx . . $ dict_field_t#fixed_len.
63 | uint32_tcxx . . $ uint32_t#(field->descendingcxx . . $ dict_field_t#descending.) << 31);
64 ptr += 4;
65
66 const char* field_name = field->namecxx . . $ dict_field_t#name. ? field->namecxx . . $ dict_field_t#name. : "";
67 /* Include the NUL byte in the length. */
68 uint32_tcxx . . $ uint32_t# len = uint32_tcxx . . $ uint32_t#(strlen(field_name) + 1);
69 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, len);
70
71 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_10",
72 close(fileno(file)););
73
74 if (fwrite(row, 1, sizeof(row), file) != sizeof(row)
75 || fwrite(field_name, 1, len, file) != len) {
76
77 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
78 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
79 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
80 "while writing index fields.");
81
82 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
83 }
84 }
85
86 return(DB_SUCCESScxx . . $ DB_SUCCESS.);
87 }
88
89 /*********************************************************************//**
90 Write the meta data config file index information.
91 @return DB_SUCCESS or error code. */
92 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
93 dberr_tcxx . . $ dberr_t#
94 row_quiesce_write_indexescxx . . $ row_quiesce_write_indexes(6ee5c190914db8c6).(
95 /*======================*/
96 const dict_table_tcxx . . $ dict_table_t#* table, /*!< in: write the meta data for
97 this table */
98 FILE* file, /*!< in: file to write to */
99 THDcxx . . $ THD#* thd) /*!< in/out: session */
100 {
101 ulintcxx . . $ ulint# n_indexes = 0;
102 for (const dict_index_tcxx . . $ dict_index_t#* index = UT_LIST_GET_FIRSTcxx . . $ `storage/innobase/include/ut0lst.h:421:9`!(table->indexes);
103 index; index = UT_LIST_GET_NEXTcxx . . $ `storage/innobase/include/ut0lst.h:401:9`!(indexes, index)) {
104 n_indexes += index->is_committedcxx . . $ dict_index_t#is_committed(50ce9a9e25b4a850).();
105 }
106
107 {
108 bytecxx . . $ byte# row[sizeof(ib_uint32_tcxx . . $ ib_uint32_t#)];
109
110 /* Write the number of indexes in the table. */
111 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(row, n_indexes);
112
113 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_11",
114 close(fileno(file)););
115
116 if (fwrite(row, 1, sizeof(row), file) != sizeof(row)) {
117 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
118 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
119 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
120 "while writing index count.");
121
122 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
123 }
124 }
125
126 dberr_tcxx . . $ dberr_t# err = DB_SUCCESScxx . . $ DB_SUCCESS.;
127
128 /* Write the index meta data. */
129 for (const dict_index_tcxx . . $ dict_index_t#* index = UT_LIST_GET_FIRSTcxx . . $ `storage/innobase/include/ut0lst.h:421:9`!(table->indexes);
130 index != 0 && err == DB_SUCCESScxx . . $ DB_SUCCESS.;
131 index = UT_LIST_GET_NEXTcxx . . $ `storage/innobase/include/ut0lst.h:401:9`!(indexes, index)) {
132
133 if (!index->is_committedcxx . . $ dict_index_t#is_committed(50ce9a9e25b4a850).()) {
134 continue;
135 }
136
137 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_indexes); ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(n_indexes--);
138
139 bytecxx . . $ byte#* ptr;
140 bytecxx . . $ byte# row[sizeof(index_id_tcxx . . $ index_id_t#)
141 + sizeof(ib_uint32_tcxx . . $ ib_uint32_t#) * 8];
142
143 ptr = row;
144
145 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(sizeof(index_id_t) == 8);
146 mach_write_to_8cxx . . $ mach_write_to_8(5500c4293b1bbef0).(ptr, index->idcxx . . $ dict_index_t#id.);
147 ptr += sizeof(index_id_tcxx . . $ index_id_t#);
148
149 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, table->space_idcxx . . $ dict_table_t#space_id.);
150 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
151
152 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, index->pagecxx . . $ dict_index_t#page.);
153 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
154
155 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, index->typecxx . . $ dict_index_t#type.);
156 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
157
158 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, index->trx_id_offsetcxx . . $ dict_index_t#trx_id_offset.);
159 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
160
161 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, index->n_user_defined_colscxx . . $ dict_index_t#n_user_defined_cols.);
162 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
163
164 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, index->n_uniqcxx . . $ dict_index_t#n_uniq.);
165 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
166
167 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, index->n_nullablecxx . . $ dict_index_t#n_nullable.);
168 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
169
170 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, index->n_fieldscxx . . $ dict_index_t#n_fields.);
171
172 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_12",
173 close(fileno(file)););
174
175 if (fwrite(row, 1, sizeof(row), file) != sizeof(row)) {
176
177 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
178 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
179 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
180 "while writing index meta-data.");
181
182 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
183 }
184
185 /* Write the length of the index name.
186 NUL byte is included in the length. */
187 ib_uint32_tcxx . . $ ib_uint32_t# len = static_cast<ib_uint32_tcxx . . $ ib_uint32_t#>(strlen(index->namecxx . . $ dict_index_t#name.) + 1);
188 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(len > 1);
189
190 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(row, len);
191
192 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_1",
193 close(fileno(file)););
194
195 if (fwrite(row, 1, sizeof(len), file) != sizeof(len)
196 || fwrite(index->namecxx . . $ dict_index_t#name., 1, len, file) != len) {
197
198 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
199 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
200 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
201 "while writing index name.");
202
203 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
204 }
205
206 err = row_quiesce_write_index_fieldscxx . . $ row_quiesce_write_index_fields(c65ab6038b9bb558).(index, file, thd);
207 }
208
209 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!n_indexes);
210 return(err);
211 }
212
213 /*********************************************************************//**
214 Write the meta data (table columns) config file. Serialise the contents of
215 dict_col_t structure, along with the column name. All fields are serialized
216 as ib_uint32_t.
217 @return DB_SUCCESS or error code. */
218 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
219 dberr_tcxx . . $ dberr_t#
220 row_quiesce_write_tablecxx . . $ row_quiesce_write_table(6ee5c190914db8c6).(
221 /*====================*/
222 const dict_table_tcxx . . $ dict_table_t#* table, /*!< in: write the meta data for
223 this table */
224 FILE* file, /*!< in: file to write to */
225 THDcxx . . $ THD#* thd) /*!< in/out: session */
226 {
227 dict_col_tcxx . . $ dict_col_t#* col;
228 bytecxx . . $ byte# row[sizeof(ib_uint32_tcxx . . $ ib_uint32_t#) * 7];
229
230 col = table->colscxx . . $ dict_table_t#cols.;
231
232 for (ulintcxx . . $ ulint# i = 0; i < table->n_colscxx . . $ dict_table_t#n_cols.; ++i, ++col) {
233 bytecxx . . $ byte#* ptr = row;
234
235 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, col->prtypecxx . . $ dict_col_t#prtype.);
236 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
237
238 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, col->mtypecxx . . $ dict_col_t#mtype.);
239 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
240
241 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, col->lencxx . . $ dict_col_t#len.);
242 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
243
244 /* FIXME: This will not work if mbminlen>4.
245 This field is also redundant, because the lengths
246 are a property of the character set encoding, which
247 in turn is encodedin prtype above. */
248 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, ulintcxx . . $ ulint#(col->mbmaxlencxx . . $ dict_col_t#mbmaxlen. * 5 + col->mbminlencxx . . $ dict_col_t#mbminlen.));
249 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
250
251 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, col->indcxx . . $ dict_col_t#ind.);
252 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
253
254 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, col->ord_partcxx . . $ dict_col_t#ord_part.);
255 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
256
257 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, col->max_prefixcxx . . $ dict_col_t#max_prefix.);
258
259 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_2",
260 close(fileno(file)););
261
262 if (fwrite(row, 1, sizeof(row), file) != sizeof(row)) {
263 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
264 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
265 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
266 "while writing table column data.");
267
268 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
269 }
270
271 /* Write out the column name as [len, byte array]. The len
272 includes the NUL byte. */
273 ib_uint32_tcxx . . $ ib_uint32_t# len;
274 const Lex_ident_columncxx . . $ Lex_ident_column# col_name = dict_table_get_col_namecxx . . $ dict_table_get_col_name(65f537fd2f040452).(table, dict_col_get_nocxx . . $ dict_col_get_no(cae70341e47142e7).(col));
275
276 /* Include the NUL byte in the length. */
277 len = static_cast<ib_uint32_tcxx . . $ ib_uint32_t#>(col_name.length + 1);
278 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(len > 1);
279
280 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(row, len);
281
282 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_3",
283 close(fileno(file)););
284
285 if (fwrite(row, 1, sizeof(len), file) != sizeof(len)
286 || fwrite(col_name.str, 1, len, file) != len) {
287
288 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
289 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
290 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
291 "while writing column name.");
292
293 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
294 }
295 }
296
297 return(DB_SUCCESScxx . . $ DB_SUCCESS.);
298 }
299
300 /*********************************************************************//**
301 Write the meta data config file header.
302 @return DB_SUCCESS or error code. */
303 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
304 dberr_tcxx . . $ dberr_t#
305 row_quiesce_write_headercxx . . $ row_quiesce_write_header(6ee5c190914db8c6).(
306 /*=====================*/
307 const dict_table_tcxx . . $ dict_table_t#* table, /*!< in: write the meta data for
308 this table */
309 FILE* file, /*!< in: file to write to */
310 THDcxx . . $ THD#* thd) /*!< in/out: session */
311 {
312 bytecxx . . $ byte# value[sizeof(ib_uint32_tcxx . . $ ib_uint32_t#)];
313
314 /* Write the meta-data version number. */
315 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(value, IB_EXPORT_CFG_VERSION_V1cxx . . $ `storage/innobase/include/row0quiesce.h:36:9`!);
316
317 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_4", close(fileno(file)););
318
319 if (fwrite(&value, 1, sizeof(value), file) != sizeof(value)) {
320 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
321 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
322 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
323 "while writing meta-data version number.");
324
325 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
326 }
327
328 /* Write the server hostname. */
329 ib_uint32_tcxx . . $ ib_uint32_t# len;
330 const char* hostname = server_get_hostnamecxx . . $ server_get_hostname(33a1f659e94feb42).();
331
332 /* Play it safe and check for NULL. */
333 if (hostname == 0) {
334 static const char NullHostname[] = "Hostname unknown";
335
336 ibcxx . . $ ib/::warncxx . . $ ib/warn#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Unable to determine server hostname.";
337
338 hostname = NullHostname;
339 }
340
341 /* The server hostname includes the NUL byte. */
342 len = static_cast<ib_uint32_tcxx . . $ ib_uint32_t#>(strlen(hostname) + 1);
343 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(value, len);
344
345 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_5", close(fileno(file)););
346
347 if (fwrite(&value, 1, sizeof(value), file) != sizeof(value)
348 || fwrite(hostname, 1, len, file) != len) {
349
350 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
351 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
352 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
353 "while writing hostname.");
354
355 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
356 }
357
358 /* The table name includes the NUL byte. */
359 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(table->name.m_name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
360 len = static_cast<ib_uint32_tcxx . . $ ib_uint32_t#>(strlen(table->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name.) + 1);
361
362 /* Write the table name. */
363 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(value, len);
364
365 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_6", close(fileno(file)););
366
367 if (fwrite(&value, 1, sizeof(value), file) != sizeof(value)
368 || fwrite(table->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name., 1, len, file) != len) {
369
370 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
371 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
372 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
373 "while writing table name.");
374
375 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
376 }
377
378 bytecxx . . $ byte# row[sizeof(ib_uint32_tcxx . . $ ib_uint32_t#) * 3];
379
380 /* Write the next autoinc value. */
381 mach_write_to_8cxx . . $ mach_write_to_8(5500c4293b1bbef0).(row, table->autoinccxx . . $ dict_table_t#autoinc.);
382
383 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_7", close(fileno(file)););
384
385 if (fwrite(row, 1, sizeof(ib_uint64_tcxx . . $ ib_uint64_t#), file) != sizeof(ib_uint64_tcxx . . $ ib_uint64_t#)) {
386 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
387 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
388 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
389 "while writing table autoinc value.");
390
391 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
392 }
393
394 bytecxx . . $ byte#* ptr = row;
395
396 /* Write the system page size. */
397 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, srv_page_sizecxx . . $ srv_page_size.);
398 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
399
400 /* Write the table->flags. */
401 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, table->flagscxx . . $ dict_table_t#flags.);
402 ptr += sizeof(ib_uint32_tcxx . . $ ib_uint32_t#);
403
404 /* Write the number of columns in the table. */
405 mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(ptr, table->n_colscxx . . $ dict_table_t#n_cols.);
406
407 DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("ib_export_io_write_failure_8", close(fileno(file)););
408
409 if (fwrite(row, 1, sizeof(row), file) != sizeof(row)) {
410 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(
411 thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_IO_WRITE_ERRORcxx . . $ `build/include/mysqld_error.h:816:9`!,
412 (ulong) errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
413 "while writing table meta-data.");
414
415 return(DB_IO_ERRORcxx . . $ DB_IO_ERROR.);
416 }
417
418 return(DB_SUCCESScxx . . $ DB_SUCCESS.);
419 }
420
421 /*********************************************************************//**
422 Write the table meta data after quiesce.
423 @return DB_SUCCESS or error code */
424
425 static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result))
426 dberr_tcxx . . $ dberr_t#
427 row_quiesce_write_cfgcxx . . $ row_quiesce_write_cfg(c707b3444b8dcb16).(
428 /*==================*/
429 dict_table_tcxx . . $ dict_table_t#* table, /*!< in: write the meta data for
430 this table */
431 THDcxx . . $ THD#* thd) /*!< in/out: session */
432 {
433 dberr_tcxx . . $ dberr_t# err;
434 char name[OS_FILE_MAX_PATHcxx . . $ `storage/innobase/include/os0file.h:307:9`!];
435
436 srv_get_meta_data_filenamecxx . . $ srv_get_meta_data_filename(33198f4e78d9d6f7).(table, name, sizeof(name));
437
438 ibcxx . . $ ib/::infocxx . . $ ib/info#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Writing table metadata to '" <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). name <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "'";
439
440 FILE* file = fopen(name, "w+b");
441
442 if (!file) {
443 fail:
444 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(thd, IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_CANT_CREATE_FILEcxx . . $ `build/include/mysqld_error.h:9:9`!,
445 name, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
446
447 err = DB_IO_ERRORcxx . . $ DB_IO_ERROR.;
448 } else {
449 err = row_quiesce_write_headercxx . . $ row_quiesce_write_header(6ee5c190914db8c6).(table, file, thd);
450
451 if (err == DB_SUCCESScxx . . $ DB_SUCCESS.) {
452 err = row_quiesce_write_tablecxx . . $ row_quiesce_write_table(6ee5c190914db8c6).(table, file, thd);
453 }
454
455 if (err == DB_SUCCESScxx . . $ DB_SUCCESS.) {
456 err = row_quiesce_write_indexescxx . . $ row_quiesce_write_indexes(6ee5c190914db8c6).(table, file, thd);
457 }
458
459 if (fflush(file)) {
460 stdcxx . . $ std/::ignore = fclose(file);
461 goto fail;
462 }
463
464 if (fclose(file)) {
465 goto fail;
466 }
467 }
468
469 return(err);
470 }
471
472 /*********************************************************************//**
473 Check whether a table has an FTS index defined on it.
474 @return true if an FTS index exists on the table */
475 static
476 bool
477 row_quiesce_table_has_fts_indexcxx . . $ row_quiesce_table_has_fts_index(69818bd0402ee958).(
478 /*============================*/
479 const dict_table_tcxx . . $ dict_table_t#* table) /*!< in: quiesce this table */
480 {
481 bool exists = false;
482
483 for (const dict_index_tcxx . . $ dict_index_t#* index = UT_LIST_GET_FIRSTcxx . . $ `storage/innobase/include/ut0lst.h:421:9`!(table->indexes);
484 index != 0;
485 index = UT_LIST_GET_NEXTcxx . . $ `storage/innobase/include/ut0lst.h:401:9`!(indexes, index)) {
486
487 if (index->typecxx . . $ dict_index_t#type. & DICT_FTScxx . . $ `storage/innobase/include/dict0mem.h:71:9`!) {
488 exists = true;
489 break;
490 }
491 }
492
493 return(exists);
494 }
495
496 /*********************************************************************//**
497 Quiesce the tablespace that the table resides in. */
498 void
499 row_quiesce_table_startcxx . . $ row_quiesce_table_start(981085076c78dade).(
500 /*====================*/
501 dict_table_tcxx . . $ dict_table_t#* table, /*!< in: quiesce this table */
502 trx_tcxx . . $ trx_t#* trx) /*!< in/out: transaction/session */
503 {
504 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(trx->mysql_thd != 0);
505 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(srv_n_purge_threads > 0);
506 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!srv_read_only_mode);
507
508 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(trx->mysql_thd != 0);
509
510 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(table->space != NULL);
511 ibcxx . . $ ib/::infocxx . . $ ib/info#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Sync to disk of " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name. <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " started.";
512
513 if (srv_undo_sourcescxx . . $ srv_undo_sources.) {
514 purge_syscxx . . $ purge_sys..stopcxx . . $ purge_sys_t#stop(49f6e7a06ebc5aa8).();
515 }
516
517 while (buf_flush_list_spacecxx . . $ buf_flush_list_space(11a03951b981ba78).(table->spacecxx . . $ dict_table_t#space.)) {
518 if (trx_is_interruptedcxx . . $ trx_is_interrupted(823690d58da80358).(trx)) {
519 goto aborted;
520 }
521 }
522
523 if (!trx_is_interruptedcxx . . $ trx_is_interrupted(823690d58da80358).(trx)) {
524 /* Ensure that all asynchronous IO is completed. */
525 os_aio_wait_until_no_pending_writescxx . . $ os_aio_wait_until_no_pending_writes(9f0ba574c1c44ffc).(true);
526 table->spacecxx . . $ dict_table_t#space.->flushcxx . . $ fil_space_t#flush(ced63f7c635d850d).<false>();
527
528 if (row_quiesce_write_cfgcxx . . $ row_quiesce_write_cfg(c707b3444b8dcb16).(table, trx->mysql_thdcxx . . $ trx_t#mysql_thd.)
529 != DB_SUCCESScxx . . $ DB_SUCCESS.) {
530 ibcxx . . $ ib/::warncxx . . $ ib/warn#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "There was an error writing to the"
531 " meta data file";
532 } else {
533 ibcxx . . $ ib/::infocxx . . $ ib/info#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.
534 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " flushed to disk";
535 }
536 } else {
537 aborted:
538 ibcxx . . $ ib/::warncxx . . $ ib/warn#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Quiesce aborted!";
539 }
540
541 dberr_tcxx . . $ dberr_t# err = row_quiesce_set_statecxx . . $ row_quiesce_set_state(4fd4a22f5c0c6939).(table, QUIESCE_COMPLETEcxx . . $ QUIESCE_COMPLETE., trx);
542 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(err == DB_SUCCESS);
543 }
544
545 /*********************************************************************//**
546 Cleanup after table quiesce. */
547 void
548 row_quiesce_table_completecxx . . $ row_quiesce_table_complete(981085076c78dade).(
549 /*=======================*/
550 dict_table_tcxx . . $ dict_table_t#* table, /*!< in: quiesce this table */
551 trx_tcxx . . $ trx_t#* trx) /*!< in/out: transaction/session */
552 {
553 ulintcxx . . $ ulint# count = 0;
554
555 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(trx->mysql_thd != 0);
556
557 /* We need to wait for the operation to complete if the
558 transaction has been killed. */
559
560 while (table->quiescecxx . . $ dict_table_t#quiesce. != QUIESCE_COMPLETEcxx . . $ QUIESCE_COMPLETE.) {
561
562 /* Print a warning after every minute. */
563 if (!(count % 60)) {
564 ibcxx . . $ ib/::warncxx . . $ ib/warn#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Waiting for quiesce of " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). table->namecxx . . $ dict_table_t#name.
565 <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " to complete";
566 }
567
568 stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/::chronocxx . . $ std/chrono/::secondscxx . . $ std/chrono/seconds#(1));
569
570 ++count;
571 }
572
573 if (!opt_bootstrapcxx . . $ opt_bootstrap.) {
574 /* Remove the .cfg file now that the user has resumed
575 normal operations. Otherwise it will cause problems when
576 the user tries to drop the database (remove directory). */
577 char cfg_name[OS_FILE_MAX_PATHcxx . . $ `storage/innobase/include/os0file.h:307:9`!];
578
579 srv_get_meta_data_filenamecxx . . $ srv_get_meta_data_filename(33198f4e78d9d6f7).(table, cfg_name, sizeof(cfg_name));
580
581 os_file_delete_if_existscxx . . $ `storage/innobase/include/os0file.h:584:10`!(innodb_data_file_key, cfg_name, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
582
583 ibcxx . . $ ib/::infocxx . . $ ib/info#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Deleting the meta-data file '" <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). cfg_name <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "'";
584 }
585
586 if (srv_undo_sourcescxx . . $ srv_undo_sources.) {
587 purge_syscxx . . $ purge_sys..resumecxx . . $ purge_sys_t#resume(49f6e7a06ebc5aa8).();
588 }
589
590 dberr_tcxx . . $ dberr_t# err = row_quiesce_set_statecxx . . $ row_quiesce_set_state(4fd4a22f5c0c6939).(table, QUIESCE_NONEcxx . . $ QUIESCE_NONE., trx);
591 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(err == DB_SUCCESS);
592 }
593
594 /*********************************************************************//**
595 Set a table's quiesce state.
596 @return DB_SUCCESS or error code. */
597 dberr_tcxx . . $ dberr_t#
598 row_quiesce_set_statecxx . . $ row_quiesce_set_state(4fd4a22f5c0c6939).(
599 /*==================*/
600 dict_table_tcxx . . $ dict_table_t#* table, /*!< in: quiesce this table */
601 ib_quiesce_tcxx . . $ ib_quiesce_t# state, /*!< in: quiesce state to set */
602 trx_tcxx . . $ trx_t#* trx) /*!< in/out: transaction */
603 {
604 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(srv_n_purge_threads > 0);
605
606 if (srv_read_only_modecxx . . $ srv_read_only_mode.) {
607
608 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(trx->mysql_thdcxx . . $ trx_t#mysql_thd.,
609 IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN., ER_READ_ONLY_MODEcxx . . $ `build/include/mysqld_error.h:841:9`!);
610
611 return(DB_UNSUPPORTEDcxx . . $ DB_UNSUPPORTED.);
612
613 } else if (table->is_temporarycxx . . $ dict_table_t#is_temporary(50ce9a9e25b4a850).()) {
614
615 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(trx->mysql_thdcxx . . $ trx_t#mysql_thd., IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN.,
616 ER_CANNOT_DISCARD_TEMPORARY_TABLEcxx . . $ `build/include/mysqld_error.h:991:9`!);
617
618 return(DB_UNSUPPORTEDcxx . . $ DB_UNSUPPORTED.);
619 } else if (table->space_idcxx . . $ dict_table_t#space_id. == TRX_SYS_SPACEcxx . . $ TRX_SYS_SPACE.) {
620
621 char table_name[MAX_FULL_NAME_LENcxx . . $ `storage/innobase/include/univ.i:260:9`! + 1];
622
623 innobase_format_namecxx . . $ innobase_format_name(4491b3f8e34856cb).(
624 table_name, sizeof(table_name),
625 table->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name.);
626
627 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(trx->mysql_thdcxx . . $ trx_t#mysql_thd., IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN.,
628 ER_TABLE_IN_SYSTEM_TABLESPACEcxx . . $ `build/include/mysqld_error.h:814:9`!, table_name);
629
630 return(DB_UNSUPPORTEDcxx . . $ DB_UNSUPPORTED.);
631 } else if (row_quiesce_table_has_fts_indexcxx . . $ row_quiesce_table_has_fts_index(69818bd0402ee958).(table)) {
632
633 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(trx->mysql_thdcxx . . $ trx_t#mysql_thd., IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN.,
634 ER_NOT_SUPPORTED_YETcxx . . $ `build/include/mysqld_error.h:240:9`!,
635 "FLUSH TABLES on tables that have an FTS index."
636 " FTS auxiliary tables will not be flushed.");
637
638 } else if (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`!)) {
639 /* If this flag is set then the table may not have any active
640 FTS indexes but it will still have the auxiliary tables. */
641
642 ib_senderrfcxx . . $ ib_senderrf(b59d816dff908cb8).(trx->mysql_thdcxx . . $ trx_t#mysql_thd., IB_LOG_LEVEL_WARNcxx . . $ IB_LOG_LEVEL_WARN.,
643 ER_NOT_SUPPORTED_YETcxx . . $ `build/include/mysqld_error.h:240:9`!,
644 "FLUSH TABLES on a table that had an FTS index,"
645 " created on a hidden column, the"
646 " auxiliary tables haven't been dropped as yet."
647 " FTS auxiliary tables will not be flushed.");
648 }
649
650 dict_index_tcxx . . $ dict_index_t#* clust_index = dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(table);
651
652 for (dict_index_tcxx . . $ dict_index_t#* index = dict_table_get_next_indexcxx . . $ `storage/innobase/include/dict0dict.h:614:10`!(clust_index);
653 index != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
654 index = dict_table_get_next_indexcxx . . $ `storage/innobase/include/dict0dict.h:614:10`!(index)) {
655 index->lockcxx . . $ dict_index_t#lock..x_lockcxx . . $ sux_lock#x_lock(b51963283f2467a4).(SRW_LOCK_CALLcxx . . $ `storage/innobase/include/srw_lock.h:44:10`!);
656 }
657
658 clust_index->lockcxx . . $ dict_index_t#lock..x_lockcxx . . $ sux_lock#x_lock(b51963283f2467a4).(SRW_LOCK_CALLcxx . . $ `storage/innobase/include/srw_lock.h:44:10`!);
659
660 switch (state) {
661 case QUIESCE_STARTcxx . . $ QUIESCE_START.:
662 break;
663
664 case QUIESCE_COMPLETEcxx . . $ QUIESCE_COMPLETE.:
665 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(table->quiesce == QUIESCE_START);
666 break;
667
668 case QUIESCE_NONEcxx . . $ QUIESCE_NONE.:
669 ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(table->quiesce == QUIESCE_COMPLETE);
670 break;
671 }
672
673 table->quiescecxx . . $ dict_table_t#quiesce. = state;
674
675 for (dict_index_tcxx . . $ dict_index_t#* index = dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(table);
676 index != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
677 index = dict_table_get_next_indexcxx . . $ `storage/innobase/include/dict0dict.h:614:10`!(index)) {
678 index->lockcxx . . $ dict_index_t#lock..x_unlockcxx . . $ sux_lock#x_unlock(b45ddcbc8423892c).();
679 }
680
681 return(DB_SUCCESScxx . . $ DB_SUCCESS.);
682 }
683