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