MySQL 8.0.31
Source Code Documentation
log0ddl.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2017, 2022, Oracle and/or its affiliates.
4
5Portions of this file contain modifications contributed and copyrighted by
6Google, Inc. Those modifications are gratefully acknowledged and are described
7briefly in the InnoDB documentation. The contributions by Google are
8incorporated with their permission, and subject to the conditions contained in
9the file COPYING.Google.
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GNU General Public License, version 2.0, as published by the
13Free Software Foundation.
14
15This program is also distributed with certain software (including but not
16limited to OpenSSL) that is licensed under separate terms, as designated in a
17particular file or component or in included license documentation. The authors
18of MySQL hereby grant you an additional permission to link the program and
19your derivative works with the separately licensed software that they have
20included with MySQL.
21
22This program is distributed in the hope that it will be useful, but WITHOUT
23ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
24FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
25for more details.
26
27You should have received a copy of the GNU General Public License along with
28this program; if not, write to the Free Software Foundation, Inc.,
2951 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
31*****************************************************************************/
32
33/** @file include/log0ddl.h
34 DDL log
35
36 Created 12/1/2016 Shaohua Wang
37 *******************************************************/
38
39#ifndef log0ddl_h
40#define log0ddl_h
41
42/** DDL log types defined as uint32_t because it costs 4 bytes in
43mysql.innodb_ddl_log. */
44enum class Log_Type : uint32_t {
45 /** Smallest log type */
46 SMALLEST_LOG = 1,
47
48 /** Drop an index tree */
49 FREE_TREE_LOG = 1,
50
51 /** Delete a file */
53
54 /** Rename a file */
56
57 /** Drop the entry in innodb_table_metadata */
59
60 /** Rename table in dict cache. */
62
63 /** Remove a table from dict cache */
65
66 /** Alter Encrypt a tablespace */
68
69 /** Alter Unencrypt a tablespace */
71
72 /** Biggest log type */
74};
75
76/** DDL log record */
78 public:
79 /** Constructor. */
80 DDL_Record();
81
82 /** Destructor. */
84
85 /** Get the id of the DDL log record.
86 @return id of the record. */
87 ulint get_id() const { return (m_id); }
88
89 /** Set the id for the DDL log record.
90 @param[in] id id of the record. */
91 void set_id(ulint id) { m_id = id; }
92
93 /** Get the type of operation to perform
94 for the DDL log record.
95 @return type of the record. */
96 Log_Type get_type() const { return (m_type); }
97
98 /** Set the type for the DDL log record.
99 @param[in] type set the record type.*/
101
102 /** Get the thread id for the DDL log record.
103 @return thread id of the DDL log record. */
104 ulint get_thread_id() const { return (m_thread_id); }
105
106 /** Set the thread id for the DDL log record.
107 @param[in] thread_id thread id. */
109
110 /** Get the space_id present in the DDL log record.
111 @return space_id in the DDL log record. */
112 space_id_t get_space_id() const { return (m_space_id); }
113
114 /** Set the space id for the DDL log record.
115 @param[in] space space id. */
116 void set_space_id(space_id_t space) { m_space_id = space; }
117
118 /** Get the page no present in the DDL log record.
119 @return page_no */
120 page_no_t get_page_no() const { return (m_page_no); }
121
122 /** Set the page number for the DDL log record.
123 @param[in] page_no page number. */
124 void set_page_no(page_no_t page_no) { m_page_no = page_no; }
125
126 /** Get the index id present in the DDL log record.
127 @return index id. */
128 ulint get_index_id() const { return (m_index_id); }
129
130 /** Set the index id for the DDL log record.
131 @param[in] index_id index id. */
132 void set_index_id(ulint index_id) { m_index_id = index_id; }
133
134 /** Get the table id present in the DDL log record.
135 @return table id from the record. */
136 table_id_t get_table_id() const { return (m_table_id); }
137
138 /** Set the table if for the DDL log record.
139 @param[in] table_id table id. */
140 void set_table_id(table_id_t table_id) { m_table_id = table_id; }
141
142 /** Set deletability of this record.
143 @param[in] deletable deletability. */
144 void set_deletable(bool deletable) { m_deletable = deletable; }
145
146 /** If this record can be deleted.
147 @return true if record is deletable. */
148 bool get_deletable() const { return (m_deletable); }
149
150 /** Get encryption operation type */
152 auto type = get_type();
153
156 }
159 }
160
161 /** Get the old file path/name present in the DDL log record.
162 @return old file path/name. */
163 const char *get_old_file_path() const { return (m_old_file_path); }
164
165 /** Set the old file path from the name for the DDL log record.
166 @param[in] name old file name. */
167 void set_old_file_path(const char *name);
168
169 /** Copy the data and set it in old file path
170 @param[in] data data to be set
171 @param[in] len length of the data. */
172 void set_old_file_path(const byte *data, ulint len);
173
174 /** Get the new file path/name present in the DDL log record.
175 @return new file path/name. */
176 const char *get_new_file_path() const { return (m_new_file_path); }
177
178 /** Set the new file path/name for the DDL log record.
179 @param[in] name name to be set. */
180 void set_new_file_path(const char *name);
181
182 /** Copy the data and set it in new file path.
183 @param[in] data data to be set
184 @param[in] len length of the data. */
185 void set_new_file_path(const byte *data, ulint len);
186
187 /** Print the DDL record to specified output stream
188 @param[in,out] out output stream
189 @return output stream */
190 std::ostream &print(std::ostream &out) const;
191
192 private:
193 /** Log id */
195
196 /** Log type */
198
199 /** Thread id */
201
202 /** Tablespace id */
204
205 /** Index root page */
207
208 /** Index id */
210
211 /** Table id */
213
214 /** Tablespace file path for DELETE, Old tablespace file path
215 for RENAME */
217
218 /** New tablespace file name for RENAME */
220
221 /** memory heap object used for storing file name. */
223
224 /** If this record can be deleted */
226};
227
228/** Forward declaration */
229class THD;
230struct que_thr_t;
231struct dtuple_t;
232
233/** Array of DDL records */
234using DDL_Records = std::vector<DDL_Record *>;
235
236/** Wrapper of mysql.innodb_ddl_log table. Accessing to this table doesn't
237require row lock because thread could only access/modify its own ddl records. */
239 public:
240 /** Constructor. */
242
243 /** Constructor and it initializes transaction and query thread.
244 Once trx is passed in, make sure destructor is called before the
245 trx commits.
246 @param[in,out] trx Transaction */
247 explicit DDL_Log_Table(trx_t *trx);
248
249 /** Destructor. */
251
252 /** Insert the DDL log record into the innodb_ddl_log table.
253 This is thread safe.
254 @param[in] record Record to be inserted.
255 @return DB_SUCCESS or error. */
257
258 /** Search for all records of specified thread_id. The records
259 are kept in reverse order.
260 This is thread safe. Because different threads have different thread
261 ids, there should not be any conflict with update.
262 @param[in] thread_id thread id to search
263 @param[out] records DDL_Records of the specified thread id
264 @return DB_SUCCESS or error. */
266
267 /** Do a reverse scan on the table to fetch all the record.
268 This is only called during recovery
269 @param[out] records DDL_Records of the whole table
270 @return DB_SUCCESS or error. */
272
273 /** Delete the innodb_ddl_log record of specified ID.
274 This is thread safe. One thread will only remove its ddl record.
275 @param[in] id ID of the DDL_Record
276 @return DB_SUCCESS or error. */
277 dberr_t remove(ulint id);
278
279 /** Delete specified DDL_Records from innodb_ddl_log.
280 This is thread safe. Different threads have their own ddl records
281 to delete. And this could be called during recovery.
282 @param[in] records DDL_Record(s) to be deleted
283 @return DB_SUCCESS or error. */
284 dberr_t remove(const DDL_Records &records);
285
286 private:
287 /** Set the query thread using graph. */
288 void start_query_thread();
289
290 /** Stop the query thread. */
291 void stop_query_thread();
292
293 /** Create tuple for the innodb_ddl_log table.
294 It is used for insert operation.
295 @param[in] record DDL log record. */
296 void create_tuple(const DDL_Record &record);
297
298 /** Create tuple for the given index. Used for search by id
299 (and following delete)
300 @param[in] id Thread id/ id of the record
301 @param[in] index Clustered index or secondary index. */
302 void create_tuple(ulint id, const dict_index_t *index);
303
304 /** Convert the innodb_ddl_log index record to DDL_Record.
305 @param[in] is_clustered true if this is clustered index record,
306 otherwise the secondary index record
307 @param[in] rec index record
308 @param[in] offsets index record offset
309 @param[in,out] record to store the innodb_ddl_log record. */
310 void convert_to_ddl_record(bool is_clustered, rec_t *rec,
311 const ulint *offsets, DDL_Record &record);
312
313 /** Parse the index record and get 'ID'.
314 @param[in] index index where the record resides
315 @param[in] rec index rec
316 @param[in] offsets offsets of the index.
317 @return id of the record. */
318 ulint parse_id(const dict_index_t *index, rec_t *rec, const ulint *offsets);
319
320 /** Set the given field of the innodb_ddl_log record from given data.
321 @param[in] data data to be set
322 @param[in] offset column of the ddl record
323 @param[in] len length of the data
324 @param[in,out] record DDL_Record to set */
325 void set_field(const byte *data, ulint offset, ulint len, DDL_Record &record);
326
327 /** Fetch the value from given offset.
328 @param[in] data value to be retrieved from data
329 @param[in] offset offset of the column
330 @return value of the given offset. */
331 ulint fetch_value(const byte *data, ulint offset);
332
333 /** Search specified index by specified ID
334 @param[in] id ID to search
335 @param[in] index index to search
336 @param[in,out] records DDL_Record(s) got by the search
337 @return DB_SUCCESS or error */
338 dberr_t search_by_id(ulint id, dict_index_t *index, DDL_Records &records);
339
340 private:
341 /** Column number of mysql.innodb_ddl_log.id. */
342 static constexpr unsigned s_id_col_no = 0;
343
344 /** Column length of mysql.innodb_ddl_log.id. */
345 static constexpr unsigned s_id_col_len = 8;
346
347 /** Column number of mysql.innodb_ddl_log.thread_id. */
348 static constexpr unsigned s_thread_id_col_no = 1;
349
350 /** Column length of mysql.innodb_ddl_log.thread_id. */
351 static constexpr unsigned s_thread_id_col_len = 8;
352
353 /** Column number of mysql.innodb_ddl_log.type. */
354 static constexpr unsigned s_type_col_no = 2;
355
356 /** Column length of mysql.innodb_ddl_log.type. */
357 static constexpr unsigned s_type_col_len = 4;
358
359 /** Column number of mysql.innodb_ddl_log.space_id. */
360 static constexpr unsigned s_space_id_col_no = 3;
361
362 /** Column length of mysql.innodb_ddl_log.space_id. */
363 static constexpr unsigned s_space_id_col_len = 4;
364
365 /** Column number of mysql.innodb_ddl_log.page_no. */
366 static constexpr unsigned s_page_no_col_no = 4;
367
368 /** Column length of mysql.innodb_ddl_log.page_no. */
369 static constexpr unsigned s_page_no_col_len = 4;
370
371 /** Column number of mysql.innodb_ddl_log.index_id. */
372 static constexpr unsigned s_index_id_col_no = 5;
373
374 /** Column length of mysql.innodb_ddl_log.index_id. */
375 static constexpr unsigned s_index_id_col_len = 8;
376
377 /** Column number of mysql.innodb_ddl_log.table_id. */
378 static constexpr unsigned s_table_id_col_no = 6;
379
380 /** Column length of mysql.innodb_ddl_log.table_id. */
381 static constexpr unsigned s_table_id_col_len = 8;
382
383 /** Column number of mysql.innodb_ddl_log.old_file_path. */
384 static constexpr unsigned s_old_file_path_col_no = 7;
385
386 /** Column number of mysql.innodb_ddl_log.new_file_path. */
387 static constexpr unsigned s_new_file_path_col_no = 8;
388
389 /** innodb_ddl_log table. */
391
392 /** Tuple used for insert, search, delete operation. */
394
395 /** Transaction used for insert, delete operation. */
397
398 /** Dummy query thread. */
400
401 /** Heap to store the m_tuple, m_thr and all
402 operation on mysql.innodb_ddl_log table. */
404};
405
406/** Class to write and replay ddl logs */
407class Log_DDL {
408 public:
409 /** Constructor */
410 Log_DDL();
411
412 /** Deconstructor */
413 ~Log_DDL() = default;
414
415 /** Write DDL log for freeing B-tree
416 @param[in,out] trx transaction
417 @param[in] index dict index
418 @param[in] is_drop_table true if this is drop table
419 @return DB_SUCCESS or error */
421 bool is_drop_table);
422
423 /** Write DDL log for deleting tablespace file
424 @param[in,out] trx transaction
425 @param[in] table dict table
426 @param[in] space_id tablespace id
427 @param[in] file_path file path
428 @param[in] is_drop flag whether dropping tablespace
429 @param[in] dict_locked true if dict_sys mutex is held
430 @return DB_SUCCESS or error */
432 space_id_t space_id, const char *file_path,
433 bool is_drop, bool dict_locked);
434
435 /** Write a RENAME log record
436 @param[in] space_id tablespace id
437 @param[in] old_file_path file path after rename
438 @param[in] new_file_path file path before rename
439 @return DB_SUCCESS or error */
440 dberr_t write_rename_space_log(space_id_t space_id, const char *old_file_path,
441 const char *new_file_path);
442
443 /** Find alter encrypt record for the tablespace.
444 @param[in] space_id space_id
445 return log record if exists, null otherwise */
447
448 /** Write an ALTER ENCRYPT Tablespace DDL log record
449 @param[in] space_id tablespace id
450 @param[in] type encryption operation type
451 @param[out] existing_rec alter_encrypt ddl record, nullptr if none
452 @return DB_SUCCESS or error */
455 DDL_Record *existing_rec);
456
457 /** Write a DROP log to indicate the entry in innodb_table_metadata
458 should be removed for specified table
459 @param[in,out] trx transaction
460 @param[in] table_id table ID
461 @return DB_SUCCESS or error */
462 dberr_t write_drop_log(trx_t *trx, const table_id_t table_id);
463
464 /** Write a RENAME table log record
465 @param[in] table dict table
466 @param[in] old_name table name after rename
467 @param[in] new_name table name before rename
468 @return DB_SUCCESS or error */
469 dberr_t write_rename_table_log(dict_table_t *table, const char *old_name,
470 const char *new_name);
471
472 /** Write a REMOVE cache log record
473 @param[in,out] trx transaction
474 @param[in] table dict table
475 @return DB_SUCCESS or error */
477
478 /** Replay DDL log record
479 @param[in,out] record DDL log record
480 return DB_SUCCESS or error */
482
483 /** Replay and clean DDL logs after DDL transaction
484 commints or rollbacks.
485 @param[in] thd mysql thread
486 @return DB_SUCCESS or error */
487 dberr_t post_ddl(THD *thd);
488
489 /** Recover in server startup.
490 Scan innodb_ddl_log table, and replay all log entries.
491 Note: redo log should be applied, and DD transactions
492 should be recovered before calling this function.
493 @return DB_SUCCESS or error */
495
496 /** Is it in ddl recovery in server startup.
497 @return true if it's in ddl recover */
498 static bool is_in_recovery() { return (s_in_recovery); }
499
500 private:
501 /** Insert a FREE log record
502 @param[in,out] trx transaction
503 @param[in] index dict index
504 @param[in] id log id
505 @param[in] thread_id thread id
506 @return DB_SUCCESS or error */
508 uint64_t id, ulint thread_id);
509
510 /** Replay FREE log(free B-tree if exist)
511 @param[in] space_id tablespace id
512 @param[in] page_no root page no
513 @param[in] index_id index id */
514 void replay_free_tree_log(space_id_t space_id, page_no_t page_no,
515 ulint index_id);
516
517 /** Insert a DELETE log record
518 @param[in,out] trx transaction
519 @param[in] id log id
520 @param[in] thread_id thread id
521 @param[in] space_id tablespace id
522 @param[in] file_path file path
523 @param[in] dict_locked true if dict_sys mutex is held
524 @return DB_SUCCESS or error */
526 space_id_t space_id, const char *file_path,
527 bool dict_locked);
528
529 /** Replay DELETE log(delete file if exist)
530 @param[in] space_id tablespace id
531 @param[in] file_path file path */
532 void replay_delete_space_log(space_id_t space_id, const char *file_path);
533
534 /** Insert a RENAME log record
535 @param[in] id log id
536 @param[in] thread_id thread id
537 @param[in] space_id tablespace id
538 @param[in] old_file_path file path after rename
539 @param[in] new_file_path file path before rename
540 @return DB_SUCCESS or error */
542 space_id_t space_id,
543 const char *old_file_path,
544 const char *new_file_path);
545
546 /** Replay RENAME log
547 @param[in] space_id tablespace id
548 @param[in] old_file_path old file path
549 @param[in] new_file_path new file path */
550 void replay_rename_space_log(space_id_t space_id, const char *old_file_path,
551 const char *new_file_path);
552
553 /** Insert an ALTER ENCRYPT TABLESPACE log record
554 @param[in] id log id
555 @param[in] thread_id thread id
556 @param[in] space_id tablespace id
557 @param[in] type encryption operation type
558 @param[out] existing_rec alter_encrypt ddl record, nullptr if none
559 @return DB_SUCCESS or error */
561 space_id_t space_id,
563 DDL_Record *existing_rec);
564
565 /** Replay an ALTER ENCRYPT TABLESPACE log record
566 @param[in] record DDL Record
567 @return DB_SUCCESS or error */
569
570 /** Insert a DROP log record
571 @param[in,out] trx transaction
572 @param[in] id log id
573 @param[in] thread_id thread id
574 @param[in] table_id table id
575 @return DB_SUCCESS or error */
576 dberr_t insert_drop_log(trx_t *trx, uint64_t id, ulint thread_id,
577 const table_id_t table_id);
578
579 /** Replay DROP log
580 @param[in] table_id table id */
581 void replay_drop_log(const table_id_t table_id);
582
583 /** Insert a RENAME TABLE log record
584 @param[in] id log id
585 @param[in] thread_id thread id
586 @param[in] table_id table id
587 @param[in] old_name table name after rename
588 @param[in] new_name table name before rename
589 @return DB_SUCCESS or error */
591 table_id_t table_id, const char *old_name,
592 const char *new_name);
593
594 /** Relay RENAME TABLE log
595 @param[in] old_name old name
596 @param[in] new_name new name */
597 void replay_rename_table_log(const char *old_name, const char *new_name);
598
599 /** Insert a REMOVE cache log record
600 @param[in] id log id
601 @param[in] thread_id thread id
602 @param[in] table_id table id
603 @param[in] table_name table name
604 @return DB_SUCCESS or error */
606 table_id_t table_id, const char *table_name);
607
608 /** Relay remove cache log
609 @param[in] table_id table id
610 @param[in] table_name table name */
611 void replay_remove_cache_log(table_id_t table_id, const char *table_name);
612
613 /** Delete log record by id
614 @param[in] trx transaction instance
615 @param[in] id log id
616 @param[in] dict_locked true if dict_sys mutex is held,
617 otherwise false
618 @return DB_SUCCESS or error */
619 dberr_t delete_by_id(trx_t *trx, uint64_t id, bool dict_locked);
620
621 /** Scan, replay and delete log records by thread id
622 @param[in] thread_id thread id
623 @return DB_SUCCESS or error */
625
626 /** Delete the log records present in the list.
627 @param[in] records DDL_Records where the IDs are got
628 @return DB_SUCCESS or error. */
630
631 /** Scan, replay and delete all log records
632 @return DB_SUCCESS or error */
634
635 /** Get next autoinc counter by increasing 1 for innodb_ddl_log
636 @return new next counter */
637 inline uint64_t next_id();
638
639 /** Check if we need to skip ddl log for a table.
640 @param[in] table dict table
641 @param[in] thd mysql thread
642 @return true if should skip, otherwise false */
643 inline bool skip(const dict_table_t *table, THD *thd);
644
645 private:
646 /** Whether in recover(replay) ddl log in startup. */
647 static bool s_in_recovery;
648};
649
650/** Object to handle Log_DDL */
651extern Log_DDL *log_ddl;
652
653/** Close the DDL log system */
655
656#ifdef UNIV_DEBUG
657struct SYS_VAR;
658
659/** Used by SET GLOBAL innodb_ddl_log_crash_counter_reset_debug = 1; */
661
662/** Reset all crash injection counters. It's used by:
663 SET GLOBAL innodb_ddl_log_crash_reset_debug = 1 (0).
664@param[in] thd thread handle
665@param[in] var pointer to system variable
666@param[in] var_ptr where the formal string goes
667@param[in] save immediate result from check function */
668void ddl_log_crash_reset(THD *thd, SYS_VAR *var, void *var_ptr,
669 const void *save);
670#endif /* UNIV_DEBUG */
671
672#endif /* log0ddl_h */
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:50
uint32_t page_no_t
Page number.
Definition: api0api.h:48
Wrapper of mysql.innodb_ddl_log table.
Definition: log0ddl.h:238
dberr_t search(ulint thread_id, DDL_Records &records)
Search for all records of specified thread_id.
Definition: log0ddl.cc:665
static constexpr unsigned s_page_no_col_no
Column number of mysql.innodb_ddl_log.page_no.
Definition: log0ddl.h:366
static constexpr unsigned s_thread_id_col_len
Column length of mysql.innodb_ddl_log.thread_id.
Definition: log0ddl.h:351
mem_heap_t * m_heap
Heap to store the m_tuple, m_thr and all operation on mysql.innodb_ddl_log table.
Definition: log0ddl.h:403
static constexpr unsigned s_index_id_col_len
Column length of mysql.innodb_ddl_log.index_id.
Definition: log0ddl.h:375
static constexpr unsigned s_table_id_col_len
Column length of mysql.innodb_ddl_log.table_id.
Definition: log0ddl.h:381
static constexpr unsigned s_id_col_no
Column number of mysql.innodb_ddl_log.id.
Definition: log0ddl.h:342
static constexpr unsigned s_index_id_col_no
Column number of mysql.innodb_ddl_log.index_id.
Definition: log0ddl.h:372
void set_field(const byte *data, ulint offset, ulint len, DDL_Record &record)
Set the given field of the innodb_ddl_log record from given data.
Definition: log0ddl.cc:557
static constexpr unsigned s_table_id_col_no
Column number of mysql.innodb_ddl_log.table_id.
Definition: log0ddl.h:378
static constexpr unsigned s_space_id_col_no
Column number of mysql.innodb_ddl_log.space_id.
Definition: log0ddl.h:360
dberr_t search_all(DDL_Records &records)
Do a reverse scan on the table to fetch all the record.
Definition: log0ddl.cc:626
dict_table_t * m_table
innodb_ddl_log table.
Definition: log0ddl.h:390
que_thr_t * m_thr
Dummy query thread.
Definition: log0ddl.h:399
dberr_t search_by_id(ulint id, dict_index_t *index, DDL_Records &records)
Search specified index by specified ID.
Definition: log0ddl.cc:686
static constexpr unsigned s_page_no_col_len
Column length of mysql.innodb_ddl_log.page_no.
Definition: log0ddl.h:369
static constexpr unsigned s_space_id_col_len
Column length of mysql.innodb_ddl_log.space_id.
Definition: log0ddl.h:363
static constexpr unsigned s_thread_id_col_no
Column number of mysql.innodb_ddl_log.thread_id.
Definition: log0ddl.h:348
static constexpr unsigned s_old_file_path_col_no
Column number of mysql.innodb_ddl_log.old_file_path.
Definition: log0ddl.h:384
ulint parse_id(const dict_index_t *index, rec_t *rec, const ulint *offsets)
Parse the index record and get 'ID'.
Definition: log0ddl.cc:546
static constexpr unsigned s_type_col_len
Column length of mysql.innodb_ddl_log.type.
Definition: log0ddl.h:357
static constexpr unsigned s_id_col_len
Column length of mysql.innodb_ddl_log.id.
Definition: log0ddl.h:345
static constexpr unsigned s_new_file_path_col_no
Column number of mysql.innodb_ddl_log.new_file_path.
Definition: log0ddl.h:387
dtuple_t * m_tuple
Tuple used for insert, search, delete operation.
Definition: log0ddl.h:393
dberr_t insert(const DDL_Record &record)
Insert the DDL log record into the innodb_ddl_log table.
Definition: log0ddl.cc:461
void stop_query_thread()
Stop the query thread.
Definition: log0ddl.cc:339
void create_tuple(const DDL_Record &record)
Create tuple for the innodb_ddl_log table.
Definition: log0ddl.cc:345
static constexpr unsigned s_type_col_no
Column number of mysql.innodb_ddl_log.type.
Definition: log0ddl.h:354
trx_t * m_trx
Transaction used for insert, delete operation.
Definition: log0ddl.h:396
DDL_Log_Table()
Constructor.
Definition: log0ddl.cc:316
ulint fetch_value(const byte *data, ulint offset)
Fetch the value from given offset.
Definition: log0ddl.cc:602
~DDL_Log_Table()
Destructor.
Definition: log0ddl.cc:327
dberr_t remove(ulint id)
Delete the innodb_ddl_log record of specified ID.
Definition: log0ddl.cc:729
void start_query_thread()
Set the query thread using graph.
Definition: log0ddl.cc:332
void convert_to_ddl_record(bool is_clustered, rec_t *rec, const ulint *offsets, DDL_Record &record)
Convert the innodb_ddl_log index record to DDL_Record.
Definition: log0ddl.cc:521
DDL log record.
Definition: log0ddl.h:77
ulint m_id
Log id.
Definition: log0ddl.h:194
ulint m_thread_id
Thread id.
Definition: log0ddl.h:200
const char * get_new_file_path() const
Get the new file path/name present in the DDL log record.
Definition: log0ddl.h:176
Log_Type m_type
Log type.
Definition: log0ddl.h:197
Log_Type get_type() const
Get the type of operation to perform for the DDL log record.
Definition: log0ddl.h:96
page_no_t get_page_no() const
Get the page no present in the DDL log record.
Definition: log0ddl.h:120
void set_new_file_path(const char *name)
Set the new file path/name for the DDL log record.
Definition: log0ddl.cc:185
void set_index_id(ulint index_id)
Set the index id for the DDL log record.
Definition: log0ddl.h:132
table_id_t get_table_id() const
Get the table id present in the DDL log record.
Definition: log0ddl.h:136
void set_table_id(table_id_t table_id)
Set the table if for the DDL log record.
Definition: log0ddl.h:140
space_id_t get_space_id() const
Get the space_id present in the DDL log record.
Definition: log0ddl.h:112
void set_page_no(page_no_t page_no)
Set the page number for the DDL log record.
Definition: log0ddl.h:124
Encryption::Progress get_encryption_type() const
Get encryption operation type.
Definition: log0ddl.h:151
~DDL_Record()
Destructor.
Definition: log0ddl.cc:160
void set_type(Log_Type type)
Set the type for the DDL log record.
Definition: log0ddl.h:100
ulint get_id() const
Get the id of the DDL log record.
Definition: log0ddl.h:87
ulint m_index_id
Index id.
Definition: log0ddl.h:209
mem_heap_t * m_heap
memory heap object used for storing file name.
Definition: log0ddl.h:222
DDL_Record()
Constructor.
Definition: log0ddl.cc:148
bool get_deletable() const
If this record can be deleted.
Definition: log0ddl.h:148
char * m_old_file_path
Tablespace file path for DELETE, Old tablespace file path for RENAME.
Definition: log0ddl.h:216
space_id_t m_space_id
Tablespace id.
Definition: log0ddl.h:203
void set_deletable(bool deletable)
Set deletability of this record.
Definition: log0ddl.h:144
table_id_t m_table_id
Table id.
Definition: log0ddl.h:212
void set_id(ulint id)
Set the id for the DDL log record.
Definition: log0ddl.h:91
page_no_t m_page_no
Index root page.
Definition: log0ddl.h:206
ulint get_index_id() const
Get the index id present in the DDL log record.
Definition: log0ddl.h:128
void set_thread_id(ulint thread_id)
Set the thread id for the DDL log record.
Definition: log0ddl.h:108
void set_space_id(space_id_t space)
Set the space id for the DDL log record.
Definition: log0ddl.h:116
const char * get_old_file_path() const
Get the old file path/name present in the DDL log record.
Definition: log0ddl.h:163
bool m_deletable
If this record can be deleted.
Definition: log0ddl.h:225
std::ostream & print(std::ostream &out) const
Print the DDL record to specified output stream.
Definition: log0ddl.cc:204
void set_old_file_path(const char *name)
Set the old file path from the name for the DDL log record.
Definition: log0ddl.cc:166
ulint get_thread_id() const
Get the thread id for the DDL log record.
Definition: log0ddl.h:104
char * m_new_file_path
New tablespace file name for RENAME.
Definition: log0ddl.h:219
Progress
Encryption progress type.
Definition: os0enc.h:79
Class to write and replay ddl logs.
Definition: log0ddl.h:407
void replay_drop_log(const table_id_t table_id)
Replay DROP log.
Definition: log0ddl.cc:1803
dberr_t replay(DDL_Record &record)
Replay DDL log record.
Definition: log0ddl.cc:1575
dberr_t insert_rename_space_log(uint64_t id, ulint thread_id, space_id_t space_id, const char *old_file_path, const char *new_file_path)
Insert a RENAME log record.
Definition: log0ddl.cc:1118
void replay_rename_space_log(space_id_t space_id, const char *old_file_path, const char *new_file_path)
Replay RENAME log.
Definition: log0ddl.cc:1721
~Log_DDL()=default
Deconstructor.
DDL_Record * find_alter_encrypt_record(space_id_t space_id)
Find alter encrypt record for the tablespace.
Definition: log0ddl.cc:1155
dberr_t write_rename_space_log(space_id_t space_id, const char *old_file_path, const char *new_file_path)
Write a RENAME log record.
Definition: log0ddl.cc:1064
dberr_t post_ddl(THD *thd)
Replay and clean DDL logs after DDL transaction commints or rollbacks.
Definition: log0ddl.cc:1904
dberr_t insert_free_tree_log(trx_t *trx, const dict_index_t *index, uint64_t id, ulint thread_id)
Insert a FREE log record.
Definition: log0ddl.cc:919
dberr_t recover()
Recover in server startup.
Definition: log0ddl.cc:1941
dberr_t delete_by_id(trx_t *trx, uint64_t id, bool dict_locked)
Delete log record by id.
Definition: log0ddl.cc:1441
dberr_t write_free_tree_log(trx_t *trx, const dict_index_t *index, bool is_drop_table)
Write DDL log for freeing B-tree.
Definition: log0ddl.cc:852
Log_DDL()
Constructor.
Definition: log0ddl.cc:829
dberr_t write_alter_encrypt_space_log(space_id_t space_id, Encryption::Progress type, DDL_Record *existing_rec)
Write an ALTER ENCRYPT Tablespace DDL log record.
Definition: log0ddl.cc:1166
dberr_t insert_alter_encrypt_space_log(uint64_t id, ulint thread_id, space_id_t space_id, Encryption::Progress type, DDL_Record *existing_rec)
Insert an ALTER ENCRYPT TABLESPACE log record.
Definition: log0ddl.cc:1210
void replay_rename_table_log(const char *old_name, const char *new_name)
Relay RENAME TABLE log.
Definition: log0ddl.cc:1812
uint64_t next_id()
Get next autoinc counter by increasing 1 for innodb_ddl_log.
Definition: log0ddl.cc:834
dberr_t insert_delete_space_log(trx_t *trx, uint64_t id, ulint thread_id, space_id_t space_id, const char *file_path, bool dict_locked)
Insert a DELETE log record.
Definition: log0ddl.cc:1015
dberr_t write_drop_log(trx_t *trx, const table_id_t table_id)
Write a DROP log to indicate the entry in innodb_table_metadata should be removed for specified table...
Definition: log0ddl.cc:1257
bool skip(const dict_table_t *table, THD *thd)
Check if we need to skip ddl log for a table.
Definition: log0ddl.cc:846
dberr_t insert_remove_cache_log(uint64_t id, ulint thread_id, table_id_t table_id, const char *table_name)
Insert a REMOVE cache log record.
Definition: log0ddl.cc:1411
dberr_t replay_by_thread_id(ulint thread_id)
Scan, replay and delete log records by thread id.
Definition: log0ddl.cc:1505
dberr_t write_rename_table_log(dict_table_t *table, const char *old_name, const char *new_name)
Write a RENAME table log record.
Definition: log0ddl.cc:1312
static bool is_in_recovery()
Is it in ddl recovery in server startup.
Definition: log0ddl.h:498
dberr_t delete_by_ids(DDL_Records &records)
Delete the log records present in the list.
Definition: log0ddl.cc:1538
dberr_t insert_rename_table_log(uint64_t id, ulint thread_id, table_id_t table_id, const char *old_name, const char *new_name)
Insert a RENAME TABLE log record.
Definition: log0ddl.cc:1344
void replay_remove_cache_log(table_id_t table_id, const char *table_name)
Relay remove cache log.
Definition: log0ddl.cc:1872
void replay_delete_space_log(space_id_t space_id, const char *file_path)
Replay DELETE log(delete file if exist)
Definition: log0ddl.cc:1658
dberr_t insert_drop_log(trx_t *trx, uint64_t id, ulint thread_id, const table_id_t table_id)
Insert a DROP log record.
Definition: log0ddl.cc:1282
dberr_t write_delete_space_log(trx_t *trx, const dict_table_t *table, space_id_t space_id, const char *file_path, bool is_drop, bool dict_locked)
Write DDL log for deleting tablespace file.
Definition: log0ddl.cc:960
dberr_t replay_alter_encrypt_space_log(DDL_Record &record)
Replay an ALTER ENCRYPT TABLESPACE log record.
Definition: log0ddl.cc:1776
dberr_t write_remove_cache_log(trx_t *trx, dict_table_t *table)
Write a REMOVE cache log record.
Definition: log0ddl.cc:1381
dberr_t replay_all()
Scan, replay and delete all log records.
Definition: log0ddl.cc:1473
static bool s_in_recovery
Whether in recover(replay) ddl log in startup.
Definition: log0ddl.h:647
void replay_free_tree_log(space_id_t space_id, page_no_t page_no, ulint index_id)
Replay FREE log(free B-tree if exist)
Definition: log0ddl.cc:1624
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:922
dberr_t
Definition: db0err.h:38
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:217
Log_Type
DDL log types defined as uint32_t because it costs 4 bytes in mysql.innodb_ddl_log.
Definition: log0ddl.h:44
@ BIGGEST_LOG
Biggest log type.
@ ALTER_UNENCRYPT_TABLESPACE_LOG
Alter Unencrypt a tablespace.
@ DROP_LOG
Drop the entry in innodb_table_metadata.
@ REMOVE_CACHE_LOG
Remove a table from dict cache.
@ SMALLEST_LOG
Smallest log type.
@ DELETE_SPACE_LOG
Delete a file.
@ RENAME_SPACE_LOG
Rename a file.
@ RENAME_TABLE_LOG
Rename table in dict cache.
@ ALTER_ENCRYPT_TABLESPACE_LOG
Alter Encrypt a tablespace.
@ FREE_TREE_LOG
Drop an index tree.
std::vector< DDL_Record * > DDL_Records
Array of DDL records.
Definition: log0ddl.h:234
void ddl_log_close()
Close the DDL log system.
Definition: log0ddl.h:654
void ddl_log_crash_reset(THD *thd, SYS_VAR *var, void *var_ptr, const void *save)
Reset all crash injection counters.
Definition: log0ddl.cc:125
bool innodb_ddl_log_crash_reset_debug
Used by SET GLOBAL innodb_ddl_log_crash_counter_reset_debug = 1;.
Definition: log0ddl.cc:73
Log_DDL * log_ddl
Object to handle Log_DDL.
Definition: log0ddl.cc:61
static my_thread_id thread_id
Definition: my_thr_init.cc:62
const char * table_name
Definition: rules_table_service.cc:55
void delete_(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new*() variants.
Definition: ut0new.h:807
byte rec_t
Definition: rem0types.h:40
required string type
Definition: replication_group_member_actions.proto:33
case opt name
Definition: sslopt-case.h:32
Definition: plugin.h:65
Data structure for an index.
Definition: dict0mem.h:1021
Data structure for a database table.
Definition: dict0mem.h:1884
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:681
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:299
Definition: que0que.h:241
Definition: mi_test3.cc:54
Definition: trx0trx.h:680
unsigned long int ulint
Definition: univ.i:407
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:68
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:506