MySQL 26.7.0
Source Code Documentation
dict0mem.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/dict0mem.h
30 Data dictionary memory object creation
31
32 Created 1/8/1996 Heikki Tuuri
33 *******************************************************/
34
35#ifndef dict0mem_h
36#define dict0mem_h
37
38#include "sql/dd/object_id.h"
39#include "sql/dd/types/column.h"
40#include "univ.i"
41#if defined UNIV_COMPILE_TEST_FUNCS || defined UNIV_HOTBACKUP
43#endif /* UNIV_COMPILE_TEST_FUNCS || UNIV_HOTBACKUP */
44#include "btr0types.h"
45#include "data0type.h"
46#include "dict0types.h"
47#include "mem0mem.h"
48#include "rem0types.h"
49#include "row0types.h"
50#ifndef UNIV_HOTBACKUP
51#include "lock0types.h"
52#include "que0types.h"
53#endif /* !UNIV_HOTBACKUP */
54#include "hash0hash.h"
55#include "sync0rw.h"
56#include "trx0types.h"
57#include "ut0byte.h"
58#include "ut0mem.h"
59#include "ut0rnd.h"
60#ifndef UNIV_HOTBACKUP
61#include "fts0fts.h"
62#endif /* !UNIV_HOTBACKUP */
63#include "buf0buf.h"
64#include "gis0type.h"
65#ifndef UNIV_HOTBACKUP
66#include "os0once.h"
67#endif /* !UNIV_HOTBACKUP */
68#include "dict/mem.h"
69#include "ut0new.h"
70
71#include "sql/sql_const.h" /* MAX_KEY_LENGTH */
72#include "sql/table.h"
73
74#include <algorithm>
75#include <atomic>
76#include <iterator>
77#include <memory> /* std::unique_ptr */
78#include <set>
79#include <string>
80#include <vector>
81
82/* Forward declaration. */
83struct ib_rbt_t;
84
85/** Format of INSTANTLY DROPPED column names. */
86constexpr char INSTANT_DROP_SUFFIX_8_0_29[] = "_dropped_v";
87constexpr char INSTANT_DROP_PREFIX_8_0_32[] = "!hidden!_dropped_";
88
89/** index/table name used while applying REDO logs during recovery */
90constexpr char RECOVERY_INDEX_TABLE_NAME[] = "LOG_DUMMY";
91
92/** Type flags of an index: OR'ing of the flags is allowed to define a
93combination of types */
94/** @{ */
95/** clustered index; for other than auto-generated clustered indexes, also
96 DICT_UNIQUE will be set */
97constexpr uint32_t DICT_CLUSTERED = 1;
98/** unique index */
99constexpr uint32_t DICT_UNIQUE = 2;
100/** insert buffer tree */
101constexpr uint32_t DICT_IBUF = 8;
102/** bit to store the corrupted flag in SYS_INDEXES.TYPE */
103constexpr uint32_t DICT_CORRUPT = 16;
104/** FTS index; can't be combined with the other flags */
105constexpr uint32_t DICT_FTS = 32;
106/** SPATIAL index; can't be combined with the other flags */
107constexpr uint32_t DICT_SPATIAL = 64;
108/** Index on Virtual column */
109constexpr uint32_t DICT_VIRTUAL = 128;
110/* Tablespace dictionary Index. Set only in in-memory index structure. */
111constexpr uint32_t DICT_SDI = 256;
112/** Multi-value index */
113constexpr uint32_t DICT_MULTI_VALUE = 512;
114
115/** number of bits used for SYS_INDEXES.TYPE */
116constexpr uint32_t DICT_IT_BITS = 10;
117/** @} */
118
119#if 0 /* not implemented, retained for history */
120/** Types for a table object */
121#define DICT_TABLE_ORDINARY 1 /*!< ordinary table */
122#define DICT_TABLE_CLUSTER_MEMBER 2
123#define DICT_TABLE_CLUSTER \
124 3 /* this means that the table is \
125really a cluster definition */
126#endif
127
128/* Table and tablespace flags are generally not used for the Antelope file
129format except for the low order bit, which is used differently depending on
130where the flags are stored.
131
132==================== Low order flags bit =========================
133 | REDUNDANT | COMPACT | COMPRESSED and DYNAMIC
134SYS_TABLES.TYPE | 1 | 1 | 1
135dict_table_t::flags | 0 | 1 | 1
136FSP_SPACE_FLAGS | 0 | 0 | 1
137fil_space_t::flags | 0 | 0 | 1
138
139Before the 5.1 plugin, SYS_TABLES.TYPE was always DICT_TABLE_ORDINARY (1)
140and the tablespace flags field was always 0. In the 5.1 plugin, these fields
141were repurposed to identify compressed and dynamic row formats.
142
143The following types and constants describe the flags found in dict_table_t
144and SYS_TABLES.TYPE. Similar flags found in fil_space_t and FSP_SPACE_FLAGS
145are described in fsp0fsp.h. */
146
147/** @{ */
148/** dict_table_t::flags bit 0 is equal to 0 if the row format = Redundant */
149/** Redundant row format. */
150constexpr uint32_t DICT_TF_REDUNDANT = 0;
151/** dict_table_t::flags bit 0 is equal to 1 if the row format = Compact */
152/** Compact row format. */
153constexpr uint32_t DICT_TF_COMPACT = 1;
154
155/** This bitmask is used in SYS_TABLES.N_COLS to set and test whether
156the Compact page format is used, i.e ROW_FORMAT != REDUNDANT */
157constexpr uint32_t DICT_N_COLS_COMPACT = 0x80000000UL;
158
159/** Width of the COMPACT flag */
160constexpr uint32_t DICT_TF_WIDTH_COMPACT = 1;
161
162/** Width of the ZIP_SSIZE flag */
163constexpr uint32_t DICT_TF_WIDTH_ZIP_SSIZE = 4;
164
165/** Width of the ATOMIC_BLOBS flag. The ROW_FORMAT=REDUNDANT and
166ROW_FORMAT=COMPACT broke up BLOB and TEXT fields, storing the first 768 bytes
167in the clustered index. ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPRESSED
168store the whole blob or text field off-page atomically.
169Secondary indexes are created from this external data using row_ext_t
170to cache the BLOB prefixes. */
171constexpr uint32_t DICT_TF_WIDTH_ATOMIC_BLOBS = 1;
172
173/** If a table is created with the MYSQL option DATA DIRECTORY and
174innodb-file-per-table, an older engine will not be able to find that table.
175This flag prevents older engines from attempting to open the table and
176allows InnoDB to update_create_info() accordingly. */
177constexpr uint32_t DICT_TF_WIDTH_DATA_DIR = 1;
178
179/** Width of the SHARED tablespace flag.
180It is used to identify tables that exist inside a shared general tablespace.
181If a table is created with the TABLESPACE=tsname option, an older engine will
182not be able to find that table. This flag prevents older engines from attempting
183to open the table and allows InnoDB to quickly find the tablespace. */
184
185constexpr uint32_t DICT_TF_WIDTH_SHARED_SPACE = 1;
186
187/** Width of all the currently known table flags */
188constexpr uint32_t DICT_TF_BITS =
192
193/** A mask of all the known/used bits in table flags */
194constexpr uint32_t DICT_TF_BIT_MASK = ~(~0U << DICT_TF_BITS);
195
196/** Zero relative shift position of the COMPACT field */
197constexpr uint32_t DICT_TF_POS_COMPACT = 0;
198/** Zero relative shift position of the ZIP_SSIZE field */
199constexpr uint32_t DICT_TF_POS_ZIP_SSIZE =
201/** Zero relative shift position of the ATOMIC_BLOBS field */
202constexpr uint32_t DICT_TF_POS_ATOMIC_BLOBS =
204/** Zero relative shift position of the DATA_DIR field */
205constexpr uint32_t DICT_TF_POS_DATA_DIR =
207/** Zero relative shift position of the SHARED TABLESPACE field */
208constexpr uint32_t DICT_TF_POS_SHARED_SPACE =
210/** Zero relative shift position of the start of the UNUSED bits */
211constexpr uint32_t DICT_TF_POS_UNUSED =
213
214/** Bit mask of the COMPACT field */
215constexpr uint32_t DICT_TF_MASK_COMPACT = (~(~0U << DICT_TF_WIDTH_COMPACT))
217/** Bit mask of the ZIP_SSIZE field */
220/** Bit mask of the ATOMIC_BLOBS field */
221constexpr uint32_t DICT_TF_MASK_ATOMIC_BLOBS =
223/** Bit mask of the DATA_DIR field */
224constexpr uint32_t DICT_TF_MASK_DATA_DIR = (~(~0U << DICT_TF_WIDTH_DATA_DIR))
226/** Bit mask of the SHARED_SPACE field */
227constexpr uint32_t DICT_TF_MASK_SHARED_SPACE =
229
230/** Return the value of the COMPACT field */
231inline uint32_t DICT_TF_GET_COMPACT(uint32_t flags) {
233}
234/** Return the value of the ZIP_SSIZE field */
235inline uint32_t DICT_TF_GET_ZIP_SSIZE(uint32_t flags) {
237}
238/** Return the value of the ATOMIC_BLOBS field */
239inline uint32_t DICT_TF_HAS_ATOMIC_BLOBS(uint32_t flags) {
241}
242/** Return the value of the DATA_DIR field */
243inline uint32_t DICT_TF_HAS_DATA_DIR(uint32_t flags) {
245}
246/** Return the value of the SHARED_SPACE field */
247inline uint32_t DICT_TF_HAS_SHARED_SPACE(uint32_t flags) {
249}
250/** Return the contents of the UNUSED bits */
251inline uint32_t DICT_TF_GET_UNUSED(uint32_t flags) {
252 return flags >> DICT_TF_POS_UNUSED;
253}
254/** @} */
255
256/** @brief Table Flags set number 2.
257
258These flags will be stored in SYS_TABLES.MIX_LEN. All unused flags
259will be written as 0. The column may contain garbage for tables
260created with old versions of InnoDB that only implemented
261ROW_FORMAT=REDUNDANT. InnoDB engines do not check these flags
262for unknown bits in order to protect backward incompatibility. */
263/** @{ */
264/** Total number of bits in table->flags2. */
265constexpr uint32_t DICT_TF2_BITS = 11;
266constexpr uint32_t DICT_TF2_UNUSED_BIT_MASK = ~0U << DICT_TF2_BITS;
267constexpr uint32_t DICT_TF2_BIT_MASK = ~DICT_TF2_UNUSED_BIT_MASK;
268
269/** TEMPORARY; true for tables from CREATE TEMPORARY TABLE. */
270constexpr uint32_t DICT_TF2_TEMPORARY = 1;
271
272/** The table has an internal defined DOC ID column */
273constexpr uint32_t DICT_TF2_FTS_HAS_DOC_ID = 2;
274
275/** The table has an FTS index */
276constexpr uint32_t DICT_TF2_FTS = 4;
277
278/** Need to add Doc ID column for FTS index build.
279This is a transient bit for index build */
280constexpr uint32_t DICT_TF2_FTS_ADD_DOC_ID = 8;
281
282/** This bit is used during table creation to indicate that it will
283use its own tablespace instead of the system tablespace. */
284constexpr uint32_t DICT_TF2_USE_FILE_PER_TABLE = 16;
285
286/** Set when we discard/detach the tablespace */
287constexpr uint32_t DICT_TF2_DISCARDED = 32;
288
289/** Intrinsic table bit
290Intrinsic table is table created internally by MySQL modules viz. Optimizer,
291FTS, etc.... Intrinsic table has all the properties of the normal table except
292it is not created by user and so not visible to end-user. */
293constexpr uint32_t DICT_TF2_INTRINSIC = 128;
294
295/** Encryption table bit for innodb_file-per-table only. */
296constexpr uint32_t DICT_TF2_ENCRYPTION_FILE_PER_TABLE = 256;
297
298/** FTS AUX hidden table bit. */
299constexpr uint32_t DICT_TF2_AUX = 512;
300
301/** Table is opened by resurrected trx during crash recovery. */
302constexpr uint32_t DICT_TF2_RESURRECT_PREPARED = 1024;
303/** @} */
304
305/** Tables could be chained together with Foreign key constraint. When
306first load the parent table, we would load all of its descedents.
307This could result in rescursive calls and out of stack error eventually.
308DICT_FK_MAX_RECURSIVE_LOAD defines the maximum number of recursive loads,
309when exceeded, the child table will not be loaded. It will be loaded when
310the foreign constraint check needs to be run. */
311constexpr uint32_t DICT_FK_MAX_RECURSIVE_LOAD = 20;
312
313/** Similarly, when tables are chained together with foreign key constraints
314with on cascading delete/update clause, delete from parent table could
315result in recursive cascading calls. This defines the maximum number of
316such cascading deletes/updates allowed. When exceeded, the delete from
317parent table will fail, and user has to drop excessive foreign constraint
318before proceeds. */
319constexpr uint32_t FK_MAX_CASCADE_DEL = 15;
320
321/** Adds a virtual column definition to a table.
322@param[in,out] table table
323@param[in] heap temporary memory heap, or NULL. It is
324 used to store name when we have not finished
325 adding all columns. When all columns are
326 added, the whole name will copy to memory from
327 table->heap
328@param[in] name column name
329@param[in] mtype main datatype
330@param[in] prtype precise type
331@param[in] len length
332@param[in] pos position in a table
333@param[in] num_base number of base columns
334@param[in] is_visible True if virtual column is visible to user
335@return the virtual column definition */
337 const char *name, ulint mtype,
338 ulint prtype, ulint len, ulint pos,
339 ulint num_base, bool is_visible);
340
341/** Adds a stored column definition to a table.
342@param[in,out] table table
343@param[in] num_base number of base columns. */
345
346/** Renames a column of a table in the data dictionary cache.
347@param[in,out] table Table
348@param[in] nth_col Column index
349@param[in] from Old column name
350@param[in] to New column name
351@param[in] is_virtual If this is a virtual column */
353 const char *from, const char *to,
354 bool is_virtual);
355
356/** This function poplulates a dict_index_t index memory structure with
357supplied information.
358@param[out] index index to be filled
359@param[in] heap memory heap
360@param[in] table_name table name
361@param[in] index_name index name
362@param[in] space space where the index tree is placed, the
363 clustered type ignored if the index is of
364the clustered type
365@param[in] type DICT_UNIQUE, DICT_CLUSTERED, ... ORed
366@param[in] n_fields number of fields */
367static inline void dict_mem_fill_index_struct(
368 dict_index_t *index, mem_heap_t *heap, const char *table_name,
369 const char *index_name, ulint space, ulint type, ulint n_fields);
370
371/** Frees an index memory object. */
372void dict_mem_index_free(dict_index_t *index); /*!< in: index */
373/** Creates and initializes a foreign constraint memory object.
374 @return own: foreign constraint struct */
376
377/** Sets the foreign_table_name_lookup pointer based on the value of
378 lower_case_table_names. If that is 0 or 1, foreign_table_name_lookup
379 will point to foreign_table_name. If 2, then another string is
380 allocated from the heap and set to lower case. */
382 dict_foreign_t *foreign, /*!< in/out: foreign struct */
383 bool do_alloc); /*!< in: is an alloc needed */
384
385/** Sets the referenced_table_name_lookup pointer based on the value of
386 lower_case_table_names. If that is 0 or 1, referenced_table_name_lookup
387 will point to referenced_table_name. If 2, then another string is
388 allocated from the heap and set to lower case. */
390 dict_foreign_t *foreign, /*!< in/out: foreign struct */
391 bool do_alloc); /*!< in: is an alloc needed */
392
393/** Fills the dependent virtual columns in a set.
394Reason for being dependent are
3951) FK can be present on base column of virtual columns
3962) FK can be present on column which is a part of virtual index
397@param[in,out] foreign foreign key information. */
399
400/** Fill virtual columns set in each fk constraint present in the table.
401@param[in,out] table innodb table object. */
403
404/** Free the vcol_set from all foreign key constraint on the table.
405@param[in,out] table innodb table object. */
407
408/** Create a temporary tablename like "#sql-ibtid-inc" where
409 tid = the Table ID
410 inc = a randomly initialized number that is incremented for each file
411The table ID is a 64 bit integer, can use up to 20 digits, and is
412initialized at bootstrap. The second number is 32 bits, can use up to 10
413digits, and is initialized at startup to a randomly distributed number.
414It is hoped that the combination of these two numbers will provide a
415reasonably unique temporary file name.
416@param[in] heap A memory heap
417@param[in] dbtab Table name in the form database/table name
418@param[in] id Table id
419@return A unique temporary tablename suitable for InnoDB use */
420char *dict_mem_create_temporary_tablename(mem_heap_t *heap, const char *dbtab,
421 table_id_t id);
422
423static inline bool is_valid_row_version(const row_version_t version) {
424 /* NOTE : 0 is also a valid row versions for rows which are inserted after
425 upgrading from earlier INSTANT implemenation */
426 if (std::cmp_less_equal(version, MAX_ROW_VERSION)) {
427 return true;
428 }
429
430 return false;
431}
432
433/** Initialize dict memory variables */
434void dict_mem_init(void);
435
436/** SQL identifier name wrapper for pretty-printing */
438 public:
439 /** Default constructor */
441 /** Constructor
442 @param[in] name identifier to assign */
443 explicit id_name_t(const char *name) : m_name(name) {}
444
445 /** Assignment operator
446 @param[in] name identifier to assign */
447 id_name_t &operator=(const char *name) {
448 m_name = name;
449 return (*this);
450 }
451
452 /** Implicit type conversion
453 @return the name */
454 operator const char *() const { return (m_name); }
455
456 /** Explicit type conversion
457 @return the name */
458 const char *operator()() const { return (m_name); }
459
460 private:
461 /** The name in internal representation */
462 const char *m_name;
463};
464
465/** Table name wrapper for pretty-printing */
467 /** The name in internal representation */
468 char *m_name;
469};
470
471/** Data structure for default value of a column in a table */
473 /** Pointer to the column itself */
475 /** Default value in bytes */
476 byte *value;
477 /** Length of default value */
478 size_t len;
479
480 bool operator==(const dict_col_default_t &other) const;
481 bool operator!=(const dict_col_default_t &other) const;
482};
483
484/** Data structure for a column in a table */
486 /*----------------------*/
487 /** The following are copied from dtype_t,
488 so that all bit-fields can be packed tightly. */
489 /** @{ */
490
491 /** Default value when this column was added instantly.
492 If this is not a instantly added column then this is nullptr. */
494
495 unsigned prtype : 32; /*!< precise type; MySQL data
496 type, charset code, flags to
497 indicate nullability,
498 signedness, whether this is a
499 binary string, whether this is
500 a true VARCHAR where MySQL
501 uses 2 bytes to store the length */
502 unsigned mtype : 8; /*!< main data type */
503
504 /* the remaining fields do not affect alphabetical ordering: */
505
506 unsigned len : 16; /*!< length; for MySQL data this
507 is field->pack_length(),
508 except that for a >= 5.0.3
509 type true VARCHAR this is the
510 maximum byte length of the
511 string data (in addition to
512 the string, MySQL uses 1 or 2
513 bytes to store the string length) */
514
515 unsigned mbminmaxlen : 5; /*!< minimum and maximum length of a
516 character, in bytes;
517 DATA_MBMINMAXLEN(mbminlen,mbmaxlen);
518 mbminlen=DATA_MBMINLEN(mbminmaxlen);
519 mbmaxlen=DATA_MBMAXLEN(mbminmaxlen) */
520 /*----------------------*/
521 /* End of definitions copied from dtype_t */
522 /** @} */
523
524 unsigned ind : 10; /*!< table column position
525 (starting from 0) */
526 unsigned ord_part : 1; /*!< nonzero if this column
527 appears in the ordering fields
528 of an index */
529 unsigned max_prefix : 12; /*!< maximum index prefix length on
530 this column. Our current max limit is
531 3072 (REC_VERSION_56_MAX_INDEX_COL_LEN)
532 bytes. */
533
534 /* True, if the column is visible */
536
537 private:
538 /* Position of column on physical row.
539 If column prefix is part of PK, it appears twice on row. First 2 bytes are
540 for prefix position and next 2 bytes are for column position on row. */
542
543 /* Row version in which this column was added INSTANTly to the table */
545
546 /* Row version in which this column was dropped INSTANTly from the table */
548
549 public:
550 /* If column prefix is there on row. */
551 bool has_prefix_phy_pos() const { return (phy_pos & 0x8000); }
552
553 /* Get the physical position of column prefix on row. */
554 uint16_t get_prefix_phy_pos() const {
556 return ((uint16_t)(phy_pos >> 16));
557 }
558
559 /* Set the physical position of column prefix on row. */
560 void set_prefix_phy_pos(uint16_t prefix_pos) {
561 phy_pos = prefix_pos;
562 phy_pos = phy_pos << 16;
563 phy_pos |= 0x8000;
564 }
565
566 /* Get the physical position of column on row. */
567 uint16_t get_col_phy_pos() const { return ((phy_pos & ~0x8000) & 0xFFFF); }
568
569 /* Set the physical position of column on row. */
570 void set_col_phy_pos(uint16_t pos) {
572 phy_pos |= pos;
573 }
574
575 /* Set the physical position metadata of column. */
576 uint32_t get_phy_pos() const { return phy_pos; }
577
578 /* Get the physical position metadata of column. */
579 void set_phy_pos(uint32_t pos) { phy_pos = pos; }
580
581 bool is_instant_added() const {
583 return true;
584 }
585 return false;
586 }
587
590 return version_added;
591 }
592
596 }
597
598 bool is_version_added_match(const dict_col_t *col) const {
599 if (is_instant_added() != col->is_instant_added()) {
600 return false;
601 }
602
603 if (is_instant_added()) {
604 return (get_version_added() == col->get_version_added());
605 }
606
607 return true;
608 }
609
610 bool is_instant_dropped() const {
612 return true;
613 }
614 return false;
615 }
616
619 return version_dropped;
620 }
621
625 }
626
627 bool is_version_dropped_match(const dict_col_t *col) const {
628 if (is_instant_dropped() != col->is_instant_dropped()) {
629 return false;
630 }
631
632 if (is_instant_dropped()) {
633 return (get_version_dropped() == col->get_version_dropped());
634 }
635
636 return true;
637 }
638
639 /** Returns the minimum size of the column.
640 @return minimum size */
643 }
644
645 /** Returns the maximum size of the column.
646 @return maximum size */
648
649 /** Check if a column is a virtual column
650 @return true if it is a virtual column, false otherwise */
651 bool is_virtual() const { return (prtype & DATA_VIRTUAL); }
652
653 /** Check if a column is a multi-value virtual column
654 @return true if it is a multi-value virtual column, false otherwise */
655 bool is_multi_value() const { return ((prtype & DATA_MULTI_VALUE) != 0); }
656
657 /** Check if a column is nullable
658 @return true if it is nullable, otherwise false */
659 bool is_nullable() const { return ((prtype & DATA_NOT_NULL) == 0); }
660
661 /** Gets the column data type.
662 @param[out] type data type */
663 void copy_type(dtype_t *type) const {
664 ut_ad(type != nullptr);
665
666 type->mtype = mtype;
667 type->prtype = prtype;
668 type->len = len;
669 type->mbminmaxlen = mbminmaxlen;
670 }
671
672 /** Gets the minimum number of bytes per character.
673 @return minimum multi-byte char size, in bytes */
675
676 /** Gets the maximum number of bytes per character.
677 @return maximum multi-byte char size, in bytes */
679
680 /** Sets the minimum and maximum number of bytes per character.
681 @param[in] mbminlen minimum multi byte character size, in bytes
682 @param[in] mbmaxlen mAXimum multi-byte character size, in bytes */
683 void set_mbminmaxlen(ulint mbminlen, ulint mbmaxlen) {
684 ut_ad(mbminlen < DATA_MBMAX);
685 ut_ad(mbmaxlen < DATA_MBMAX);
686 ut_ad(mbminlen <= mbmaxlen);
687
688 mbminmaxlen = DATA_MBMINMAXLEN(mbminlen, mbmaxlen);
689 }
690
691 /** Returns the size of a fixed size column, 0 if not a fixed size column.
692 @param[in] comp nonzero=ROW_FORMAT=COMPACT
693 @return fixed size, or 0 */
696 }
697
698 /** Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column.
699 For fixed length types it is the fixed length of the type, otherwise 0.
700 @param[in] comp nonzero=ROW_FORMAT=COMPACT
701 @return SQL null storage size in ROW_FORMAT=REDUNDANT */
702 ulint get_null_size(ulint comp) const { return (get_fixed_size(comp)); }
703
704 /** Check whether the col is used in spatial index or regular index.
705 @return spatial status */
707 spatial_status_t spatial_status = SPATIAL_NONE;
708
709 /* Column is not a part of any index. */
710 if (!ord_part) {
711 return (spatial_status);
712 }
713
715 if (max_prefix == 0) {
716 spatial_status = SPATIAL_ONLY;
717 } else {
718 /* Any regular index on a geometry column
719 should have a prefix. */
720 spatial_status = SPATIAL_MIXED;
721 }
722 }
723
724 return (spatial_status);
725 }
726
727 /** Set default value
728 @param[in] value Default value
729 @param[in] length Default value length
730 @param[in,out] heap Heap to allocate memory */
731 void set_default(const byte *value, size_t length, mem_heap_t *heap);
732
733 /** Check if column is dropped before the given version.
734 @param[in] version row version
735 @return true if the column is dropped before or in the version. */
738
739 if (!is_instant_dropped()) {
740 return false;
741 }
742
743 return (get_version_dropped() <= version);
744 }
745
746 /** Check if column is added after the current version.
747 @param[in] version row version
748 @return true if column is added after the current row version. */
751
752 if (!is_instant_added()) {
753 return false;
754 }
755
756 return (get_version_added() > version);
757 }
758
759 /** Check if a column is visible in given version.
760 @param[in] version row version
761 return true if column is visible in version. */
765 }
766
767#ifdef UNIV_DEBUG
768 /** Assert that a column and a data type match.
769 param[in] type data type
770 @return true */
771 bool assert_equal(const dtype_t *type) const {
772 ut_ad(type);
773
774 ut_ad_eq(mtype, type->mtype);
775 ut_ad_eq((prtype | DATA_VIRTUAL), (type->prtype | DATA_VIRTUAL));
776 // ut_ad(col->len == type->len);
777#ifndef UNIV_HOTBACKUP
778 ut_ad(mbminmaxlen == type->mbminmaxlen);
779#endif /* !UNIV_HOTBACKUP */
780
781 return true;
782 }
783
784 /** Check if a column name resembles format for dropped column.
785 param[in] type column name
786 @return true if column name resembles dropped column. */
787 static bool is_instant_dropped_name(const std::string col_name) {
788 if (col_name.find(INSTANT_DROP_SUFFIX_8_0_29) != std::string::npos ||
789 col_name.find(INSTANT_DROP_PREFIX_8_0_32) != std::string::npos)
790 return true;
791 return false;
792 }
793#endif /* UNIV_DEBUG */
794};
795
796/** Index information put in a list of virtual column structure. Index
797id and virtual column position in the index will be logged.
798There can be multiple entries for a given index, with a different position. */
800 /** active index on the column */
802
803 /** position in this index */
805};
806
807/** Index list to put in dict_v_col_t */
808typedef std::list<dict_v_idx_t, ut::allocator<dict_v_idx_t>> dict_v_idx_list;
809
810/** Data structure for a virtual column in a table */
812 /** column structure */
814
815 /** array of base column ptr */
817
818 /** number of base columns */
820
821 /** column pos in table */
823
824 /** Virtual index list, and column position in the index,
825 the allocated memory is not from table->heap, nor it is
826 tracked by dict_sys->size */
828};
829
830/** Data structure for newly added virtual column in a table */
832 /** number of new virtual column */
834
835 /** column structures */
837
838 /** new col names */
839 const char **v_col_name;
840};
841
842/** Data structure for a stored column in a table. */
844 /** Stored column ptr */
846 /** array of base col ptr */
848 /** number of base columns */
850 /** column pos in table */
852};
853
854/** list to put stored column for dict_table_t */
855typedef std::list<dict_s_col_t, ut::allocator<dict_s_col_t>> dict_s_col_list;
856
857/** @brief DICT_ANTELOPE_MAX_INDEX_COL_LEN is measured in bytes and
858is the maximum indexed column length (or indexed prefix length) in
859ROW_FORMAT=REDUNDANT and ROW_FORMAT=COMPACT. Also, in any format,
860any fixed-length field that is longer than this will be encoded as
861a variable-length field.
862
863It is set to 3*256, so that one can create a column prefix index on
864256 characters of a TEXT or VARCHAR column also in the UTF-8
865charset. In that charset, a character may take at most 3 bytes. This
866constant MUST NOT BE CHANGED, or the compatibility of InnoDB data
867files would be at risk! */
870
871/** Find out maximum indexed column length by its table format.
872For ROW_FORMAT=REDUNDANT and ROW_FORMAT=COMPACT, the maximum
873field length is REC_ANTELOPE_MAX_INDEX_COL_LEN - 1 (767). For
874ROW_FORMAT=COMPRESSED and ROW_FORMAT=DYNAMIC, the length could
875be REC_VERSION_56_MAX_INDEX_COL_LEN (3072) bytes */
876#define DICT_MAX_FIELD_LEN_BY_FORMAT(table) \
877 (dict_table_has_atomic_blobs(table) ? REC_VERSION_56_MAX_INDEX_COL_LEN \
878 : REC_ANTELOPE_MAX_INDEX_COL_LEN - 1)
879
880static inline uint32_t DICT_MAX_FIELD_LEN_BY_FORMAT_FLAG(uint32_t flags) {
883 }
885}
886
887/** Defines the maximum fixed length column size */
889
890/** Data structure for a field in an index */
893
894 dict_col_t *col; /*!< pointer to the table column */
895 id_name_t name; /*!< name of the column */
896 unsigned prefix_len : 12; /*!< 0 or the length of the column
897 prefix in bytes in a MySQL index of
898 type, e.g., INDEX (textcol(25));
899 must be smaller than
900 DICT_MAX_FIELD_LEN_BY_FORMAT;
901 NOTE that in the UTF-8 charset, MySQL
902 sets this to (mbmaxlen * the prefix len)
903 in UTF-8 chars */
904 unsigned fixed_len : 10; /*!< 0 or the fixed length of the
905 column if smaller than
906 DICT_ANTELOPE_MAX_INDEX_COL_LEN */
907 unsigned is_ascending : 1; /*!< 0=DESC, 1=ASC */
908
909 uint16_t get_phy_pos() const {
910 if (prefix_len != 0) {
911 return col->get_prefix_phy_pos();
912 }
913
914 return col->get_col_phy_pos();
915 }
916
917 size_t get_mbmaxlen() const { return DATA_MBMAXLEN(col->mbminmaxlen); }
918};
919
920/** PADDING HEURISTIC BASED ON LINEAR INCREASE OF PADDING TO AVOID
921 COMPRESSION FAILURES
922 (Note: this is relevant only for compressed indexes)
923 GOAL: Avoid compression failures by maintaining information about the
924 compressibility of data. If data is not very compressible then leave
925 some extra space 'padding' in the uncompressed page making it more
926 likely that compression of less than fully packed uncompressed page will
927 succeed.
928
929 This padding heuristic works by increasing the pad linearly until the
930 desired failure rate is reached. A "round" is a fixed number of
931 compression operations.
932 After each round, the compression failure rate for that round is
933 computed. If the failure rate is too high, then padding is incremented
934 by a fixed value, otherwise it's left intact.
935 If the compression failure is lower than the desired rate for a fixed
936 number of consecutive rounds, then the padding is decreased by a fixed
937 value. This is done to prevent overshooting the padding value,
938 and to accommodate the possible change in data compressibility. */
939
940/** Number of zip ops in one round. */
941constexpr uint32_t ZIP_PAD_ROUND_LEN = 128;
942
943/** Number of successful rounds after which the padding is decreased */
944constexpr uint32_t ZIP_PAD_SUCCESSFUL_ROUND_LIMIT = 5;
945
946/** Amount by which padding is increased. */
947constexpr uint32_t ZIP_PAD_INCR = 128;
948
949/** Percentage of compression failures that are allowed in a single
950round */
951extern ulong zip_failure_threshold_pct;
952
953/** Maximum percentage of a page that can be allowed as a pad to avoid
954compression failures */
955extern ulong zip_pad_max;
956
957/** Data structure to hold information about about how much space in
958an uncompressed page should be left as padding to avoid compression
959failures. This estimate is based on a self-adapting heuristic. */
961 SysMutex *mutex; /*!< mutex protecting the info */
962 std::atomic<ulint> pad; /*!< number of bytes used as pad */
963 ulint success; /*!< successful compression ops during
964 current round */
965 ulint failure; /*!< failed compression ops during
966 current round */
967 ulint n_rounds; /*!< number of currently successful
968 rounds */
969#ifndef UNIV_HOTBACKUP
970 std::atomic<os_once::state_t> mutex_created;
971 /*!< Creation state of mutex member */
972#endif /* !UNIV_HOTBACKUP */
973};
974
975/** If key is fixed length key then cache the record offsets on first
976computation. This will help save computation cycle that generate same
977redundant data. */
979 /** Holds reference to cached offsets for record. */
980 const ulint *offsets{nullptr};
981
982 /** Number of NULLable columns among those for which offsets are cached */
983 size_t nullable_cols{0};
984};
985
986/** Cache position of last inserted or selected record by caching record
987and holding reference to the block where record resides.
988Note: We don't commit mtr and hold it beyond a transaction lifetime as this is
989a special case (intrinsic table) that are not shared across connection. */
991 public:
992 /** Constructor */
994 /* Do Nothing. */
995 }
996
997 /* Commit mtr and re-initialize cache record and block to NULL. */
998 void release() {
999 if (mtr.is_active()) {
1000 mtr_commit(&mtr);
1001 }
1002 rec = nullptr;
1003 block = nullptr;
1004 invalid = false;
1005 }
1006
1007 public:
1008 /** last inserted/selected record. */
1010
1011 /** block where record reside. */
1013
1014 /** active mtr that will be re-used for next insert/select. */
1016
1017 /** disable caching. (disabled when table involves blob/text.) */
1019
1020 /** If index structure is undergoing structural change viz.
1021 split then invalidate the cached position as it would be no more
1022 remain valid. Will be re-cached on post-split insert. */
1024};
1025
1026/** Data structure storing index statistics for query optimization. */
1028#ifndef UNIV_HOTBACKUP
1029 /** approximate number of different key values for this index, for each
1030 n-column prefix where 1 <= n <= dict_get_n_unique(index) (the array is
1031 indexed from 0 to n_uniq-1); we periodically calculate new estimates */
1033
1034 /** number of pages that were sampled to calculate each of
1035 n_diff_key_vals[], e.g. stat_n_sample_sizes[3] pages were sampled to get
1036 the number n_diff_key_vals[3]. */
1038
1039 /* approximate number of non-null key values for this index, for each column
1040 where 1 <= n <= dict_get_n_unique(index) (the array is indexed from 0 to
1041 n_uniq-1); This is used when innodb_stats_method is "nulls_ignored". */
1043
1044 /** approximate index size in database pages */
1046#endif /* !UNIV_HOTBACKUP */
1047 /** approximate number of leaf pages in the index tree */
1049};
1050
1051/** "GEN_CLUST_INDEX" is the name reserved for InnoDB default
1052system clustered index when there is no primary key. */
1053const char innobase_index_reserve_name[] = "GEN_CLUST_INDEX";
1054
1055namespace dd {
1056class Spatial_reference_system;
1057}
1058
1059#ifdef UNIV_DEBUG
1060/** Value of dict_index_t::magic_n */
1061constexpr uint32_t DICT_INDEX_MAGIC_N = 76789786;
1062#endif
1063
1065constexpr uint32_t MAX_KEY_LENGTH_BITS = 12;
1066
1067/** Data structure for an index. Most fields will be
1068initialized to 0, NULL or false in dict_mem_index_create(). */
1070 /** id of the index */
1072
1073 /** memory heap */
1075
1076 /** index name */
1078
1079 /** table name */
1080 const char *table_name;
1081
1082 /** back pointer to table */
1084
1085 /** space where the index tree is placed */
1086 unsigned space : 32;
1087
1088 /** index tree root page number */
1089 unsigned page : 32;
1090
1091 /** In the pessimistic delete, if the page data size drops below this limit
1092 in percent, merging it to a neighbor is tried */
1093 unsigned merge_threshold : 6;
1094
1095 /** index type (DICT_CLUSTERED, DICT_UNIQUE, DICT_IBUF, DICT_CORRUPT) */
1096 unsigned type : DICT_IT_BITS;
1097
1098 /** position of the trx id column in a clustered index record, if the fields
1099 before it are known to be of a fixed size, 0 otherwise */
1101
1102 static_assert(1 << MAX_KEY_LENGTH_BITS >= MAX_KEY_LENGTH,
1103 "1<<MAX_KEY_LENGTH_BITS) < MAX_KEY_LENGTH");
1104
1105 /** number of columns the user defined to be in the index: in the internal
1106 representation we add more columns */
1107 unsigned n_user_defined_cols : 10;
1108
1109 /** if true, allow duplicate values even if index is created with unique
1110 constraint */
1111 unsigned allow_duplicates : 1;
1112
1113 /** if true, SQL NULL == SQL NULL */
1114 unsigned nulls_equal : 1;
1115
1116 /** if true, then disable AHI. Currently limited to intrinsic temporary table
1117 and SDI table as index id is not unique for such table which is one of the
1118 validation criterion for ahi. */
1119 unsigned disable_ahi : 1;
1120
1121 /** number of fields from the beginning which are enough to determine an index
1122 entry uniquely */
1123 unsigned n_uniq : 10;
1124
1125 /** number of fields defined so far */
1126 unsigned n_def : 10;
1127
1128 /** number of fields in the index */
1129 unsigned n_fields : 10;
1130
1131 /** number of total fields in the index (including INSTANT dropped fields) */
1132 unsigned n_total_fields : 10;
1133
1134 /** number of nullable fields */
1135 unsigned n_nullable : 10;
1136
1137 /** number of nullable fields before first instant ADD COLUMN applied to this
1138 table. This is valid only when has_instant_cols() is true */
1139 unsigned n_instant_nullable : 10;
1140
1141 /** true if the index object is in the dictionary cache */
1142 unsigned cached : 1;
1143
1144 /** true if the index is to be dropped; protected by dict_operation_lock */
1145 unsigned to_be_dropped : 1;
1146
1147 /** enum online_index_status. Transitions from ONLINE_INDEX_COMPLETE (to
1148 ONLINE_INDEX_CREATION) are protected by dict_operation_lock and
1149 dict_sys->mutex. Other changes are protected by index->lock. */
1150 unsigned online_status : 2;
1151
1152 /** a flag that is set for secondary indexes that have not been committed to
1153 the data dictionary yet */
1154 unsigned uncommitted : 1;
1155
1156 /** true if the index is clustered index and it has some instant columns */
1157 unsigned instant_cols : 1;
1158
1159 /** true if the index is clustered index and table has row versions */
1160 unsigned row_versions : 1;
1161
1162 /** spatial reference id */
1163 uint32_t srid;
1164
1165 /** says whether SRID is valid - it cane be undefined */
1167
1168 /** Cached spatial reference system dictionary entry used by R-tree indexes.
1169 */
1170 std::unique_ptr<dd::Spatial_reference_system> rtr_srs;
1171
1172#ifdef UNIV_DEBUG
1173 uint32_t magic_n; /*!< magic number */
1174#endif
1175
1176 /** array of field descriptions */
1178
1179 /** Array of field pos sorted as per their physical pos in record. Only
1180 needed for clustered index having INSTANT ADD/DROP columns. */
1181 std::vector<uint16_t> fields_array;
1182
1183 /** Number of nullable columns in each version. Only needed for clustered
1184 index having INSTANT ADD/DROP columns. */
1185 uint32_t nullables[MAX_ROW_VERSION + 1] = {0};
1186
1187#ifndef UNIV_HOTBACKUP
1188 /** fulltext parser plugin */
1190
1191 /** true if it's ngram parser */
1193
1194 /** whether it has a newly added virtual column in ALTER */
1196
1197 /** if the index is an hidden index */
1199#endif /* !UNIV_HOTBACKUP */
1200
1201 /** list of indexes of the table */
1203
1204 /** info used in optimistic searches */
1206
1207#ifndef UNIV_HOTBACKUP
1208 /** the log of modifications during online index creation;
1209 valid when online_status is ONLINE_INDEX_CREATION */
1211#endif /* !UNIV_HOTBACKUP */
1212
1213 /*----------------------*/
1214 /** Statistics for query optimization */
1215 /** @{ */
1217 /** @} */
1218
1219 /** cache the last insert position. Currently limited to auto-generated
1220 clustered index on intrinsic table only. */
1222
1223 /** cache the last selected position. Currently limited to intrinsic table
1224 only. */
1226
1227 /** cache the field that needs to be re-computed on each insert. Limited to
1228 intrinsic table as this is common share and can't be used without protection
1229 if table is accessible to multiple-threads. */
1231
1232 /** Node sequence number for RTree */
1234
1235 /** tracking all R-Tree search cursors */
1237
1238 /** id of the transaction that created this index, or 0 if the index existed
1239 when InnoDB was started up */
1241
1242 /** Information about state of compression failures and successes */
1244
1245 /** read-write lock protecting the upper levels of the index tree */
1247
1248 /** Flag whether need to fill dd tables when it's a fulltext index. */
1250
1251 /** Set instant nullable
1252 @param[in] n nullable fields before first INSTANT ADD */
1254
1255 /** Get instant nullable.
1256 @return number of nullable fields before first INSTANT ADD */
1257 uint16_t get_instant_nullable() const { return n_instant_nullable; }
1258
1259 /** Get the nullable fields before any INSTANT ADD/DROP
1260 @return number of nullable fields */
1262 if (has_instant_cols()) {
1263 return get_instant_nullable();
1264 }
1265
1266 if (has_row_versions()) {
1267 return get_nullable_in_version(0);
1268 }
1269
1270 return n_nullable;
1271 }
1272
1273 /** Determine if the index has been committed to the
1274 data dictionary.
1275 @return whether the index definition has been committed */
1276 bool is_committed() const {
1278 return (UNIV_LIKELY(!uncommitted));
1279 }
1280
1281 /** Flag an index committed or uncommitted.
1282 @param[in] committed whether the index is committed */
1283 void set_committed(bool committed) {
1285 ut_ad(committed || !(type & DICT_CLUSTERED));
1286 uncommitted = !committed;
1287 }
1288
1289 /** Get the next index.
1290 @return next index
1291 @retval NULL if this was the last index */
1292 const dict_index_t *next() const {
1293 const dict_index_t *next = UT_LIST_GET_NEXT(indexes, this);
1295 return (next);
1296 }
1297 /** Get the next index.
1298 @return next index
1299 @retval NULL if this was the last index */
1301 return (const_cast<dict_index_t *>(
1302 const_cast<const dict_index_t *>(this)->next()));
1303 }
1304
1305 /** Check whether the index is corrupted.
1306 @return true if index is corrupted, otherwise false */
1307 bool is_corrupted() const {
1309
1310 return (type & DICT_CORRUPT);
1311 }
1312
1313 /* Check whether the index is the clustered index
1314 @return nonzero for clustered index, zero for other indexes */
1315
1316 bool is_clustered() const {
1318
1319 return (type & DICT_CLUSTERED);
1320 }
1321
1322 /** Check whether the index is the multi-value index
1323 @return nonzero for multi-value index, zero for other indexes */
1324 bool is_multi_value() const {
1326
1327 return (type & DICT_MULTI_VALUE);
1328 }
1329
1330 /** Returns the minimum data size of an index record.
1331 @return minimum data size in bytes */
1333 ulint size = 0;
1334
1335 for (unsigned i = 0; i < n_fields; i++) {
1336 size += get_col(i)->get_min_size();
1337 }
1338
1339 return (size);
1340 }
1341
1342 /** Check whether index can be used by transaction
1343 @param[in] trx transaction*/
1344 bool is_usable(const trx_t *trx) const;
1345
1346 /** Check whether index has any instantly added columns.
1347 Possible only if table has INSTANT ADD columns and is upgraded.
1348 @return true if this is instant affected, otherwise false */
1349 bool has_instant_cols() const { return (instant_cols); }
1350
1351 /** Check whether index belongs to a table having row versions
1352 @return true if table has row versions, otherwise false */
1353 bool has_row_versions() const { return (row_versions); }
1354
1355 /** check if either instant or versioned.
1356 @return true if table has row versions or instant cols, otherwise false */
1358 if (!is_clustered()) {
1360 return false;
1361 }
1362
1363 return (has_row_versions() || has_instant_cols());
1364 }
1365
1366 /** Check if tuple is having instant format.
1367 @param[in] n_fields_in_tuple number of fields in tuple
1368 @return true if yes, false otherwise. */
1369 bool is_tuple_instant_format(const uint16_t n_fields_in_tuple) const;
1370
1371 /** Returns the number of nullable fields before specified nth field
1372 @param[in] nth nth field to check */
1373 uint32_t get_n_nullable_before(uint32_t nth) const {
1374 uint32_t nullable = 0;
1375 ut_ad(nth <= n_total_fields);
1376
1377 for (size_t i = 0; i < nth; ++i) {
1378 dict_col_t *col = get_field(i)->col;
1379
1380 ut_ad(!col->is_instant_dropped());
1381
1382 if (col->is_nullable()) {
1383 nullable++;
1384 }
1385 }
1386
1387 return (nullable);
1388 }
1389
1390 /** Returns total fields including INSTANT DROP fields. */
1391 uint32_t get_n_total_fields() const {
1393 return n_total_fields;
1394 }
1395
1396 /** Returns the number of fields before first instant ADD COLUMN. This is
1397 needed only for V1 INSTANT ADD. */
1398 uint32_t get_instant_fields() const;
1399
1400 size_t calculate_n_instant_nullable(size_t _n_fields) const {
1401 if (!has_row_versions()) {
1403 return get_n_nullable_before(_n_fields);
1404 }
1405
1406 size_t n_drop_nullable_cols = 0;
1407 size_t new_n_nullable = 0;
1408 for (size_t i = 0; i < n_def; i++) {
1409 const dict_field_t *field = &fields[i];
1410 const dict_col_t *col = field->col;
1411
1412 if (col->is_instant_added()) {
1413 continue;
1414 }
1415
1416 if (col->is_instant_dropped()) {
1417 if (col->get_col_phy_pos() < _n_fields && col->is_nullable()) {
1418 n_drop_nullable_cols++;
1419 }
1420 continue;
1421 }
1422
1423 /* This is regular column */
1424 if (col->get_col_phy_pos() < _n_fields) {
1425 if (col->is_nullable()) {
1426 new_n_nullable++;
1427 }
1428 }
1429 }
1430
1431 new_n_nullable += n_drop_nullable_cols;
1432
1433 return new_n_nullable;
1434 }
1435
1436 /** Create nullables array.
1437 @param[in] current_row_version current row version of table */
1438 void create_nullables(uint32_t current_row_version);
1439
1440 /** Return nullable in a specific row version */
1443
1444 return nullables[version];
1445 }
1446
1447 /** Create fields array sorted by phy_pos of field in row */
1449 fields_array.resize(n_def);
1450 for (uint32_t i = 0; i < n_def; i++) {
1451 dict_field_t *field = get_field(i);
1452 ut_ad(field != nullptr && field->col != nullptr);
1453
1454 size_t pos = field->get_phy_pos();
1455
1456 fields_array[pos] = i;
1457 }
1458 }
1459
1461 /* The dict_index_t destructor is never called. The object is "destructed"
1462 manually in dict_mem_index_free() and then the memory is just freed. This
1463 method is called from the mentioned dict_mem_index_free(). Please note that
1464 this vector is never constructed either - we just zero the memory and start
1465 using it after calling a "constructor" dict_mem_fill_index_struct(). */
1466 fields_array.~vector<uint16_t>();
1467 }
1468
1469 /** Adds a field definition to an index. NOTE: does not take a copy
1470 of the column name if the field is a column. The memory occupied
1471 by the column name may be released only after publishing the index.
1472 @param[in] name_arg column name
1473 @param[in] prefix_len 0 or the column prefix length in a MySQL index
1474 like INDEX (textcol(25))
1475 @param[in] is_ascending true=ASC, false=DESC */
1476 void add_field(const char *name_arg, ulint prefix_len, bool is_ascending) {
1477 dict_field_t *field;
1478
1480
1481 n_def++;
1482
1483 field = get_field(n_def - 1);
1484
1485 field->name = name_arg;
1486 field->prefix_len = (unsigned int)prefix_len;
1487 field->is_ascending = is_ascending;
1488 }
1489
1490 /** Gets the nth physical pos field.
1491 @param[in] pos physical position of the field
1492 @return pointer to the field object. */
1494 ut_ad(pos < n_def);
1496
1497 if (has_row_versions()) {
1498 return get_field(fields_array[pos]);
1499 }
1500
1501 return get_field(pos);
1502 }
1503
1504 /** Gets the nth field of an index.
1505 @param[in] pos position of field
1506 @return pointer to field object */
1508 ut_ad(pos < n_def);
1510
1511 return (fields + pos);
1512 }
1513
1514 /** Given the physical position, find the logical position of field.
1515 @param[in] phy_pos physical position of field
1516 @return logical position of field */
1517 uint16_t get_logical_pos(uint16_t phy_pos) const {
1518 for (size_t i = 0; i < n_def; i++) {
1519 if (get_field(i)->get_phy_pos() == phy_pos) {
1520 return i;
1521 }
1522 }
1523 ut_ad(false);
1524 return UINT16_UNDEFINED;
1525 }
1526
1527 /** Get the physical position of a field on a row. For table having INSTANT
1528 column, it might differ from field index (pos).
1529 @param[in] pos field index
1530 @return physical position on row */
1531 uint16_t get_field_off_pos(ulint pos) const {
1532 return get_field(pos)->get_phy_pos();
1533 }
1534
1536 uint16_t phy_pos = get_field(pos)->get_phy_pos();
1538 return phy_pos;
1539 }
1540
1541 uint16_t res = phy_pos;
1542 for (size_t i = 0; i < phy_pos; i++) {
1543 if (get_field(fields_array[i])->col->is_dropped_in_or_before(version)) {
1544 res--;
1545 }
1546 }
1547
1548 return res;
1549 }
1550
1551 /** Gets pointer to the nth column in an index.
1552 @param[in] pos position of the field
1553 @return column */
1554 const dict_col_t *get_col(ulint pos) const { return (get_field(pos)->col); }
1555
1556 /** Gets the column number the nth field in an index.
1557 @param[in] pos position of the field
1558 @return column number */
1559 ulint get_col_no(ulint pos) const;
1560
1561 /** Returns the position of a system column in an index.
1562 @param[in] type DATA_ROW_ID, ...
1563 @return position, ULINT_UNDEFINED if not contained */
1565
1566 /** Looks for column n in an index.
1567 @param[in] n column number
1568 @param[in] inc_prefix true=consider column prefixes too
1569 @param[in] is_virtual true==virtual column
1570 @return position in internal representation of the index;
1571 ULINT_UNDEFINED if not contained */
1572 ulint get_col_pos(ulint n, bool inc_prefix = false,
1573 bool is_virtual = false) const;
1574
1575 /** Get the default value of nth field and its length if exists.
1576 If not exists, both the return value is nullptr and length is 0.
1577 @param[in] nth nth field to get
1578 @param[in,out] length length of the default value
1579 @return the default value data of nth field */
1580 const byte *get_nth_default(ulint nth, ulint *length) const {
1581 ut_ad(nth < get_n_total_fields());
1582
1583 const dict_col_t *col = get_physical_field(nth)->col;
1584 if (col->instant_default == nullptr) {
1585 *length = 0;
1586 return (nullptr);
1587 }
1588
1589 *length = col->instant_default->len;
1590 ut_ad(*length == 0 || *length == UNIV_SQL_NULL ||
1591 col->instant_default->value != nullptr);
1592 return (col->instant_default->value);
1593 }
1594
1595 /** Sets srid and srid_is_valid values
1596 @param[in] srid_value value of SRID, may be garbage
1597 if srid_is_valid_value = false
1598 @param[in] srid_is_valid_value value of srid_is_valid */
1599 void fill_srid_value(uint32_t srid_value, bool srid_is_valid_value) {
1600 srid_is_valid = srid_is_valid_value;
1601 srid = srid_value;
1602 }
1603
1604 /** Check if the underlying table is compressed.
1605 @return true if compressed, false otherwise. */
1606 inline bool is_compressed() const;
1607
1608 /** Check if a multi-value index is built on specified multi-value
1609 virtual column. Please note that there could be only one multi-value
1610 virtual column on the multi-value index, but not necessary the first
1611 field of the index.
1612 @param[in] mv_col multi-value virtual column
1613 @return non-zero means the column is on the index and this is the
1614 nth position of the column, zero means it's not on the index */
1615 uint32_t has_multi_value_col(const dict_v_col_t *mv_col) const {
1617 for (uint32_t i = 0; i < n_fields; ++i) {
1618 const dict_col_t *col = get_col(i);
1619 if (mv_col->m_col.ind == col->ind) {
1620 return (i + 1);
1621 }
1622
1623 /* Only one multi-value field, if not match then no match. */
1624 if (col->is_multi_value()) {
1625 break;
1626 }
1627 }
1628
1629 return (0);
1630 }
1631
1632 public:
1633 /** Get the page size of the tablespace to which this index belongs.
1634 @return the page size. */
1635 page_size_t get_page_size() const;
1636
1637 /** Get the space id of the tablespace to which this index belongs.
1638 @return the space id. */
1639 space_id_t space_id() const { return space; }
1640
1641 /** Check if it is a full-text search (FTS) index
1642 @return true if this is a FTS index, false otherwise. */
1643 bool is_fts_index() const { return type & DICT_FTS; }
1644};
1645
1646/** The status of online index creation */
1648 /** the index is complete and ready for access */
1650 /** the index is being created, online
1651 (allowing concurrent modifications) */
1653 /** secondary index creation was aborted and the index
1654 should be dropped as soon as index->table->n_ref_count reaches 0,
1655 or online table rebuild was aborted and the clustered index
1656 of the original table should soon be restored to
1657 ONLINE_INDEX_COMPLETE */
1659 /** the online index creation was aborted, the index was
1660 dropped from the data dictionary and the tablespace, and it
1661 should be dropped from the data dictionary cache as soon as
1662 index->table->n_ref_count reaches 0. */
1665
1666/** Set to store the virtual columns which are affected by Foreign
1667key constraint. */
1668typedef std::set<dict_v_col_t *, std::less<dict_v_col_t *>,
1671
1672/** Data structure for a foreign key constraint; an example:
1673FOREIGN KEY (A, B) REFERENCES TABLE2 (C, D). Most fields will be
1674initialized to 0, NULL or false in dict_mem_foreign_create(). */
1676 mem_heap_t *heap; /*!< this object is allocated from
1677 this memory heap */
1678 char *id; /*!< id of the constraint as a
1679 null-terminated string */
1680 unsigned n_fields : 10; /*!< number of indexes' first fields
1681 for which the foreign key
1682 constraint is defined: we allow the
1683 indexes to contain more fields than
1684 mentioned in the constraint, as long
1685 as the first fields are as mentioned */
1686 unsigned type : 6; /*!< 0 or DICT_FOREIGN_ON_DELETE_CASCADE
1687 or DICT_FOREIGN_ON_DELETE_SET_NULL */
1688 char *foreign_table_name; /*!< foreign table name */
1690 /*!< foreign table name used for dict lookup */
1691 dict_table_t *foreign_table; /*!< table where the foreign key is */
1692 const char **foreign_col_names; /*!< names of the columns in the
1693 foreign key */
1694 char *referenced_table_name; /*!< referenced table name */
1696 /*!< referenced table name for dict lookup*/
1697 dict_table_t *referenced_table; /*!< table where the referenced key
1698 is */
1699 const char **referenced_col_names; /*!< names of the referenced
1700 columns in the referenced table */
1701 dict_index_t *foreign_index; /*!< foreign index; we require that
1702 both tables contain explicitly defined
1703 indexes for the constraint: InnoDB
1704 does not generate new indexes
1705 implicitly */
1706 dict_index_t *referenced_index; /*!< referenced index */
1707
1708 dict_vcol_set *v_cols; /*!< set of virtual columns affected
1709 by foreign key constraint. */
1710
1711 /** Check whether foreign key constraint contains a column with a full
1712 index on it. The function is used in the context of cascading DML
1713 operations.
1714 @retval true if the column has FTS index on it.
1715 @retval false if the FK table has no FTS index or has self referential
1716 relationship
1717 */
1718 bool is_fts_col_affected() const;
1719};
1720
1721std::ostream &operator<<(std::ostream &out, const dict_foreign_t &foreign);
1722
1724 dict_foreign_print(std::ostream &out) : m_out(out) {}
1725
1726 void operator()(const dict_foreign_t *foreign) { m_out << *foreign; }
1727
1728 private:
1729 std::ostream &m_out;
1730};
1731
1732/** Compare two dict_foreign_t objects using their ids. Used in the ordering
1733of dict_table_t::foreign_set and dict_table_t::referenced_set. It returns
1734true if the first argument is considered to go before the second in the
1735strict weak ordering it defines, and false otherwise. */
1737 bool operator()(const dict_foreign_t *lhs, const dict_foreign_t *rhs) const {
1738 return (ut_strcmp(lhs->id, rhs->id) < 0);
1739 }
1740};
1741
1742/** A function object to find a foreign key with the given index as the
1743referenced index. Return the foreign key with matching criteria or NULL */
1746
1747 bool operator()(const dict_foreign_t *foreign) const {
1748 return (foreign->referenced_index == m_index);
1749 }
1750
1752};
1753
1754/* A function object to check if the foreign constraint is between different
1755tables. Returns true if foreign key constraint is between different tables,
1756false otherwise. */
1758 bool operator()(const dict_foreign_t *foreign) const {
1759 return (foreign->foreign_table != foreign->referenced_table);
1760 }
1761};
1762
1766
1767std::ostream &operator<<(std::ostream &out, const dict_foreign_set &fk_set);
1768
1769/** Function object to check if a foreign key object is there
1770in the given foreign key set or not. It returns true if the
1771foreign key is not found, false otherwise */
1774
1775 /* Return true if the given foreign key is not found */
1776 bool operator()(dict_foreign_t *const &foreign) const {
1777 return (m_foreigns.find(foreign) == m_foreigns.end());
1778 }
1779
1780 private:
1782};
1783
1784/** Validate the search order in the foreign key set.
1785@param[in] fk_set the foreign key set to be validated
1786@return true if search order is fine in the set, false otherwise. */
1788
1789/** Validate the search order in the foreign key sets of the table
1790(foreign_set and referenced_set).
1791@param[in] table table whose foreign key sets are to be validated
1792@return true if foreign key sets are fine, false otherwise. */
1794
1795/** Frees a foreign key struct. */
1797 dict_foreign_t *foreign) /*!< in, own: foreign key struct */
1798{
1799 if (foreign->v_cols != nullptr) {
1800 ut::delete_(foreign->v_cols);
1801 }
1802
1803 mem_heap_free(foreign->heap);
1804}
1805
1806/** The destructor will free all the foreign key constraints in the set
1807by calling dict_foreign_free() on each of the foreign key constraints.
1808This is used to free the allocated memory when a local set goes out
1809of scope. */
1812 : m_foreign_set(foreign_set) {}
1813
1817 }
1818
1820};
1821
1822/** The flags for ON_UPDATE and ON_DELETE can be ORed; the default is that
1823a foreign key constraint is enforced, therefore RESTRICT just means no flag */
1824/** @{ */
1825/** ON DELETE CASCADE */
1826constexpr uint32_t DICT_FOREIGN_ON_DELETE_CASCADE = 1;
1827/** ON DELETE SET NULL */
1828constexpr uint32_t DICT_FOREIGN_ON_DELETE_SET_NULL = 2;
1829/** ON UPDATE CASCADE */
1830constexpr uint32_t DICT_FOREIGN_ON_UPDATE_CASCADE = 4;
1831/** ON UPDATE SET NULL */
1832constexpr uint32_t DICT_FOREIGN_ON_UPDATE_SET_NULL = 8;
1833/** ON DELETE NO ACTION */
1834constexpr uint32_t DICT_FOREIGN_ON_DELETE_NO_ACTION = 16;
1835/** ON UPDATE NO ACTION */
1836constexpr uint32_t DICT_FOREIGN_ON_UPDATE_NO_ACTION = 32;
1837/** @} */
1838
1839/** Display an identifier.
1840@param[in,out] s output stream
1841@param[in] id_name SQL identifier (other than table name)
1842@return the output stream */
1843std::ostream &operator<<(std::ostream &s, const id_name_t &id_name);
1844
1845/** Display a table name.
1846@param[in,out] s output stream
1847@param[in] table_name table name
1848@return the output stream */
1849std::ostream &operator<<(std::ostream &s, const table_name_t &table_name);
1850
1851#ifndef UNIV_HOTBACKUP
1852/** List of locks that different transactions have acquired on a table. This
1853list has a list node that is embedded in a nested union/structure. We have to
1854generate a specific template for it. */
1855struct TableLockGetNode;
1857#endif /* !UNIV_HOTBACKUP */
1858
1859/** mysql template structure defined in row0mysql.cc */
1860struct mysql_row_templ_t;
1861
1862/** Structure defines template related to virtual columns and
1863their base columns */
1865 /** number of regular columns */
1867
1868 /** number of virtual columns */
1870
1871 /** array of templates for virtual col and their base columns */
1873
1874 /** table's database name */
1875 std::string db_name;
1876
1877 /** table name */
1878 std::string tb_name;
1879
1880 /** share->table_name */
1881 std::string share_name;
1882
1883 /** MySQL record length */
1885
1886 /** default column value if any */
1888};
1889
1890/** The dirty status of tables, used to indicate if a table has some
1891dynamic metadata changed to be written back */
1893 /** Some persistent metadata is now dirty in memory, need to be
1894 written back to DDTableBuffer table and(or directly to) DD table.
1895 There could be some exceptions, when it's marked as dirty, but
1896 the metadata has already been written back to DDTableBuffer.
1897 For example, if a corrupted index is found and marked as corrupted,
1898 then it gets dropped. At this time, the dirty_status is still of
1899 this dirty value. Also a concurrent checkpoint make this bit
1900 out-of-date for other working threads, which still think the
1901 status is dirty and write-back is necessary.
1902 There could be either one row or no row for this table in
1903 DDTableBuffer table */
1905 /** Some persistent metadata is buffered in DDTableBuffer table,
1906 need to be written back to DD table. There is must be one row in
1907 DDTableBuffer table for this table */
1909 /** All persistent metadata are up to date. There is no row
1910 for this table in DDTableBuffer table */
1913
1914#ifndef UNIV_HOTBACKUP
1915/** A vector to collect prebuilt from different readers working on the same
1916temp table */
1917typedef std::vector<row_prebuilt_t *> temp_prebuilt_vec;
1918#endif /* !UNIV_HOTBACKUP */
1919
1920#ifdef UNIV_DEBUG
1921/** Value of 'magic_n'. */
1922constexpr uint32_t DICT_TABLE_MAGIC_N = 76333786;
1923#endif
1924
1925/** Data structure for a database table. Most fields will be
1926initialized to 0, NULL or false in dict_mem_table_create(). */
1928 /** Check if the table is compressed.
1929 @return true if compressed, false otherwise. */
1930 bool is_compressed() const { return (DICT_TF_GET_ZIP_SSIZE(flags) != 0); }
1931
1932 /** Check if the table is encrypted. Only for file per table tablespace.
1933 @return true if encrypted, false otherwise. */
1934 bool is_encrypted() const {
1936 }
1937
1938 /** Get reference count.
1939 @return current value of n_ref_count */
1940 inline uint64_t get_ref_count() const;
1941
1942 /** Acquire the table handle. */
1943 inline void acquire();
1944
1945 /** Acquire the table handle, with lock() and unlock() the table.
1946 This function needs to be called for opening table when the table
1947 is in memory and later the stats information would be initialized */
1948 inline void acquire_with_lock();
1949
1950 /** Release the table handle. */
1951 inline void release();
1952
1953 /** Lock the table handle. */
1954 inline void lock();
1955
1956 /** Unlock the table handle. */
1957 inline void unlock();
1958
1959#ifndef UNIV_HOTBACKUP
1960 /** Get schema and table name in system character set.
1961 @param[out] schema schema name
1962 @param[out] table table name */
1963 void get_table_name(std::string &schema, std::string &table) const;
1964
1965 bool is_system_schema() const {
1966 std::string schema_name;
1967 std::string table_name;
1968
1969 get_table_name(schema_name, table_name);
1970
1971 if (0 == strcmp(schema_name.c_str(), MYSQL_SCHEMA_NAME.str) ||
1972 0 == strcmp(schema_name.c_str(), "sys") ||
1973 0 == strcmp(schema_name.c_str(), PERFORMANCE_SCHEMA_DB_NAME.str) ||
1974 0 == strcmp(schema_name.c_str(), INFORMATION_SCHEMA_NAME.str)) {
1975 return (true);
1976 }
1977 return (false);
1978 }
1979
1980 /** Mutex of the table for concurrency access. */
1981 ib_mutex_t *mutex;
1982
1983 /** Creation state of mutex. */
1984 std::atomic<os_once::state_t> mutex_created;
1985#endif /* !UNIV_HOTBACKUP */
1986
1987 /** Id of the table. */
1989
1990 /** Memory heap. If you allocate from this heap after the table has
1991 been created then be sure to account the allocation into
1992 dict_sys->size. When closing the table we do something like
1993 dict_sys->size -= mem_heap_get_size(table->heap) and if that is going
1994 to become negative then we would assert. Something like this should do:
1995 old_size = mem_heap_get_size()
1996 mem_heap_alloc()
1997 new_size = mem_heap_get_size()
1998 dict_sys->size += new_size - old_size. */
2000
2001 /** Table name. */
2003
2004 /** Truncate name. */
2006
2007 /** NULL or the directory path specified by DATA DIRECTORY. */
2009
2010 /** NULL or the tablespace name that this table is assigned to,
2011 specified by the TABLESPACE option.*/
2013
2014 /** Space where the clustered index of the table is placed. */
2016
2017 /** dd::Tablespace::id of the table */
2019
2020 /** Stores information about:
2021 1 row format (redundant or compact),
2022 2 compressed page size (zip shift size),
2023 3 whether using atomic blobs,
2024 4 whether the table has been created with the option DATA DIRECTORY.
2025 Use DICT_TF_GET_COMPACT(), DICT_TF_GET_ZIP_SSIZE(),
2026 DICT_TF_HAS_ATOMIC_BLOBS() and DICT_TF_HAS_DATA_DIR() to parse this
2027 flag. */
2029
2030 /** Stores information about:
2031 1 whether the table has been created using CREATE TEMPORARY TABLE,
2032 2 whether the table has an internally defined DOC ID column,
2033 3 whether the table has a FTS index,
2034 4 whether DOC ID column need to be added to the FTS index,
2035 5 whether the table is being created its own tablespace,
2036 6 whether the table has been DISCARDed,
2037 7 whether the aux FTS tables names are in hex.
2038 8 whether the table is instinc table.
2039 9 whether the table has encryption setting.
2040 Use DICT_TF2_FLAG_IS_SET() to parse this flag. */
2042
2043 /** true if the table is an intermediate table during copy alter
2044 operation or a partition/subpartition which is required for copying
2045 data and skip the undo log for insertion of row in the table.
2046 This variable will be set and unset during extra(), or during the
2047 process of altering partitions */
2048 unsigned skip_alter_undo : 1;
2049
2050 /** true if this is in a single-table tablespace and the .ibd file is
2051 missing. Then we must return in ha_innodb.cc an error if the user
2052 tries to query such an orphaned table. */
2053 unsigned ibd_file_missing : 1;
2054
2055 /** true if the table object has been added to the dictionary cache. */
2056 unsigned cached : 1;
2057
2058 /** true if the table is to be dropped, but not yet actually dropped
2059 (could in the background drop list). It is turned on at the beginning
2060 of row_drop_table_for_mysql() and turned off just before we start to
2061 update system tables for the drop. It is protected by
2062 dict_operation_lock. */
2063 unsigned to_be_dropped : 1;
2064
2065 /** Number of non-virtual columns defined so far. */
2066 unsigned n_def : 10;
2067
2068 /** Number of non-virtual columns. */
2069 unsigned n_cols : 10;
2070
2071 /** Number of non-virtual columns before first instant ADD COLUMN,
2072 including the system columns like n_cols. This is used only when table has
2073 instant ADD clumns in V1. */
2074 unsigned n_instant_cols : 10;
2075
2076 /** Number of total columns (include virtual and non-virtual) */
2077 unsigned n_t_cols : 10;
2078
2079 /** Number of total columns defined so far. */
2080 unsigned n_t_def : 10;
2081
2082 /** Number of virtual columns defined so far. */
2083 unsigned n_v_def : 10;
2084
2085 /** Number of virtual columns. */
2086 unsigned n_v_cols : 10;
2087
2088 /** Number of multi-value virtual columns. */
2089 unsigned n_m_v_cols : 10;
2090
2091 /** true if this table is expected to be kept in memory. This table
2092 could be a table that has FK relationships or is undergoing DDL */
2094
2095 /** true if this table is not evictable(can_be_evicted) and this is
2096 because of DDL operation */
2097 unsigned ddl_not_evictable : 1;
2098
2099 /** true if some indexes should be dropped after ONLINE_INDEX_ABORTED
2100 or ONLINE_INDEX_ABORTED_DROPPED. */
2101 unsigned drop_aborted : 1;
2102
2103 /** Array of column descriptions. */
2105
2106 /** Array of virtual column descriptions. */
2108
2109 /** List of stored column descriptions. It is used only for foreign key
2110 check during create table and copy alter operations.
2111 During copy alter, s_cols list is filled during create table operation
2112 and need to preserve till rename table operation. That is the
2113 reason s_cols is a part of dict_table_t */
2115
2116 /** Check if the given column is a stored generated column. */
2118
2119 /** Column names packed in a character string
2120 "name1\0name2\0...nameN\0". Until the string contains n_cols, it will
2121 be allocated from a temporary heap. The final string will be allocated
2122 from table->heap. */
2123 const char *col_names;
2124
2125 /** Virtual column names */
2126 const char *v_col_names;
2127
2128 /** True if the table belongs to a system database (mysql, information_schema
2129 or performance_schema) */
2131
2132 /** Hash chain node. */
2134
2135 /** Hash chain node. */
2137
2138 /** The FTS_DOC_ID_INDEX, or NULL if no fulltext indexes exist */
2140
2141 /** List of indexes of the table. */
2143
2144 size_t get_index_count() const { return UT_LIST_GET_LEN(indexes); }
2145
2146 /** Node of the LRU list of tables. */
2148
2149 /** metadata version number of dd::Table::se_private_data() */
2150 uint64_t version;
2151
2152 /** Current row version in case columns are added/dropped INSTANTly */
2154
2155 /** Initial non-virtual column count */
2157
2158 /** Current non-virtual column count */
2160
2161 /** Total non-virtual column count */
2162 uint32_t total_col_count{0};
2163
2164 /** Set if table is upgraded instant table */
2166
2167 /** table dynamic metadata status, protected by dict_persist->mutex */
2168 std::atomic<table_dirty_status> dirty_status;
2169
2170#ifndef UNIV_HOTBACKUP
2171 /** Node of the dirty table list of tables, which is protected
2172 by dict_persist->mutex */
2173 UT_LIST_NODE_T(dict_table_t) dirty_dict_tables;
2174#endif /* !UNIV_HOTBACKUP */
2175
2176#ifdef UNIV_DEBUG
2177 /** This field is used to mark if a table is in the
2178 dirty_dict_tables_list. if the dirty_status is not of
2179 METADATA_CLEAN, the table should be in the list, otherwise not.
2180 This field should be protected by dict_persist->mutex too. */
2182#endif /* UNIV_DEBUG */
2183
2184 /** Count of how many foreign key check operations are currently being
2185 performed on the table. We cannot drop the table while there are
2186 foreign key checks running on it. */
2188
2189 /** Transaction id that last touched the table definition. Either when
2190 loading the definition or CREATE TABLE, or ALTER TABLE (prepare,
2191 commit, and rollback phases). */
2193
2194 /*!< set of foreign key constraints in the table; these refer to
2195 columns in other tables */
2197
2198 /*!< set of foreign key constraints which refer to this table */
2200
2201#ifdef UNIV_DEBUG
2202 /** This field is used to specify in simulations tables which are so
2203 big that disk should be accessed. Disk access is simulated by putting
2204 the thread to sleep for a while. NOTE that this flag is not stored to
2205 the data dictionary on disk, and the database will forget about value
2206 true if it has to reload the table definition from disk. */
2208#endif /* UNIV_DEBUG */
2209
2210 /** true if the maximum length of a single row exceeds BIG_ROW_SIZE.
2211 Initialized in dict_table_add_to_cache(). */
2212 unsigned big_rows : 1;
2213
2214#ifndef UNIV_HOTBACKUP
2215 /** Statistics for query optimization. @{ */
2216
2217 /** Creation state of 'stats_latch'. */
2218 std::atomic<os_once::state_t> stats_latch_created;
2219
2220 /** This latch protects:
2221 "dict_table_t::stat_initialized",
2222 "dict_table_t::stat_n_rows (*)",
2223 "dict_table_t::stat_clustered_index_size",
2224 "dict_table_t::stat_sum_of_other_index_sizes",
2225 "dict_table_t::stat_modified_counter (*)",
2226 "dict_table_t::indexes*::stats::n_diff_key_vals[]",
2227 "dict_table_t::indexes*::stats::index_size",
2228 "dict_table_t::indexes*::stats::n_leaf_pages".
2229 (*) Those are not always protected for
2230 performance reasons. */
2232
2233 /** Creation state of 'stats_compute_mutex'. */
2234 std::atomic<os_once::state_t> stats_compute_mutex_created;
2235
2236 /** Mutex protecting table and index statistics calculation process. */
2238
2239 /** true if statistics have been calculated the first time after
2240 database startup or table creation. */
2241 unsigned stat_initialized : 1;
2242
2243 /** true if statistics have been updated in the background and not yet
2244 collected by the optimizer */
2245 std::atomic<bool> stats_updated = false;
2246
2247 /** Timestamp of last recalc of the stats. */
2248 std::chrono::steady_clock::time_point stats_last_recalc;
2249
2250/** The two bits below are set in the 'stat_persistent' member. They
2251have the following meaning:
22521. _ON=0, _OFF=0, no explicit persistent stats setting for this table,
2253the value of the global srv_stats_persistent is used to determine
2254whether the table has persistent stats enabled or not
22552. _ON=0, _OFF=1, persistent stats are explicitly disabled for this
2256table, regardless of the value of the global srv_stats_persistent
22573. _ON=1, _OFF=0, persistent stats are explicitly enabled for this
2258table, regardless of the value of the global srv_stats_persistent
22594. _ON=1, _OFF=1, not allowed, we assert if this ever happens. */
2260#define DICT_STATS_PERSISTENT_ON (1 << 1)
2261#define DICT_STATS_PERSISTENT_OFF (1 << 2)
2262
2263 /** Indicates whether the table uses persistent stats or not. See
2264 DICT_STATS_PERSISTENT_ON and DICT_STATS_PERSISTENT_OFF. */
2266
2267/** The two bits below are set in the 'stats_auto_recalc' member. They
2268have the following meaning:
22691. _ON=0, _OFF=0, no explicit auto recalc setting for this table, the
2270value of the global srv_stats_persistent_auto_recalc is used to
2271determine whether the table has auto recalc enabled or not
22722. _ON=0, _OFF=1, auto recalc is explicitly disabled for this table,
2273regardless of the value of the global srv_stats_persistent_auto_recalc
22743. _ON=1, _OFF=0, auto recalc is explicitly enabled for this table,
2275regardless of the value of the global srv_stats_persistent_auto_recalc
22764. _ON=1, _OFF=1, not allowed, we assert if this ever happens. */
2277#define DICT_STATS_AUTO_RECALC_ON (1 << 1)
2278#define DICT_STATS_AUTO_RECALC_OFF (1 << 2)
2279
2280 /** Indicates whether the table uses automatic recalc for persistent
2281 stats or not. See DICT_STATS_AUTO_RECALC_ON and
2282 DICT_STATS_AUTO_RECALC_OFF. */
2284
2285 /** The number of pages to sample for this table during persistent
2286 stats estimation. If this is 0, then the value of the global
2287 srv_stats_persistent_sample_pages will be used instead. */
2289
2290 /** Approximate number of rows in the table. We periodically calculate
2291 new estimates. */
2292 uint64_t stat_n_rows;
2293
2294 /** Approximate clustered index size in database pages. */
2296
2297 /** Approximate size of other indexes in database pages. */
2299
2300 /** If FTS AUX table, parent table id */
2302
2303 /** How many rows are modified since last stats recalc. When a row is
2304 inserted, updated, or deleted, we add 1 to this number; we calculate
2305 new estimates for the table and the indexes if the table has changed
2306 too much, see row_update_statistics_if_needed(). The counter is reset
2307 to zero at statistics calculation. This counter is not protected by
2308 any latch, because this is only used for heuristics. */
2310
2311/** Background stats thread is not working on this table. */
2312#define BG_STAT_NONE 0
2313
2314/** Set in 'stats_bg_flag' when the background stats code is working
2315on this table. The DROP TABLE code waits for this to be cleared before
2316proceeding. */
2317#define BG_STAT_IN_PROGRESS (1 << 0)
2318
2319/** Set in 'stats_bg_flag' when DROP TABLE starts waiting on
2320BG_STAT_IN_PROGRESS to be cleared. The background stats thread will
2321detect this and will eventually quit sooner. */
2322#define BG_STAT_SHOULD_QUIT (1 << 1)
2323
2324 /** The state of the background stats thread wrt this table.
2325 See BG_STAT_NONE, BG_STAT_IN_PROGRESS and BG_STAT_SHOULD_QUIT.
2326 Writes are covered by dict_sys->mutex. It is read without mutex. */
2327 std::atomic<int8_t> stats_bg_flag;
2328
2329 /** @} */
2330#endif /* !UNIV_HOTBACKUP */
2331
2332 /** AUTOINC related members. @{ */
2333
2334 /* The actual collection of tables locked during AUTOINC read/write is
2335 kept in trx_t. In order to quickly determine whether a transaction has
2336 locked the AUTOINC lock we keep a pointer to the transaction here in
2337 the 'autoinc_trx' member. This is to avoid acquiring lock_sys latches and
2338 scanning the vector in trx_t.
2339 When an AUTOINC lock has to wait, the corresponding lock instance is
2340 created on the trx lock heap rather than use the pre-allocated instance
2341 in autoinc_lock below. */
2342
2343 /** A buffer for an AUTOINC lock for this table. We allocate the
2344 memory here so that individual transactions can get it and release it
2345 without a need to allocate space from the lock heap of the trx:
2346 otherwise the lock heap would grow rapidly if we do a large insert
2347 from a select. */
2348#ifndef UNIV_HOTBACKUP
2350
2351 /** Creation state of autoinc_mutex member */
2352 std::atomic<os_once::state_t> autoinc_mutex_created;
2353#endif /* !UNIV_HOTBACKUP */
2354
2355 /** Mutex protecting the autoincrement counter. */
2356 ib_mutex_t *autoinc_mutex;
2357
2358 /** Autoinc counter value to give to the next inserted row. */
2359 uint64_t autoinc;
2360
2361 /** Mutex protecting the persisted autoinc_persisted counter. */
2363
2364 /** The autoinc counter value that we would like to be persisted to the
2365 DDTableBuffer on the next occasion when the persistent metadata of this table
2366 will be stored to it.
2367 It may be smaller than the currently stored value (autoinc_buffered) due to
2368 the innodb_autoinc_preallocate mechanism.
2369 It should be equal to autoinc_buffered if dirty_status==METADATA_BUFFERED.
2370 This is different from the 'autoinc' above, which could be bigger
2371 than this one, because 'autoinc' will get updated right after
2372 some counters are allocated, but we will persist the counter later.
2373 Eventually autoinc_persisted should match autoinc, and on clean shutdown we
2374 should also make autoinc_buffered match the two and the DDTableBuffer.
2375 We want this counter because we can't read the 'autoinc' directly easily,
2376 because the autoinc_lock is required and there could be a deadlock.
2377 This variable is modified under autoinc_persisted_mutex.
2378 It might be temporarily modified to a "fake" (too large) value when the
2379 innodb_autoinc_preallocate mechanism is persisting it, but then it happens
2380 under both: autoinc_persisted_mutex and dict_persist->mutex.
2381 Readers can thus read it:
2382 a) under dict_persist->mutex if all they care is to not see "a fake" value,
2383 but don't really care "which" of "real" values they'll see
2384 b) under autoinc_persisted_mutex if they want to see "most current" value
2385 c) without any latch if they just want to avoid "torn" reads */
2386 std::atomic<uint64_t> autoinc_persisted;
2387
2388 /** The autoinc counter value that has been persisted to DDTableBuffer last
2389 time during this run of mysqld.
2390 It might be larger than autoinc_persisted, due to innodb_autoinc_preallocate
2391 mechanism.
2392 It might also be zero before first store to DDTableBuffer.
2393 This variable is modified under dict_persist->mutex.
2394 It can be read without any latch, but the reader must be aware that another
2395 thread might be setting it to the autoinc_persisted value it seen some time
2396 before (but after setting dirty_status to METADATA_BUFFERED). */
2397 std::atomic<uint64_t> autoinc_buffered{0};
2398
2399 /** The position of autoinc counter field in clustered index. This would
2400 be set when CREATE/ALTER/OPEN TABLE and IMPORT TABLESPACE, and used in
2401 modifications to clustered index, such as INSERT/UPDATE. There should
2402 be no conflict to access it, so no protection is needed. */
2404
2405 /** The transaction that currently holds the AUTOINC lock on this table.
2406 Protected by lock_sys table shard latch. To "peek" the current value one
2407 can read it without any latch, understanding that in general it may change.
2408 Such access pattern is correct if trx thread wants to check if it has the lock
2409 granted, as the field can only change to other value when lock is released,
2410 which can not happen concurrently to thread executing the trx. */
2411 std::atomic<const trx_t *> autoinc_trx;
2412
2413 /** @} */
2414
2415#ifndef UNIV_HOTBACKUP
2416 /** FTS specific state variables. */
2418#endif /* !UNIV_HOTBACKUP */
2419
2420 /** Quiescing states, protected by the dict_index_t::lock. ie. we can
2421 only change the state if we acquire all the latches (dict_index_t::lock)
2422 in X mode of this table's indexes. */
2424
2425 /** Count of the number of record locks on this table. We use this to
2426 determine whether we can evict the table from the dictionary cache.
2427 Writes (atomic increments and decrements) are performed when holding a shared
2428 latch on lock_sys. (Note that this the table's shard latch is NOT required,
2429 as this is field counts *record* locks, so a page shard is latched instead)
2430 Reads should be performed when holding exclusive lock_sys latch, however:
2431 - Some places assert this field is zero without holding any latch.
2432 - Some places assert this field is positive holding only shared latch. */
2433 std::atomic<size_t> n_rec_locks;
2434
2435#ifndef UNIV_DEBUG
2436 private:
2437#endif
2438 /** Count of how many handles are opened to this table. Dropping of the
2439 table is NOT allowed until this count gets to zero. MySQL does NOT
2440 itself check the number of open handles at DROP. */
2441 std::atomic<uint64_t> n_ref_count;
2442
2443 public:
2444#ifndef UNIV_HOTBACKUP
2445 /** List of locks on the table. Protected by lock_sys shard latch. */
2447 /** count_by_mode[M] = number of locks in this->locks with
2448 lock->type_mode&LOCK_MODE_MASK == M.
2449 Used to quickly verify that there are no LOCK_S or LOCK_X, which are the only
2450 modes incompatible with LOCK_IS and LOCK_IX, to avoid costly iteration over
2451 this->locks when adding LOCK_IS or LOCK_IX.
2452 We use count_by_mode[LOCK_AUTO_INC] to track the number of granted and pending
2453 autoinc locks on this table. This value is set after acquiring the lock_sys
2454 table shard latch, but we peek the contents to determine whether other
2455 transactions have acquired the AUTOINC lock or not. Of course only one
2456 transaction can be granted the lock but there can be multiple
2457 waiters.
2458 Protected by lock_sys table shard latch. */
2460#endif /* !UNIV_HOTBACKUP */
2461
2462 /** Timestamp of the last modification of this table. */
2463 std::atomic<std::chrono::system_clock::time_point> update_time;
2464 static_assert(decltype(update_time)::is_always_lock_free);
2465
2466 /** row-id counter for use by intrinsic table for getting row-id.
2467 Given intrinsic table semantics, row-id can be locally maintained
2468 instead of getting it from central generator which involves mutex
2469 locking. */
2470 uint64_t sess_row_id;
2471
2472 /** trx_id counter for use by intrinsic table for getting trx-id.
2473 Intrinsic table are not shared so don't need a central trx-id
2474 but just need a increased counter to track consistent view while
2475 proceeding SELECT as part of UPDATE. */
2476 uint64_t sess_trx_id;
2477
2478#ifdef UNIV_DEBUG
2479 /** Magic number. */
2481#endif /* UNIV_DEBUG */
2482 /** mysql_row_templ_t for base columns used for compute the virtual
2483 columns */
2485
2486 /** remove the dict_table_t from cache after DDL operation */
2488
2489 /** refresh/reload FK info */
2491
2492#ifndef UNIV_HOTBACKUP
2493 /** multiple cursors can be active on this temporary table */
2495#endif /* !UNIV_HOTBACKUP */
2496
2497 /** true only for dictionary tables like mysql/tables,
2498 mysql/columns, mysql/tablespaces, etc. This flag is used
2499 to do non-locking reads on DD tables. */
2501
2502 /** true if this table is explicitly put to non-LRU list
2503 during table creation */
2505
2506 /** Check if the table has user defined primary key (PK).
2507 @return true if table has user defined PK, false otherwise. */
2508 bool has_pk() const;
2509
2510 /** @return the clustered index */
2511 const dict_index_t *first_index() const {
2513 const dict_index_t *first = UT_LIST_GET_FIRST(indexes);
2514 return (first);
2515 }
2516 /** @return the clustered index */
2518 return (const_cast<dict_index_t *>(
2519 const_cast<const dict_table_t *>(this)->first_index()));
2520 }
2521
2522 /** @returns true if the table has row versions.. */
2523 bool has_row_versions() const {
2524 if (current_row_version > 0) {
2526 return (true);
2527 }
2528
2529 return false;
2530 }
2531
2532 /** @return if there was any instantly added column.
2533 This will be true after one or more instant ADD COLUMN, however,
2534 it would become false after ALTER TABLE which rebuilds or copies
2535 the old table.
2536 If this is true, all instantly added columns should have default
2537 values, and records in the table may have REC_INFO_INSTANT_FLAG set. */
2538 bool has_instant_cols() const {
2540 /* Instant add col V1 */
2541 return (true);
2542 }
2543
2544 return false;
2545 }
2546
2547 /** Set the number of columns when the first instant ADD COLUMN happens.
2548 @param[in] n_inst_cols number of fields when first instant
2549 ADD COLUMN happens, without system columns */
2550 void set_instant_cols(uint16_t n_inst_cols) {
2551 n_instant_cols = static_cast<unsigned>(n_inst_cols) + get_n_sys_cols();
2552 }
2553
2554 /** Get the number of user columns when the first instant ADD COLUMN
2555 happens.
2556 @return the number of user columns as described above */
2557 uint16_t get_instant_cols() const {
2558 return static_cast<uint16_t>(n_instant_cols - get_n_sys_cols());
2559 }
2560
2562 size_t n_cols_dropped = get_n_instant_drop_cols();
2563 size_t n_cols_added = get_n_instant_add_cols();
2564 size_t n_instant_added_cols =
2565 n_cols + n_cols_dropped - n_cols_added - n_instant_cols;
2566
2567 return (n_instant_added_cols);
2568 }
2569
2570 /** Get number of columns added instantly */
2571 uint32_t get_n_instant_add_cols() const {
2574 }
2575
2576 /** Get number of columns dropped instantly */
2577 uint32_t get_n_instant_drop_cols() const {
2580 }
2581
2582 /** check if table has INSTANT ADD columns.
2583 @return true if the table has INSTANT ADD columns, otherwise false */
2584 bool has_instant_add_cols() const { return (get_n_instant_add_cols() > 0); }
2585
2586 /** check if table has INSTANT DROP columns.
2587 @return true if the table has INSTANT DROP columns, otherwise false */
2588 bool has_instant_drop_cols() const { return (get_n_instant_drop_cols() > 0); }
2589
2590 /** Set table to be upgraded table with INSTANT ADD columns in V1. */
2592
2593 /** Checks if table is upgraded table with INSTANT ADD columns in V1.
2594 @return true if it is, false otherwise */
2596
2597 /** Check whether the table is corrupted.
2598 @return true if the table is corrupted, otherwise false */
2599 bool is_corrupted() const {
2601
2602 const dict_index_t *index = first_index();
2603
2604 /* It is possible that this table is only half created, in which case
2605 the clustered index may be NULL. If the clustered index is corrupted,
2606 the table is corrupt. We do not consider the table corrupt if only
2607 a secondary index is corrupt. */
2608 ut_ad(index == nullptr || index->is_clustered());
2609
2610 return (index != nullptr && index->type & DICT_CORRUPT);
2611 }
2612
2613 /** Returns a column's name.
2614 @param[in] col_nr column number
2615 @return column name. NOTE: not guaranteed to stay valid if table is
2616 modified in any way (columns added, etc.). */
2617 const char *get_col_name(ulint col_nr) const {
2618 ut_ad(col_nr < n_def);
2620
2621 const char *s = col_names;
2622 if (s) {
2623 for (ulint i = 0; i < col_nr; i++) {
2624 s += strlen(s) + 1;
2625 }
2626 }
2627
2628 return (s);
2629 }
2630
2631 /** Gets the nth column of a table.
2632 @param[in] pos position of column
2633 @return pointer to column object */
2634 dict_col_t *get_col(uint pos) const {
2635 ut_ad(pos < n_def);
2637
2638 return (cols + pos);
2639 }
2640
2641 /** Get column by name
2642 @param[in] name column name
2643 @return column name if found, null otherwise */
2644 dict_col_t *get_col_by_name(const char *name) const {
2645 ut_ad(name != nullptr);
2646
2647 dict_col_t *ret = nullptr;
2648
2649 const char *s = col_names;
2650 for (ulint i = 0; i < n_def; i++) {
2651 if (strcmp(s, name) == 0) {
2652 ret = get_col(i);
2653 }
2654 s += strlen(s) + 1;
2655 }
2656
2657 return ret;
2658 }
2659
2660 /** Gets the number of user-defined non-virtual columns in a table
2661 in the dictionary cache.
2662 @return number of user-defined (e.g., not ROW_ID) non-virtual columns
2663 of a table */
2664 uint16_t get_n_user_cols() const {
2666
2667 return (static_cast<uint16_t>(n_cols) - get_n_sys_cols());
2668 }
2669
2670 /** Gets the number of system columns in a table.
2671 For intrinsic table on ROW_ID column is added for all other
2672 tables TRX_ID and ROLL_PTR are all also appended.
2673 @return number of system (e.g., ROW_ID) columns of a table */
2674 uint16_t get_n_sys_cols() const {
2676
2678 }
2679
2680 /** Gets the number of all non-virtual columns (also system) in a table
2681 in the dictionary cache.
2682 @return number of non-virtual columns of a table */
2685
2686 return (n_cols);
2687 }
2688
2689 /** Gets the number of all non-virtual columns in a table including columns
2690 dropped INSTANTly.
2691 @returns number of non-virtual columns of a table */
2693 if (!has_row_versions()) {
2694 return n_cols;
2695 }
2696
2700 }
2701
2702 /** Gets the given system column of a table.
2703 @param[in] sys DATA_ROW_ID, ...
2704 @return pointer to column object */
2706 dict_col_t *col;
2707
2708 ut_ad(sys < get_n_sys_cols());
2710
2711 col = get_col(n_cols - get_n_sys_cols() + sys);
2712 ut_ad(col->mtype == DATA_SYS);
2713 ut_ad(col->prtype == (sys | DATA_NOT_NULL));
2714
2715 return (col);
2716 }
2717
2718 /** Determine if this is a temporary table. */
2719 bool is_temporary() const {
2721 return (flags2 & DICT_TF2_TEMPORARY);
2722 }
2723
2724 /** Determine if this is a FTS AUX table. */
2725 bool is_fts_aux() const {
2727 return (flags2 & DICT_TF2_AUX);
2728 }
2729
2730 /** Determine whether the table is intrinsic.
2731 An intrinsic table is a special kind of temporary table that
2732 is invisible to the end user. It can be created internally by InnoDB,
2733 the MySQL server layer or other modules connected to InnoDB in order
2734 to gather and use data as part of a larger task. Since access to it
2735 must be as fast as possible, it does not need UNDO semantics, system
2736 fields DB_TRX_ID & DB_ROLL_PTR, doublewrite, checksum, insert buffer,
2737 use of the shared data dictionary, locking, or even a transaction.
2738 In short, these are not ACID tables at all, just temporary data stored
2739 and manipulated during a larger process.*/
2740 bool is_intrinsic() const {
2741 if (flags2 & DICT_TF2_INTRINSIC) {
2743 return (true);
2744 }
2745
2746 return (false);
2747 }
2748
2749 /* GAP locks are skipped for DD tables and SDI tables
2750 @return true if table is DD table or SDI table, else false */
2751 inline bool skip_gap_locks() const;
2752
2753 /** Determine if the table can support instant ADD/DROP COLUMN */
2754 inline bool support_instant_add_drop() const;
2755};
2756
2758 if (s_cols != nullptr) {
2759 for (auto &stored_gcol : *s_cols) {
2760 if (stored_gcol.m_col == col) {
2761 return &stored_gcol;
2762 }
2763 }
2764 }
2765 return nullptr;
2766}
2767
2768static inline void DICT_TF2_FLAG_SET(dict_table_t *table, uint32_t flag) {
2769 table->flags2 |= flag;
2770}
2771
2772static inline bool DICT_TF2_FLAG_IS_SET(const dict_table_t *table,
2773 uint32_t flag) {
2774 return table->flags2 & flag;
2775}
2776
2777static inline void DICT_TF2_FLAG_UNSET(dict_table_t *table, uint32_t flag) {
2778 table->flags2 &= ~flag;
2779}
2780
2782
2783/** Persistent dynamic metadata type, there should be 1 to 1
2784relationship between the metadata and the type. Please keep them in order
2785so that we can iterate over it */
2787 /** The smallest type, which should be 1 less than the first
2788 true type */
2790
2791 /** Persistent Metadata type for corrupted indexes */
2793
2794 /** Persistent Metadata type for autoinc counter */
2796
2797 /* TODO: Will add following types
2798 PM_TABLE_UPDATE_TIME = 3,
2799 Maybe something tablespace related
2800 PM_TABLESPACE_SIZE = 4,
2801 PM_TABLESPACE_MAX_TRX_ID = 5, */
2802
2803 /** The biggest type, which should be 1 bigger than the last
2804 true type */
2805 PM_BIGGEST_TYPE = 3
2807
2808typedef std::vector<index_id_t, ut::allocator<index_id_t>> corrupted_ids_t;
2809
2810/** Persistent dynamic metadata for a table */
2812 public:
2813 /** Constructor
2814 @param[in] id table id
2815 @param[in] version table dynamic metadata version */
2818
2819 /** Get the corrupted indexes' IDs
2820 @return the vector of indexes' IDs */
2822 return (m_corrupted_ids);
2823 }
2824
2825 /** Add a corrupted index id and space id
2826 @param[in] id corrupted index id */
2828 m_corrupted_ids.push_back(id);
2829 }
2830
2831 /** Set the dynamic metadata version.
2832 @param[in] version dynamic metadata version */
2833 void set_version(uint64_t version) { m_version = version; }
2834
2835 /** Get the dynamic metadata version */
2836 uint64_t get_version() const { return (m_version); }
2837
2838 /** Get the table id of the metadata
2839 @return table id */
2840 table_id_t get_table_id() const { return (m_id); }
2841
2842 /** Set the autoinc counter of the table if it's bigger
2843 @param[in] autoinc autoinc counter */
2844 void set_autoinc_if_bigger(uint64_t autoinc) {
2845 /* We only set the biggest autoinc counter. Callers don't
2846 guarantee passing a bigger number in. */
2847 if (autoinc > m_autoinc) {
2848 m_autoinc = autoinc;
2849 }
2850 }
2851
2852 /** Set the autoinc counter of the table
2853 @param[in] autoinc autoinc counter */
2854 void set_autoinc(uint64_t autoinc) { m_autoinc = autoinc; }
2855
2856 /** Get the autoinc counter of the table
2857 @return the autoinc counter */
2858 uint64_t get_autoinc() const { return (m_autoinc); }
2859
2860 private:
2861 /** Table ID which this metadata belongs to */
2863
2864 /** Table dynamic metadata version of the change */
2865 uint64_t m_version;
2866
2867 /** Storing the corrupted indexes' ID if exist, or else empty */
2869
2870 /** Autoinc counter of the table */
2871 uint64_t m_autoinc;
2872
2873 /* TODO: We will add update_time, etc. here and APIs accordingly */
2874};
2875
2876/** Interface for persistent dynamic table metadata. */
2878 public:
2879 /** Virtual destructor */
2880 virtual ~Persister() = default;
2881
2882 /** Write the dynamic metadata of a table, we can pre-calculate
2883 the size by calling get_write_size()
2884 @param[in] metadata persistent data
2885 @param[out] buffer write buffer
2886 @param[in] size size of write buffer, should be
2887 at least get_write_size()
2888 @return the length of bytes written */
2889 [[nodiscard]] virtual size_t write(const PersistentTableMetadata &metadata,
2890 byte *buffer, size_t size) const = 0;
2891
2892 /** Pre-calculate the size of metadata to be written
2893 @param[in] metadata metadata to be written
2894 @return the size of metadata */
2895 [[nodiscard]] virtual size_t get_write_size(
2896 const PersistentTableMetadata &metadata) const = 0;
2897
2898 /** Read the dynamic metadata from buffer, and store them to
2899 metadata object
2900 @param[out] metadata metadata where we store the read data
2901 @param[in] buffer buffer to read
2902 @param[in] size size of buffer
2903 @param[out] corrupt true if we found something wrong in
2904 the buffer except incomplete buffer,
2905 otherwise false
2906 @return the bytes we read from the buffer if the buffer data
2907 is complete and we get everything, 0 if the buffer is incompleted */
2908 [[nodiscard]] virtual size_t read(PersistentTableMetadata &metadata,
2909 const byte *buffer, size_t size,
2910 bool *corrupt) const = 0;
2911
2912 /** Aggregate metadata entries into a single metadata instance, considering
2913 version numbers
2914 @param[in,out] metadata metadata object to be modified
2915 @param[in] new_entry metadata entry from logs */
2916 virtual void aggregate(PersistentTableMetadata &metadata,
2917 const PersistentTableMetadata &new_entry) const = 0;
2918};
2919
2920/** Persister used for corrupted indexes */
2922 public:
2923 /** Write the corrupted indexes of a table, we can pre-calculate the size
2924 by calling get_write_size()
2925 @param[in] metadata persistent data
2926 @param[out] buffer write buffer
2927 @param[in] size size of write buffer, should be at least
2928 get_write_size()
2929 @return the length of bytes written */
2930 [[nodiscard]] size_t write(const PersistentTableMetadata &metadata,
2931 byte *buffer, size_t size) const override;
2932
2933 /** Pre-calculate the size of metadata to be written
2934 @param[in] metadata metadata to be written
2935 @return the size of metadata */
2936 [[nodiscard]] size_t get_write_size(
2937 const PersistentTableMetadata &metadata) const override;
2938
2939 /** Read the corrupted indexes from buffer, and store them to
2940 metadata object
2941 @param[out] metadata metadata where we store the read data
2942 @param[in] buffer buffer to read
2943 @param[in] size size of buffer
2944 @param[out] corrupt true if we found something wrong in
2945 the buffer except incomplete buffer,
2946 otherwise false
2947 @return the bytes we read from the buffer if the buffer data
2948 is complete and we get everything, 0 if the buffer is incompleted */
2949 [[nodiscard]] size_t read(PersistentTableMetadata &metadata,
2950 const byte *buffer, size_t size,
2951 bool *corrupt) const override;
2952
2953 void aggregate(PersistentTableMetadata &metadata,
2954 const PersistentTableMetadata &new_entry) const override;
2955
2956 private:
2957 /** The length of index_id_t we will write */
2958 static const size_t INDEX_ID_LENGTH = 12;
2959};
2960
2961/** Persister used for autoinc counters */
2963 public:
2964 /** Write the autoinc counter of a table, we can pre-calculate
2965 the size by calling get_write_size()
2966 @param[in] metadata persistent metadata
2967 @param[out] buffer write buffer
2968 @param[in] size size of write buffer, should be
2969 at least get_write_size()
2970 @return the length of bytes written */
2971 [[nodiscard]] size_t write(const PersistentTableMetadata &metadata,
2972 byte *buffer, size_t size) const override;
2973
2974 /** Pre-calculate the size of metadata to be written
2975 @param[in] metadata metadata to be written
2976 @return the size of metadata */
2977 [[nodiscard]] inline size_t get_write_size(
2978 const PersistentTableMetadata &metadata [[maybe_unused]]) const override {
2979 /* We just return the max possible size that would be used
2980 if the counter exists, so we don't calculate every time.
2981 Here we need 1 byte for dynamic metadata type and 11 bytes
2982 for the max possible size of counter. */
2983 return (12);
2984 }
2985
2986 /** Read the autoinc counter from buffer, and store them to
2987 metadata object
2988 @param[out] metadata metadata where we store the read data
2989 @param[in] buffer buffer to read
2990 @param[in] size size of buffer
2991 @param[out] corrupt true if we found something wrong in
2992 the buffer except incomplete buffer,
2993 otherwise false
2994 @return the bytes we read from the buffer if the buffer data
2995 is complete and we get everything, 0 if the buffer is incomplete */
2996 [[nodiscard]] size_t read(PersistentTableMetadata &metadata,
2997 const byte *buffer, size_t size,
2998 bool *corrupt) const override;
2999
3000 void aggregate(PersistentTableMetadata &metadata,
3001 const PersistentTableMetadata &new_entry) const override;
3002};
3003
3004/** Container of persisters used in the system. Currently we don't need
3005to protect this object since we only initialize it at very beginning and
3006destroy it in the end. During the server running, we only get the persisters */
3008 typedef std::map<
3009 persistent_type_t, Persister *, std::less<persistent_type_t>,
3012
3013 public:
3014 /** Constructor */
3016
3017 /** Destructor */
3018 ~Persisters();
3019
3020 /** Get the persister object with specified type
3021 @param[in] type persister type
3022 @return Persister object required or NULL if not found */
3023 [[nodiscard]] Persister *get(persistent_type_t type) const;
3024
3025 /** Add a specified persister of type, we will allocate the Persister
3026 if there is no such persister exist, otherwise do nothing and return
3027 the existing one
3028 @param[in] type persister type
3029 @return the persister of type */
3031
3032 /** Remove a specified persister of type, we will free the Persister
3033 @param[in] type persister type */
3035
3036 /** Serialize the metadata to a buffer
3037 @param[in] metadata metadata to serialize
3038 @param[out] buffer buffer to store the serialized metadata
3039 @return the length of serialized metadata */
3040 [[nodiscard]] size_t write(PersistentTableMetadata &metadata,
3041 byte *buffer) const;
3042
3043 private:
3044 /** A map to store all persisters needed */
3046};
3047
3048#ifndef UNIV_HOTBACKUP
3049
3050/** A function object to add the foreign key constraint to the referenced set
3051of the referenced table, if it exists in the dictionary cache. */
3053 void operator()(dict_foreign_t *foreign) const {
3054 if (dict_table_t *table = foreign->referenced_table) {
3055 std::pair<dict_foreign_set::iterator, bool> ret =
3056 table->referenced_set.insert(foreign);
3057 ut_a(ret.second);
3058 }
3059 }
3060};
3061
3062/** Request for lazy creation of the mutex of a given table.
3063This function is only called from either single threaded environment
3064or from a thread that has not shared the table object with other threads.
3065@param[in,out] table table whose mutex is to be created */
3067 table->mutex = nullptr;
3068 table->mutex_created = os_once::NEVER_DONE;
3069}
3070
3071/** Destroy the mutex of a given table.
3072This function is only called from either single threaded environment
3073or from a thread that has not shared the table object with other threads.
3074@param[in,out] table table whose mutex is to be created */
3076 if (table->mutex_created == os_once::DONE) {
3077 if (table->mutex != nullptr) {
3078 mutex_free(table->mutex);
3079 ut::delete_(table->mutex);
3080 }
3081 }
3082}
3083
3084/** Destroy the autoinc latch of the given table.
3085This function is only called from either single threaded environment
3086or from a thread that has not shared the table object with other threads.
3087@param[in,out] table table whose stats latch to destroy */
3089 if (table->autoinc_mutex_created == os_once::DONE) {
3090 if (table->autoinc_mutex != nullptr) {
3091 mutex_free(table->autoinc_mutex);
3092 ut::delete_(table->autoinc_mutex);
3093 }
3094
3095 if (table->autoinc_persisted_mutex != nullptr) {
3096 mutex_free(table->autoinc_persisted_mutex);
3097 ut::delete_(table->autoinc_persisted_mutex);
3098 }
3099 }
3100}
3101
3102/** Request for lazy creation of the autoinc latch of a given table.
3103This function is only called from either single threaded environment
3104or from a thread that has not shared the table object with other threads.
3105@param[in,out] table table whose autoinc latch is to be created. */
3107 table->autoinc_mutex = nullptr;
3108 table->autoinc_persisted_mutex = nullptr;
3109 table->autoinc_mutex_created = os_once::NEVER_DONE;
3110}
3111
3112/** Request a lazy creation of dict_index_t::zip_pad::mutex.
3113This function is only called from either single threaded environment
3114or from a thread that has not shared the table object with other threads.
3115@param[in,out] index index whose zip_pad mutex is to be created */
3117 index->zip_pad.mutex = nullptr;
3118 index->zip_pad.mutex_created = os_once::NEVER_DONE;
3119}
3120
3121/** Destroy the zip_pad_mutex of the given index.
3122This function is only called from either single threaded environment
3123or from a thread that has not shared the table object with other threads.
3124@param[in,out] index index whose stats latch to destroy */
3126 if (index->zip_pad.mutex_created == os_once::DONE &&
3127 index->zip_pad.mutex != nullptr) {
3128 mutex_free(index->zip_pad.mutex);
3129 ut::delete_(index->zip_pad.mutex);
3130 }
3131}
3132#endif /* !UNIV_HOTBACKUP */
3133
3134/** Release the zip_pad_mutex of a given index.
3135@param[in,out] index index whose zip_pad_mutex is to be released */
3137#ifndef UNIV_HOTBACKUP
3138 mutex_exit(index->zip_pad.mutex);
3139#endif /* !UNIV_HOTBACKUP */
3140}
3141
3142#ifdef UNIV_DEBUG
3143/** Check if the current thread owns the autoinc_mutex of a given table.
3144@param[in] table the autoinc_mutex belongs to this table
3145@return true, if the current thread owns the autoinc_mutex, false otherwise.*/
3147 return (mutex_own(table->autoinc_mutex));
3148}
3149#endif /* UNIV_DEBUG */
3150
3151#ifndef UNIV_HOTBACKUP
3152/** Data structure storing index statistics. Used as
3153temporary state during statistics calculation. The final version of statistics
3154for reading by optimizer are stored in dict_index_t::stats. */
3157 unsigned type : DICT_IT_BITS;
3158 unsigned n_uniq : 10;
3159};
3160#endif /* !UNIV_HOTBACKUP */
3161
3162#include "dict0mem.ic"
3163
3164#endif /* dict0mem_h */
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:49
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
The index tree general types.
The database buffer pool high-level routines.
Persister used for autoinc counters.
Definition: dict0mem.h:2962
size_t get_write_size(const PersistentTableMetadata &metadata) const override
Pre-calculate the size of metadata to be written.
Definition: dict0mem.h:2977
size_t read(PersistentTableMetadata &metadata, const byte *buffer, size_t size, bool *corrupt) const override
Read the autoinc counter from buffer, and store them to metadata object.
Definition: dict0dict.cc:5591
void aggregate(PersistentTableMetadata &metadata, const PersistentTableMetadata &new_entry) const override
Aggregate metadata entries into a single metadata instance, considering version numbers.
Definition: dict0dict.cc:5611
size_t write(const PersistentTableMetadata &metadata, byte *buffer, size_t size) const override
Write the autoinc counter of a table, we can pre-calculate the size by calling get_write_size()
Definition: dict0dict.cc:5562
Persister used for corrupted indexes.
Definition: dict0mem.h:2921
size_t write(const PersistentTableMetadata &metadata, byte *buffer, size_t size) const override
Write the corrupted indexes of a table, we can pre-calculate the size by calling get_write_size()
Definition: dict0dict.cc:5447
static const size_t INDEX_ID_LENGTH
The length of index_id_t we will write.
Definition: dict0mem.h:2958
size_t get_write_size(const PersistentTableMetadata &metadata) const override
Pre-calculate the size of metadata to be written.
Definition: dict0dict.cc:5484
size_t read(PersistentTableMetadata &metadata, const byte *buffer, size_t size, bool *corrupt) const override
Read the corrupted indexes from buffer, and store them to metadata object.
Definition: dict0dict.cc:5508
void aggregate(PersistentTableMetadata &metadata, const PersistentTableMetadata &new_entry) const override
Aggregate metadata entries into a single metadata instance, considering version numbers.
Definition: dict0dict.cc:5547
Persistent dynamic metadata for a table.
Definition: dict0mem.h:2811
uint64_t get_autoinc() const
Get the autoinc counter of the table.
Definition: dict0mem.h:2858
table_id_t get_table_id() const
Get the table id of the metadata.
Definition: dict0mem.h:2840
void add_corrupted_index(const index_id_t id)
Add a corrupted index id and space id.
Definition: dict0mem.h:2827
const corrupted_ids_t & get_corrupted_indexes() const
Get the corrupted indexes' IDs.
Definition: dict0mem.h:2821
void set_version(uint64_t version)
Set the dynamic metadata version.
Definition: dict0mem.h:2833
void set_autoinc(uint64_t autoinc)
Set the autoinc counter of the table.
Definition: dict0mem.h:2854
uint64_t m_autoinc
Autoinc counter of the table.
Definition: dict0mem.h:2871
void set_autoinc_if_bigger(uint64_t autoinc)
Set the autoinc counter of the table if it's bigger.
Definition: dict0mem.h:2844
table_id_t m_id
Table ID which this metadata belongs to.
Definition: dict0mem.h:2862
uint64_t get_version() const
Get the dynamic metadata version.
Definition: dict0mem.h:2836
uint64_t m_version
Table dynamic metadata version of the change.
Definition: dict0mem.h:2865
corrupted_ids_t m_corrupted_ids
Storing the corrupted indexes' ID if exist, or else empty.
Definition: dict0mem.h:2868
PersistentTableMetadata(table_id_t id, uint64_t version)
Constructor.
Definition: dict0mem.h:2816
Interface for persistent dynamic table metadata.
Definition: dict0mem.h:2877
virtual size_t write(const PersistentTableMetadata &metadata, byte *buffer, size_t size) const =0
Write the dynamic metadata of a table, we can pre-calculate the size by calling get_write_size()
virtual ~Persister()=default
Virtual destructor.
virtual size_t read(PersistentTableMetadata &metadata, const byte *buffer, size_t size, bool *corrupt) const =0
Read the dynamic metadata from buffer, and store them to metadata object.
virtual size_t get_write_size(const PersistentTableMetadata &metadata) const =0
Pre-calculate the size of metadata to be written.
virtual void aggregate(PersistentTableMetadata &metadata, const PersistentTableMetadata &new_entry) const =0
Aggregate metadata entries into a single metadata instance, considering version numbers.
Container of persisters used in the system.
Definition: dict0mem.h:3007
persisters_t m_persisters
A map to store all persisters needed.
Definition: dict0mem.h:3045
std::map< persistent_type_t, Persister *, std::less< persistent_type_t >, ut::allocator< std::pair< const persistent_type_t, Persister * > > > persisters_t
Definition: dict0mem.h:3011
size_t write(PersistentTableMetadata &metadata, byte *buffer) const
Serialize the metadata to a buffer.
Definition: dict0dict.cc:5691
~Persisters()
Destructor.
Definition: dict0dict.cc:5623
void remove(persistent_type_t type)
Remove a specified persister of type, we will free the Persister.
Definition: dict0dict.cc:5677
Persister * get(persistent_type_t type) const
Get the persister object with specified type.
Definition: dict0dict.cc:5633
Persisters()
Constructor.
Definition: dict0mem.h:3015
Persister * add(persistent_type_t type)
Add a specified persister of type, we will allocate the Persister if there is no such persister exist...
Definition: dict0dict.cc:5647
The state of the FTS sub system.
Definition: fts0fts.h:364
SQL identifier name wrapper for pretty-printing.
Definition: dict0mem.h:437
const char * operator()() const
Explicit type conversion.
Definition: dict0mem.h:458
id_name_t & operator=(const char *name)
Assignment operator.
Definition: dict0mem.h:447
const char * m_name
The name in internal representation.
Definition: dict0mem.h:462
id_name_t(const char *name)
Constructor.
Definition: dict0mem.h:443
id_name_t()
Default constructor.
Definition: dict0mem.h:440
Globally unique index identifier.
Definition: dict0types.h:221
Cache position of last inserted or selected record by caching record and holding reference to the blo...
Definition: dict0mem.h:990
last_ops_cur_t()
Constructor.
Definition: dict0mem.h:993
void release()
Definition: dict0mem.h:998
bool disable_caching
disable caching.
Definition: dict0mem.h:1018
mtr_t mtr
active mtr that will be re-used for next insert/select.
Definition: dict0mem.h:1015
buf_block_t * block
block where record reside.
Definition: dict0mem.h:1012
rec_t * rec
last inserted/selected record.
Definition: dict0mem.h:1009
bool invalid
If index structure is undergoing structural change viz.
Definition: dict0mem.h:1023
static const state_t NEVER_DONE
Not yet executed.
Definition: os0once.h:70
static const state_t DONE
Finished execution.
Definition: os0once.h:76
Page size descriptor.
Definition: page0size.h:50
Allocator that allows std containers to manage their memory through ut::malloc* and ut::free library ...
Definition: ut0new.h:2023
#define PERFORMANCE_SCHEMA_DB_NAME
Name of the performance schema database.
Definition: client_priv.h:222
Data types.
constexpr uint32_t DATA_MULTI_VALUE
Multi-value Virtual column.
Definition: data0type.h:225
ulint DATA_MBMINMAXLEN(ulint mbminlen, ulint mbmaxlen)
Definition: data0type.h:250
constexpr uint32_t DATA_MBMAX
Definition: data0type.h:238
static ulint dtype_get_max_size_low(ulint mtype, ulint len)
Returns the maximum size of a data type.
constexpr uint32_t DATA_VIRTUAL
Virtual column.
Definition: data0type.h:223
constexpr uint32_t DATA_ITT_N_SYS_COLS
number of system columns for intrinsic temporary table
Definition: data0type.h:197
constexpr uint32_t DATA_SYS
system column
Definition: data0type.h:75
ulint DATA_MBMINLEN(ulint mbminmaxlen)
Definition: data0type.h:255
ulint DATA_MBMAXLEN(ulint mbminmaxlen)
Definition: data0type.h:259
static ulint dtype_get_fixed_size_low(ulint mtype, ulint prtype, ulint len, ulint mbminmaxlen, bool comp)
Returns the size of a fixed size data type, 0 if not a fixed size type.
constexpr uint32_t DATA_NOT_NULL
this is ORed to the precise type when the column is declared as NOT NULL
Definition: data0type.h:207
constexpr uint32_t DATA_N_SYS_COLS
number of system columns defined above
Definition: data0type.h:194
static ulint dtype_get_min_size_low(ulint mtype, ulint prtype, ulint len, ulint mbminmaxlen)
Returns the minimum size of a data type.
bool DATA_GEOMETRY_MTYPE(ulint mtype)
Definition: data0type.h:269
void dict_mem_init(void)
Initialize dict memory variables.
Definition: dict0mem.cc:844
constexpr uint32_t DICT_CLUSTERED
Type flags of an index: OR'ing of the flags is allowed to define a combination of types.
Definition: dict0mem.h:97
void dict_table_autoinc_create_lazy(dict_table_t *table)
Request for lazy creation of the autoinc latch of a given table.
Definition: dict0mem.h:3106
char * dict_mem_create_temporary_tablename(mem_heap_t *heap, const char *dbtab, table_id_t id)
Create a temporary tablename like "#sql-ibtid-inc" where tid = the Table ID inc = a randomly initiali...
Definition: dict0mem.cc:822
void dict_mem_foreign_fill_vcol_set(dict_foreign_t *foreign)
Fills the dependent virtual columns in a set.
Definition: dict0mem.cc:500
static void DICT_TF2_FLAG_UNSET(dict_table_t *table, uint32_t flag)
Definition: dict0mem.h:2777
void dict_mem_foreign_table_name_lookup_set(dict_foreign_t *foreign, bool do_alloc)
Sets the foreign_table_name_lookup pointer based on the value of lower_case_table_names.
Definition: dict0mem.cc:367
constexpr uint32_t DICT_TF2_FTS_ADD_DOC_ID
Need to add Doc ID column for FTS index build.
Definition: dict0mem.h:280
constexpr uint32_t DICT_TF2_ENCRYPTION_FILE_PER_TABLE
Encryption table bit for innodb_file-per-table only.
Definition: dict0mem.h:296
constexpr uint32_t DICT_TF_BIT_MASK
A mask of all the known/used bits in table flags.
Definition: dict0mem.h:194
constexpr uint32_t DICT_IT_BITS
number of bits used for SYS_INDEXES.TYPE
Definition: dict0mem.h:116
void dict_index_zip_pad_mutex_destroy(dict_index_t *index)
Destroy the zip_pad_mutex of the given index.
Definition: dict0mem.h:3125
ulong zip_failure_threshold_pct
Percentage of compression failures that are allowed in a single round.
Definition: dict0dict.cc:180
constexpr uint32_t DICT_TF_WIDTH_SHARED_SPACE
Width of the SHARED tablespace flag.
Definition: dict0mem.h:185
std::set< dict_foreign_t *, dict_foreign_compare, ut::allocator< dict_foreign_t * > > dict_foreign_set
Definition: dict0mem.h:1765
table_dirty_status
The dirty status of tables, used to indicate if a table has some dynamic metadata changed to be writt...
Definition: dict0mem.h:1892
@ METADATA_CLEAN
All persistent metadata are up to date.
Definition: dict0mem.h:1911
@ METADATA_BUFFERED
Some persistent metadata is buffered in DDTableBuffer table, need to be written back to DD table.
Definition: dict0mem.h:1908
@ METADATA_DIRTY
Some persistent metadata is now dirty in memory, need to be written back to DDTableBuffer table and(o...
Definition: dict0mem.h:1904
constexpr uint32_t MAX_KEY_LENGTH_BITS
Definition: dict0mem.h:1065
constexpr char INSTANT_DROP_SUFFIX_8_0_29[]
Format of INSTANTLY DROPPED column names.
Definition: dict0mem.h:86
constexpr uint32_t DICT_N_COLS_COMPACT
This bitmask is used in SYS_TABLES.N_COLS to set and test whether the Compact page format is used,...
Definition: dict0mem.h:157
std::list< dict_v_idx_t, ut::allocator< dict_v_idx_t > > dict_v_idx_list
Index list to put in dict_v_col_t.
Definition: dict0mem.h:808
constexpr uint32_t DICT_FK_MAX_RECURSIVE_LOAD
Tables could be chained together with Foreign key constraint.
Definition: dict0mem.h:311
std::list< dict_s_col_t, ut::allocator< dict_s_col_t > > dict_s_col_list
list to put stored column for dict_table_t
Definition: dict0mem.h:855
static uint32_t DICT_MAX_FIELD_LEN_BY_FORMAT_FLAG(uint32_t flags)
Definition: dict0mem.h:880
void dict_table_mutex_destroy(dict_table_t *table)
Destroy the mutex of a given table.
Definition: dict0mem.h:3075
constexpr uint32_t DICT_MULTI_VALUE
Multi-value index.
Definition: dict0mem.h:113
constexpr uint32_t DICT_TF_POS_UNUSED
Zero relative shift position of the start of the UNUSED bits.
Definition: dict0mem.h:211
constexpr uint32_t DICT_TF2_FTS
The table has an FTS index.
Definition: dict0mem.h:276
uint32_t DICT_TF_HAS_SHARED_SPACE(uint32_t flags)
Return the value of the SHARED_SPACE field.
Definition: dict0mem.h:247
const char innobase_index_reserve_name[]
"GEN_CLUST_INDEX" is the name reserved for InnoDB default system clustered index when there is no pri...
Definition: dict0mem.h:1053
constexpr uint32_t DICT_SDI
Definition: dict0mem.h:111
constexpr uint32_t DICT_VIRTUAL
Index on Virtual column.
Definition: dict0mem.h:109
constexpr uint32_t DICT_TF_POS_SHARED_SPACE
Zero relative shift position of the SHARED TABLESPACE field.
Definition: dict0mem.h:208
dict_foreign_t * dict_mem_foreign_create(void)
Creates and initializes a foreign constraint memory object.
Definition: dict0mem.cc:344
constexpr uint32_t DICT_TF_MASK_SHARED_SPACE
Bit mask of the SHARED_SPACE field.
Definition: dict0mem.h:227
void dict_foreign_free(dict_foreign_t *foreign)
Frees a foreign key struct.
Definition: dict0mem.h:1796
std::vector< row_prebuilt_t * > temp_prebuilt_vec
A vector to collect prebuilt from different readers working on the same temp table.
Definition: dict0mem.h:1917
constexpr uint32_t DICT_CORRUPT
bit to store the corrupted flag in SYS_INDEXES.TYPE
Definition: dict0mem.h:103
constexpr uint32_t DICT_TF2_BIT_MASK
Definition: dict0mem.h:267
static void dict_mem_fill_index_struct(dict_index_t *index, mem_heap_t *heap, const char *table_name, const char *index_name, ulint space, ulint type, ulint n_fields)
This function poplulates a dict_index_t index memory structure with supplied information.
static bool DICT_TF2_FLAG_IS_SET(const dict_table_t *table, uint32_t flag)
Definition: dict0mem.h:2772
std::ostream & operator<<(std::ostream &out, const dict_foreign_t &foreign)
Definition: dict0mem.cc:909
constexpr uint32_t DICT_FOREIGN_ON_DELETE_SET_NULL
ON DELETE SET NULL.
Definition: dict0mem.h:1828
constexpr uint32_t DICT_FOREIGN_ON_DELETE_NO_ACTION
ON DELETE NO ACTION.
Definition: dict0mem.h:1834
constexpr uint32_t DICT_TF_COMPACT
dict_table_t::flags bit 0 is equal to 1 if the row format = Compact
Definition: dict0mem.h:153
bool dict_foreign_set_validate(const dict_foreign_set &fk_set)
Validate the search order in the foreign key set.
Definition: dict0mem.cc:860
void dict_mem_table_fill_foreign_vcol_set(dict_table_t *table)
Fill virtual columns set in each fk constraint present in the table.
Definition: dict0mem.cc:523
constexpr uint32_t DICT_TF_POS_ZIP_SSIZE
Zero relative shift position of the ZIP_SSIZE field.
Definition: dict0mem.h:199
constexpr uint32_t DICT_TF2_USE_FILE_PER_TABLE
This bit is used during table creation to indicate that it will use its own tablespace instead of the...
Definition: dict0mem.h:284
constexpr uint32_t DICT_TF_WIDTH_DATA_DIR
If a table is created with the MYSQL option DATA DIRECTORY and innodb-file-per-table,...
Definition: dict0mem.h:177
constexpr uint32_t DICT_TF2_AUX
FTS AUX hidden table bit.
Definition: dict0mem.h:299
constexpr uint32_t DICT_TF_REDUNDANT
dict_table_t::flags bit 0 is equal to 0 if the row format = Redundant
Definition: dict0mem.h:150
dict_v_col_t * dict_mem_table_add_v_col(dict_table_t *table, mem_heap_t *heap, const char *name, ulint mtype, ulint prtype, ulint len, ulint pos, ulint num_base, bool is_visible)
Adds a virtual column definition to a table.
Definition: dict0mem.cc:95
void dict_mem_table_free_foreign_vcol_set(dict_table_t *table)
Free the vcol_set from all foreign key constraint on the table.
Definition: dict0mem.cc:536
constexpr uint32_t DICT_FOREIGN_ON_UPDATE_NO_ACTION
ON UPDATE NO ACTION.
Definition: dict0mem.h:1836
persistent_type_t
Persistent dynamic metadata type, there should be 1 to 1 relationship between the metadata and the ty...
Definition: dict0mem.h:2786
@ PM_BIGGEST_TYPE
The biggest type, which should be 1 bigger than the last true type.
Definition: dict0mem.h:2805
@ PM_TABLE_AUTO_INC
Persistent Metadata type for autoinc counter.
Definition: dict0mem.h:2795
@ PM_INDEX_CORRUPTED
Persistent Metadata type for corrupted indexes.
Definition: dict0mem.h:2792
@ PM_SMALLEST_TYPE
The smallest type, which should be 1 less than the first true type.
Definition: dict0mem.h:2789
constexpr uint32_t FK_MAX_CASCADE_DEL
Similarly, when tables are chained together with foreign key constraints with on cascading delete/upd...
Definition: dict0mem.h:319
constexpr char INSTANT_DROP_PREFIX_8_0_32[]
Definition: dict0mem.h:87
static bool is_valid_row_version(const row_version_t version)
Definition: dict0mem.h:423
uint32_t DICT_TF_GET_ZIP_SSIZE(uint32_t flags)
Return the value of the ZIP_SSIZE field.
Definition: dict0mem.h:235
uint32_t DICT_TF_HAS_DATA_DIR(uint32_t flags)
Return the value of the DATA_DIR field.
Definition: dict0mem.h:243
constexpr uint32_t DICT_MAX_FIXED_COL_LEN
Defines the maximum fixed length column size.
Definition: dict0mem.h:888
constexpr uint32_t DICT_FTS
FTS index; can't be combined with the other flags.
Definition: dict0mem.h:105
constexpr uint32_t DICT_TF2_TEMPORARY
TEMPORARY; true for tables from CREATE TEMPORARY TABLE.
Definition: dict0mem.h:270
ulong zip_pad_max
Maximum percentage of a page that can be allowed as a pad to avoid compression failures.
Definition: dict0dict.cc:184
online_index_status
The status of online index creation.
Definition: dict0mem.h:1647
@ ONLINE_INDEX_ABORTED
secondary index creation was aborted and the index should be dropped as soon as index->table->n_ref_c...
Definition: dict0mem.h:1658
@ ONLINE_INDEX_ABORTED_DROPPED
the online index creation was aborted, the index was dropped from the data dictionary and the tablesp...
Definition: dict0mem.h:1663
@ ONLINE_INDEX_CREATION
the index is being created, online (allowing concurrent modifications)
Definition: dict0mem.h:1652
@ ONLINE_INDEX_COMPLETE
the index is complete and ready for access
Definition: dict0mem.h:1649
constexpr uint32_t DICT_TF2_DISCARDED
Set when we discard/detach the tablespace.
Definition: dict0mem.h:287
constexpr uint32_t DICT_TF2_BITS
Table Flags set number 2.
Definition: dict0mem.h:265
constexpr uint32_t DICT_TF_MASK_DATA_DIR
Bit mask of the DATA_DIR field.
Definition: dict0mem.h:224
constexpr uint32_t DICT_TF2_UNUSED_BIT_MASK
Definition: dict0mem.h:266
ut_list_base< lock_t, TableLockGetNode > table_lock_list_t
Definition: dict0mem.h:1855
constexpr uint32_t DICT_SPATIAL
SPATIAL index; can't be combined with the other flags.
Definition: dict0mem.h:107
constexpr uint32_t DICT_FOREIGN_ON_UPDATE_SET_NULL
ON UPDATE SET NULL.
Definition: dict0mem.h:1832
constexpr uint32_t DICT_TF_POS_ATOMIC_BLOBS
Zero relative shift position of the ATOMIC_BLOBS field.
Definition: dict0mem.h:202
std::set< dict_v_col_t *, std::less< dict_v_col_t * >, ut::allocator< dict_v_col_t * > > dict_vcol_set
Set to store the virtual columns which are affected by Foreign key constraint.
Definition: dict0mem.h:1670
void dict_mem_table_col_rename(dict_table_t *table, ulint nth_col, const char *from, const char *to, bool is_virtual)
Renames a column of a table in the data dictionary cache.
Definition: dict0mem.cc:320
constexpr uint32_t DICT_TF_BITS
Width of all the currently known table flags.
Definition: dict0mem.h:188
static void DICT_TF2_FLAG_SET(dict_table_t *table, uint32_t flag)
Definition: dict0mem.h:2768
constexpr uint32_t DICT_TF_MASK_ATOMIC_BLOBS
Bit mask of the ATOMIC_BLOBS field.
Definition: dict0mem.h:221
constexpr uint32_t ZIP_PAD_ROUND_LEN
PADDING HEURISTIC BASED ON LINEAR INCREASE OF PADDING TO AVOID COMPRESSION FAILURES (Note: this is re...
Definition: dict0mem.h:941
void dict_mem_table_add_s_col(dict_table_t *table, ulint num_base)
Adds a stored column definition to a table.
Definition: dict0mem.cc:152
constexpr uint32_t DICT_FOREIGN_ON_DELETE_CASCADE
The flags for ON_UPDATE and ON_DELETE can be ORed; the default is that a foreign key constraint is en...
Definition: dict0mem.h:1826
uint32_t DICT_TF_GET_COMPACT(uint32_t flags)
Return the value of the COMPACT field.
Definition: dict0mem.h:231
constexpr uint32_t ZIP_PAD_SUCCESSFUL_ROUND_LIMIT
Number of successful rounds after which the padding is decreased.
Definition: dict0mem.h:944
void dict_index_zip_pad_mutex_create_lazy(dict_index_t *index)
Request a lazy creation of dict_index_t::zip_pad::mutex.
Definition: dict0mem.h:3116
constexpr uint32_t DICT_UNIQUE
unique index
Definition: dict0mem.h:99
constexpr uint32_t DICT_TABLE_MAGIC_N
Value of 'magic_n'.
Definition: dict0mem.h:1922
constexpr uint32_t ZIP_PAD_INCR
Amount by which padding is increased.
Definition: dict0mem.h:947
constexpr uint32_t DICT_IBUF
insert buffer tree
Definition: dict0mem.h:101
constexpr uint32_t DICT_TF_MASK_COMPACT
Bit mask of the COMPACT field.
Definition: dict0mem.h:215
constexpr uint32_t DICT_INDEX_MAGIC_N
Value of dict_index_t::magic_n.
Definition: dict0mem.h:1061
void dict_table_autoinc_destroy(dict_table_t *table)
Destroy the autoinc latch of the given table.
Definition: dict0mem.h:3088
uint32_t DICT_TF_HAS_ATOMIC_BLOBS(uint32_t flags)
Return the value of the ATOMIC_BLOBS field.
Definition: dict0mem.h:239
constexpr uint32_t DICT_TF2_FTS_HAS_DOC_ID
The table has an internal defined DOC ID column.
Definition: dict0mem.h:273
constexpr uint32_t DICT_TF_POS_DATA_DIR
Zero relative shift position of the DATA_DIR field.
Definition: dict0mem.h:205
bool dict_table_autoinc_own(const dict_table_t *table)
Check if the current thread owns the autoinc_mutex of a given table.
Definition: dict0mem.h:3146
constexpr uint32_t DICT_TF_WIDTH_COMPACT
Width of the COMPACT flag.
Definition: dict0mem.h:160
constexpr char RECOVERY_INDEX_TABLE_NAME[]
index/table name used while applying REDO logs during recovery
Definition: dict0mem.h:90
constexpr uint32_t DICT_FOREIGN_ON_UPDATE_CASCADE
ON UPDATE CASCADE.
Definition: dict0mem.h:1830
constexpr uint32_t DICT_TF2_INTRINSIC
Intrinsic table bit Intrinsic table is table created internally by MySQL modules viz.
Definition: dict0mem.h:293
constexpr uint32_t DICT_TF2_RESURRECT_PREPARED
Table is opened by resurrected trx during crash recovery.
Definition: dict0mem.h:302
uint32_t DICT_TF_GET_UNUSED(uint32_t flags)
Return the contents of the UNUSED bits.
Definition: dict0mem.h:251
void dict_mem_referenced_table_name_lookup_set(dict_foreign_t *foreign, bool do_alloc)
Sets the referenced_table_name_lookup pointer based on the value of lower_case_table_names.
Definition: dict0mem.cc:391
constexpr uint32_t DICT_INDEX_MERGE_THRESHOLD_DEFAULT
Definition: dict0mem.h:1064
void dict_mem_index_free(dict_index_t *index)
Frees an index memory object.
Definition: dict0mem.cc:776
constexpr uint32_t DICT_TF_POS_COMPACT
Zero relative shift position of the COMPACT field.
Definition: dict0mem.h:197
constexpr uint32_t DICT_TF_WIDTH_ZIP_SSIZE
Width of the ZIP_SSIZE flag.
Definition: dict0mem.h:163
void dict_table_mutex_create_lazy(dict_table_t *table)
Request for lazy creation of the mutex of a given table.
Definition: dict0mem.h:3066
constexpr uint32_t DICT_ANTELOPE_MAX_INDEX_COL_LEN
DICT_ANTELOPE_MAX_INDEX_COL_LEN is measured in bytes and is the maximum indexed column length (or ind...
Definition: dict0mem.h:868
std::vector< index_id_t, ut::allocator< index_id_t > > corrupted_ids_t
Definition: dict0mem.h:2808
constexpr uint32_t DICT_TF_MASK_ZIP_SSIZE
Bit mask of the ZIP_SSIZE field.
Definition: dict0mem.h:218
constexpr uint32_t DICT_TF_WIDTH_ATOMIC_BLOBS
Width of the ATOMIC_BLOBS flag.
Definition: dict0mem.h:171
void dict_index_zip_pad_unlock(dict_index_t *index)
Release the zip_pad_mutex of a given index.
Definition: dict0mem.h:3136
Data dictionary memory object creation.
Data dictionary global types.
ib_id_t space_index_t
Index identifier (unique within a tablespace).
Definition: dict0types.h:218
spatial_status_t
whether a col is used in spatial index or regular index Note: the spatial status is part of persisten...
Definition: dict0types.h:330
@ SPATIAL_MIXED
Used in both spatial index and regular index.
Definition: dict0types.h:338
@ SPATIAL_NONE
Not used in gis index.
Definition: dict0types.h:335
@ SPATIAL_ONLY
Only used in spatial index.
Definition: dict0types.h:341
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:216
ib_quiesce_t
Quiescing states for flushing tables to disk.
Definition: dict0types.h:295
Full text search header file.
R-tree header file.
The simple hash table utility.
void * hash_node_t
Definition: hash0hash.h:47
static int flags[50]
Definition: hp_test1.cc:40
static int flag
Definition: hp_test1.cc:40
The transaction lock system global types.
@ LOCK_NUM
Definition: lock0types.h:62
The memory management.
static void mem_heap_free(mem_heap_t *heap)
Frees the space occupied by a memory heap.
Data dictionary memory object creation.
#define mtr_commit(m)
Commit a mini-transaction.
Definition: mtr0mtr.h:56
void for_each(const Shards< COUNT > &shards, Function &&f) noexcept
Iterate over the shards.
Definition: ut0counter.h:323
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
const dd::String_type MYSQL_SCHEMA_NAME
Definition: server.cc:265
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:44
unsigned long long Object_id
Definition: object_id.h:31
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
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
void delete_(T *ptr) noexcept
Releases storage which has been dynamically allocated through any of the ut::new*() variants.
Definition: ut0new.h:651
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2732
std::map< Key, Value, Compare, ut::allocator< std::pair< const Key, Value > > > map
Specialization of map which uses ut_allocator.
Definition: ut0new.h:2742
A class that aids executing a given function exactly once in a multi-threaded environment.
Query graph global types.
Record manager global types.
const uint8_t MAX_ROW_VERSION
Definition: rem0types.h:46
constexpr uint32_t REC_ANTELOPE_MAX_INDEX_COL_LEN
Definition: rem0types.h:82
constexpr uint32_t REC_VERSION_56_MAX_INDEX_COL_LEN
Maximum indexed field length for tables that have atomic BLOBs.
Definition: rem0types.h:87
const row_version_t INVALID_ROW_VERSION
Definition: rem0types.h:56
byte rec_t
Definition: rem0types.h:41
uint16_t row_version_t
Definition: rem0types.h:53
required uint64 version
Definition: replication_group_member_actions.proto:41
required string type
Definition: replication_group_member_actions.proto:34
Row operation global types.
LEX_CSTRING INFORMATION_SCHEMA_NAME
Definition: table.cc:137
File containing constants that can be used throughout the server.
constexpr const unsigned int MAX_KEY_LENGTH
Definition: sql_const.h:47
case opt name
Definition: sslopt-case.h:29
const char * str
Definition: mysql_lex_string.h:41
Definition: lock0priv.h:283
The search info struct in an index.
Definition: btr0sea.h:46
The buffer control block structure.
Definition: buf0buf.h:1756
Data structure for newly added virtual column in a table.
Definition: dict0mem.h:831
const dict_v_col_t * v_col
column structures
Definition: dict0mem.h:836
ulint n_v_col
number of new virtual column
Definition: dict0mem.h:833
const char ** v_col_name
new col names
Definition: dict0mem.h:839
Data structure for default value of a column in a table.
Definition: dict0mem.h:472
byte * value
Default value in bytes.
Definition: dict0mem.h:476
dict_col_t * col
Pointer to the column itself.
Definition: dict0mem.h:474
size_t len
Length of default value.
Definition: dict0mem.h:478
bool operator!=(const dict_col_default_t &other) const
Definition: dict0mem.cc:600
bool operator==(const dict_col_default_t &other) const
Definition: dict0mem.cc:578
Data structure for a column in a table.
Definition: dict0mem.h:485
uint16_t get_col_phy_pos() const
Definition: dict0mem.h:567
void copy_type(dtype_t *type) const
Gets the column data type.
Definition: dict0mem.h:663
unsigned ord_part
nonzero if this column appears in the ordering fields of an index
Definition: dict0mem.h:526
bool is_dropped_in_or_before(row_version_t version) const
Check if column is dropped before the given version.
Definition: dict0mem.h:736
void set_phy_pos(uint32_t pos)
Definition: dict0mem.h:579
void set_prefix_phy_pos(uint16_t prefix_pos)
Definition: dict0mem.h:560
row_version_t get_version_added() const
Definition: dict0mem.h:588
spatial_status_t get_spatial_status() const
Check whether the col is used in spatial index or regular index.
Definition: dict0mem.h:706
ulint get_null_size(ulint comp) const
Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column.
Definition: dict0mem.h:702
row_version_t version_added
Definition: dict0mem.h:544
bool is_visible
Definition: dict0mem.h:535
unsigned mtype
main data type
Definition: dict0mem.h:502
unsigned max_prefix
maximum index prefix length on this column.
Definition: dict0mem.h:529
ulint get_fixed_size(ulint comp) const
Returns the size of a fixed size column, 0 if not a fixed size column.
Definition: dict0mem.h:694
bool is_version_added_match(const dict_col_t *col) const
Definition: dict0mem.h:598
static bool is_instant_dropped_name(const std::string col_name)
Check if a column name resembles format for dropped column.
Definition: dict0mem.h:787
bool is_instant_added() const
Definition: dict0mem.h:581
ulint get_min_size() const
Returns the minimum size of the column.
Definition: dict0mem.h:641
void set_default(const byte *value, size_t length, mem_heap_t *heap)
Set default value.
Definition: dict0mem.cc:554
ulint get_mbminlen() const
Gets the minimum number of bytes per character.
Definition: dict0mem.h:674
bool is_version_dropped_match(const dict_col_t *col) const
Definition: dict0mem.h:627
bool is_nullable() const
Check if a column is nullable.
Definition: dict0mem.h:659
bool is_visible_in_version(row_version_t version) const
Check if a column is visible in given version.
Definition: dict0mem.h:762
void set_version_added(row_version_t version)
Definition: dict0mem.h:593
void set_col_phy_pos(uint16_t pos)
Definition: dict0mem.h:570
bool is_instant_dropped() const
Definition: dict0mem.h:610
bool is_multi_value() const
Check if a column is a multi-value virtual column.
Definition: dict0mem.h:655
row_version_t version_dropped
Definition: dict0mem.h:547
uint32_t phy_pos
Definition: dict0mem.h:541
ulint get_max_size() const
Returns the maximum size of the column.
Definition: dict0mem.h:647
bool is_added_after(row_version_t version) const
Check if column is added after the current version.
Definition: dict0mem.h:749
bool assert_equal(const dtype_t *type) const
Assert that a column and a data type match.
Definition: dict0mem.h:771
unsigned len
length; for MySQL data this is field->pack_length(), except that for a >= 5.0.3 type true VARCHAR thi...
Definition: dict0mem.h:506
dict_col_default_t * instant_default
The following are copied from dtype_t, so that all bit-fields can be packed tightly.
Definition: dict0mem.h:493
uint16_t get_prefix_phy_pos() const
Definition: dict0mem.h:554
bool is_virtual() const
Check if a column is a virtual column.
Definition: dict0mem.h:651
unsigned mbminmaxlen
minimum and maximum length of a character, in bytes; DATA_MBMINMAXLEN(mbminlen,mbmaxlen); mbminlen=DA...
Definition: dict0mem.h:515
row_version_t get_version_dropped() const
Definition: dict0mem.h:617
void set_version_dropped(row_version_t version)
Definition: dict0mem.h:622
void set_mbminmaxlen(ulint mbminlen, ulint mbmaxlen)
Sets the minimum and maximum number of bytes per character.
Definition: dict0mem.h:683
unsigned ind
table column position (starting from 0)
Definition: dict0mem.h:524
unsigned prtype
precise type; MySQL data type, charset code, flags to indicate nullability, signedness,...
Definition: dict0mem.h:495
ulint get_mbmaxlen() const
Gets the maximum number of bytes per character.
Definition: dict0mem.h:678
bool has_prefix_phy_pos() const
Definition: dict0mem.h:551
uint32_t get_phy_pos() const
Definition: dict0mem.h:576
Data structure for a field in an index.
Definition: dict0mem.h:891
dict_col_t * col
pointer to the table column
Definition: dict0mem.h:894
id_name_t name
name of the column
Definition: dict0mem.h:895
unsigned is_ascending
0=DESC, 1=ASC
Definition: dict0mem.h:907
unsigned prefix_len
0 or the length of the column prefix in bytes in a MySQL index of type, e.g., INDEX (textcol(25)); mu...
Definition: dict0mem.h:896
unsigned fixed_len
0 or the fixed length of the column if smaller than DICT_ANTELOPE_MAX_INDEX_COL_LEN
Definition: dict0mem.h:904
uint16_t get_phy_pos() const
Definition: dict0mem.h:909
dict_field_t()
Definition: dict0mem.h:892
size_t get_mbmaxlen() const
Definition: dict0mem.h:917
A function object to add the foreign key constraint to the referenced set of the referenced table,...
Definition: dict0mem.h:3052
void operator()(dict_foreign_t *foreign) const
Definition: dict0mem.h:3053
Compare two dict_foreign_t objects using their ids.
Definition: dict0mem.h:1736
bool operator()(const dict_foreign_t *lhs, const dict_foreign_t *rhs) const
Definition: dict0mem.h:1737
Definition: dict0mem.h:1757
bool operator()(const dict_foreign_t *foreign) const
Definition: dict0mem.h:1758
Function object to check if a foreign key object is there in the given foreign key set or not.
Definition: dict0mem.h:1772
bool operator()(dict_foreign_t *const &foreign) const
Definition: dict0mem.h:1776
const dict_foreign_set & m_foreigns
Definition: dict0mem.h:1781
dict_foreign_not_exists(const dict_foreign_set &obj_)
Definition: dict0mem.h:1773
Definition: dict0mem.h:1723
void operator()(const dict_foreign_t *foreign)
Definition: dict0mem.h:1726
dict_foreign_print(std::ostream &out)
Definition: dict0mem.h:1724
std::ostream & m_out
Definition: dict0mem.h:1729
The destructor will free all the foreign key constraints in the set by calling dict_foreign_free() on...
Definition: dict0mem.h:1810
~dict_foreign_set_free()
Definition: dict0mem.h:1814
dict_foreign_set_free(const dict_foreign_set &foreign_set)
Definition: dict0mem.h:1811
const dict_foreign_set & m_foreign_set
Definition: dict0mem.h:1819
Data structure for a foreign key constraint; an example: FOREIGN KEY (A, B) REFERENCES TABLE2 (C,...
Definition: dict0mem.h:1675
unsigned type
0 or DICT_FOREIGN_ON_DELETE_CASCADE or DICT_FOREIGN_ON_DELETE_SET_NULL
Definition: dict0mem.h:1686
char * referenced_table_name_lookup
referenced table name for dict lookup
Definition: dict0mem.h:1695
dict_vcol_set * v_cols
set of virtual columns affected by foreign key constraint.
Definition: dict0mem.h:1708
char * referenced_table_name
referenced table name
Definition: dict0mem.h:1694
dict_table_t * referenced_table
table where the referenced key is
Definition: dict0mem.h:1697
char * foreign_table_name_lookup
foreign table name used for dict lookup
Definition: dict0mem.h:1689
const char ** referenced_col_names
names of the referenced columns in the referenced table
Definition: dict0mem.h:1699
const char ** foreign_col_names
names of the columns in the foreign key
Definition: dict0mem.h:1692
unsigned n_fields
number of indexes' first fields for which the foreign key constraint is defined: we allow the indexes...
Definition: dict0mem.h:1680
bool is_fts_col_affected() const
Check whether foreign key constraint contains a column with a full index on it.
Definition: dict0mem.cc:886
dict_table_t * foreign_table
table where the foreign key is
Definition: dict0mem.h:1691
char * foreign_table_name
foreign table name
Definition: dict0mem.h:1688
mem_heap_t * heap
this object is allocated from this memory heap
Definition: dict0mem.h:1676
dict_index_t * referenced_index
referenced index
Definition: dict0mem.h:1706
char * id
id of the constraint as a null-terminated string
Definition: dict0mem.h:1678
dict_index_t * foreign_index
foreign index; we require that both tables contain explicitly defined indexes for the constraint: Inn...
Definition: dict0mem.h:1701
A function object to find a foreign key with the given index as the referenced index.
Definition: dict0mem.h:1744
const dict_index_t * m_index
Definition: dict0mem.h:1751
dict_foreign_with_index(const dict_index_t *index)
Definition: dict0mem.h:1745
bool operator()(const dict_foreign_t *foreign) const
Definition: dict0mem.h:1747
Data structure storing index statistics.
Definition: dict0mem.h:3155
dict_index_stats_t stats
Definition: dict0mem.h:3156
unsigned type
Definition: dict0mem.h:3157
unsigned n_uniq
Definition: dict0mem.h:3158
Data structure storing index statistics for query optimization.
Definition: dict0mem.h:1027
uint64_t * n_sample_sizes
number of pages that were sampled to calculate each of n_diff_key_vals[], e.g.
Definition: dict0mem.h:1037
ulint index_size
approximate index size in database pages
Definition: dict0mem.h:1045
uint64_t * n_non_null_key_vals
Definition: dict0mem.h:1042
uint64_t * n_diff_key_vals
approximate number of different key values for this index, for each n-column prefix where 1 <= n <= d...
Definition: dict0mem.h:1032
ulint n_leaf_pages
approximate number of leaf pages in the index tree
Definition: dict0mem.h:1048
Data structure for an index.
Definition: dict0mem.h:1069
uint32_t get_n_nullable_before(uint32_t nth) const
Returns the number of nullable fields before specified nth field.
Definition: dict0mem.h:1373
bool is_committed() const
Determine if the index has been committed to the data dictionary.
Definition: dict0mem.h:1276
unsigned uncommitted
a flag that is set for secondary indexes that have not been committed to the data dictionary yet
Definition: dict0mem.h:1154
const char * table_name
table name
Definition: dict0mem.h:1080
const dict_index_t * next() const
Get the next index.
Definition: dict0mem.h:1292
unsigned instant_cols
true if the index is clustered index and it has some instant columns
Definition: dict0mem.h:1157
rtr_ssn_t rtr_ssn
Node sequence number for RTree.
Definition: dict0mem.h:1233
rw_lock_t lock
read-write lock protecting the upper levels of the index tree
Definition: dict0mem.h:1246
id_name_t name
index name
Definition: dict0mem.h:1077
const byte * get_nth_default(ulint nth, ulint *length) const
Get the default value of nth field and its length if exists.
Definition: dict0mem.h:1580
dict_index_stats_t stats
Statistics for query optimization.
Definition: dict0mem.h:1216
unsigned type
index type (DICT_CLUSTERED, DICT_UNIQUE, DICT_IBUF, DICT_CORRUPT)
Definition: dict0mem.h:1096
uint32_t magic_n
magic number
Definition: dict0mem.h:1173
uint32_t get_nullable_in_version(row_version_t version) const
Return nullable in a specific row version.
Definition: dict0mem.h:1441
uint32_t get_n_total_fields() const
Returns total fields including INSTANT DROP fields.
Definition: dict0mem.h:1391
bool has_instant_cols_or_row_versions() const
check if either instant or versioned.
Definition: dict0mem.h:1357
void destroy_fields_array()
Definition: dict0mem.h:1460
unsigned n_total_fields
number of total fields in the index (including INSTANT dropped fields)
Definition: dict0mem.h:1132
dict_field_t * get_physical_field(size_t pos) const
Gets the nth physical pos field.
Definition: dict0mem.h:1493
uint32_t get_instant_fields() const
Returns the number of fields before first instant ADD COLUMN.
Definition: dict0mem.ic:92
unsigned trx_id_offset
position of the trx id column in a clustered index record, if the fields before it are known to be of...
Definition: dict0mem.h:1100
void create_fields_array()
Create fields array sorted by phy_pos of field in row.
Definition: dict0mem.h:1448
uint16_t get_field_off_pos(ulint pos) const
Get the physical position of a field on a row.
Definition: dict0mem.h:1531
void set_instant_nullable(uint16_t n)
Set instant nullable.
Definition: dict0mem.h:1253
trx_id_t trx_id
id of the transaction that created this index, or 0 if the index existed when InnoDB was started up
Definition: dict0mem.h:1240
bool fill_dd
Flag whether need to fill dd tables when it's a fulltext index.
Definition: dict0mem.h:1249
const dict_col_t * get_col(ulint pos) const
Gets pointer to the nth column in an index.
Definition: dict0mem.h:1554
std::unique_ptr< dd::Spatial_reference_system > rtr_srs
Cached spatial reference system dictionary entry used by R-tree indexes.
Definition: dict0mem.h:1170
dict_field_t * fields
array of field descriptions
Definition: dict0mem.h:1177
uint32_t srid
spatial reference id
Definition: dict0mem.h:1163
last_ops_cur_t * last_ins_cur
cache the last insert position.
Definition: dict0mem.h:1221
ulint get_col_pos(ulint n, bool inc_prefix=false, bool is_virtual=false) const
Looks for column n in an index.
Definition: dict0mem.cc:743
space_id_t space_id() const
Get the space id of the tablespace to which this index belongs.
Definition: dict0mem.h:1639
uint32_t has_multi_value_col(const dict_v_col_t *mv_col) const
Check if a multi-value index is built on specified multi-value virtual column.
Definition: dict0mem.h:1615
void add_field(const char *name_arg, ulint prefix_len, bool is_ascending)
Adds a field definition to an index.
Definition: dict0mem.h:1476
uint16_t get_instant_nullable() const
Get instant nullable.
Definition: dict0mem.h:1257
unsigned nulls_equal
if true, SQL NULL == SQL NULL
Definition: dict0mem.h:1114
bool is_usable(const trx_t *trx) const
Check whether index can be used by transaction.
Definition: dict0mem.cc:606
UT_LIST_NODE_T(dict_index_t) indexes
list of indexes of the table
unsigned row_versions
true if the index is clustered index and table has row versions
Definition: dict0mem.h:1160
bool is_fts_index() const
Check if it is a full-text search (FTS) index.
Definition: dict0mem.h:1643
uint16_t get_field_phy_pos(ulint pos, row_version_t version) const
Definition: dict0mem.h:1535
unsigned n_instant_nullable
number of nullable fields before first instant ADD COLUMN applied to this table.
Definition: dict0mem.h:1139
unsigned space
space where the index tree is placed
Definition: dict0mem.h:1086
unsigned cached
true if the index object is in the dictionary cache
Definition: dict0mem.h:1142
ulint get_sys_col_pos(ulint type) const
Returns the position of a system column in an index.
Definition: dict0mem.cc:726
zip_pad_info_t zip_pad
Information about state of compression failures and successes.
Definition: dict0mem.h:1243
dict_field_t * get_field(ulint pos) const
Gets the nth field of an index.
Definition: dict0mem.h:1507
row_log_t * online_log
the log of modifications during online index creation; valid when online_status is ONLINE_INDEX_CREAT...
Definition: dict0mem.h:1210
uint16_t get_nullable_before_instant_add_drop() const
Get the nullable fields before any INSTANT ADD/DROP.
Definition: dict0mem.h:1261
unsigned disable_ahi
if true, then disable AHI.
Definition: dict0mem.h:1119
ulint get_min_size() const
Returns the minimum data size of an index record.
Definition: dict0mem.h:1332
size_t calculate_n_instant_nullable(size_t _n_fields) const
Definition: dict0mem.h:1400
unsigned n_def
number of fields defined so far
Definition: dict0mem.h:1126
unsigned n_nullable
number of nullable fields
Definition: dict0mem.h:1135
rec_cache_t rec_cache
cache the field that needs to be re-computed on each insert.
Definition: dict0mem.h:1230
bool is_multi_value() const
Check whether the index is the multi-value index.
Definition: dict0mem.h:1324
last_ops_cur_t * last_sel_cur
cache the last selected position.
Definition: dict0mem.h:1225
unsigned n_fields
number of fields in the index
Definition: dict0mem.h:1129
uint16_t get_logical_pos(uint16_t phy_pos) const
Given the physical position, find the logical position of field.
Definition: dict0mem.h:1517
st_mysql_ftparser * parser
fulltext parser plugin
Definition: dict0mem.h:1189
uint32_t nullables[MAX_ROW_VERSION+1]
Number of nullable columns in each version.
Definition: dict0mem.h:1185
bool has_row_versions() const
Check whether index belongs to a table having row versions.
Definition: dict0mem.h:1353
space_index_t id
id of the index
Definition: dict0mem.h:1071
void set_committed(bool committed)
Flag an index committed or uncommitted.
Definition: dict0mem.h:1283
bool is_compressed() const
Check if the underlying table is compressed.
Definition: dict0mem.h:2781
void create_nullables(uint32_t current_row_version)
Create nullables array.
Definition: dict0mem.cc:632
bool is_corrupted() const
Check whether the index is corrupted.
Definition: dict0mem.h:1307
bool srid_is_valid
says whether SRID is valid - it cane be undefined
Definition: dict0mem.h:1166
rtr_info_track_t * rtr_track
tracking all R-Tree search cursors
Definition: dict0mem.h:1236
dict_index_t * next()
Get the next index.
Definition: dict0mem.h:1300
bool is_clustered() const
Definition: dict0mem.h:1316
bool has_instant_cols() const
Check whether index has any instantly added columns.
Definition: dict0mem.h:1349
ulint get_col_no(ulint pos) const
Gets the column number the nth field in an index.
Definition: dict0mem.cc:719
mem_heap_t * heap
memory heap
Definition: dict0mem.h:1074
unsigned merge_threshold
In the pessimistic delete, if the page data size drops below this limit in percent,...
Definition: dict0mem.h:1093
std::vector< uint16_t > fields_array
Array of field pos sorted as per their physical pos in record.
Definition: dict0mem.h:1181
dict_table_t * table
back pointer to table
Definition: dict0mem.h:1083
bool is_ngram
true if it's ngram parser
Definition: dict0mem.h:1192
unsigned online_status
enum online_index_status.
Definition: dict0mem.h:1150
bool has_new_v_col
whether it has a newly added virtual column in ALTER
Definition: dict0mem.h:1195
page_size_t get_page_size() const
Get the page size of the tablespace to which this index belongs.
Definition: dict0mem.cc:927
bool is_tuple_instant_format(const uint16_t n_fields_in_tuple) const
Check if tuple is having instant format.
Definition: dict0mem.cc:682
unsigned allow_duplicates
if true, allow duplicate values even if index is created with unique constraint
Definition: dict0mem.h:1111
void fill_srid_value(uint32_t srid_value, bool srid_is_valid_value)
Sets srid and srid_is_valid values.
Definition: dict0mem.h:1599
bool hidden
if the index is an hidden index
Definition: dict0mem.h:1198
unsigned page
index tree root page number
Definition: dict0mem.h:1089
unsigned n_user_defined_cols
number of columns the user defined to be in the index: in the internal representation we add more col...
Definition: dict0mem.h:1103
btr_search_t * search_info
info used in optimistic searches
Definition: dict0mem.h:1205
unsigned to_be_dropped
true if the index is to be dropped; protected by dict_operation_lock
Definition: dict0mem.h:1145
unsigned n_uniq
number of fields from the beginning which are enough to determine an index entry uniquely
Definition: dict0mem.h:1123
Data structure for a stored column in a table.
Definition: dict0mem.h:843
dict_col_t * m_col
Stored column ptr.
Definition: dict0mem.h:845
ulint s_pos
column pos in table
Definition: dict0mem.h:851
dict_col_t ** base_col
array of base col ptr
Definition: dict0mem.h:847
ulint num_base
number of base columns
Definition: dict0mem.h:849
Data structure for a database table.
Definition: dict0mem.h:1927
uint32_t stats_auto_recalc
Indicates whether the table uses automatic recalc for persistent stats or not.
Definition: dict0mem.h:2283
bool has_instant_cols() const
Definition: dict0mem.h:2538
bool refresh_fk
refresh/reload FK info
Definition: dict0mem.h:2490
bool support_instant_add_drop() const
Determine if the table can support instant ADD/DROP COLUMN.
Definition: dict0dict.ic:1248
dict_vcol_templ_t * vc_templ
mysql_row_templ_t for base columns used for compute the virtual columns
Definition: dict0mem.h:2484
dict_col_t * get_col_by_name(const char *name) const
Get column by name.
Definition: dict0mem.h:2644
bool has_row_versions() const
Definition: dict0mem.h:2523
unsigned n_cols
Number of non-virtual columns.
Definition: dict0mem.h:2069
rw_lock_t * stats_latch
This latch protects: "dict_table_t::stat_initialized", "dict_table_t::stat_n_rows (*)",...
Definition: dict0mem.h:2231
std::atomic< const trx_t * > autoinc_trx
The transaction that currently holds the AUTOINC lock on this table.
Definition: dict0mem.h:2411
ulint stat_clustered_index_size
Approximate clustered index size in database pages.
Definition: dict0mem.h:2295
uint32_t get_n_instant_add_cols() const
Get number of columns added instantly.
Definition: dict0mem.h:2571
void unlock()
Unlock the table handle.
Definition: dict0dict.ic:1089
const char * get_col_name(ulint col_nr) const
Returns a column's name.
Definition: dict0mem.h:2617
std::atomic< int8_t > stats_bg_flag
The state of the background stats thread wrt this table.
Definition: dict0mem.h:2327
std::atomic< ulint > n_foreign_key_checks_running
Count of how many foreign key check operations are currently being performed on the table.
Definition: dict0mem.h:2187
unsigned drop_aborted
true if some indexes should be dropped after ONLINE_INDEX_ABORTED or ONLINE_INDEX_ABORTED_DROPPED.
Definition: dict0mem.h:2101
ulint magic_n
Magic number.
Definition: dict0mem.h:2480
dict_foreign_set foreign_set
set of foreign key constraints which refer to this table
Definition: dict0mem.h:2196
UT_LIST_BASE_NODE_T(dict_index_t, indexes) indexes
List of indexes of the table.
bool skip_gap_locks() const
Definition: dict0dict.ic:1243
table_lock_list_t locks
List of locks on the table.
Definition: dict0mem.h:2446
unsigned to_be_dropped
true if the table is to be dropped, but not yet actually dropped (could in the background drop list).
Definition: dict0mem.h:2063
dict_col_t * get_col(uint pos) const
Gets the nth column of a table.
Definition: dict0mem.h:2634
uint64_t version
metadata version number of dd::Table::se_private_data()
Definition: dict0mem.h:2150
id_name_t tablespace
NULL or the tablespace name that this table is assigned to, specified by the TABLESPACE option.
Definition: dict0mem.h:2012
unsigned ibd_file_missing
true if this is in a single-table tablespace and the .ibd file is missing.
Definition: dict0mem.h:2053
hash_node_t name_hash
Hash chain node.
Definition: dict0mem.h:2133
unsigned n_instant_cols
Number of non-virtual columns before first instant ADD COLUMN, including the system columns like n_co...
Definition: dict0mem.h:2074
unsigned n_v_def
Number of virtual columns defined so far.
Definition: dict0mem.h:2083
ulint stats_sample_pages
The number of pages to sample for this table during persistent stats estimation.
Definition: dict0mem.h:2288
size_t get_index_count() const
Definition: dict0mem.h:2144
unsigned skip_alter_undo
true if the table is an intermediate table during copy alter operation or a partition/subpartition wh...
Definition: dict0mem.h:2048
bool explicitly_non_lru
true if this table is explicitly put to non-LRU list during table creation
Definition: dict0mem.h:2504
bool is_system_table
True if the table belongs to a system database (mysql, information_schema or performance_schema)
Definition: dict0mem.h:2130
std::atomic< size_t > n_rec_locks
Count of the number of record locks on this table.
Definition: dict0mem.h:2433
size_t get_n_instant_added_col_v1() const
Definition: dict0mem.h:2561
unsigned flags2
Stores information about: 1 whether the table has been created using CREATE TEMPORARY TABLE,...
Definition: dict0mem.h:2041
void lock()
Lock the table handle.
Definition: dict0dict.ic:1080
ib_quiesce_t quiesce
Quiescing states, protected by the dict_index_t::lock.
Definition: dict0mem.h:2423
bool has_pk() const
Check if the table has user defined primary key (PK).
Definition: dict0mem.cc:931
unsigned n_t_def
Number of total columns defined so far.
Definition: dict0mem.h:2080
void set_instant_cols(uint16_t n_inst_cols)
Set the number of columns when the first instant ADD COLUMN happens.
Definition: dict0mem.h:2550
unsigned flags
Stores information about: 1 row format (redundant or compact), 2 compressed page size (zip shift size...
Definition: dict0mem.h:2028
ulint autoinc_field_no
The position of autoinc counter field in clustered index.
Definition: dict0mem.h:2403
uint64_t sess_row_id
row-id counter for use by intrinsic table for getting row-id.
Definition: dict0mem.h:2464
void acquire()
Acquire the table handle.
Definition: dict0dict.ic:1038
uint16_t get_instant_cols() const
Get the number of user columns when the first instant ADD COLUMN happens.
Definition: dict0mem.h:2557
std::atomic< table_dirty_status > dirty_status
table dynamic metadata status, protected by dict_persist->mutex
Definition: dict0mem.h:2168
table_id_t id
Id of the table.
Definition: dict0mem.h:1988
UT_LIST_NODE_T(dict_table_t) table_LRU
Node of the LRU list of tables.
unsigned cached
true if the table object has been added to the dictionary cache.
Definition: dict0mem.h:2056
dict_s_col_t * is_stored_gcol(dict_col_t *col) const
Check if the given column is a stored generated column.
Definition: dict0mem.h:2757
dict_index_t * first_index()
Definition: dict0mem.h:2517
bool is_temporary() const
Determine if this is a temporary table.
Definition: dict0mem.h:2719
bool discard_after_ddl
remove the dict_table_t from cache after DDL operation
Definition: dict0mem.h:2487
uint16_t get_n_user_cols() const
Gets the number of user-defined non-virtual columns in a table in the dictionary cache.
Definition: dict0mem.h:2664
void acquire_with_lock()
Acquire the table handle, with lock() and unlock() the table.
Definition: dict0dict.ic:1044
trx_id_t def_trx_id
Transaction id that last touched the table definition.
Definition: dict0mem.h:2192
ulint get_total_cols() const
Gets the number of all non-virtual columns in a table including columns dropped INSTANTly.
Definition: dict0mem.h:2692
dd::Object_id dd_space_id
dd::Tablespace::id of the table
Definition: dict0mem.h:2018
uint32_t total_col_count
Total non-virtual column count.
Definition: dict0mem.h:2162
dict_s_col_list * s_cols
List of stored column descriptions.
Definition: dict0mem.h:2114
unsigned n_m_v_cols
Number of multi-value virtual columns.
Definition: dict0mem.h:2089
unsigned n_t_cols
Number of total columns (include virtual and non-virtual)
Definition: dict0mem.h:2077
ib_mutex_t * mutex
Mutex of the table for concurrency access.
Definition: dict0mem.h:1981
table_id_t parent_id
If FTS AUX table, parent table id.
Definition: dict0mem.h:2301
uint64_t stat_modified_counter
How many rows are modified since last stats recalc.
Definition: dict0mem.h:2309
void release()
Release the table handle.
Definition: dict0dict.ic:1060
bool is_compressed() const
Check if the table is compressed.
Definition: dict0mem.h:1930
uint64_t autoinc
Autoinc counter value to give to the next inserted row.
Definition: dict0mem.h:2359
ulint stat_sum_of_other_index_sizes
Approximate size of other indexes in database pages.
Definition: dict0mem.h:2298
dict_col_t * get_sys_col(ulint sys) const
Gets the given system column of a table.
Definition: dict0mem.h:2705
void get_table_name(std::string &schema, std::string &table) const
Get schema and table name in system character set.
Definition: dict0dd.cc:7184
bool is_system_schema() const
Definition: dict0mem.h:1965
dict_foreign_set referenced_set
Definition: dict0mem.h:2199
unsigned n_def
Number of non-virtual columns defined so far.
Definition: dict0mem.h:2066
std::atomic< bool > stats_updated
true if statistics have been updated in the background and not yet collected by the optimizer
Definition: dict0mem.h:2245
uint16_t get_n_sys_cols() const
Gets the number of system columns in a table.
Definition: dict0mem.h:2674
std::atomic< os_once::state_t > mutex_created
Creation state of mutex.
Definition: dict0mem.h:1984
bool is_encrypted() const
Check if the table is encrypted.
Definition: dict0mem.h:1934
bool has_instant_add_cols() const
check if table has INSTANT ADD columns.
Definition: dict0mem.h:2584
fts_t * fts
FTS specific state variables.
Definition: dict0mem.h:2417
std::atomic< std::chrono::system_clock::time_point > update_time
Timestamp of the last modification of this table.
Definition: dict0mem.h:2463
bool is_intrinsic() const
Determine whether the table is intrinsic.
Definition: dict0mem.h:2740
ib_mutex_t * autoinc_mutex
Mutex protecting the autoincrement counter.
Definition: dict0mem.h:2356
bool can_be_evicted
true if this table is expected to be kept in memory.
Definition: dict0mem.h:2093
ulong count_by_mode[LOCK_NUM]
count_by_mode[M] = number of locks in this->locks with lock->type_mode&LOCK_MODE_MASK == M.
Definition: dict0mem.h:2459
dict_v_col_t * v_cols
Array of virtual column descriptions.
Definition: dict0mem.h:2107
temp_prebuilt_vec * temp_prebuilt
multiple cursors can be active on this temporary table
Definition: dict0mem.h:2494
void set_upgraded_instant()
Set table to be upgraded table with INSTANT ADD columns in V1.
Definition: dict0mem.h:2591
mem_heap_t * heap
Memory heap.
Definition: dict0mem.h:1999
dict_index_t * fts_doc_id_index
The FTS_DOC_ID_INDEX, or NULL if no fulltext indexes exist.
Definition: dict0mem.h:2139
table_name_t trunc_name
Truncate name.
Definition: dict0mem.h:2005
unsigned stat_initialized
true if statistics have been calculated the first time after database startup or table creation.
Definition: dict0mem.h:2241
uint64_t sess_trx_id
trx_id counter for use by intrinsic table for getting trx-id.
Definition: dict0mem.h:2476
std::atomic< uint64_t > n_ref_count
Count of how many handles are opened to this table.
Definition: dict0mem.h:2441
unsigned n_v_cols
Number of virtual columns.
Definition: dict0mem.h:2086
bool in_dirty_dict_tables_list
This field is used to mark if a table is in the dirty_dict_tables_list.
Definition: dict0mem.h:2181
ib_mutex_t * stats_compute_mutex
Mutex protecting table and index statistics calculation process.
Definition: dict0mem.h:2237
std::chrono::steady_clock::time_point stats_last_recalc
Timestamp of last recalc of the stats.
Definition: dict0mem.h:2248
bool is_corrupted() const
Check whether the table is corrupted.
Definition: dict0mem.h:2599
std::atomic< uint64_t > autoinc_persisted
The autoinc counter value that we would like to be persisted to the DDTableBuffer on the next occasio...
Definition: dict0mem.h:2386
std::atomic< os_once::state_t > stats_compute_mutex_created
Creation state of 'stats_compute_mutex'.
Definition: dict0mem.h:2234
ulint get_n_cols() const
Gets the number of all non-virtual columns (also system) in a table in the dictionary cache.
Definition: dict0mem.h:2683
const char * col_names
Column names packed in a character string "name1\0name2\0...nameN\0".
Definition: dict0mem.h:2123
table_name_t name
Table name.
Definition: dict0mem.h:2002
char * data_dir_path
NULL or the directory path specified by DATA DIRECTORY.
Definition: dict0mem.h:2008
const dict_index_t * first_index() const
Definition: dict0mem.h:2511
uint64_t get_ref_count() const
Get reference count.
Definition: dict0dict.ic:1035
lock_t * autoinc_lock
AUTOINC related members.
Definition: dict0mem.h:2349
uint32_t stat_persistent
Indicates whether the table uses persistent stats or not.
Definition: dict0mem.h:2265
uint32_t initial_col_count
Initial non-virtual column count.
Definition: dict0mem.h:2156
const char * v_col_names
Virtual column names.
Definition: dict0mem.h:2126
uint32_t current_col_count
Current non-virtual column count.
Definition: dict0mem.h:2159
unsigned big_rows
true if the maximum length of a single row exceeds BIG_ROW_SIZE.
Definition: dict0mem.h:2212
hash_node_t id_hash
Hash chain node.
Definition: dict0mem.h:2136
bool m_upgraded_instant
Set if table is upgraded instant table.
Definition: dict0mem.h:2165
bool has_instant_drop_cols() const
check if table has INSTANT DROP columns.
Definition: dict0mem.h:2588
uint64_t stat_n_rows
Approximate number of rows in the table.
Definition: dict0mem.h:2292
bool is_fts_aux() const
Determine if this is a FTS AUX table.
Definition: dict0mem.h:2725
uint32_t get_n_instant_drop_cols() const
Get number of columns dropped instantly.
Definition: dict0mem.h:2577
uint32_t current_row_version
Current row version in case columns are added/dropped INSTANTly.
Definition: dict0mem.h:2153
std::atomic< uint64_t > autoinc_buffered
The autoinc counter value that has been persisted to DDTableBuffer last time during this run of mysql...
Definition: dict0mem.h:2397
std::atomic< os_once::state_t > autoinc_mutex_created
Creation state of autoinc_mutex member.
Definition: dict0mem.h:2352
bool is_dd_table
true only for dictionary tables like mysql/tables, mysql/columns, mysql/tablespaces,...
Definition: dict0mem.h:2500
bool is_upgraded_instant() const
Checks if table is upgraded table with INSTANT ADD columns in V1.
Definition: dict0mem.h:2595
UT_LIST_NODE_T(dict_table_t) dirty_dict_tables
Node of the dirty table list of tables, which is protected by dict_persist->mutex.
std::atomic< os_once::state_t > stats_latch_created
Statistics for query optimization.
Definition: dict0mem.h:2218
ib_mutex_t * autoinc_persisted_mutex
Mutex protecting the persisted autoinc_persisted counter.
Definition: dict0mem.h:2362
bool does_not_fit_in_memory
This field is used to specify in simulations tables which are so big that disk should be accessed.
Definition: dict0mem.h:2207
unsigned ddl_not_evictable
true if this table is not evictable(can_be_evicted) and this is because of DDL operation
Definition: dict0mem.h:2097
dict_col_t * cols
Array of column descriptions.
Definition: dict0mem.h:2104
space_id_t space
Space where the clustered index of the table is placed.
Definition: dict0mem.h:2015
Data structure for a virtual column in a table.
Definition: dict0mem.h:811
dict_v_idx_list * v_indexes
Virtual index list, and column position in the index, the allocated memory is not from table->heap,...
Definition: dict0mem.h:827
ulint v_pos
column pos in table
Definition: dict0mem.h:822
dict_col_t m_col
column structure
Definition: dict0mem.h:813
ulint num_base
number of base columns
Definition: dict0mem.h:819
dict_col_t ** base_col
array of base column ptr
Definition: dict0mem.h:816
Index information put in a list of virtual column structure.
Definition: dict0mem.h:799
ulint nth_field
position in this index
Definition: dict0mem.h:804
dict_index_t * index
active index on the column
Definition: dict0mem.h:801
Structure defines template related to virtual columns and their base columns.
Definition: dict0mem.h:1864
byte * default_rec
default column value if any
Definition: dict0mem.h:1887
ulint n_v_col
number of virtual columns
Definition: dict0mem.h:1869
std::string tb_name
table name
Definition: dict0mem.h:1878
ulint rec_len
MySQL record length.
Definition: dict0mem.h:1884
std::string share_name
share->table_name
Definition: dict0mem.h:1881
ulint n_col
number of regular columns
Definition: dict0mem.h:1866
mysql_row_templ_t ** vtempl
array of templates for virtual col and their base columns
Definition: dict0mem.h:1872
std::string db_name
table's database name
Definition: dict0mem.h:1875
Definition: data0type.h:498
Red black tree instance.
Definition: ut0rbt.h:72
Lock struct; protected by lock_sys latches.
Definition: lock0priv.h:137
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:295
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:174
bool is_active() const
Definition: mtr0mtr.h:507
Definition: row0mysql.h:455
If key is fixed length key then cache the record offsets on first computation.
Definition: dict0mem.h:978
size_t nullable_cols
Number of NULLable columns among those for which offsets are cached.
Definition: dict0mem.h:983
const ulint * offsets
Holds reference to cached offsets for record.
Definition: dict0mem.h:980
Buffer for logging modifications during online index creation.
Definition: row0log.cc:186
Definition: gis0type.h:152
Definition: gis0type.h:160
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:362
Definition: plugin_ftparser.h:216
Table name wrapper for pretty-printing.
Definition: dict0mem.h:466
char * m_name
The name in internal representation.
Definition: dict0mem.h:468
Definition: trx0trx.h:670
Data structure to hold information about about how much space in an uncompressed page should be left ...
Definition: dict0mem.h:960
SysMutex * mutex
mutex protecting the info
Definition: dict0mem.h:961
ulint success
successful compression ops during current round
Definition: dict0mem.h:963
std::atomic< ulint > pad
number of bytes used as pad
Definition: dict0mem.h:962
ulint n_rounds
number of currently successful rounds
Definition: dict0mem.h:967
ulint failure
failed compression ops during current round
Definition: dict0mem.h:965
std::atomic< os_once::state_t > mutex_created
Creation state of mutex member.
Definition: dict0mem.h:970
The read-write lock (for threads, not for database transactions)
Transaction system global type definitions.
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:138
Definition: dtoa.cc:595
Version control for database, common definitions, and include files.
constexpr uint32_t UINT32_UNDEFINED
The 'undefined' value for a 32-bit unsigned integer.
Definition: univ.i:425
#define UNIV_LIKELY(cond)
Definition: univ.i:522
constexpr uint32_t UNIV_SQL_NULL
The following number as the length of a logical field means that the field has the SQL NULL as its va...
Definition: univ.i:466
constexpr uint16_t UINT16_UNDEFINED
The 'undefined' value for a 16-bit unsigned integer.
Definition: univ.i:428
unsigned long int ulint
Definition: univ.i:403
Utilities for byte operations.
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:109
#define ut_ad_eq(LHS, RHS)
Debug-only assertion that LHS == RHS.
Definition: ut0dbg.h:119
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:97
#define UT_LIST_GET_LEN(BASE)
Alternative macro to get the number of nodes in a two-way list, i.e., its length.
Definition: ut0lst.h:441
#define UT_LIST_GET_FIRST(BASE)
Gets the first node in a two-way list.
Definition: ut0lst.h:446
#define UT_LIST_GET_NEXT(NAME, N)
Gets the next node in a two-way list.
Definition: ut0lst.h:429
Memory primitives.
static int ut_strcmp(const char *str1, const char *str2)
Wrapper for strcmp(3).
#define mutex_own(M)
Checks that the current thread owns the mutex.
Definition: ut0mutex.h:166
#define mutex_exit(M)
Definition: ut0mutex.h:122
#define mutex_free(M)
Definition: ut0mutex.h:124
Dynamic memory allocation routines and custom allocators specifically crafted to support memory instr...
Random numbers and hashing.
unsigned long id[MAX_DEAD]
Definition: xcom_base.cc:510
int n
Definition: xcom_base.cc:509