MySQL 8.3.0
Source Code Documentation
dict0dict.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1996, 2023, Oracle and/or its affiliates.
4Copyright (c) 2012, Facebook Inc.
5
6This program is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License, version 2.0, as published by the
8Free Software Foundation.
9
10This program is also distributed with certain software (including but not
11limited to OpenSSL) that is licensed under separate terms, as designated in a
12particular file or component or in included license documentation. The authors
13of MySQL hereby grant you an additional permission to link the program and
14your derivative works with the separately licensed software that they have
15included with MySQL.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20for more details.
21
22You should have received a copy of the GNU General Public License along with
23this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26*****************************************************************************/
27
28/** @file include/dict0dict.h
29 Data dictionary system
30
31 Created 1/8/1996 Heikki Tuuri
32 *******************************************************/
33
34#ifndef dict0dict_h
35#define dict0dict_h
36
37#include <set>
38#include <vector>
39
40#include <deque>
41#include "data0data.h"
42#include "data0type.h"
43#include "dict/dict.h"
44#include "dict0mem.h"
45#include "dict0types.h"
46#include "fsp0fsp.h"
47#include "fsp0sysspace.h"
48#include "hash0hash.h"
49#include "mem0mem.h"
50#include "rem0types.h"
51#include "row0types.h"
52#include "sql/dd/object_id.h"
53#include "srv0mon.h" /* for dict0dict.ic */
54#include "sync0rw.h"
55#include "trx0types.h"
56#include "univ.i"
57#include "ut0byte.h"
58#include "ut0mem.h"
59#include "ut0new.h"
60#include "ut0rnd.h"
61
62#define dict_sys_mutex_enter() mutex_enter(&dict_sys->mutex)
63
64#define dict_sys_mutex_exit() mutex_exit(&dict_sys->mutex)
65
66#define dict_sys_mutex_own() mutex_own(&dict_sys->mutex)
67
68#define dict_sys_mutex_free() mutex_free(&dict_sys->mutex)
69/** initial memory heap size when creating a table or index object */
70constexpr uint32_t DICT_HEAP_SIZE = 100;
71
72/** SDI version. Written on Page 1 & 2 at FIL_PAGE_FILE_FLUSH_LSN offset. */
73const uint32_t SDI_VERSION = 1;
74
75/** Space id of system tablespace */
77
78/** Get the database name length in a table name.
79 @return database name length */
80[[nodiscard]] ulint dict_get_db_name_len(
81 const char *name); /*!< in: table name in the form
82 dbname '/' tablename */
83#ifndef UNIV_HOTBACKUP
84/** Frees a foreign key struct. */
86 dict_foreign_t *foreign); /*!< in, own: foreign key struct */
87/** Finds the highest [number] for foreign key constraints of the table. Looks
88 only at the >= 4.0.18-format id's, which are of the form
89 databasename/tablename_ibfk_[number].
90 @return highest number, 0 if table has no new format foreign key constraints */
92 dict_table_t *table); /*!< in: table in the dictionary
93 memory cache */
94#endif /* !UNIV_HOTBACKUP */
95/** Return the end of table name where we have removed dbname and '/'.
96 @return table name */
97[[nodiscard]] const char *dict_remove_db_name(
98 const char *name); /*!< in: table name in the
99 form dbname '/' tablename */
100
101/** Operation to perform when opening a table */
103 /** Expect the tablespace to exist. */
105 /** Drop any orphan indexes after an aborted online index creation */
107 /** Silently load the tablespace if it does not exist,
108 and do not load the definitions of incomplete indexes. */
111
112/** Decrements the count of open handles to a table.
113@param[in,out] table Table
114@param[in] dict_locked True=data dictionary locked
115@param[in] try_drop True=try to drop any orphan indexes after an aborted online
116index creation */
117void dict_table_close(dict_table_t *table, bool dict_locked, bool try_drop);
118
119/** Closes the only open handle to a table and drops a table while assuring
120 that dict_sys->mutex is held the whole time. This assures that the table
121 is not evicted after the close when the count of open handles goes to zero.
122 Because dict_sys->mutex is held, we do not need to call
123 dict_table_prevent_eviction(). */
125 trx_t *trx, /*!< in: data dictionary transaction */
126 dict_table_t *table); /*!< in/out: table */
127/** Inits the data dictionary module. */
128void dict_init(void);
129
130/** Closes the data dictionary module. */
131void dict_close(void);
132
133/** Inits the structure for persisting dynamic metadata */
134void dict_persist_init(void);
135
136/** Clear the structure */
137void dict_persist_close(void);
138
139#ifndef UNIV_HOTBACKUP
140/** Write back the dirty persistent dynamic metadata of the table
141to DDTableBuffer.
142@param[in,out] table table object */
144
145/** Read persistent dynamic metadata stored in a buffer
146@param[in] buffer buffer to read
147@param[in] size size of data in buffer
148@param[in] metadata where we store the metadata from buffer */
149void dict_table_read_dynamic_metadata(const byte *buffer, ulint size,
150 PersistentTableMetadata *metadata);
151
152/** Determine bytes of column prefix to be stored in the undo log. Please
153note that if !dict_table_has_atomic_blobs(table), no prefix
154needs to be stored in the undo log.
155@param[in] table Table.
156@param[in] col Column which index prefix is based on.
157@return bytes of column prefix to be stored in the undo log */
158[[nodiscard]] static inline ulint dict_max_field_len_store_undo(
159 dict_table_t *table, const dict_col_t *col);
160
161/** Determine maximum bytes of a virtual column need to be stored
162in the undo log.
163@param[in] table dict_table_t for the table
164@param[in] col_no virtual column number
165@return maximum bytes of virtual column to be stored in the undo log */
167 ulint col_no);
168
169#endif /* !UNIV_HOTBACKUP */
170/** Gets the column number.
171 @return col->ind, table column position (starting from 0) */
172[[nodiscard]] static inline ulint dict_col_get_no(
173 const dict_col_t *col); /*!< in: column */
174/** Gets the column position in the clustered index.
175@param[in] col Table column.
176@param[in] clust_index Clustered index. */
177[[nodiscard]] static inline ulint dict_col_get_clust_pos(
178 const dict_col_t *col, const dict_index_t *clust_index);
179
180#ifndef UNIV_HOTBACKUP
181/** Gets the column position in the given index.
182@param[in] col table column
183@param[in] index index to be searched for column
184@return position of column in the given index. */
185[[nodiscard]] static inline ulint dict_col_get_index_pos(
186 const dict_col_t *col, const dict_index_t *index) MY_ATTRIBUTE((nonnull));
187
188/** If the given column name is reserved for InnoDB system columns, return
189 true.
190 @return true if name is reserved */
191[[nodiscard]] bool dict_col_name_is_reserved(
192 const char *name); /*!< in: column name */
193/** Acquire the autoinc lock. */
194void dict_table_autoinc_lock(dict_table_t *table); /*!< in/out: table */
195
196/** Unconditionally set the autoinc counter.
197@param[in,out] table Table
198@param[in] value Next value to assign to a row */
200
201/** Reads the next autoinc value (== autoinc counter value), 0 if not yet
202 initialized.
203 @return value for a new row, or 0 */
204[[nodiscard]] uint64_t dict_table_autoinc_read(
205 const dict_table_t *table); /*!< in: table */
206
207/** Updates the autoinc counter if the value supplied is greater than the
208 current value.
209@param[in,out] table Table
210@param[in] value Value which was assigned to a row */
212
213/** Release the autoinc lock. */
214void dict_table_autoinc_unlock(dict_table_t *table); /*!< in/out: table */
215
216/** Update the persisted autoinc counter to specified one, we should hold
217autoinc_persisted_mutex.
218@param[in,out] table table
219@param[in] autoinc set autoinc_persisted to this value */
221 uint64_t autoinc);
222
223/** Set the column position of autoinc column in clustered index for a table.
224@param[in] table table
225@param[in] pos column position in table definition */
227 ulint pos);
228
229/** Write redo logs for autoinc counter that is to be inserted, or to
230update some existing smaller one to bigger.
231@param[in,out] table InnoDB table object
232@param[in] value AUTOINC counter to log
233@param[in,out] mtr Mini-transaction
234@return true if auto increment needs to be persisted to DD table buffer. */
235bool dict_table_autoinc_log(dict_table_t *table, uint64_t value, mtr_t *mtr);
236
237/** Check if a table has an autoinc counter column.
238@param[in] table table
239@return true if there is an autoinc column in the table, otherwise false. */
241
242#endif /* !UNIV_HOTBACKUP */
243
244/** Adds system columns to a table object.
245@param[in,out] table Table
246@param[in] heap Temporary heap */
248
249#ifndef UNIV_HOTBACKUP
250/** Mark if table has big rows.
251@param[in,out] table table handler */
252void dict_table_set_big_rows(dict_table_t *table) MY_ATTRIBUTE((nonnull));
253
254/** Adds a table object to the dictionary cache.
255@param[in,out] table table
256@param[in] can_be_evicted true if can be evicted */
257void dict_table_add_to_cache(dict_table_t *table, bool can_be_evicted);
258
259/** Removes a table object from the dictionary cache. */
260void dict_table_remove_from_cache(dict_table_t *table); /*!< in, own: table */
261
262/** Try to invalidate an entry from the dict cache, for a partitioned table,
263if any table found.
264@param[in] name Table name */
266
267#ifdef UNIV_DEBUG
268/** Removes a table object from the dictionary cache, for debug purpose
269@param[in,out] table table object
270@param[in] lru_evict true if table being evicted to make room
271 in the table LRU list */
273#endif /* UNIV_DEBUG */
274
275/** Renames a table object.
276 @return true if success */
278 dict_table_t *table, /*!< in/out: table */
279 const char *new_name, /*!< in: new name */
280 bool rename_also_foreigns);
281/*!< in: in ALTER TABLE we want
282to preserve the original table name
283in constraints which reference it */
284
285/** Removes an index from the dictionary cache.
286@param[in,out] table table whose index to remove
287@param[in,out] index index to remove, this object is destroyed and must not
288be accessed by the caller afterwards */
290
291/** Change the id of a table object in the dictionary cache. This is used in
292 DISCARD TABLESPACE. */
294 dict_table_t *table, /*!< in/out: table object already in cache */
295 table_id_t new_id); /*!< in: new id to set */
296/** Removes a foreign constraint struct from the dictionary cache. */
298 dict_foreign_t *foreign); /*!< in, own: foreign constraint */
299/** Adds a foreign key constraint object to the dictionary cache. May free
300 the object if there already is an object with the same identifier in.
301 At least one of foreign table or referenced table must already be in
302 the dictionary cache!
303 @return DB_SUCCESS or error code */
305 dict_foreign_t *foreign,
306 /*!< in, own: foreign key constraint */
307 const char **col_names,
308 /*!< in: column names, or NULL to use
309 foreign->foreign_table->col_names */
310 bool check_charsets,
311 /*!< in: whether to check charset
312 compatibility */
313 bool can_free_fk,
314 /*!< in: whether free existing FK */
315 dict_err_ignore_t ignore_err);
316/*!< in: error to be ignored */
317/** Checks if a table is referenced by foreign keys.
318 @return true if table is referenced by a foreign key */
320 const dict_table_t *table); /*!< in: InnoDB table */
321/** Replace the index passed in with another equivalent index in the
322 foreign key lists of the table.
323 @return whether all replacements were found */
324[[nodiscard]] bool dict_foreign_replace_index(
325 dict_table_t *table, /*!< in/out: table */
326 const char **col_names,
327 /*!< in: column names, or NULL
328 to use table->col_names */
329 const dict_index_t *index); /*!< in: index to be replaced */
330#endif /* !UNIV_HOTBACKUP */
331/** Returns a table object and increments its open handle count.
332 NOTE! This is a high-level function to be used mainly from outside the
333 'dict' directory. Inside this directory dict_table_get_low
334 is usually the appropriate function.
335 @param[in] table_name Table name
336 @param[in] dict_locked true=data dictionary locked
337 @param[in] try_drop true=try to drop any orphan indexes after
338 an aborted online index creation
339 @param[in] ignore_err error to be ignored when loading the table
340 @return table, NULL if does not exist */
342 const char *table_name, bool dict_locked, bool try_drop,
343 dict_err_ignore_t ignore_err);
344
345/** Tries to find an index whose first fields are the columns in the array,
346 in the same order and is not marked for deletion and is not the same
347 as types_idx.
348 @return matching index, NULL if not found */
350 const dict_table_t *table, /*!< in: table */
351 const char **col_names,
352 /*!< in: column names, or NULL
353 to use table->col_names */
354 const char **columns, /*!< in: array of column names */
355 ulint n_cols, /*!< in: number of columns */
356 const dict_index_t *types_idx,
357 /*!< in: NULL or an index
358 whose types the column types
359 must match */
360 bool check_charsets,
361 /*!< in: whether to check
362 charsets. only has an effect
363 if types_idx != NULL */
364 ulint check_null);
365/*!< in: nonzero if none of
366the columns must be declared
367NOT NULL */
368
369/** Returns a virtual column's name.
370@param[in] table target table
371@param[in] col_nr virtual column number (nth virtual column)
372@return column name or NULL if column number out of range. */
373const char *dict_table_get_v_col_name(const dict_table_t *table, ulint col_nr);
374
375/** Check if the table has a given (non_virtual) column.
376@param[in] table table object
377@param[in] col_name column name
378@param[in] col_nr column number guessed, 0 as default
379@return column number if the table has the specified column,
380otherwise table->n_def */
381ulint dict_table_has_column(const dict_table_t *table, const char *col_name,
382 ulint col_nr = 0);
383
384/** Outputs info on a foreign key of a table in a format suitable for
385 CREATE TABLE.
386@param[in] file File where to print
387@param[in] trx Transaction
388@param[in] foreign Foreign key constraint
389@param[in] add_newline Whether to add a newline */
391 dict_foreign_t *foreign,
392 bool add_newline);
393
394/** Tries to find an index whose first fields are the columns in the array,
395 in the same order and is not marked for deletion and is not the same
396 as types_idx.
397 @return matching index, NULL if not found */
398[[nodiscard]] bool dict_foreign_qualify_index(
399 const dict_table_t *table, /*!< in: table */
400 const char **col_names,
401 /*!< in: column names, or NULL
402 to use table->col_names */
403 const char **columns, /*!< in: array of column names */
404 ulint n_cols, /*!< in: number of columns */
405 const dict_index_t *index, /*!< in: index to check */
406 const dict_index_t *types_idx,
407 /*!< in: NULL or an index
408 whose types the column types
409 must match */
410 bool check_charsets,
411 /*!< in: whether to check
412 charsets. only has an effect
413 if types_idx != NULL */
414 ulint check_null);
415/*!< in: nonzero if none of
416the columns must be declared
417NOT NULL */
418
419/* Skip corrupted index */
420static inline void dict_table_skip_corrupt_index(dict_index_t *&index) {
421 while (index && index->is_corrupted()) {
422 index = index->next();
423 }
424}
425
426/* Get the next non-corrupt index */
428 index = index->next();
430}
431
432/** Check if index is auto-generated clustered index.
433@param[in] index index
434
435@return true if index is auto-generated clustered index. */
436static inline bool dict_index_is_auto_gen_clust(const dict_index_t *index);
437
438/** Check whether the index is unique.
439 @return nonzero for unique index, zero for other indexes */
440[[nodiscard]] static inline ulint dict_index_is_unique(
441 const dict_index_t *index); /*!< in: index */
442/** Check whether the index is a Spatial Index.
443 @return nonzero for Spatial Index, zero for other indexes */
444[[nodiscard]] static inline ulint dict_index_is_spatial(
445 const dict_index_t *index); /*!< in: index */
446/** Check whether the index contains a virtual column.
447@param[in] index index
448@return nonzero for index on virtual column, zero for other indexes */
449static inline ulint dict_index_has_virtual(const dict_index_t *index);
450/** Check whether the index is the insert buffer tree.
451 @return nonzero for insert buffer, zero for other indexes */
452[[nodiscard]] static inline ulint dict_index_is_ibuf(
453 const dict_index_t *index); /*!< in: index */
454
455/** Check whether the index consists of descending columns only.
456@param[in] index index tree
457@retval true if index has any descending column
458@retval false if index has only ascending columns */
459[[nodiscard]] static inline bool dict_index_has_desc(const dict_index_t *index);
460/** Check whether the index is a secondary index or the insert buffer tree.
461 @return nonzero for insert buffer, zero for other indexes */
462[[nodiscard]] static inline ulint dict_index_is_sec_or_ibuf(
463 const dict_index_t *index); /*!< in: index */
464
465/** Get all the FTS indexes on a table.
466@param[in] table table
467@param[out] indexes all FTS indexes on this table
468@return number of FTS indexes */
470
472
473/** Gets the number of virtual columns in a table in the dictionary cache.
474@param[in] table the table to check
475@return number of virtual columns of a table */
477
478/** Check if a table has indexed virtual columns
479@param[in] table the table to check
480@return true is the table has indexed virtual columns */
482
483#ifndef UNIV_HOTBACKUP
484/** Gets the approximately estimated number of rows in the table.
485 @return estimated number of rows */
486[[nodiscard]] static inline uint64_t dict_table_get_n_rows(
487 const dict_table_t *table); /*!< in: table */
488/** Increment the number of rows in the table by one.
489 Notice that this operation is not protected by any latch, the number is
490 approximate. */
491static inline void dict_table_n_rows_inc(
492 dict_table_t *table); /*!< in/out: table */
493/** Decrement the number of rows in the table by one.
494 Notice that this operation is not protected by any latch, the number is
495 approximate. */
496static inline void dict_table_n_rows_dec(
497 dict_table_t *table); /*!< in/out: table */
498#endif /* !UNIV_HOTBACKUP */
499
500/** Get nth virtual column according to its original MySQL table position
501@param[in] table target table
502@param[in] col_nr column number in MySQL Table definition
503@return dict_v_col_t ptr */
505 ulint col_nr);
506
507#ifdef UNIV_DEBUG
508/** Gets the nth virtual column of a table.
509@param[in] table table
510@param[in] pos position of virtual column
511@return pointer to virtual column object */
513 ulint pos);
514
515#else /* UNIV_DEBUG */
516/* Get nth virtual columns */
517#define dict_table_get_nth_v_col(table, pos) ((table)->v_cols + (pos))
518#endif /* UNIV_DEBUG */
519/** Gets the given system column number of a table.
520@param[in] table Table.
521@param[in] sys DATA_ROW_ID, ...
522@return column number */
523[[nodiscard]] static inline ulint dict_table_get_sys_col_no(
524 const dict_table_t *table, ulint sys);
525/** Check whether the table uses the compact page format.
526 @return true if table uses the compact page format */
527[[nodiscard]] static inline bool dict_table_is_comp(
528 const dict_table_t *table); /*!< in: table */
529
530/** Determine if a table uses atomic BLOBs (no locally stored prefix).
531@param[in] table InnoDB table
532@return whether BLOBs are atomic */
533[[nodiscard]] static inline bool dict_table_has_atomic_blobs(
534 const dict_table_t *table);
535
536#ifndef UNIV_HOTBACKUP
537/** Set the various values in a dict_table_t::flags pointer.
538@param[in,out] flags Pointer to a 4 byte Table Flags
539@param[in] format File Format
540@param[in] zip_ssize Zip Shift Size
541@param[in] use_data_dir Table uses DATA DIRECTORY
542@param[in] shared_space Table uses a General Shared Tablespace */
543static inline void dict_tf_set(uint32_t *flags, rec_format_t format,
544 uint32_t zip_ssize, bool use_data_dir,
545 bool shared_space);
546
547/** Initialize a dict_table_t::flags pointer.
548@param[in] compact Table uses Compact or greater
549@param[in] zip_ssize Zip Shift Size (log 2 minus 9)
550@param[in] atomic_blobs Table uses Compressed or Dynamic
551@param[in] data_dir Table uses DATA DIRECTORY
552@param[in] shared_space Table uses a General Shared Tablespace */
553static inline uint32_t dict_tf_init(bool compact, ulint zip_ssize,
554 bool atomic_blobs, bool data_dir,
555 bool shared_space);
556
557/** Convert a 32 bit integer table flags to the 32 bit FSP Flags.
558Fsp Flags are written into the tablespace header at the offset
559FSP_SPACE_FLAGS and are also stored in the fil_space_t::flags field.
560The following chart shows the translation of the low order bit.
561Other bits are the same.
562========================= Low order bit ==========================
563 | REDUNDANT | COMPACT | COMPRESSED | DYNAMIC
564dict_table_t::flags | 0 | 1 | 1 | 1
565fil_space_t::flags | 0 | 0 | 1 | 1
566==================================================================
567@param[in] table_flags dict_table_t::flags
568@return tablespace flags (fil_space_t::flags) */
569uint32_t dict_tf_to_fsp_flags(uint32_t table_flags);
570
571/** Extract the page size info from table flags.
572@param[in] flags flags
573@return a structure containing the compressed and uncompressed
574page sizes and a boolean indicating if the page is compressed. */
575static inline const page_size_t dict_tf_get_page_size(uint32_t flags);
576
577#endif /* !UNIV_HOTBACKUP */
578
579/** Determine the extent size (in pages) for the given table
580@param[in] table the table whose extent size is being
581 calculated.
582@return extent size in pages (256, 128 or 64) */
584
585/** Get the table page size.
586@param[in] table table
587@return compressed page size, or 0 if not compressed */
588[[nodiscard]] static inline const page_size_t dict_table_page_size(
589 const dict_table_t *table);
590
591#ifndef UNIV_HOTBACKUP
592/** Obtain exclusive locks on all index trees of the table. This is to prevent
593 accessing index trees while InnoDB is updating internal metadata for
594 operations such as FLUSH TABLES. */
595static inline void dict_table_x_lock_indexes(
596 dict_table_t *table); /*!< in: table */
597/** Release the exclusive locks on all index tree. */
599 dict_table_t *table); /*!< in: table */
600/** Check if the table has an FTS index.
601 @return true if table has an FTS index */
602[[nodiscard]] static inline bool dict_table_has_fts_index(
603 dict_table_t *table); /*!< in: table */
604#ifdef UNIV_DEBUG
605/** Validate no active background threads to cause purge or rollback
606 operations. */
608#endif /* UNIV_DEBUG */
609#endif /* !UNIV_HOTBACKUP */
610/** Checks if a column is in the ordering columns of the clustered index of a
611 table. Column prefixes are treated like whole columns.
612 @return true if the column, or its prefix, is in the clustered key */
613[[nodiscard]] bool dict_table_col_in_clustered_key(
614 const dict_table_t *table, /*!< in: table */
615 ulint n); /*!< in: column number */
616/** Copies types of virtual columns contained in table to tuple and sets all
617fields of the tuple to the SQL NULL value. This function should
618be called right after dtuple_create().
619@param[in,out] tuple data tuple
620@param[in] table table */
622/** Copies types of columns contained in table to tuple and sets all
623 fields of the tuple to the SQL NULL value. This function should
624 be called right after dtuple_create(). */
625void dict_table_copy_types(dtuple_t *tuple, /*!< in/out: data tuple */
626 const dict_table_t *table); /*!< in: table */
627#ifndef UNIV_HOTBACKUP
628/********************************************************************
629Wait until all the background threads of the given table have exited, i.e.,
630bg_threads == 0. Note: bg_threads_mutex must be reserved when
631calling this. */
633 dict_table_t *table, /* in: table */
634 std::chrono::microseconds delay); /* in: time to wait between
635 checks of bg_threads. */
636
637/** Look up an index among already opened tables. Does not attempt to open
638tables that are not available in the dictionary cache. This behaviour is fine
639for information schema's scenarios - use dd_table_open_on_id() if you need
640to access index meta-data reliably.
641@param[in] id index identifier
642@return index or NULL if not found */
643[[nodiscard]] const dict_index_t *dict_index_find(const index_id_t &id);
644
645/** Make room in the table cache by evicting an unused table. The unused table
646 should not be part of FK relationship and currently not used in any user
647 transaction. There is no guarantee that it will remove a table.
648 @return number of tables evicted. */
650 ulint max_tables, /*!< in: max tables allowed in cache */
651 ulint pct_check); /*!< in: max percent to check */
652
653constexpr uint32_t BIG_ROW_SIZE = 1024;
654
655/** Adds an index to the dictionary cache.
656@param[in,out] table table on which the index is
657@param[in,out] index index; NOTE! The index memory
658 object is freed in this function!
659@param[in] page_no root page number of the index
660@param[in] strict true=refuse to create the index
661 if records could be too big to fit in
662 an B-tree page
663@return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */
665 dict_index_t *index,
666 page_no_t page_no, bool strict);
667
668/** Clears the virtual column's index list before index is being freed.
669@param[in] index Index being freed */
671
672/** Adds an index to the dictionary cache, with possible indexing newly
673added column.
674@param[in,out] table table on which the index is
675@param[in,out] index index; NOTE! The index memory
676 object is freed in this function!
677@param[in] add_v new virtual column that being added along with
678 an add index call
679@param[in] page_no root page number of the index
680@param[in] strict true=refuse to create the index
681 if records could be too big to fit in
682 an B-tree page
683@return DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION */
685 dict_table_t *table, dict_index_t *index, const dict_add_v_col_t *add_v,
686 page_no_t page_no, bool strict);
687#endif /* !UNIV_HOTBACKUP */
688/** Gets the number of fields in the internal representation of an index,
689 including fields added by the dictionary system.
690 @return number of fields */
691[[nodiscard]] static inline ulint dict_index_get_n_fields(
692 const dict_index_t *index); /*!< in: an internal
693 representation of index (in
694 the dictionary cache) */
695/** Gets the number of fields in the internal representation of an index
696 that uniquely determine the position of an index entry in the index, if
697 we do not take multiversioning into account: in the B-tree use the value
698 returned by dict_index_get_n_unique_in_tree.
699 @return number of fields */
700[[nodiscard]] static inline ulint dict_index_get_n_unique(
701 const dict_index_t *index); /*!< in: an internal representation
702 of index (in the dictionary cache) */
703/** Gets the number of fields in the internal representation of an index
704 which uniquely determine the position of an index entry in the index, if
705 we also take multiversioning into account.
706 @return number of fields */
707[[nodiscard]] static inline ulint dict_index_get_n_unique_in_tree(
708 const dict_index_t *index); /*!< in: an internal representation
709 of index (in the dictionary cache) */
710
711/** The number of fields in the nonleaf page of spatial index, except
712the page no field. */
713constexpr uint32_t DICT_INDEX_SPATIAL_NODEPTR_SIZE = 1;
714/**
715Gets the number of fields on nonleaf page level in the internal representation
716of an index which uniquely determine the position of an index entry in the
717index, if we also take multiversioning into account. Note, it doesn't
718include page no field.
719@param[in] index index
720@return number of fields */
721[[nodiscard]] static inline uint16_t dict_index_get_n_unique_in_tree_nonleaf(
722 const dict_index_t *index);
723/** Gets the number of user-defined ordering fields in the index. In the
724 internal representation we add the row id to the ordering fields to make all
725 indexes unique, but this function returns the number of fields the user defined
726 in the index as ordering fields.
727 @return number of fields */
729 const dict_index_t *index); /*!< in: an internal representation
730 of index (in the dictionary cache) */
731/** Returns true if the index contains a column or a prefix of that column.
732@param[in] index index
733@param[in] n column number
734@param[in] is_virtual whether it is a virtual col
735@return true if contains the column or its prefix */
736[[nodiscard]] bool dict_index_contains_col_or_prefix(const dict_index_t *index,
737 ulint n, bool is_virtual);
738/** Looks for a matching field in an index. The column has to be the same. The
739 column in index must be complete, or must contain a prefix longer than the
740 column in index2. That is, we must be able to construct the prefix in index2
741 from the prefix in index.
742 @return position in internal representation of the index;
743 ULINT_UNDEFINED if not contained */
745 const dict_index_t *index, /*!< in: index from which to search */
746 const dict_index_t *index2, /*!< in: index */
747 ulint n); /*!< in: field number in index2 */
748/** Looks for non-virtual column n position in the clustered index.
749 @return position in internal representation of the clustered index */
751 const dict_table_t *table, /*!< in: table */
752 ulint n); /*!< in: column number */
753
754/** Get the innodb column position for a non-virtual column according to
755its original MySQL table position n
756@param[in] table table
757@param[in] n MySQL column position
758@return column position in InnoDB */
760
761/** Copies types of fields contained in index to tuple.
762@param[in,out] tuple Data tuple
763@param[in] index Index
764@param[in] n_fields Number of field types to copy */
765void dict_index_copy_types(dtuple_t *tuple, const dict_index_t *index,
766 ulint n_fields);
767
768#ifdef UNIV_DEBUG
769/** Checks that a tuple has n_fields_cmp value in a sensible range, so that
770 no comparison can occur with the page number field in a node pointer.
771 @return true if ok */
772[[nodiscard]] bool dict_index_check_search_tuple(
773 const dict_index_t *index, /*!< in: index tree */
774 const dtuple_t *tuple); /*!< in: tuple used in a search */
775/** Whether and when to allow temporary index names */
777 /** Require all indexes to be complete. */
779 /** Allow aborted online index creation. */
781 /** Allow partial indexes to exist. */
784
785/** Check for duplicate index entries in a table [using the index name]
786@param[in] table Check for dup indexes in this table
787@param[in] check Whether and when to allow temporary index names */
789 enum check_name check);
790
791/** Check if a table is a temporary table with compressed row format,
792we should always expect false.
793@param[in] table table
794@return true if it's a compressed temporary table, false otherwise */
796#endif /* UNIV_DEBUG */
797/** Builds a node pointer out of a physical record and a page number.
798 @return own: node pointer */
800 const dict_index_t *index, /*!< in: index */
801 const rec_t *rec, /*!< in: record for which
802 to build node pointer */
803 page_no_t page_no, /*!< in: page number to
804 put in node pointer */
805 mem_heap_t *heap, /*!< in: memory heap where
806 pointer created */
807 ulint level); /*!< in: level of rec in tree:
808 0 means leaf level */
809/** Copies an initial segment of a physical record, long enough to specify an
810index entry uniquely. In case buf is nullptr or the buf_size is not enough to
811store the prefix, the new buffer will be allocated.
812@param[in] index index
813@param[in] rec record for which to copy prefix
814@param[out] n_fields number of fields copied
815@param[in,out] buf memory buffer for the copied prefix, or nullptr
816@param[in,out] buf_size buffer size, size of allocated buffer
817@return pointer to the prefix record */
818[[nodiscard]] rec_t *dict_index_copy_rec_order_prefix(const dict_index_t *index,
819 const rec_t *rec,
820 ulint *n_fields,
821 byte **buf,
822 size_t *buf_size);
823/** Builds a typed data tuple out of a physical record.
824 @return own: data tuple */
826 dict_index_t *index, /*!< in: index */
827 rec_t *rec, /*!< in: record for which to build data tuple */
828 ulint n_fields, /*!< in: number of data fields */
829 mem_heap_t *heap); /*!< in: memory heap where tuple created */
830/** Gets the space id of the root of the index tree.
831 @return space id */
832[[nodiscard]] static inline space_id_t dict_index_get_space(
833 const dict_index_t *index); /*!< in: index */
834
835/** Sets the space id of the root of the index tree.
836@param[in,out] index index
837@param[in] space space id */
838static inline void dict_index_set_space(dict_index_t *index, space_id_t space);
839
840/** Gets the page number of the root of the index tree.
841 @return page number */
842[[nodiscard]] static inline page_no_t dict_index_get_page(
843 const dict_index_t *tree); /*!< in: index */
844/** Gets the read-write lock of the index tree.
845 @return read-write lock */
846[[nodiscard]] static inline rw_lock_t *dict_index_get_lock(
847 dict_index_t *index); /*!< in: index */
848/** Returns free space reserved for future updates of records. This is
849 relevant only in the case of many consecutive inserts, as updates
850 which make the records bigger might fragment the index.
851 @return number of free bytes on page, reserved for updates */
853
854/* Online index creation @{ */
855/** Gets the status of online index creation.
856 @return the status */
857[[nodiscard]] static inline enum online_index_status
859 const dict_index_t *index); /*!< in: secondary index */
860
861/** Sets the status of online index creation.
862@param[in,out] index index
863@param[in] status status */
866
867/** Determines if a secondary index is being or has been created online,
868 or if the table is being rebuilt online, allowing concurrent modifications
869 to the table.
870 @retval true if the index is being or has been built online, or
871 if this is a clustered index and the table is being or has been rebuilt online
872 @retval false if the index has been created or the table has been
873 rebuilt completely */
874[[nodiscard]] static inline bool dict_index_is_online_ddl(
875 const dict_index_t *index); /*!< in: index */
876/** Calculates the minimum record length in an index. */
878 const dict_index_t *index); /*!< in: index */
879/** Reserves the dictionary system mutex for MySQL. */
881/** Releases the dictionary system mutex for MySQL. */
883
884#ifndef UNIV_HOTBACKUP
885/** Create a dict_table_t's stats latch or delay for lazy creation.
886This function is only called from either single threaded environment
887or from a thread that has not shared the table object with other threads.
888@param[in,out] table table whose stats latch to create
889@param[in] enabled if false then the latch is disabled
890and dict_table_stats_lock()/unlock() become noop on this table. */
892
893/** Destroy a dict_table_t's stats latch.
894This function is only called from either single threaded environment
895or from a thread that has not shared the table object with other threads.
896@param[in,out] table table whose stats latch to destroy */
898
899/** Lock the appropriate latch to protect a given table's statistics.
900@param[in] table table whose stats to lock
901@param[in] latch_mode RW_S_LATCH or RW_X_LATCH */
903
904/** Unlock the latch that has been locked by dict_table_stats_lock().
905@param[in] table table whose stats to unlock
906@param[in] latch_mode RW_S_LATCH or RW_X_LATCH */
908
909/** Checks if the database name in two table names is the same.
910 @return true if same db name */
911[[nodiscard]] bool dict_tables_have_same_db(
912 const char *name1, /*!< in: table name in the
913 form dbname '/' tablename */
914 const char *name2); /*!< in: table name in the
915 form dbname '/' tablename */
916/** Get an index by name.
917@param[in] table the table where to look for the index
918@param[in] name the index name to look for
919@param[in] committed true=search for committed,
920false=search for uncommitted
921@return index, NULL if does not exist */
923 const char *name,
924 bool committed = true);
925/** Get an index by name.
926@param[in] table the table where to look for the index
927@param[in] name the index name to look for
928@param[in] committed true=search for committed,
929false=search for uncommitted
930@return index, NULL if does not exist */
932 const dict_table_t *table, const char *name, bool committed = true) {
933 return (dict_table_get_index_on_name(const_cast<dict_table_t *>(table), name,
934 committed));
935}
936
937/** Check whether a column exists in an FTS index.
938@param[in] indexes Vector containing only FTS indexes
939@param[in] col_no Column number to search for.
940@param[in] is_virtual Whether it is a virtual column.
941@return ULINT_UNDEFINED if no match else the offset within the vector. */
942[[nodiscard]] static inline ulint dict_table_is_fts_column(ib_vector_t *indexes,
943 ulint col_no,
944 bool is_virtual);
945/** Prevent table eviction by moving a table to the non-LRU list from the
946 LRU list if it is not already there. */
948 dict_table_t *table); /*!< in: table to prevent eviction */
949
950/** Allow the table to be evicted by moving a table to the LRU list from
951the non-LRU list if it is not already there.
952@param[in] table InnoDB table object can be evicted */
954
955/** Move this table to non-LRU list for DDL operations if it's
956currently not there. This also prevents later opening table via DD objects,
957when the table name in InnoDB doesn't match with DD object.
958@param[in,out] table Table to put in non-LRU list */
960
961/** Move this table to LRU list after DDL operations if it was moved
962to non-LRU list
963@param[in,out] table Table to put in LRU list */
965
966/** Move a table to the non LRU end of the LRU list. */
968 dict_table_t *table); /*!< in: table to move from LRU to non-LRU */
969
970/** Move a table to the LRU end from the non LRU list.
971@param[in] table InnoDB table object */
973
974/** Move to the most recently used segment of the LRU list. */
975void dict_move_to_mru(dict_table_t *table); /*!< in: table to move to MRU */
976
977/** Maximum number of columns in a foreign key constraint. Please Note MySQL
978has a much lower limit on the number of columns allowed in a foreign key
979constraint */
980constexpr uint32_t MAX_NUM_FK_COLUMNS = 500;
981
982/* Buffers for storing detailed information about the latest foreign key
983and unique key errors */
985extern ib_mutex_t dict_foreign_err_mutex; /* mutex protecting the
986 foreign key error messages */
987#endif /* !UNIV_HOTBACKUP */
988
989/** the dictionary system */
990extern dict_sys_t *dict_sys;
991#ifndef UNIV_HOTBACKUP
992/** the data dictionary rw-latch protecting dict_sys */
994
995/** Forward declaration */
996class DDTableBuffer;
997#endif /* !UNIV_HOTBACKUP */
998struct dict_persist_t;
999
1000/** the dictionary persisting structure */
1002
1003/* Dictionary system struct */
1005#ifndef UNIV_HOTBACKUP
1006 DictSysMutex mutex; /*!< mutex protecting the data
1007 dictionary; protects also the
1008 disk-based dictionary system tables;
1009 this mutex serializes CREATE TABLE
1010 and DROP TABLE, as well as reading
1011 the dictionary data for a table from
1012 system tables */
1013#endif /* !UNIV_HOTBACKUP */
1014 row_id_t row_id; /*!< the next row id to assign;
1015 NOTE that at a checkpoint this
1016 must be written to the dict system
1017 header and flushed to a file; in
1018 recovery this must be derived from
1019 the log records */
1020 hash_table_t *table_hash; /*!< hash table of the tables, based
1021 on name */
1022 hash_table_t *table_id_hash; /*!< hash table of the tables, based
1023 on id */
1024 size_t size; /*!< varying space in bytes occupied
1025 by the data dictionary table and
1026 index objects */
1027 /** Handler to sys_* tables, they're only for upgrade */
1028 dict_table_t *sys_tables; /*!< SYS_TABLES table */
1029 dict_table_t *sys_columns; /*!< SYS_COLUMNS table */
1030 dict_table_t *sys_indexes; /*!< SYS_INDEXES table */
1031 dict_table_t *sys_fields; /*!< SYS_FIELDS table */
1032 dict_table_t *sys_virtual; /*!< SYS_VIRTUAL table */
1033
1034 /** Permanent handle to mysql.innodb_table_stats */
1036 /** Permanent handle to mysql.innodb_index_stats */
1038 /** Permanent handle to mysql.innodb_ddl_log */
1040 /** Permanent handle to mysql.innodb_dynamic_metadata */
1043
1044 /** List of tables that can be evicted from the cache */
1046 /** List of tables that can't be evicted from the cache */
1048
1049 /** Iterate each table.
1050 @tparam Functor visitor
1051 @param[in,out] functor to be invoked on each table */
1052 template <typename Functor>
1053 void for_each_table(Functor &functor) {
1055
1057 const auto n_cells = hash->get_n_cells();
1058 for (ulint i = 0; i < n_cells; i++) {
1059 for (dict_table_t *table =
1060 static_cast<dict_table_t *>(hash_get_first(hash, i));
1061 table;
1062 table = static_cast<dict_table_t *>(HASH_GET_NEXT(id_hash, table))) {
1063 functor(table);
1064 }
1065 }
1066
1067 mutex_exit(&mutex);
1068 }
1069
1070 /** Check if a tablespace id is a reserved tablespace ID
1071 @param[in] space tablespace id to check
1072 @return true if a reserved tablespace id, otherwise false */
1073 static bool is_reserved(space_id_t space) {
1074 return (space >= dict_sys_t::s_reserved_space_id);
1075 }
1076
1077 /** Set of ids of DD tables */
1078 static std::set<dd::Object_id> s_dd_table_ids;
1079
1080 /** Check if a table is hardcoded. it only includes the dd tables
1081 @param[in] id table ID
1082 @retval true if the table is a persistent hard-coded table
1083 (dict_table_t::is_temporary() will not hold)
1084 @retval false if the table is not hard-coded
1085 (it can be persistent or temporary) */
1086 static bool is_dd_table_id(table_id_t id) {
1087 return (s_dd_table_ids.find(id) != s_dd_table_ids.end());
1088 }
1089
1090 /** The first ID of the redo log pseudo-tablespace */
1091 static constexpr space_id_t s_log_space_id = 0xFFFFFFF0UL;
1092
1093 /** Use maximum UINT value to indicate invalid space ID. */
1094 static constexpr space_id_t s_invalid_space_id = 0xFFFFFFFF;
1095
1096 /** The data dictionary tablespace ID. */
1097 static constexpr space_id_t s_dict_space_id = 0xFFFFFFFE;
1098
1099 /** The innodb_temporary tablespace ID. */
1100 static constexpr space_id_t s_temp_space_id = 0xFFFFFFFD;
1101
1102 /** The number of space IDs dedicated to each undo tablespace */
1103 static constexpr space_id_t s_undo_space_id_range = 400000;
1104
1105 /** The lowest undo tablespace ID. */
1108
1109 /** The highest undo tablespace ID. */
1111
1112 /** Start space_ids for temporary tablespaces. */
1114
1115 /** The number of space IDs dedicated to temporary tablespaces */
1116 static constexpr space_id_t s_temp_space_id_range = 400000;
1117
1118 /** Lowest temporary general space id */
1121
1122 /** The first reserved tablespace ID */
1124
1125 /** The dd::Tablespace::id of the dictionary tablespace. */
1126 static constexpr dd::Object_id s_dd_dict_space_id = 1;
1127
1128 /** The dd::Tablespace::id of innodb_system. */
1129 static constexpr dd::Object_id s_dd_sys_space_id = 2;
1130
1131 /** The dd::Tablespace::id of innodb_temporary. */
1132 static constexpr dd::Object_id s_dd_temp_space_id = 3;
1133
1134 /** The name of the data dictionary tablespace. */
1135 static const char *s_dd_space_name;
1136
1137 /** The file name of the data dictionary tablespace. */
1138 static const char *s_dd_space_file_name;
1139
1140 /** The name of the hard-coded system tablespace. */
1141 static const char *s_sys_space_name;
1142
1143 /** The name of the predefined temporary tablespace. */
1144 static const char *s_temp_space_name;
1145
1146 /** The file name of the predefined temporary tablespace. */
1147 static const char *s_temp_space_file_name;
1148
1149 /** The hard-coded tablespace name innodb_file_per_table. */
1150 static const char *s_file_per_table_name;
1151
1152 /** These two undo tablespaces cannot be dropped. */
1155
1156 /** The table ID of mysql.innodb_dynamic_metadata */
1158
1159 /** The clustered index ID of mysql.innodb_dynamic_metadata */
1161};
1162
1163/** Structure for persisting dynamic metadata of data dictionary */
1165#ifndef UNIV_HOTBACKUP
1166 /** Write dynamic metadata to DD buffer table immediately when such data is
1167 generated. By default, the metadata is first written to redo log and then to
1168 the DD buffer table during checkpoint. This is going to hurt auto increment
1169 performance and Currently enabled by clone for short time to eliminate
1170 dependency with dynamic metadata recovered from redo log. */
1172 public:
1173 /** Constructor to immediate persisting mode.
1174 @param[in,out] persister dictionary persister */
1175 Enable_immediate(dict_persist_t *persister);
1176
1177 /** Destructor to switch back to default mode. */
1179
1180 /** Disable copy construction */
1182
1183 /** Disable assignment */
1185
1186 private:
1187 /** Dictionary persister */
1189 };
1190
1191 /** @return true if need to write dynamic metadata to DD buffer table
1192 immediately after logging. */
1194 return m_persist_immediately.load();
1195 }
1196
1197 /** List of tables whose dirty_status are marked as METADATA_DIRTY,
1198 or METADATA_BUFFERED. It's protected by the mutex */
1201#endif
1202
1203 /** Mutex to protect data in this structure, also the
1204 dict_table_t::dirty_status and
1205 dict_table_t::in_dirty_dict_tables_list
1206 This mutex should be low-level one so that it can be used widely
1207 when necessary, so its level had to be above SYNC_LOG. However,
1208 after this mutex, persister may have to access B-tree and require
1209 tree latch, the latch level of this mutex then has to be right
1210 before the SYNC_INDEX_TREE. */
1211 ib_mutex_t mutex;
1212
1213 /** Number of the tables which are of status METADATA_DIRTY.
1214 It's protected by the mutex */
1215 std::atomic<uint32_t> num_dirty_tables;
1216
1217 /** If set, dynamic metadata is saved to DD buffer table immediately.
1218 Currently we consider only auto increment PM_TABLE_AUTO_INC. Corrupt
1219 index PM_INDEX_CORRUPTED is not needed to be saved immediately. */
1220 std::atomic<bool> m_persist_immediately;
1221
1222#ifndef UNIV_HOTBACKUP
1223 /** DDTableBuffer table for persistent dynamic metadata */
1225#endif /* !UNIV_HOTBACKUP */
1226
1227 /** Collection of instances to persist dynamic metadata */
1229};
1230
1231#ifndef UNIV_HOTBACKUP
1232/** dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records */
1234
1235/** Inits dict_ind_redundant. */
1236void dict_ind_init(void);
1237
1238/** Converts a database and table name from filesystem encoding (e.g.
1239"@code d@i1b/a@q1b@1Kc @endcode", same format as used in dict_table_t::name)
1240in two strings in UTF8MB3 encoding (e.g. dцb and aюbØc). The output buffers must
1241be at least MAX_DB_UTF8MB3_LEN and MAX_TABLE_UTF8MB3_LEN bytes.
1242@param[in] db_and_table database and table names,
1243 e.g. "@code d@i1b/a@q1b@1Kc @endcode"
1244@param[out] db_utf8mb3 database name, e.g. dцb
1245@param[in] db_utf8mb3_size db_utf8mb3 size
1246@param[out] table_utf8mb3 table name, e.g. aюbØc
1247@param[in] table_utf8mb3_size table_utf8mb3 size */
1248void dict_fs2utf8(const char *db_and_table, char *db_utf8mb3,
1249 size_t db_utf8mb3_size, char *table_utf8mb3,
1250 size_t table_utf8mb3_size);
1251
1252/** Resize the hash tables based on the current buffer pool size. */
1253void dict_resize();
1254
1255/** Wrapper for the mysql.innodb_dynamic_metadata used to buffer the persistent
1256dynamic metadata.
1257This should be a table with only clustered index, no delete-marked records,
1258no locking, no undo logging, no purge, no adaptive hash index.
1259We should always use low level btr functions to access and modify the table.
1260Accessing this table should be protected by dict_sys->mutex */
1262 public:
1263 /** Default constructor */
1264 DDTableBuffer();
1265
1266 /** Destructor */
1268
1269 /** Replace the dynamic metadata for a specific table
1270 @param[in] id table id
1271 @param[in] version table dynamic metadata version
1272 @param[in] metadata the metadata we want to replace
1273 @param[in] len the metadata length
1274 @return DB_SUCCESS or error code */
1275 dberr_t replace(table_id_t id, uint64_t version, const byte *metadata,
1276 size_t len);
1277
1278 /** Remove the whole row for a specific table
1279 @param[in] id table id
1280 @return DB_SUCCESS or error code */
1282
1283 /** Truncate the table. We can call it after all the dynamic
1284 metadata has been written back to DD table */
1285 void truncate(void);
1286
1287 /** Get the buffered metadata for a specific table, the caller
1288 has to delete the returned std::string object by ut::delete_
1289 @param[in] id table id
1290 @param[out] version table dynamic metadata version
1291 @return the metadata saved in a vector object, if nothing, the
1292 vector would be empty */
1293 std::vector<byte> get(table_id_t id, uint64_t *version);
1294
1295 private:
1296 /** Initialize m_index, the in-memory clustered index of the table
1297 and two tuples used in this class */
1298 void init();
1299
1300 /** Open the mysql.innodb_dynamic_metadata when DD is not fully up */
1301 void open();
1302
1303 /** Create the search and replace tuples */
1304 void create_tuples();
1305
1306 /** Initialize the id field of tuple
1307 @param[out] tuple the tuple to be initialized
1308 @param[in] id table id */
1309 void init_tuple_with_id(dtuple_t *tuple, table_id_t id);
1310
1311 /** Free the things initialized in init() */
1312 void close();
1313
1314 /** Prepare for a update on METADATA field
1315 @param[in] entry clustered index entry to replace rec
1316 @param[in] rec clustered index record
1317 @return update vector of differing fields without system columns,
1318 or NULL if there isn't any different field */
1319 upd_t *update_set_metadata(const dtuple_t *entry, const rec_t *rec);
1320
1321 private:
1322 /** The clustered index of this system table */
1324
1325 /** The heap used for dynamic allocations, which should always
1326 be freed before return */
1328
1329 /** The heap used during replace() operation, which should always
1330 be freed before return */
1332
1333 /** The heap used to create the search tuple and replace tuple */
1335
1336 /** The tuple used to search for specified table, it's protected
1337 by dict_persist->mutex */
1339
1340 /** The tuple used to replace for specified table, it's protected
1341 by dict_persist->mutex */
1343
1344 private:
1345 /** Column number of mysql.innodb_dynamic_metadata.table_id */
1346 static constexpr unsigned TABLE_ID_COL_NO = 0;
1347
1348 /** Column number of mysql.innodb_dynamic_metadata.version */
1349 static constexpr unsigned VERSION_COL_NO = 1;
1350
1351 /** Column number of mysql.innodb_dynamic_metadata.metadata */
1352 static constexpr unsigned METADATA_COL_NO = 2;
1353
1354 /** Number of user columns */
1355 static constexpr unsigned N_USER_COLS = METADATA_COL_NO + 1;
1356
1357 /** Number of columns */
1358 static constexpr unsigned N_COLS = N_USER_COLS + DATA_N_SYS_COLS;
1359
1360 /** Clustered index field number of
1361 mysql.innodb_dynamic_metadata.table_id */
1362 static constexpr unsigned TABLE_ID_FIELD_NO = TABLE_ID_COL_NO;
1363
1364 /** Clustered index field number of
1365 mysql.innodb_dynamic_metadata.version */
1366 static constexpr unsigned VERSION_FIELD_NO = VERSION_COL_NO + 2;
1367
1368 /** Clustered index field number of
1369 mysql.innodb_dynamic_metadata.metadata
1370 Plusing 2 here skips the DATA_TRX_ID and DATA_ROLL_PTR fields */
1371 static constexpr unsigned METADATA_FIELD_NO = METADATA_COL_NO + 2;
1372
1373 /** Number of fields in the clustered index */
1374 static constexpr unsigned N_FIELDS = METADATA_FIELD_NO + 1;
1375};
1376
1377/** Mark the dirty_status of a table as METADATA_DIRTY, and add it to the
1378dirty_dict_tables list if necessary.
1379@param[in,out] table table */
1381#endif /* !UNIV_HOTBACKUP */
1382
1383/** Flags an index corrupted in the data dictionary cache only. This
1384is used to mark a corrupted index when index's own dictionary
1385is corrupted, and we would force to load such index for repair purpose.
1386Besides, we have to write a redo log.
1387We don't want to hold dict_sys->mutex here, so that we can set index as
1388corrupted in some low-level functions. We would only set the flags from
1389not corrupted to corrupted when server is running, so it should be safe
1390to set it directly.
1391@param[in,out] index index, must not be NULL */
1393
1394#ifndef UNIV_HOTBACKUP
1395
1396/** Check if there is any latest persistent dynamic metadata recorded
1397in DDTableBuffer table of the specific table. If so, read the metadata and
1398update the table object accordingly. It's used when loading table.
1399@param[in] table table object */
1401
1402/** Check if any table has any dirty persistent data, if so
1403write dirty persistent data of table to mysql.innodb_dynamic_metadata
1404accordingly. */
1406
1407/** Sets merge_threshold in the SYS_INDEXES
1408@param[in,out] index index
1409@param[in] merge_threshold value to set */
1411
1412#ifdef UNIV_DEBUG
1413/** Sets merge_threshold for all indexes in dictionary cache for debug.
1414@param[in] merge_threshold_all value to set for all indexes */
1415void dict_set_merge_threshold_all_debug(uint merge_threshold_all);
1416#endif /* UNIV_DEBUG */
1417
1418/** Validate the table flags.
1419@param[in] flags Table flags
1420@return true if valid. */
1421static inline bool dict_tf_is_valid(uint32_t flags);
1422
1423/** Validate both table flags and table flags2 and make sure they
1424are compatible.
1425@param[in] flags Table flags
1426@param[in] flags2 Table flags2
1427@return true if valid. */
1428static inline bool dict_tf2_is_valid(uint32_t flags, uint32_t flags2);
1429
1430/** Check if the tablespace for the table has been discarded.
1431 @return true if the tablespace has been discarded. */
1432[[nodiscard]] static inline bool dict_table_is_discarded(
1433 const dict_table_t *table); /*!< in: table to check */
1434
1435/** Check whether the table is DDTableBuffer. See class DDTableBuffer
1436@param[in] table table to check
1437@return true if this is a DDTableBuffer table. */
1439
1440/** Check if the table is in a shared tablespace (System or General).
1441@param[in] table table to check
1442@return true if table is a shared tablespace, false if not. */
1443[[nodiscard]] static inline bool dict_table_in_shared_tablespace(
1444 const dict_table_t *table);
1445
1446/** Check whether locking is disabled for this table.
1447Currently this is done for intrinsic table as their visibility is limited
1448to the connection and the DDTableBuffer as it's protected by
1449dict_persist->mutex.
1450
1451@param[in] table table to check
1452@return true if locking is disabled. */
1453[[nodiscard]] static inline bool dict_table_is_locking_disabled(
1454 const dict_table_t *table);
1455
1456/** Turn-off redo-logging if temporary table.
1457@param[in] table Table to check
1458@param[out] mtr Mini-transaction */
1460 mtr_t *mtr);
1461
1462/** Get table session row-id and increment the row-id counter for next use.
1463@param[in,out] table table handler
1464@return next table local row-id. */
1467
1468/** Get table session trx-id and increment the trx-id counter for next use.
1469@param[in,out] table table handler
1470@return next table local trx-id. */
1473
1474/** Get current session trx-id.
1475@param[in] table table handler
1476@return table local trx-id. */
1478 const dict_table_t *table);
1479
1480/** This function should be called whenever a page is successfully
1481 compressed. Updates the compression padding information. */
1483 dict_index_t *index); /*!< in/out: index to be updated. */
1484/** This function should be called whenever a page compression attempt
1485 fails. Updates the compression padding information. */
1487 dict_index_t *index); /*!< in/out: index to be updated. */
1488/** Return the optimal page size, for which page will likely compress.
1489 @return page size beyond which page may not compress*/
1491 dict_index_t *index); /*!< in: index for which page size
1492 is requested */
1493/** Convert table flag to row format string.
1494 @return row format name */
1496 uint32_t table_flag); /*!< in: row format setting */
1497/** Return maximum size of the node pointer record.
1498 @return maximum size of the record in bytes */
1500 const dict_index_t *index); /*!< in: index */
1501
1502/** Get index by first field of the index.
1503@param[in] table table
1504@param[in] col_index position of column in table
1505@return index which is having first field matches with the field present in
1506field_index position of table */
1508 dict_table_t *table, ulint col_index);
1509#endif /* !UNIV_HOTBACKUP */
1510
1511/** encode number of columns and number of virtual columns in one
15124 bytes value. We could do this because the number of columns in
1513InnoDB is limited to 1017
1514@param[in] n_col number of non-virtual column
1515@param[in] n_v_col number of virtual column
1516@return encoded value */
1517static inline ulint dict_table_encode_n_col(ulint n_col, ulint n_v_col);
1518
1519/** Decode number of virtual and non-virtual columns in one 4 bytes value.
1520@param[in] encoded encoded value
1521@param[in,out] n_col number of non-virtual column
1522@param[in,out] n_v_col number of virtual column */
1523static inline void dict_table_decode_n_col(uint32_t encoded, uint32_t *n_col,
1524 uint32_t *n_v_col);
1525
1526/** Free the virtual column template
1527@param[in,out] vc_templ virtual column template */
1528static inline void dict_free_vc_templ(dict_vcol_templ_t *vc_templ);
1529
1530/** Returns a virtual column's name according to its original
1531MySQL table position.
1532@param[in] table target table
1533@param[in] col_nr column number (nth column in the table)
1534@return column name. */
1536 ulint col_nr);
1537
1538/** Check whether the table have virtual index.
1539@param[in] table InnoDB table
1540@return true if the table have virtual index, false otherwise. */
1542
1543/** Retrieve in-memory index for SDI table.
1544@param[in] tablespace_id innodb tablespace ID
1545@return dict_index_t structure or NULL*/
1547
1548/** Retrieve in-memory table object for SDI table.
1549@param[in] tablespace_id innodb tablespace ID
1550@param[in] dict_locked true if dict_sys mutex is acquired
1551@param[in] is_create true when creating SDI Index
1552@return dict_table_t structure */
1553dict_table_t *dict_sdi_get_table(space_id_t tablespace_id, bool dict_locked,
1554 bool is_create);
1555
1556/** Remove the SDI table from table cache.
1557@param[in] space_id InnoDB tablespace ID
1558@param[in] sdi_table SDI table
1559@param[in] dict_locked true if dict_sys mutex acquired */
1560void dict_sdi_remove_from_cache(space_id_t space_id, dict_table_t *sdi_table,
1561 bool dict_locked);
1562
1563/** Check if the index is SDI index
1564@param[in] index in-memory index structure
1565@return true if index is SDI index else false */
1566static inline bool dict_index_is_sdi(const dict_index_t *index);
1567
1568/** Check if an table id belongs SDI table
1569@param[in] table_id dict_table_t id
1570@return true if table_id is SDI table_id else false */
1571static inline bool dict_table_is_sdi(uint64_t table_id);
1572
1573/** Close SDI table.
1574@param[in] table the in-memory SDI table object */
1576
1577/** Acquire exclusive MDL on SDI tables. This is acquired to
1578prevent concurrent DROP table/tablespace when there is purge
1579happening on SDI table records. Purge will acquire shared
1580MDL on SDI table.
1581
1582Exclusive MDL is transactional(released on trx commit). So
1583for successful acquisition, there should be a valid thd associated
1584with a trx.
1585
1586Acquisition order of SDI MDL and SDI table has to be in the same
1587order:
1588
15891. dd_sdi_acquire_exclusive_mdl
15902. row_drop_table_from_cache()/innodb_drop_tablespace()
1591 ->dict_sdi_remove_from_cache()->dd_table_open_on_id()
1592
1593In purge:
1594
15951. dd_sdi_acquire_shared_mdl
15962. dd_table_open_on_id()
1597
1598@param[in] thd server thread instance
1599@param[in] space_id InnoDB tablespace id
1600@param[in,out] sdi_mdl MDL ticket on SDI table
1601@retval DB_SUCESS on success
1602@retval DB_LOCK_WAIT_TIMEOUT on error */
1604 MDL_ticket **sdi_mdl);
1605
1606/** Acquire shared MDL on SDI tables. This is acquired by purge to
1607prevent concurrent DROP table/tablespace.
1608DROP table/tablespace will acquire exclusive MDL on SDI table
1609
1610Acquisition order of SDI MDL and SDI table has to be in same
1611order:
1612
16131. dd_sdi_acquire_exclusive_mdl
16142. row_drop_table_from_cache()/innodb_drop_tablespace()
1615 ->dict_sdi_remove_from_cache()->dd_table_open_on_id()
1616
1617In purge:
1618
16191. dd_sdi_acquire_shared_mdl
16202. dd_table_open_on_id()
1621
1622MDL should be released by caller
1623@param[in] thd server thread instance
1624@param[in] space_id InnoDB tablespace id
1625@param[in,out] sdi_mdl MDL ticket on SDI table
1626@retval DB_SUCESS on success
1627@retval DB_LOCK_WAIT_TIMEOUT on error */
1629 MDL_ticket **sdi_mdl);
1630
1631/** Check whether the dict_table_t is a partition.
1632A partitioned table on the SQL level is composed of InnoDB tables,
1633where each InnoDB table is a [sub]partition including its secondary indexes
1634which belongs to the partition.
1635@param[in] table Table to check.
1636@return true if the dict_table_t is a partition else false. */
1637static inline bool dict_table_is_partition(const dict_table_t *table);
1638
1639/** Allocate memory for intrinsic cache elements in the index
1640@param[in] index index object */
1642
1643/** Evict all tables that are loaded for applying purge.
1644Since we move the offset of all table ids during upgrade,
1645these tables cannot exist in cache. Also change table_ids
1646of SYS_* tables if they are upgraded from earlier versions */
1648
1649/** @return true if table is InnoDB SYS_* table
1650@param[in] table_id table id */
1651bool dict_table_is_system(table_id_t table_id);
1652
1653/** Build the table_id array of SYS_* tables. This
1654array is used to determine if a table is InnoDB SYSTEM
1655table or not.
1656@return true if successful, false otherwise */
1658
1659/** Change the table_id of SYS_* tables if they have been created after
1660an earlier upgrade. This will update the table_id by adding DICT_MAX_DD_TABLES
1661*/
1663
1664/** Get the tablespace data directory if set, otherwise empty string.
1665@return the data directory */
1666[[nodiscard]] std::string dict_table_get_datadir(const dict_table_t *table);
1667
1668/** Set the compression type for the tablespace of a table
1669@param[in] table The table that should be compressed
1670@param[in] algorithm Text representation of the algorithm
1671@param[in] is_import_op True if it's being set during import operation
1672@return DB_SUCCESS or error code */
1674 const char *algorithm,
1675 bool is_import_op);
1676
1677/** @return true if all base column of virtual column is foreign key column
1678@param[in] vcol in-memory virtual column
1679@param[in] foreign in-memory Foreign key constraint */
1681 dict_foreign_t *foreign);
1682
1683/** Get maximum possible size needed for a field.
1684@param[in] table innodb table definition cache
1685@param[in] index index
1686@param[in] field field
1687@param[out] rec_max_size max record size needed */
1688void get_field_max_size(const dict_table_t *table, const dict_index_t *index,
1689 const dict_field_t *field, size_t &rec_max_size);
1690
1691/** Get the maximum size of a record permissible on an index page.
1692@param[in] table innodb table definition cache
1693@param[in] index index
1694@param[out] page_rec_max maximum size of record on a leaf page
1695@param[out] page_ptr_max maximum size of record on non-leaf page */
1697 const dict_index_t *index, size_t &page_rec_max,
1698 size_t &page_ptr_max);
1699
1700/** validate that maximum possible size of a row is within permissible limit.
1701@param[in] table innodb table definition cache
1702@param[in] index index
1703@param[in] strict true if error is to be reported
1704@param[in] page_rec_max maximum size of possible record on leaf page
1705@param[in] page_ptr_max maximum size of possible record on non-leaf page
1706@param[out] rec_max_size maximum size of record on page
1707@return true if max record size is within limit, false otherwise. */
1709 const dict_index_t *index, bool strict,
1710 const size_t page_rec_max,
1711 const size_t page_ptr_max,
1712 size_t &rec_max_size);
1713
1714#include "dict0dict.ic"
1715
1716#endif
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:46
uint32_t page_no_t
Page number.
Definition: api0api.h:44
Wrapper for the mysql.innodb_dynamic_metadata used to buffer the persistent dynamic metadata.
Definition: dict0dict.h:1261
~DDTableBuffer()
Destructor.
Definition: dict0dict.cc:5069
static constexpr unsigned N_USER_COLS
Number of user columns.
Definition: dict0dict.h:1355
std::vector< byte > get(table_id_t id, uint64_t *version)
Get the buffered metadata for a specific table, the caller has to delete the returned std::string obj...
Definition: dict0dict.cc:5419
void init_tuple_with_id(dtuple_t *tuple, table_id_t id)
Initialize the id field of tuple.
Definition: dict0dict.cc:5224
static constexpr unsigned TABLE_ID_COL_NO
Column number of mysql.innodb_dynamic_metadata.table_id.
Definition: dict0dict.h:1346
mem_heap_t * m_replace_heap
The heap used during replace() operation, which should always be freed before return.
Definition: dict0dict.h:1331
void create_tuples()
Create the search and replace tuples.
Definition: dict0dict.cc:5072
dict_index_t * m_index
The clustered index of this system table.
Definition: dict0dict.h:1323
void init()
Initialize m_index, the in-memory clustered index of the table and two tuples used in this class.
Definition: dict0dict.cc:5115
static constexpr unsigned METADATA_COL_NO
Column number of mysql.innodb_dynamic_metadata.metadata.
Definition: dict0dict.h:1352
static constexpr unsigned VERSION_FIELD_NO
Clustered index field number of mysql.innodb_dynamic_metadata.version.
Definition: dict0dict.h:1366
DDTableBuffer()
Default constructor.
Definition: dict0dict.cc:5061
dtuple_t * m_replace_tuple
The tuple used to replace for specified table, it's protected by dict_persist->mutex.
Definition: dict0dict.h:1342
static constexpr unsigned METADATA_FIELD_NO
Clustered index field number of mysql.innodb_dynamic_metadata.metadata Plusing 2 here skips the DATA_...
Definition: dict0dict.h:1371
void close()
Free the things initialized in init()
Definition: dict0dict.cc:5233
upd_t * update_set_metadata(const dtuple_t *entry, const rec_t *rec)
Prepare for a update on METADATA field.
Definition: dict0dict.cc:5247
void open()
Open the mysql.innodb_dynamic_metadata when DD is not fully up.
Definition: dict0dict.cc:5141
static constexpr unsigned TABLE_ID_FIELD_NO
Clustered index field number of mysql.innodb_dynamic_metadata.table_id.
Definition: dict0dict.h:1362
static constexpr unsigned N_COLS
Number of columns.
Definition: dict0dict.h:1358
static constexpr unsigned N_FIELDS
Number of fields in the clustered index.
Definition: dict0dict.h:1374
dtuple_t * m_search_tuple
The tuple used to search for specified table, it's protected by dict_persist->mutex.
Definition: dict0dict.h:1338
void truncate(void)
Truncate the table.
Definition: dict0dict.cc:5407
dberr_t remove(table_id_t id)
Remove the whole row for a specific table.
Definition: dict0dict.cc:5376
mem_heap_t * m_dynamic_heap
The heap used for dynamic allocations, which should always be freed before return.
Definition: dict0dict.h:1327
mem_heap_t * m_heap
The heap used to create the search tuple and replace tuple.
Definition: dict0dict.h:1334
dberr_t replace(table_id_t id, uint64_t version, const byte *metadata, size_t len)
Replace the dynamic metadata for a specific table.
Definition: dict0dict.cc:5296
static constexpr unsigned VERSION_COL_NO
Column number of mysql.innodb_dynamic_metadata.version.
Definition: dict0dict.h:1349
A granted metadata lock.
Definition: mdl.h:984
Persistent dynamic metadata for a table.
Definition: dict0mem.h:2755
Container of persisters used in the system.
Definition: dict0mem.h:2955
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
Write dynamic metadata to DD buffer table immediately when such data is generated.
Definition: dict0dict.h:1171
~Enable_immediate()
Destructor to switch back to default mode.
Definition: dict0dict.cc:6072
Enable_immediate(dict_persist_t *persister)
Constructor to immediate persisting mode.
Definition: dict0dict.cc:6062
Enable_immediate & operator=(Enable_immediate const &)=delete
Disable assignment.
Enable_immediate(Enable_immediate const &)=delete
Disable copy construction.
dict_persist_t * m_persister
Dictionary persister.
Definition: dict0dict.h:1188
Definition: hash0hash.h:373
size_t get_n_cells()
Returns number of cells in cells[] array.
Definition: hash0hash.h:391
Globally unique index identifier.
Definition: dict0types.h:222
Page size descriptor.
Definition: page0size.h:49
constexpr DWORD buf_size
Definition: create_def.cc:228
SQL data field and tuple.
Data types.
constexpr uint32_t DATA_N_SYS_COLS
number of system columns defined above
Definition: data0type.h:193
dberr_t
Definition: db0err.h:38
page_no_t dict_table_extent_size(const dict_table_t *table)
Determine the extent size (in pages) for the given table.
Definition: dict0dict.cc:5019
static void dict_free_vc_templ(dict_vcol_templ_t *vc_templ)
Free the virtual column template.
void dict_table_change_id_in_cache(dict_table_t *table, table_id_t new_id)
Change the id of a table object in the dictionary cache.
Definition: dict0dict.cc:1839
bool dict_table_autoinc_log(dict_table_t *table, uint64_t value, mtr_t *mtr)
Write redo logs for autoinc counter that is to be inserted, or to update some existing smaller one to...
Definition: dict0dict.cc:757
void dict_init(void)
Inits the data dictionary module.
Definition: dict0dict.cc:1008
constexpr uint32_t BIG_ROW_SIZE
Definition: dict0dict.h:653
static ulint dict_table_encode_n_col(ulint n_col, ulint n_v_col)
encode number of columns and number of virtual columns in one 4 bytes value.
constexpr uint32_t DICT_INDEX_SPATIAL_NODEPTR_SIZE
The number of fields in the nonleaf page of spatial index, except the page no field.
Definition: dict0dict.h:713
dberr_t dd_sdi_acquire_exclusive_mdl(THD *thd, space_id_t space_id, MDL_ticket **sdi_mdl)
Acquire exclusive MDL on SDI tables.
Definition: dict0dict.cc:5963
ulint dict_get_db_name_len(const char *name)
Get the database name length in a table name.
Definition: dict0dict.cc:294
void dict_print_info_on_foreign_key_in_create_format(FILE *file, trx_t *trx, dict_foreign_t *foreign, bool add_newline)
Outputs info on a foreign key of a table in a format suitable for CREATE TABLE.
Definition: dict0dict.cc:3802
static dict_v_col_t * dict_table_get_nth_v_col(const dict_table_t *table, ulint pos)
Gets the nth virtual column of a table.
ulint dict_table_get_highest_foreign_id(dict_table_t *table)
Finds the highest [number] for foreign key constraints of the table.
Definition: dict0dict.cc:3569
static bool dict_index_has_desc(const dict_index_t *index)
Check whether the index consists of descending columns only.
static void dict_index_set_space(dict_index_t *index, space_id_t space)
Sets the space id of the root of the index tree.
static ulint dict_table_get_sys_col_no(const dict_table_t *table, ulint sys)
Gets the given system column number of a table.
ulint dict_table_mysql_pos_to_innodb(const dict_table_t *table, ulint n)
Get the innodb column position for a non-virtual column according to its original MySQL table positio...
Definition: dict0dict.cc:950
static void dict_table_next_uncorrupted_index(dict_index_t *&index)
Definition: dict0dict.h:427
void dict_partitioned_table_remove_from_cache(const char *name)
Try to invalidate an entry from the dict cache, for a partitioned table, if any table found.
Definition: dict0dict.cc:1976
const char * dict_remove_db_name(const char *name)
Return the end of table name where we have removed dbname and '/'.
Definition: dict0dict.cc:282
bool dict_foreign_qualify_index(const dict_table_t *table, const char **col_names, const char **columns, ulint n_cols, const dict_index_t *index, const dict_index_t *types_idx, bool check_charsets, ulint check_null)
Tries to find an index whose first fields are the columns in the array, in the same order and is not ...
Definition: dict0dict.cc:4757
static ulint dict_col_get_index_pos(const dict_col_t *col, const dict_index_t *index)
Gets the column position in the given index.
static void dict_table_prevent_eviction(dict_table_t *table)
Prevent table eviction by moving a table to the non-LRU list from the LRU list if it is not already t...
dberr_t dict_table_rename_in_cache(dict_table_t *table, const char *new_name, bool rename_also_foreigns)
Renames a table object.
Definition: dict0dict.cc:1462
void dict_mutex_exit_for_mysql(void)
Releases the dictionary system mutex for MySQL.
Definition: dict0dict.cc:310
uint32_t dict_tf_to_fsp_flags(uint32_t table_flags)
Convert a 32 bit integer table flags to the 32 bit FSP Flags.
Definition: dict0dict.cc:4974
bool dict_tables_have_same_db(const char *name1, const char *name2)
Checks if the database name in two table names is the same.
Definition: dict0dict.cc:266
static bool dict_table_in_shared_tablespace(const dict_table_t *table)
Check if the table is in a shared tablespace (System or General).
void dict_close(void)
Closes the data dictionary module.
Definition: dict0dict.cc:4630
static bool dict_table_is_discarded(const dict_table_t *table)
Check if the tablespace for the table has been discarded.
rec_t * dict_index_copy_rec_order_prefix(const dict_index_t *index, const rec_t *rec, ulint *n_fields, byte **buf, size_t *buf_size)
Copies an initial segment of a physical record, long enough to specify an index entry uniquely.
Definition: dict0dict.cc:3699
static ulint dict_table_get_n_tot_u_cols(const dict_table_t *table)
static trx_id_t dict_table_get_curr_table_sess_trx_id(const dict_table_t *table)
Get current session trx-id.
static bool dict_table_has_indexed_v_cols(const dict_table_t *table)
Check if a table has indexed virtual columns.
static ulint dict_col_get_clust_pos(const dict_col_t *col, const dict_index_t *clust_index)
Gets the column position in the clustered index.
void dict_table_mark_dirty(dict_table_t *table)
Mark the dirty_status of a table as METADATA_DIRTY, and add it to the dirty_dict_tables list if neces...
Definition: dict0dict.cc:4112
void dict_persist_close(void)
Clear the structure.
Definition: dict0dict.cc:3918
static bool dict_tf2_is_valid(uint32_t flags, uint32_t flags2)
Validate both table flags and table flags2 and make sure they are compatible.
static void dict_table_n_rows_dec(dict_table_t *table)
Decrement the number of rows in the table by one.
static row_id_t dict_table_get_next_table_sess_row_id(dict_table_t *table)
Get table session row-id and increment the row-id counter for next use.
dberr_t dict_index_add_to_cache_w_vcol(dict_table_t *table, dict_index_t *index, const dict_add_v_col_t *add_v, page_no_t page_no, bool strict)
Adds an index to the dictionary cache, with possible indexing newly added column.
Definition: dict0dict.cc:2441
static ulint dict_index_is_ibuf(const dict_index_t *index)
Check whether the index is the insert buffer tree.
static void dict_table_x_unlock_indexes(dict_table_t *table)
Release the exclusive locks on all index tree.
static void dict_disable_redo_if_temporary(const dict_table_t *table, mtr_t *mtr)
Turn-off redo-logging if temporary table.
static ulint dict_index_get_n_ordering_defined_by_user(const dict_index_t *index)
Gets the number of user-defined ordering fields in the index.
const char * dict_table_get_v_col_name(const dict_table_t *table, ulint col_nr)
Returns a virtual column's name.
Definition: dict0dict.cc:624
constexpr uint32_t MAX_NUM_FK_COLUMNS
Maximum number of columns in a foreign key constraint.
Definition: dict0dict.h:980
void dict_table_wait_for_bg_threads_to_exit(dict_table_t *table, std::chrono::microseconds delay)
Definition: dict0dict.cc:2930
rw_lock_t * dict_operation_lock
the data dictionary rw-latch protecting dict_sys
Definition: dict0dict.cc:176
void dict_table_move_from_non_lru_to_lru(dict_table_t *table)
Move a table to the LRU end from the non LRU list.
Definition: dict0dict.cc:1393
void dict_validate_no_purge_rollback_threads()
Validate no active background threads to cause purge or rollback operations.
Definition: dict0dict.cc:6097
void dict_table_stats_latch_destroy(dict_table_t *table)
Destroy a dict_table_t's stats latch.
Definition: dict0dict.cc:359
void dict_foreign_free(dict_foreign_t *foreign)
Frees a foreign key struct.
Definition: dict0mem.h:1777
dict_persist_t * dict_persist
the dictionary persisting structure
Definition: dict0dict.cc:166
static ulint dict_index_is_sec_or_ibuf(const dict_index_t *index)
Check whether the index is a secondary index or the insert buffer tree.
void dict_table_autoinc_lock(dict_table_t *table)
Acquire the autoinc lock.
Definition: dict0dict.cc:731
static page_no_t dict_index_get_page(const dict_index_t *tree)
Gets the page number of the root of the index tree.
ib_mutex_t dict_foreign_err_mutex
Definition: dict0dict.cc:262
void dict_table_add_to_cache(dict_table_t *table, bool can_be_evicted)
Adds a table object to the dictionary cache.
Definition: dict0dict.cc:1190
static ulint dict_max_v_field_len_store_undo(dict_table_t *table, ulint col_no)
Determine maximum bytes of a virtual column need to be stored in the undo log.
void dict_table_move_from_lru_to_non_lru(dict_table_t *table)
Move a table to the non LRU end of the LRU list.
Definition: dict0dict.cc:1375
void dict_index_remove_from_cache(dict_table_t *table, dict_index_t *index)
Removes an index from the dictionary cache.
Definition: dict0dict.cc:2715
void dict_ind_init(void)
Inits dict_ind_redundant.
Definition: dict0dict.cc:4365
dict_index_t * dict_sdi_get_index(space_id_t tablespace_id)
Retrieve in-memory index for SDI table.
Definition: dict0dict.cc:5775
void dict_table_close(dict_table_t *table, bool dict_locked, bool try_drop)
Decrements the count of open handles to a table.
Definition: dict0dict.cc:494
void dict_persist_init(void)
Inits the structure for persisting dynamic metadata.
Definition: dict0dict.cc:3893
void dict_index_set_merge_threshold(dict_index_t *index, ulint merge_threshold)
Sets merge_threshold in the SYS_INDEXES.
void dict_table_close_and_drop(trx_t *trx, dict_table_t *table)
Closes the only open handle to a table and drops a table while assuring that dict_sys->mutex is held ...
Definition: dict0dict.cc:570
const dict_index_t * dict_index_find(const index_id_t &id)
Look up an index among already opened tables.
Definition: dict0dict.cc:1425
static uint16_t dict_index_get_n_unique_in_tree_nonleaf(const dict_index_t *index)
Gets the number of fields on nonleaf page level in the internal representation of an index which uniq...
void dict_move_to_mru(dict_table_t *table)
Move to the most recently used segment of the LRU list.
Definition: dict0dict.cc:1041
static bool dict_table_have_virtual_index(dict_table_t *table)
Check whether the table have virtual index.
void dict_upgrade_evict_tables_cache()
Evict all tables that are loaded for applying purge.
Definition: dict0dict.cc:5882
ulint dict_index_node_ptr_max_size(const dict_index_t *index)
Return maximum size of the node pointer record.
Definition: dict0dict.cc:2041
static bool dict_index_is_online_ddl(const dict_index_t *index)
Determines if a secondary index is being or has been created online, or if the table is being rebuilt...
const uint32_t SDI_VERSION
SDI version.
Definition: dict0dict.h:73
void dict_table_autoinc_unlock(dict_table_t *table)
Release the autoinc lock.
Definition: dict0dict.cc:850
bool dict_sys_table_id_build()
Build the table_id array of SYS_* tables.
Definition: dict0dict.cc:5934
static bool dict_table_is_partition(const dict_table_t *table)
Check whether the dict_table_t is a partition.
ulint dict_table_get_all_fts_indexes(dict_table_t *table, ib_vector_t *indexes)
Get all the FTS indexes on a table.
Definition: dict0dict.cc:812
void dict_index_remove_from_v_col_list(dict_index_t *index)
Clears the virtual column's index list before index is being freed.
Definition: dict0dict.cc:2333
void dict_resize()
Resize the hash tables based on the current buffer pool size.
Definition: dict0dict.cc:4584
void dict_set_merge_threshold_all_debug(uint merge_threshold_all)
Sets merge_threshold for all indexes in dictionary cache for debug.
Definition: dict0dict.cc:4352
static bool dict_index_is_sdi(const dict_index_t *index)
Check if the index is SDI index.
static ulint dict_index_is_unique(const dict_index_t *index)
Check whether the index is unique.
static bool dict_table_is_table_buffer(const dict_table_t *table)
Check whether the table is DDTableBuffer.
static void dict_table_decode_n_col(uint32_t encoded, uint32_t *n_col, uint32_t *n_v_col)
Decode number of virtual and non-virtual columns in one 4 bytes value.
FILE * dict_foreign_err_file
Definition: dict0dict.cc:260
bool dict_table_is_system(table_id_t table_id)
Definition: dict0dict.cc:5954
static bool dict_table_is_comp(const dict_table_t *table)
Check whether the table uses the compact page format.
static ulint dict_index_get_space_reserve(void)
Returns free space reserved for future updates of records.
static void dict_table_skip_corrupt_index(dict_index_t *&index)
Definition: dict0dict.h:420
static void dict_table_autoinc_persisted_update(dict_table_t *table, uint64_t autoinc)
Update the persisted autoinc counter to specified one, we should hold autoinc_persisted_mutex.
dtuple_t * dict_index_build_node_ptr(const dict_index_t *index, const rec_t *rec, page_no_t page_no, mem_heap_t *heap, ulint level)
Builds a node pointer out of a physical record and a page number.
Definition: dict0dict.cc:3637
void dict_table_persist_to_dd_table_buffer(dict_table_t *table)
Write back the dirty persistent dynamic metadata of the table to DDTableBuffer.
Definition: dict0dict.cc:4217
ulint dict_index_get_nth_field_pos(const dict_index_t *index, const dict_index_t *index2, ulint n)
Looks for a matching field in an index.
Definition: dict0dict.cc:894
void dict_sdi_remove_from_cache(space_id_t space_id, dict_table_t *sdi_table, bool dict_locked)
Remove the SDI table from table cache.
Definition: dict0dict.cc:5815
void dict_table_read_dynamic_metadata(const byte *buffer, ulint size, PersistentTableMetadata *metadata)
Read persistent dynamic metadata stored in a buffer.
Definition: dict0dict.cc:4034
void dict_table_stats_latch_create(dict_table_t *table, bool enabled)
Create a dict_table_t's stats latch or delay for lazy creation.
Definition: dict0dict.cc:343
uint32_t dict_vcol_base_is_foreign_key(dict_v_col_t *vcol, dict_foreign_t *foreign)
Definition: dict0dict.cc:6077
static bool dict_tf_is_valid(uint32_t flags)
Validate the table flags.
static ulint dict_table_get_n_v_cols(const dict_table_t *table)
Gets the number of virtual columns in a table in the dictionary cache.
static ulint dict_index_get_n_unique_in_tree(const dict_index_t *index)
Gets the number of fields in the internal representation of an index which uniquely determine the pos...
const char * dict_tf_to_row_format_string(uint32_t table_flag)
Convert table flag to row format string.
Definition: dict0dict.cc:4998
dict_index_t * dict_table_get_index_on_name(dict_table_t *table, const char *name, bool committed=true)
Get an index by name.
Definition: dict0dict.cc:4397
ulint dict_table_has_column(const dict_table_t *table, const char *col_name, ulint col_nr=0)
Check if the table has a given (non_virtual) column.
Definition: dict0dict.cc:596
void dict_set_corrupted(dict_index_t *index) UNIV_COLD
Flags an index corrupted in the data dictionary cache only.
Definition: dict0dict.cc:4150
void dict_sdi_close_table(dict_table_t *table)
Close SDI table.
Definition: dict0dict.cc:5767
void dict_table_stats_unlock(dict_table_t *table, ulint latch_mode)
Unlock the latch that has been locked by dict_table_stats_lock().
Definition: dict0dict.cc:400
dict_index_t * dict_ind_redundant
dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records
Definition: dict0dict.cc:70
static trx_id_t dict_table_get_next_table_sess_trx_id(dict_table_t *table)
Get table session trx-id and increment the trx-id counter for next use.
static void dict_tf_set(uint32_t *flags, rec_format_t format, uint32_t zip_ssize, bool use_data_dir, bool shared_space)
Set the various values in a dict_table_t::flags pointer.
void dict_table_remove_from_cache_debug(dict_table_t *table, bool lru_evict)
Removes a table object from the dictionary cache, for debug purpose.
Definition: dict0dict.cc:2011
static const page_size_t dict_tf_get_page_size(uint32_t flags)
Extract the page size info from table flags.
void dict_table_stats_lock(dict_table_t *table, ulint latch_mode)
Lock the appropriate latch to protect a given table's statistics.
Definition: dict0dict.cc:369
static void dict_table_n_rows_inc(dict_table_t *table)
Increment the number of rows in the table by one.
void dict_index_copy_types(dtuple_t *tuple, const dict_index_t *index, ulint n_fields)
Copies types of fields contained in index to tuple.
Definition: dict0dict.cc:2862
static ulint dict_table_is_fts_column(ib_vector_t *indexes, ulint col_no, bool is_virtual)
Check whether a column exists in an FTS index.
check_name
Whether and when to allow temporary index names.
Definition: dict0dict.h:776
@ CHECK_ABORTED_OK
Allow aborted online index creation.
Definition: dict0dict.h:780
@ CHECK_ALL_COMPLETE
Require all indexes to be complete.
Definition: dict0dict.h:778
@ CHECK_PARTIAL_OK
Allow partial indexes to exist.
Definition: dict0dict.h:782
const space_id_t SYSTEM_TABLE_SPACE
Space id of system tablespace.
Definition: dict0dict.h:76
static bool dict_index_is_auto_gen_clust(const dict_index_t *index)
Check if index is auto-generated clustered index.
static void dict_allocate_mem_intrinsic_cache(dict_index_t *index)
Allocate memory for intrinsic cache elements in the index.
bool dict_table_is_referenced_by_foreign_key(const dict_table_t *table)
Checks if a table is referenced by foreign keys.
Definition: dict0dict.cc:3291
static bool dict_table_is_locking_disabled(const dict_table_t *table)
Check whether locking is disabled for this table.
static const page_size_t dict_table_page_size(const dict_table_t *table)
Get the table page size.
void dict_mutex_enter_for_mysql(void)
Reserves the dictionary system mutex for MySQL.
Definition: dict0dict.cc:307
dberr_t dict_foreign_add_to_cache(dict_foreign_t *foreign, const char **col_names, bool check_charsets, bool can_free_fk, dict_err_ignore_t ignore_err)
Adds a foreign key constraint object to the dictionary cache.
Definition: dict0dict.cc:3425
dberr_t dict_set_compression(dict_table_t *table, const char *algorithm, bool is_import_op)
Set the compression type for the tablespace of a table.
Definition: dict0dict.cc:6038
void dict_index_zip_failure(dict_index_t *index)
This function should be called whenever a page compression attempt fails.
Definition: dict0dict.cc:4913
void dict_table_copy_v_types(dtuple_t *tuple, const dict_table_t *table)
Copies types of virtual columns contained in table to tuple and sets all fields of the tuple to the S...
Definition: dict0dict.cc:2896
void dict_table_change_id_sys_tables()
Change the table_id of SYS_* tables if they have been created after an earlier upgrade.
Definition: dict0dict.cc:5846
constexpr uint32_t DICT_HEAP_SIZE
initial memory heap size when creating a table or index object
Definition: dict0dict.h:70
ulint dict_make_room_in_cache(ulint max_tables, ulint pct_check)
Make room in the table cache by evicting an unused table.
Definition: dict0dict.cc:1315
void dict_table_copy_types(dtuple_t *tuple, const dict_table_t *table)
Copies types of columns contained in table to tuple and sets all fields of the tuple to the SQL NULL ...
Definition: dict0dict.cc:2914
static ulint dict_col_get_no(const dict_col_t *col)
Gets the column number.
static uint32_t dict_tf_init(bool compact, ulint zip_ssize, bool atomic_blobs, bool data_dir, bool shared_space)
Initialize a dict_table_t::flags pointer.
bool dict_col_name_is_reserved(const char *name)
If the given column name is reserved for InnoDB system columns, return true.
Definition: dict0dict.cc:2019
static void dict_table_ddl_acquire(dict_table_t *table)
Move this table to non-LRU list for DDL operations if it's currently not there.
void dict_foreign_remove_from_cache(dict_foreign_t *foreign)
Removes a foreign constraint struct from the dictionary cache.
Definition: dict0dict.cc:3298
static uint64_t dict_table_get_n_rows(const dict_table_t *table)
Gets the approximately estimated number of rows in the table.
bool dict_foreign_replace_index(dict_table_t *table, const char **col_names, const dict_index_t *index)
Replace the index passed in with another equivalent index in the foreign key lists of the table.
Definition: dict0dict.cc:4418
uint64_t dict_table_autoinc_read(const dict_table_t *table)
Reads the next autoinc value (== autoinc counter value), 0 if not yet initialized.
Definition: dict0dict.cc:830
void dict_fs2utf8(const char *db_and_table, char *db_utf8mb3, size_t db_utf8mb3_size, char *table_utf8mb3, size_t table_utf8mb3_size)
Converts a database and table name from filesystem encoding (e.g.
Definition: dict0dict.cc:4536
bool dict_index_check_search_tuple(const dict_index_t *index, const dtuple_t *tuple)
Checks that a tuple has n_fields_cmp value in a sensible range, so that no comparison can occur with ...
Definition: dict0dict.cc:3620
dberr_t dict_index_add_to_cache(dict_table_t *table, dict_index_t *index, page_no_t page_no, bool strict)
Adds an index to the dictionary cache.
Definition: dict0dict.cc:2324
std::string dict_table_get_datadir(const dict_table_t *table)
Get the tablespace data directory if set, otherwise empty string.
Definition: dict0dict.cc:6028
void dict_table_autoinc_update_if_greater(dict_table_t *table, uint64_t value)
Updates the autoinc counter if the value supplied is greater than the current value.
Definition: dict0dict.cc:841
ulint dict_index_zip_pad_optimal_page_size(dict_index_t *index)
Return the optimal page size, for which page will likely compress.
Definition: dict0dict.cc:4932
static ulint dict_index_has_virtual(const dict_index_t *index)
Check whether the index contains a virtual column.
dict_index_t * dict_foreign_find_index(const dict_table_t *table, const char **col_names, const char **columns, ulint n_cols, const dict_index_t *types_idx, bool check_charsets, ulint check_null)
Tries to find an index whose first fields are the columns in the array, in the same order and is not ...
Definition: dict0dict.cc:3346
void dict_index_zip_success(dict_index_t *index)
This function should be called whenever a page is successfully compressed.
Definition: dict0dict.cc:4894
void dict_table_add_system_columns(dict_table_t *table, mem_heap_t *heap)
Adds system columns to a table object.
Definition: dict0dict.cc:1130
void get_permissible_max_size(const dict_table_t *table, const dict_index_t *index, size_t &page_rec_max, size_t &page_ptr_max)
Get the maximum size of a record permissible on an index page.
Definition: dict0dict.cc:2117
void dict_table_set_big_rows(dict_table_t *table)
Mark if table has big rows.
Definition: dict0dict.cc:1171
void dict_table_autoinc_initialize(dict_table_t *table, uint64_t value)
Unconditionally set the autoinc counter.
Definition: dict0dict.cc:751
static void dict_table_allow_eviction(dict_table_t *table)
Allow the table to be evicted by moving a table to the LRU list from the non-LRU list if it is not al...
ulint dict_table_get_nth_col_pos(const dict_table_t *table, ulint n)
Looks for non-virtual column n position in the clustered index.
Definition: dict0dict.cc:939
void dict_table_check_for_dup_indexes(const dict_table_t *table, enum check_name check)
Check for duplicate index entries in a table [using the index name].
Definition: dict0dict.cc:4482
dict_table_op_t
Operation to perform when opening a table.
Definition: dict0dict.h:102
@ DICT_TABLE_OP_NORMAL
Expect the tablespace to exist.
Definition: dict0dict.h:104
@ DICT_TABLE_OP_LOAD_TABLESPACE
Silently load the tablespace if it does not exist, and do not load the definitions of incomplete inde...
Definition: dict0dict.h:109
@ DICT_TABLE_OP_DROP_ORPHAN
Drop any orphan indexes after an aborted online index creation.
Definition: dict0dict.h:106
static bool dict_table_is_sdi(uint64_t table_id)
Check if an table id belongs SDI table.
dict_table_t * dict_sdi_get_table(space_id_t tablespace_id, bool dict_locked, bool is_create)
Retrieve in-memory table object for SDI table.
Definition: dict0dict.cc:5791
static rw_lock_t * dict_index_get_lock(dict_index_t *index)
Gets the read-write lock of the index tree.
static bool dict_table_has_fts_index(dict_table_t *table)
Check if the table has an FTS index.
bool dict_table_col_in_clustered_key(const dict_table_t *table, ulint n)
Checks if a column is in the ordering columns of the clustered index of a table.
Definition: dict0dict.cc:977
static void dict_table_ddl_release(dict_table_t *table)
Move this table to LRU list after DDL operations if it was moved to non-LRU list.
ulint dict_index_calc_min_rec_len(const dict_index_t *index)
Calculates the minimum record length in an index.
Definition: dict0dict.cc:3753
static void dict_index_set_online_status(dict_index_t *index, enum online_index_status status)
Sets the status of online index creation.
static ulint dict_max_field_len_store_undo(dict_table_t *table, const dict_col_t *col)
Determine bytes of column prefix to be stored in the undo log.
void dict_table_load_dynamic_metadata(dict_table_t *table)
Check if there is any latest persistent dynamic metadata recorded in DDTableBuffer table of the speci...
Definition: dict0dict.cc:4067
static dict_index_t * dict_table_get_index_on_first_col(dict_table_t *table, ulint col_index)
Get index by first field of the index.
bool dict_index_validate_max_rec_size(const dict_table_t *table, const dict_index_t *index, bool strict, const size_t page_rec_max, const size_t page_ptr_max, size_t &rec_max_size)
validate that maximum possible size of a row is within permissible limit.
Definition: dict0dict.cc:2250
dict_v_col_t * dict_table_get_nth_v_col_mysql(const dict_table_t *table, ulint col_nr)
Get nth virtual column according to its original MySQL table position.
Definition: dict0dict.cc:693
static enum online_index_status dict_index_get_online_status(const dict_index_t *index)
Gets the status of online index creation.
bool dict_index_contains_col_or_prefix(const dict_index_t *index, ulint n, bool is_virtual)
Returns true if the index contains a column or a prefix of that column.
Definition: dict0dict.cc:855
static void dict_table_autoinc_set_col_pos(dict_table_t *table, ulint pos)
Set the column position of autoinc column in clustered index for a table.
void dict_table_remove_from_cache(dict_table_t *table)
Removes a table object from the dictionary cache.
Definition: dict0dict.cc:1968
static ulint dict_index_is_spatial(const dict_index_t *index)
Check whether the index is a Spatial Index.
const char * dict_table_get_v_col_name_mysql(const dict_table_t *table, ulint col_nr)
Returns a virtual column's name according to its original MySQL table position.
Definition: dict0dict.cc:678
static space_id_t dict_index_get_space(const dict_index_t *index)
Gets the space id of the root of the index tree.
void get_field_max_size(const dict_table_t *table, const dict_index_t *index, const dict_field_t *field, size_t &rec_max_size)
Get maximum possible size needed for a field.
Definition: dict0dict.cc:2151
static bool dict_table_has_autoinc_col(const dict_table_t *table)
Check if a table has an autoinc counter column.
bool dict_table_is_compressed_temporary(const dict_table_t *table)
Check if a table is a temporary table with compressed row format, we should always expect false.
Definition: dict0dict.ic:756
dtuple_t * dict_index_build_data_tuple(dict_index_t *index, rec_t *rec, ulint n_fields, mem_heap_t *heap)
Builds a typed data tuple out of a physical record.
Definition: dict0dict.cc:3730
dberr_t dd_sdi_acquire_shared_mdl(THD *thd, space_id_t space_id, MDL_ticket **sdi_mdl)
Acquire shared MDL on SDI tables.
Definition: dict0dict.cc:6001
static ulint dict_index_get_n_unique(const dict_index_t *index)
Gets the number of fields in the internal representation of an index that uniquely determine the posi...
dict_sys_t * dict_sys
the dictionary system
Definition: dict0dict.cc:136
static ulint dict_index_get_n_fields(const dict_index_t *index)
Gets the number of fields in the internal representation of an index, including fields added by the d...
void dict_persist_to_dd_table_buffer()
Check if any table has any dirty persistent data, if so write dirty persistent data of table to mysql...
Definition: dict0dict.cc:4237
static void dict_table_x_lock_indexes(dict_table_t *table)
Obtain exclusive locks on all index trees of the table.
dict_table_t * dict_table_open_on_name(const char *table_name, bool dict_locked, bool try_drop, dict_err_ignore_t ignore_err)
Returns a table object and increments its open handle count.
Definition: dict0dict.cc:1061
static bool dict_table_has_atomic_blobs(const dict_table_t *table)
Determine if a table uses atomic BLOBs (no locally stored prefix).
Data dictionary system.
Data dictionary memory object creation.
online_index_status
The status of online index creation.
Definition: dict0mem.h:1637
Data dictionary global types.
ib_id_t space_index_t
Index identifier (unique within a tablespace).
Definition: dict0types.h:219
ib_mutex_t DictSysMutex
Definition: dict0types.h:303
dict_err_ignore_t
Error to ignore when we load table dictionary into memory.
Definition: dict0types.h:279
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:217
Data dictionary system.
File space management.
Multi file, shared, system tablespace implementation.
constexpr size_t FSP_MAX_UNDO_TABLESPACES
Definition: fsp0types.h:402
The simple hash table utility.
static void *& hash_get_first(hash_table_t *table, size_t cell_id)
Gets the first struct in a hash chain, NULL if none.
Definition: hash0hash.h:158
#define HASH_GET_NEXT(NAME, DATA)
Gets the next struct in a hash chain, NULL if none.
Definition: hash0hash.h:164
static int flags[50]
Definition: hp_test1.cc:39
The memory management.
static PFS_engine_table_share_proxy table
Definition: pfs.cc:60
Definition: buf0block_hint.cc:29
const std::string FILE("FILE")
unsigned long long Object_id
Definition: object_id.h:30
Definition: os0file.h:88
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:417
const char * table_name
Definition: rules_table_service.cc:55
Record manager global types.
byte rec_t
Definition: rem0types.h:40
enum rec_format_enum rec_format_t
Definition: rem0types.h:82
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:60
required uint64 version
Definition: replication_group_member_actions.proto:40
required bool enabled
Definition: replication_group_member_actions.proto:32
Row operation global types.
Server monitor counter related defines.
case opt name
Definition: sslopt-case.h:32
Definition: completion_hash.h:34
Data structure for newly added virtual column in a table.
Definition: dict0mem.h:834
Data structure for a column in a table.
Definition: dict0mem.h:488
Data structure for a field in an index.
Definition: dict0mem.h:894
Data structure for a foreign key constraint; an example: FOREIGN KEY (A, B) REFERENCES TABLE2 (C,...
Definition: dict0mem.h:1665
Data structure for an index.
Definition: dict0mem.h:1045
const dict_index_t * next() const
Get the next index.
Definition: dict0mem.h:1286
bool is_corrupted() const
Check whether the index is corrupted.
Definition: dict0mem.h:1301
Structure for persisting dynamic metadata of data dictionary.
Definition: dict0dict.h:1164
Persisters * persisters
Collection of instances to persist dynamic metadata.
Definition: dict0dict.h:1228
ib_mutex_t mutex
Mutex to protect data in this structure, also the dict_table_t::dirty_status and dict_table_t::in_dir...
Definition: dict0dict.h:1211
std::atomic< uint32_t > num_dirty_tables
Number of the tables which are of status METADATA_DIRTY.
Definition: dict0dict.h:1215
std::atomic< bool > m_persist_immediately
If set, dynamic metadata is saved to DD buffer table immediately.
Definition: dict0dict.h:1220
DDTableBuffer * table_buffer
DDTableBuffer table for persistent dynamic metadata.
Definition: dict0dict.h:1224
bool check_persist_immediately() const
Definition: dict0dict.h:1193
dirty_dict_tables
List of tables whose dirty_status are marked as METADATA_DIRTY, or METADATA_BUFFERED.
Definition: dict0dict.h:1200
Definition: dict0dict.h:1004
void for_each_table(Functor &functor)
Iterate each table.
Definition: dict0dict.h:1053
row_id_t row_id
the next row id to assign; NOTE that at a checkpoint this must be written to the dict system header a...
Definition: dict0dict.h:1014
static constexpr space_id_t s_undo_space_id_range
The number of space IDs dedicated to each undo tablespace.
Definition: dict0dict.h:1103
static constexpr space_id_t s_max_undo_space_id
The highest undo tablespace ID.
Definition: dict0dict.h:1110
dict_table_t * ddl_log
Permanent handle to mysql.innodb_ddl_log.
Definition: dict0dict.h:1039
static bool is_reserved(space_id_t space)
Check if a tablespace id is a reserved tablespace ID.
Definition: dict0dict.h:1073
static constexpr space_id_t s_reserved_space_id
The first reserved tablespace ID.
Definition: dict0dict.h:1123
static std::set< dd::Object_id > s_dd_table_ids
Set of ids of DD tables.
Definition: dict0dict.h:1078
static constexpr table_id_t s_dynamic_meta_table_id
The table ID of mysql.innodb_dynamic_metadata.
Definition: dict0dict.h:1157
static constexpr space_id_t s_min_temp_space_id
Lowest temporary general space id.
Definition: dict0dict.h:1119
static constexpr dd::Object_id s_dd_sys_space_id
The dd::Tablespace::id of innodb_system.
Definition: dict0dict.h:1129
static const char * s_default_undo_space_name_2
Definition: dict0dict.h:1154
UT_LIST_BASE_NODE_T(dict_table_t, table_LRU) Table_LRU_list_base
Definition: dict0dict.h:1042
dict_table_t * sys_fields
SYS_FIELDS table.
Definition: dict0dict.h:1031
static const char * s_file_per_table_name
The hard-coded tablespace name innodb_file_per_table.
Definition: dict0dict.h:1150
static constexpr space_id_t s_log_space_id
The first ID of the redo log pseudo-tablespace.
Definition: dict0dict.h:1091
Table_LRU_list_base table_LRU
List of tables that can be evicted from the cache.
Definition: dict0dict.h:1045
static const char * s_dd_space_name
The name of the data dictionary tablespace.
Definition: dict0dict.h:1135
DictSysMutex mutex
mutex protecting the data dictionary; protects also the disk-based dictionary system tables; this mut...
Definition: dict0dict.h:1006
static constexpr space_id_t s_min_undo_space_id
The lowest undo tablespace ID.
Definition: dict0dict.h:1106
static const char * s_temp_space_file_name
The file name of the predefined temporary tablespace.
Definition: dict0dict.h:1147
static bool is_dd_table_id(table_id_t id)
Check if a table is hardcoded.
Definition: dict0dict.h:1086
static const char * s_default_undo_space_name_1
These two undo tablespaces cannot be dropped.
Definition: dict0dict.h:1153
size_t size
varying space in bytes occupied by the data dictionary table and index objects
Definition: dict0dict.h:1024
static const char * s_dd_space_file_name
The file name of the data dictionary tablespace.
Definition: dict0dict.h:1138
dict_table_t * sys_tables
Handler to sys_* tables, they're only for upgrade.
Definition: dict0dict.h:1028
Table_LRU_list_base table_non_LRU
List of tables that can't be evicted from the cache.
Definition: dict0dict.h:1047
static constexpr dd::Object_id s_dd_dict_space_id
The dd::Tablespace::id of the dictionary tablespace.
Definition: dict0dict.h:1126
static const char * s_sys_space_name
The name of the hard-coded system tablespace.
Definition: dict0dict.h:1141
static constexpr space_id_t s_temp_space_id
The innodb_temporary tablespace ID.
Definition: dict0dict.h:1100
dict_table_t * index_stats
Permanent handle to mysql.innodb_index_stats.
Definition: dict0dict.h:1037
static constexpr space_id_t s_dict_space_id
The data dictionary tablespace ID.
Definition: dict0dict.h:1097
dict_table_t * table_stats
Permanent handle to mysql.innodb_table_stats.
Definition: dict0dict.h:1035
static constexpr space_index_t s_dynamic_meta_index_id
The clustered index ID of mysql.innodb_dynamic_metadata.
Definition: dict0dict.h:1160
static constexpr space_id_t s_max_temp_space_id
Start space_ids for temporary tablespaces.
Definition: dict0dict.h:1113
dict_table_t * sys_indexes
SYS_INDEXES table.
Definition: dict0dict.h:1030
static constexpr dd::Object_id s_dd_temp_space_id
The dd::Tablespace::id of innodb_temporary.
Definition: dict0dict.h:1132
static const char * s_temp_space_name
The name of the predefined temporary tablespace.
Definition: dict0dict.h:1144
static constexpr space_id_t s_invalid_space_id
Use maximum UINT value to indicate invalid space ID.
Definition: dict0dict.h:1094
dict_table_t * dynamic_metadata
Permanent handle to mysql.innodb_dynamic_metadata.
Definition: dict0dict.h:1041
dict_table_t * sys_columns
SYS_COLUMNS table.
Definition: dict0dict.h:1029
static constexpr space_id_t s_temp_space_id_range
The number of space IDs dedicated to temporary tablespaces.
Definition: dict0dict.h:1116
hash_table_t * table_id_hash
hash table of the tables, based on id
Definition: dict0dict.h:1022
dict_table_t * sys_virtual
SYS_VIRTUAL table.
Definition: dict0dict.h:1032
hash_table_t * table_hash
hash table of the tables, based on name
Definition: dict0dict.h:1020
Data structure for a database table.
Definition: dict0mem.h:1908
Data structure for a virtual column in a table.
Definition: dict0mem.h:814
Structure defines template related to virtual columns and their base columns.
Definition: dict0mem.h:1845
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:681
Definition: ut0vec.h:212
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:301
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:176
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:362
Definition: trx0trx.h:683
Definition: row0upd.h:564
The read-write lock (for threads, not for database transactions)
typedef UT_LIST_BASE_NODE_T(rw_lock_t, list) rw_lock_list_t
Transaction system global type definitions.
ib_id_t row_id_t
Row identifier (DB_ROW_ID, DATA_ROW_ID)
Definition: trx0types.h:131
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:137
static const space_id_t TRX_SYS_SPACE
Space id of the transaction system page (the system tablespace)
Definition: trx0types.h:51
Version control for database, common definitions, and include files.
#define UNIV_COLD
Definition: univ.i:266
unsigned long int ulint
Definition: univ.i:405
Utilities for byte operations.
Memory primitives.
#define mutex_exit(M)
Definition: ut0mutex.h:122
#define mutex_enter(M)
Definition: ut0mutex.h:116
Dynamic memory allocation routines and custom allocators specifically crafted to support memory instr...
Random numbers and hashing.
uint32_t new_id()
Create a new (hopefully unique) ID.
Definition: xcom_base.cc:1785
int n
Definition: xcom_base.cc:508