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