MySQL  8.0.20
Source Code Documentation
dict0mem.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2019, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2012, Facebook Inc.
5 
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License, version 2.0, as published by the
8 Free Software Foundation.
9 
10 This program is also distributed with certain software (including but not
11 limited to OpenSSL) that is licensed under separate terms, as designated in a
12 particular file or component or in included license documentation. The authors
13 of MySQL hereby grant you an additional permission to link the program and
14 your derivative works with the separately licensed software that they have
15 included with MySQL.
16 
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
20 for more details.
21 
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc.,
24 51 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 #ifdef UNIV_HOTBACKUP
42 #endif /* 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 
72 #include <algorithm>
73 #include <iterator>
74 #include <memory> /* std::unique_ptr */
75 #include <set>
76 #include <string>
77 #include <vector>
78 
79 /* Forward declaration. */
80 struct ib_rbt_t;
81 
82 /** Type flags of an index: OR'ing of the flags is allowed to define a
83 combination of types */
84 /* @{ */
85 #define DICT_CLUSTERED \
86  1 /*!< clustered index; for other than \
87  auto-generated clustered indexes, \
88  also DICT_UNIQUE will be set */
89 #define DICT_UNIQUE 2 /*!< unique index */
90 #define DICT_IBUF 8 /*!< insert buffer tree */
91 #define DICT_CORRUPT \
92  16 /*!< bit to store the corrupted flag \
93  in SYS_INDEXES.TYPE */
94 #define DICT_FTS \
95  32 /* FTS index; can't be combined with the \
96  other flags */
97 #define DICT_SPATIAL \
98  64 /* SPATIAL index; can't be combined with the \
99  other flags */
100 #define DICT_VIRTUAL 128 /* Index on Virtual column */
101 
102 #define DICT_SDI \
103  256 /* Tablespace dictionary Index. Set only in \
104  in-memory index structure. */
105 #define DICT_MULTI_VALUE 512 /* Multi-value index */
106 
107 #define DICT_IT_BITS \
108  10 /*!< number of bits used for \
109  SYS_INDEXES.TYPE */
110 /* @} */
111 
112 #if 0 /* not implemented, retained for history */
113 /** Types for a table object */
114 #define DICT_TABLE_ORDINARY 1 /*!< ordinary table */
115 #define DICT_TABLE_CLUSTER_MEMBER 2
116 #define DICT_TABLE_CLUSTER \
117  3 /* this means that the table is \
118  really a cluster definition */
119 #endif
120 
121 /* Table and tablespace flags are generally not used for the Antelope file
122 format except for the low order bit, which is used differently depending on
123 where the flags are stored.
124 
125 ==================== Low order flags bit =========================
126  | REDUNDANT | COMPACT | COMPRESSED and DYNAMIC
127 SYS_TABLES.TYPE | 1 | 1 | 1
128 dict_table_t::flags | 0 | 1 | 1
129 FSP_SPACE_FLAGS | 0 | 0 | 1
130 fil_space_t::flags | 0 | 0 | 1
131 
132 Before the 5.1 plugin, SYS_TABLES.TYPE was always DICT_TABLE_ORDINARY (1)
133 and the tablespace flags field was always 0. In the 5.1 plugin, these fields
134 were repurposed to identify compressed and dynamic row formats.
135 
136 The following types and constants describe the flags found in dict_table_t
137 and SYS_TABLES.TYPE. Similar flags found in fil_space_t and FSP_SPACE_FLAGS
138 are described in fsp0fsp.h. */
139 
140 /* @{ */
141 /** dict_table_t::flags bit 0 is equal to 0 if the row format = Redundant */
142 #define DICT_TF_REDUNDANT 0 /*!< Redundant row format. */
143 /** dict_table_t::flags bit 0 is equal to 1 if the row format = Compact */
144 #define DICT_TF_COMPACT 1 /*!< Compact row format. */
145 
146 /** This bitmask is used in SYS_TABLES.N_COLS to set and test whether
147 the Compact page format is used, i.e ROW_FORMAT != REDUNDANT */
148 #define DICT_N_COLS_COMPACT 0x80000000UL
149 
150 /** Width of the COMPACT flag */
151 #define DICT_TF_WIDTH_COMPACT 1
153 /** Width of the ZIP_SSIZE flag */
154 #define DICT_TF_WIDTH_ZIP_SSIZE 4
156 /** Width of the ATOMIC_BLOBS flag. The ROW_FORMAT=REDUNDANT and
157 ROW_FORMAT=COMPACT broke up BLOB and TEXT fields, storing the first 768 bytes
158 in the clustered index. ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPRESSED
159 store the whole blob or text field off-page atomically.
160 Secondary indexes are created from this external data using row_ext_t
161 to cache the BLOB prefixes. */
162 #define DICT_TF_WIDTH_ATOMIC_BLOBS 1
163 
164 /** If a table is created with the MYSQL option DATA DIRECTORY and
165 innodb-file-per-table, an older engine will not be able to find that table.
166 This flag prevents older engines from attempting to open the table and
167 allows InnoDB to update_create_info() accordingly. */
168 #define DICT_TF_WIDTH_DATA_DIR 1
169 
170 /** Width of the SHARED tablespace flag.
171 It is used to identify tables that exist inside a shared general tablespace.
172 If a table is created with the TABLESPACE=tsname option, an older engine will
173 not be able to find that table. This flag prevents older engines from attempting
174 to open the table and allows InnoDB to quickly find the tablespace. */
175 
176 #define DICT_TF_WIDTH_SHARED_SPACE 1
177 
178 /** Width of all the currently known table flags */
179 #define DICT_TF_BITS \
180  (DICT_TF_WIDTH_COMPACT + DICT_TF_WIDTH_ZIP_SSIZE + \
181  DICT_TF_WIDTH_ATOMIC_BLOBS + DICT_TF_WIDTH_DATA_DIR + \
182  DICT_TF_WIDTH_SHARED_SPACE)
184 /** A mask of all the known/used bits in table flags */
185 #define DICT_TF_BIT_MASK (~(~0 << DICT_TF_BITS))
186 
187 /** Zero relative shift position of the COMPACT field */
188 #define DICT_TF_POS_COMPACT 0
189 /** Zero relative shift position of the ZIP_SSIZE field */
190 #define DICT_TF_POS_ZIP_SSIZE (DICT_TF_POS_COMPACT + DICT_TF_WIDTH_COMPACT)
191 /** Zero relative shift position of the ATOMIC_BLOBS field */
192 #define DICT_TF_POS_ATOMIC_BLOBS \
193  (DICT_TF_POS_ZIP_SSIZE + DICT_TF_WIDTH_ZIP_SSIZE)
194 /** Zero relative shift position of the DATA_DIR field */
195 #define DICT_TF_POS_DATA_DIR \
196  (DICT_TF_POS_ATOMIC_BLOBS + DICT_TF_WIDTH_ATOMIC_BLOBS)
197 /** Zero relative shift position of the SHARED TABLESPACE field */
198 #define DICT_TF_POS_SHARED_SPACE (DICT_TF_POS_DATA_DIR + DICT_TF_WIDTH_DATA_DIR)
199 /** Zero relative shift position of the start of the UNUSED bits */
200 #define DICT_TF_POS_UNUSED \
201  (DICT_TF_POS_SHARED_SPACE + DICT_TF_WIDTH_SHARED_SPACE)
203 /** Bit mask of the COMPACT field */
204 #define DICT_TF_MASK_COMPACT \
205  ((~(~0U << DICT_TF_WIDTH_COMPACT)) << DICT_TF_POS_COMPACT)
206 /** Bit mask of the ZIP_SSIZE field */
207 #define DICT_TF_MASK_ZIP_SSIZE \
208  ((~(~0U << DICT_TF_WIDTH_ZIP_SSIZE)) << DICT_TF_POS_ZIP_SSIZE)
209 /** Bit mask of the ATOMIC_BLOBS field */
210 #define DICT_TF_MASK_ATOMIC_BLOBS \
211  ((~(~0U << DICT_TF_WIDTH_ATOMIC_BLOBS)) << DICT_TF_POS_ATOMIC_BLOBS)
212 /** Bit mask of the DATA_DIR field */
213 #define DICT_TF_MASK_DATA_DIR \
214  ((~(~0U << DICT_TF_WIDTH_DATA_DIR)) << DICT_TF_POS_DATA_DIR)
215 /** Bit mask of the SHARED_SPACE field */
216 #define DICT_TF_MASK_SHARED_SPACE \
217  ((~(~0U << DICT_TF_WIDTH_SHARED_SPACE)) << DICT_TF_POS_SHARED_SPACE)
218 
219 /** Return the value of the COMPACT field */
220 #define DICT_TF_GET_COMPACT(flags) \
221  ((flags & DICT_TF_MASK_COMPACT) >> DICT_TF_POS_COMPACT)
222 /** Return the value of the ZIP_SSIZE field */
223 #define DICT_TF_GET_ZIP_SSIZE(flags) \
224  ((flags & DICT_TF_MASK_ZIP_SSIZE) >> DICT_TF_POS_ZIP_SSIZE)
225 /** Return the value of the ATOMIC_BLOBS field */
226 #define DICT_TF_HAS_ATOMIC_BLOBS(flags) \
227  ((flags & DICT_TF_MASK_ATOMIC_BLOBS) >> DICT_TF_POS_ATOMIC_BLOBS)
228 /** Return the value of the DATA_DIR field */
229 #define DICT_TF_HAS_DATA_DIR(flags) \
230  ((flags & DICT_TF_MASK_DATA_DIR) >> DICT_TF_POS_DATA_DIR)
231 /** Return the value of the SHARED_SPACE field */
232 #define DICT_TF_HAS_SHARED_SPACE(flags) \
233  ((flags & DICT_TF_MASK_SHARED_SPACE) >> DICT_TF_POS_SHARED_SPACE)
234 /** Return the contents of the UNUSED bits */
235 #define DICT_TF_GET_UNUSED(flags) (flags >> DICT_TF_POS_UNUSED)
236 /* @} */
237 
238 /** @brief Table Flags set number 2.
240 These flags will be stored in SYS_TABLES.MIX_LEN. All unused flags
241 will be written as 0. The column may contain garbage for tables
242 created with old versions of InnoDB that only implemented
243 ROW_FORMAT=REDUNDANT. InnoDB engines do not check these flags
244 for unknown bits in order to protect backward incompatibility. */
245 /* @{ */
246 /** Total number of bits in table->flags2. */
247 #define DICT_TF2_BITS 11
248 #define DICT_TF2_UNUSED_BIT_MASK (~0U << DICT_TF2_BITS)
249 #define DICT_TF2_BIT_MASK ~DICT_TF2_UNUSED_BIT_MASK
250 
251 /** TEMPORARY; TRUE for tables from CREATE TEMPORARY TABLE. */
252 #define DICT_TF2_TEMPORARY 1
254 /** The table has an internal defined DOC ID column */
255 #define DICT_TF2_FTS_HAS_DOC_ID 2
257 /** The table has an FTS index */
258 #define DICT_TF2_FTS 4
260 /** Need to add Doc ID column for FTS index build.
261 This is a transient bit for index build */
262 #define DICT_TF2_FTS_ADD_DOC_ID 8
263 
264 /** This bit is used during table creation to indicate that it will
265 use its own tablespace instead of the system tablespace. */
266 #define DICT_TF2_USE_FILE_PER_TABLE 16
267 
268 /** Set when we discard/detach the tablespace */
269 #define DICT_TF2_DISCARDED 32
271 /** Intrinsic table bit
272 Intrinsic table is table created internally by MySQL modules viz. Optimizer,
273 FTS, etc.... Intrinsic table has all the properties of the normal table except
274 it is not created by user and so not visible to end-user. */
275 #define DICT_TF2_INTRINSIC 128
276 
277 /** Encryption table bit for innodb_file-per-table only. */
278 #define DICT_TF2_ENCRYPTION_FILE_PER_TABLE 256
280 /** FTS AUX hidden table bit. */
281 #define DICT_TF2_AUX 512
283 /** Table is opened by resurrected trx during crash recovery. */
284 #define DICT_TF2_RESURRECT_PREPARED 1024
285 /* @} */
286 
287 #define DICT_TF2_FLAG_SET(table, flag) (table->flags2 |= (flag))
289 #define DICT_TF2_FLAG_IS_SET(table, flag) (table->flags2 & (flag))
290 
291 #define DICT_TF2_FLAG_UNSET(table, flag) (table->flags2 &= ~(flag))
292 
293 /** Tables could be chained together with Foreign key constraint. When
294 first load the parent table, we would load all of its descedents.
295 This could result in rescursive calls and out of stack error eventually.
296 DICT_FK_MAX_RECURSIVE_LOAD defines the maximum number of recursive loads,
297 when exceeded, the child table will not be loaded. It will be loaded when
298 the foreign constraint check needs to be run. */
299 #define DICT_FK_MAX_RECURSIVE_LOAD 20
300 
301 /** Similarly, when tables are chained together with foreign key constraints
302 with on cascading delete/update clause, delete from parent table could
303 result in recursive cascading calls. This defines the maximum number of
304 such cascading deletes/updates allowed. When exceeded, the delete from
305 parent table will fail, and user has to drop excessive foreign constraint
306 before proceeds. */
307 #define FK_MAX_CASCADE_DEL 15
308 
309 /** Adds a virtual column definition to a table.
310 @param[in,out] table table
311 @param[in] heap temporary memory heap, or NULL. It is
312  used to store name when we have not finished
313  adding all columns. When all columns are
314  added, the whole name will copy to memory from
315  table->heap
316 @param[in] name column name
317 @param[in] mtype main datatype
318 @param[in] prtype precise type
319 @param[in] len length
320 @param[in] pos position in a table
321 @param[in] num_base number of base columns
322 @return the virtual column definition */
324  const char *name, ulint mtype,
325  ulint prtype, ulint len, ulint pos,
326  ulint num_base);
327 
328 /** Adds a stored column definition to a table.
329 @param[in,out] table table
330 @param[in] num_base number of base columns. */
331 void dict_mem_table_add_s_col(dict_table_t *table, ulint num_base);
332 
333 /** Renames a column of a table in the data dictionary cache. */
334 void dict_mem_table_col_rename(dict_table_t *table, /*!< in/out: table */
335  ulint nth_col, /*!< in: column index */
336  const char *from, /*!< in: old column name */
337  const char *to, /*!< in: new column name */
338  bool is_virtual);
339 /*!< in: if this is a virtual column */
340 
341 /** This function poplulates a dict_index_t index memory structure with
342 supplied information.
343 @param[out] index index to be filled
344 @param[in] heap memory heap
345 @param[in] table_name table name
346 @param[in] index_name index name
347 @param[in] space space where the index tree is placed, the
348  clustered type ignored if the index is of the
349  clustered type
350 @param[in] type DICT_UNIQUE, DICT_CLUSTERED, ... ORed
351 @param[in] n_fields number of fields */
352 UNIV_INLINE
354  const char *table_name, const char *index_name,
355  ulint space, ulint type, ulint n_fields);
356 
357 /** Frees an index memory object. */
358 void dict_mem_index_free(dict_index_t *index); /*!< in: index */
359 /** Creates and initializes a foreign constraint memory object.
360  @return own: foreign constraint struct */
362 
363 /** Sets the foreign_table_name_lookup pointer based on the value of
364  lower_case_table_names. If that is 0 or 1, foreign_table_name_lookup
365  will point to foreign_table_name. If 2, then another string is
366  allocated from the heap and set to lower case. */
368  dict_foreign_t *foreign, /*!< in/out: foreign struct */
369  ibool do_alloc); /*!< in: is an alloc needed */
370 
371 /** Sets the referenced_table_name_lookup pointer based on the value of
372  lower_case_table_names. If that is 0 or 1, referenced_table_name_lookup
373  will point to referenced_table_name. If 2, then another string is
374  allocated from the heap and set to lower case. */
376  dict_foreign_t *foreign, /*!< in/out: foreign struct */
377  ibool do_alloc); /*!< in: is an alloc needed */
378 
379 /** Fills the dependent virtual columns in a set.
380 Reason for being dependent are
381 1) FK can be present on base column of virtual columns
382 2) FK can be present on column which is a part of virtual index
383 @param[in,out] foreign foreign key information. */
385 
386 /** Fill virtual columns set in each fk constraint present in the table.
387 @param[in,out] table innodb table object. */
389 
390 /** Free the vcol_set from all foreign key constraint on the table.
391 @param[in,out] table innodb table object. */
393 
394 /** Create a temporary tablename like "#sql-ibtid-inc" where
395  tid = the Table ID
396  inc = a randomly initialized number that is incremented for each file
397 The table ID is a 64 bit integer, can use up to 20 digits, and is
398 initialized at bootstrap. The second number is 32 bits, can use up to 10
399 digits, and is initialized at startup to a randomly distributed number.
400 It is hoped that the combination of these two numbers will provide a
401 reasonably unique temporary file name.
402 @param[in] heap A memory heap
403 @param[in] dbtab Table name in the form database/table name
404 @param[in] id Table id
405 @return A unique temporary tablename suitable for InnoDB use */
406 char *dict_mem_create_temporary_tablename(mem_heap_t *heap, const char *dbtab,
407  table_id_t id);
408 
409 /** Initialize dict memory variables */
410 void dict_mem_init(void);
411 
412 /** SQL identifier name wrapper for pretty-printing */
413 class id_name_t {
414  public:
415  /** Default constructor */
416  id_name_t() : m_name() {}
417  /** Constructor
418  @param[in] name identifier to assign */
419  explicit id_name_t(const char *name) : m_name(name) {}
421  /** Assignment operator
422  @param[in] name identifier to assign */
423  id_name_t &operator=(const char *name) {
424  m_name = name;
425  return (*this);
426  }
428  /** Implicit type conversion
429  @return the name */
430  operator const char *() const { return (m_name); }
431 
432  /** Explicit type conversion
433  @return the name */
434  const char *operator()() const { return (m_name); }
435 
436  private:
437  /** The name in internal representation */
438  const char *m_name;
439 };
440 
441 /** Table name wrapper for pretty-printing */
442 struct table_name_t {
443  /** The name in internal representation */
444  char *m_name;
445 };
447 /** Data structure for default value of a column in a table */
449  /** Pointer to the column itself */
450  dict_col_t *col;
451  /** Default value in bytes */
453  /** Length of default value */
454  size_t len;
455 
456  bool operator==(const dict_col_default_t &other);
457  bool operator!=(const dict_col_default_t &other);
458 };
459 
460 /** Data structure for a column in a table */
461 struct dict_col_t {
462  /*----------------------*/
463  /** The following are copied from dtype_t,
464  so that all bit-fields can be packed tightly. */
465  /* @{ */
466 
467  /** Default value when this column was added instantly.
468  If this is not a instantly added column then this is nullptr. */
469  dict_col_default_t *instant_default;
470 
471  unsigned prtype : 32; /*!< precise type; MySQL data
472  type, charset code, flags to
473  indicate nullability,
474  signedness, whether this is a
475  binary string, whether this is
476  a true VARCHAR where MySQL
477  uses 2 bytes to store the length */
478  unsigned mtype : 8; /*!< main data type */
479 
480  /* the remaining fields do not affect alphabetical ordering: */
481 
482  unsigned len : 16; /*!< length; for MySQL data this
483  is field->pack_length(),
484  except that for a >= 5.0.3
485  type true VARCHAR this is the
486  maximum byte length of the
487  string data (in addition to
488  the string, MySQL uses 1 or 2
489  bytes to store the string length) */
490 
491  unsigned mbminmaxlen : 5; /*!< minimum and maximum length of a
492  character, in bytes;
493  DATA_MBMINMAXLEN(mbminlen,mbmaxlen);
494  mbminlen=DATA_MBMINLEN(mbminmaxlen);
495  mbmaxlen=DATA_MBMINLEN(mbminmaxlen) */
496  /*----------------------*/
497  /* End of definitions copied from dtype_t */
498  /* @} */
499 
500  unsigned ind : 10; /*!< table column position
501  (starting from 0) */
502  unsigned ord_part : 1; /*!< nonzero if this column
503  appears in the ordering fields
504  of an index */
505  unsigned max_prefix : 12; /*!< maximum index prefix length on
506  this column. Our current max limit is
507  3072 (REC_VERSION_56_MAX_INDEX_COL_LEN)
508  bytes. */
510  /** Returns the minimum size of the column.
511  @return minimum size */
512  ulint get_min_size() const {
513  return (dtype_get_min_size_low(mtype, prtype, len, mbminmaxlen));
514  }
515 
516  /** Returns the maximum size of the column.
517  @return maximum size */
518  ulint get_max_size() const { return (dtype_get_max_size_low(mtype, len)); }
519 
520  /** Check if a column is a virtual column
521  @return true if it is a virtual column, false otherwise */
522  bool is_virtual() const { return (prtype & DATA_VIRTUAL); }
523 
524  /** Check if a column is a multi-value virtual column
525  @return true if it is a multi-value virtual column, false otherwise */
526  bool is_multi_value() const { return ((prtype & DATA_MULTI_VALUE) != 0); }
527 
528  /** Check if a column is nullable
529  @return true if it is nullable, otherwise false */
530  bool is_nullable() const { return ((prtype & DATA_NOT_NULL) == 0); }
531 
532  /** Gets the column data type.
533  @param[out] type data type */
534  void copy_type(dtype_t *type) const {
535  ut_ad(type != nullptr);
536 
537  type->mtype = mtype;
538  type->prtype = prtype;
539  type->len = len;
540  type->mbminmaxlen = mbminmaxlen;
541  }
542 
543  /** Gets the minimum number of bytes per character.
544  @return minimum multi-byte char size, in bytes */
545  ulint get_mbminlen() const { return (DATA_MBMINLEN(mbminmaxlen)); }
546 
547  /** Gets the maximum number of bytes per character.
548  @return maximum multi-byte char size, in bytes */
549  ulint get_mbmaxlen() const { return (DATA_MBMAXLEN(mbminmaxlen)); }
550 
551  /** Sets the minimum and maximum number of bytes per character.
552  @param[in] mbminlen minimum multi byte character size, in bytes
553  @param[in] mbmaxlen mAXimum multi-byte character size, in bytes */
554  void set_mbminmaxlen(ulint mbminlen, ulint mbmaxlen) {
555  ut_ad(mbminlen < DATA_MBMAX);
556  ut_ad(mbmaxlen < DATA_MBMAX);
557  ut_ad(mbminlen <= mbmaxlen);
559  mbminmaxlen = DATA_MBMINMAXLEN(mbminlen, mbmaxlen);
560  }
561 
562  /** Returns the size of a fixed size column, 0 if not a fixed size column.
563  @param[in] comp nonzero=ROW_FORMAT=COMPACT
564  @return fixed size, or 0 */
565  ulint get_fixed_size(ulint comp) const {
566  return (dtype_get_fixed_size_low(mtype, prtype, len, mbminmaxlen, comp));
567  }
568 
569  /** Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column.
570  For fixed length types it is the fixed length of the type, otherwise 0.
571  @param[in] comp nonzero=ROW_FORMAT=COMPACT
572  @return SQL null storage size in ROW_FORMAT=REDUNDANT */
573  ulint get_null_size(ulint comp) const { return (get_fixed_size(comp)); }
574 
575  /** Check whether the col is used in spatial index or regular index.
576  @return spatial status */
577  spatial_status_t get_spatial_status() const {
578  spatial_status_t spatial_status = SPATIAL_NONE;
579 
580  /* Column is not a part of any index. */
581  if (!ord_part) {
582  return (spatial_status);
583  }
584 
585  if (DATA_GEOMETRY_MTYPE(mtype)) {
586  if (max_prefix == 0) {
587  spatial_status = SPATIAL_ONLY;
588  } else {
589  /* Any regular index on a geometry column
590  should have a prefix. */
591  spatial_status = SPATIAL_MIXED;
592  }
593  }
594 
595  return (spatial_status);
596  }
597 
598  /** Set default value
599  @param[in] value Default value
600  @param[in] length Default value length
601  @param[in,out] heap Heap to allocate memory */
602  void set_default(const byte *value, size_t length, mem_heap_t *heap);
603 
604 #ifdef UNIV_DEBUG
605  /** Assert that a column and a data type match.
606  param[in] type data type
607  @return true */
608  bool assert_equal(const dtype_t *type) const {
609  ut_ad(type);
610 
611  ut_ad(mtype == type->mtype);
612  ut_ad(prtype == type->prtype);
613  // ut_ad(col->len == type->len);
614 #ifndef UNIV_HOTBACKUP
615  ut_ad(mbminmaxlen == type->mbminmaxlen);
616 #endif /* !UNIV_HOTBACKUP */
617 
618  return true;
619  }
620 #endif /* UNIV_DEBUG */
621 };
622 
623 /** Index information put in a list of virtual column structure. Index
624 id and virtual column position in the index will be logged.
625 There can be multiple entries for a given index, with a different position. */
626 struct dict_v_idx_t {
627  /** active index on the column */
628  dict_index_t *index;
629 
630  /** position in this index */
631  ulint nth_field;
632 };
633 
634 /** Index list to put in dict_v_col_t */
635 typedef std::list<dict_v_idx_t, ut_allocator<dict_v_idx_t>> dict_v_idx_list;
636 
637 /** Data structure for a virtual column in a table */
638 struct dict_v_col_t {
639  /** column structure */
640  dict_col_t m_col;
641 
642  /** array of base column ptr */
643  dict_col_t **base_col;
645  /** number of base column */
646  ulint num_base;
648  /** column pos in table */
649  ulint v_pos;
651  /** Virtual index list, and column position in the index,
652  the allocated memory is not from table->heap, nor it is
653  tracked by dict_sys->size */
654  dict_v_idx_list *v_indexes;
655 };
656 
657 /** Data structure for newly added virtual column in a table */
659  /** number of new virtual column */
660  ulint n_v_col;
661 
662  /** column structures */
663  const dict_v_col_t *v_col;
665  /** new col names */
666  const char **v_col_name;
667 };
668 
669 /** Data structure for a stored column in a table. */
670 struct dict_s_col_t {
671  /** Stored column ptr */
672  dict_col_t *m_col;
673  /** array of base col ptr */
674  dict_col_t **base_col;
675  /** number of base columns */
676  ulint num_base;
677  /** column pos in table */
678  ulint s_pos;
679 };
681 /** list to put stored column for dict_table_t */
682 typedef std::list<dict_s_col_t, ut_allocator<dict_s_col_t>> dict_s_col_list;
683 
684 /** @brief DICT_ANTELOPE_MAX_INDEX_COL_LEN is measured in bytes and
685 is the maximum indexed column length (or indexed prefix length) in
686 ROW_FORMAT=REDUNDANT and ROW_FORMAT=COMPACT. Also, in any format,
687 any fixed-length field that is longer than this will be encoded as
688 a variable-length field.
689 
690 It is set to 3*256, so that one can create a column prefix index on
691 256 characters of a TEXT or VARCHAR column also in the UTF-8
692 charset. In that charset, a character may take at most 3 bytes. This
693 constant MUST NOT BE CHANGED, or the compatibility of InnoDB data
694 files would be at risk! */
695 #define DICT_ANTELOPE_MAX_INDEX_COL_LEN REC_ANTELOPE_MAX_INDEX_COL_LEN
696 
697 /** Find out maximum indexed column length by its table format.
698 For ROW_FORMAT=REDUNDANT and ROW_FORMAT=COMPACT, the maximum
699 field length is REC_ANTELOPE_MAX_INDEX_COL_LEN - 1 (767). For
700 ROW_FORMAT=COMPRESSED and ROW_FORMAT=DYNAMIC, the length could
701 be REC_VERSION_56_MAX_INDEX_COL_LEN (3072) bytes */
702 #define DICT_MAX_FIELD_LEN_BY_FORMAT(table) \
703  (dict_table_has_atomic_blobs(table) ? REC_VERSION_56_MAX_INDEX_COL_LEN \
704  : REC_ANTELOPE_MAX_INDEX_COL_LEN - 1)
705 
706 #define DICT_MAX_FIELD_LEN_BY_FORMAT_FLAG(flags) \
707  (DICT_TF_HAS_ATOMIC_BLOBS(flags) ? REC_VERSION_56_MAX_INDEX_COL_LEN \
708  : REC_ANTELOPE_MAX_INDEX_COL_LEN - 1)
709 
710 /** Defines the maximum fixed length column size */
711 #define DICT_MAX_FIXED_COL_LEN DICT_ANTELOPE_MAX_INDEX_COL_LEN
712 
713 /** Data structure for a field in an index */
714 struct dict_field_t {
715  dict_field_t() : col(nullptr), prefix_len(0), fixed_len(0), is_ascending(0) {}
716 
717  dict_col_t *col; /*!< pointer to the table column */
718  id_name_t name; /*!< name of the column */
719  unsigned prefix_len : 12; /*!< 0 or the length of the column
720  prefix in bytes in a MySQL index of
721  type, e.g., INDEX (textcol(25));
722  must be smaller than
723  DICT_MAX_FIELD_LEN_BY_FORMAT;
724  NOTE that in the UTF-8 charset, MySQL
725  sets this to (mbmaxlen * the prefix len)
726  in UTF-8 chars */
727  unsigned fixed_len : 10; /*!< 0 or the fixed length of the
728  column if smaller than
729  DICT_ANTELOPE_MAX_INDEX_COL_LEN */
730  unsigned is_ascending : 1; /*!< 0=DESC, 1=ASC */
731 };
732 
733 /** PADDING HEURISTIC BASED ON LINEAR INCREASE OF PADDING TO AVOID
734  COMPRESSION FAILURES
735  (Note: this is relevant only for compressed indexes)
736  GOAL: Avoid compression failures by maintaining information about the
737  compressibility of data. If data is not very compressible then leave
738  some extra space 'padding' in the uncompressed page making it more
739  likely that compression of less than fully packed uncompressed page will
740  succeed.
741 
742  This padding heuristic works by increasing the pad linearly until the
743  desired failure rate is reached. A "round" is a fixed number of
744  compression operations.
745  After each round, the compression failure rate for that round is
746  computed. If the failure rate is too high, then padding is incremented
747  by a fixed value, otherwise it's left intact.
748  If the compression failure is lower than the desired rate for a fixed
749  number of consecutive rounds, then the padding is decreased by a fixed
750  value. This is done to prevent overshooting the padding value,
751  and to accommodate the possible change in data compressibility. */
752 
753 /** Number of zip ops in one round. */
754 #define ZIP_PAD_ROUND_LEN (128)
755 
756 /** Number of successful rounds after which the padding is decreased */
757 #define ZIP_PAD_SUCCESSFUL_ROUND_LIMIT (5)
759 /** Amount by which padding is increased. */
760 #define ZIP_PAD_INCR (128)
762 /** Percentage of compression failures that are allowed in a single
763 round */
765 
766 /** Maximum percentage of a page that can be allowed as a pad to avoid
767 compression failures */
768 extern ulong zip_pad_max;
769 
770 /** Data structure to hold information about about how much space in
771 an uncompressed page should be left as padding to avoid compression
772 failures. This estimate is based on a self-adapting heuristic. */
773 struct zip_pad_info_t {
774  SysMutex *mutex; /*!< mutex protecting the info */
775  ulint pad; /*!< number of bytes used as pad */
776  ulint success; /*!< successful compression ops during
777  current round */
778  ulint failure; /*!< failed compression ops during
779  current round */
780  ulint n_rounds; /*!< number of currently successful
781  rounds */
782 #ifndef UNIV_HOTBACKUP
783  volatile os_once::state_t mutex_created;
784  /*!< Creation state of mutex member */
785 #endif /* !UNIV_HOTBACKUP */
786 };
788 /** If key is fixed length key then cache the record offsets on first
789 computation. This will help save computation cycle that generate same
790 redundant data. */
791 class rec_cache_t {
792  public:
793  /** Constructor */
794  rec_cache_t()
795  : rec_size(),
796  offsets(),
797  sz_of_offsets(),
798  fixed_len_key(),
799  offsets_cached(),
800  key_has_null_cols() {
801  /* Do Nothing. */
802  }
803 
804  public:
805  /** Record size. (for fixed length key record size is constant) */
806  ulint rec_size;
807 
808  /** Holds reference to cached offsets for record. */
809  ulint *offsets;
811  /** Size of offset array */
812  uint32_t sz_of_offsets;
814  /** If true, then key is fixed length key. */
815  bool fixed_len_key;
817  /** If true, then offset has been cached for re-use. */
818  bool offsets_cached;
820  /** If true, then key part can have columns that can take
821  NULL values. */
822  bool key_has_null_cols;
823 };
824 
825 /** Cache position of last inserted or selected record by caching record
826 and holding reference to the block where record resides.
827 Note: We don't commit mtr and hold it beyond a transaction lifetime as this is
828 a special case (intrinsic table) that are not shared accross connection. */
829 class last_ops_cur_t {
830  public:
831  /** Constructor */
832  last_ops_cur_t() : rec(), block(), mtr(), disable_caching(), invalid() {
833  /* Do Nothing. */
834  }
835 
836  /* Commit mtr and re-initialize cache record and block to NULL. */
837  void release() {
838  if (mtr.is_active()) {
839  mtr_commit(&mtr);
840  }
841  rec = nullptr;
842  block = nullptr;
843  invalid = false;
844  }
845 
846  public:
847  /** last inserted/selected record. */
848  rec_t *rec;
849 
850  /** block where record reside. */
851  buf_block_t *block;
853  /** active mtr that will be re-used for next insert/select. */
854  mtr_t mtr;
856  /** disable caching. (disabled when table involves blob/text.) */
857  bool disable_caching;
859  /** If index structure is undergoing structural change viz.
860  split then invalidate the cached position as it would be no more
861  remain valid. Will be re-cached on post-split insert. */
862  bool invalid;
863 };
864 
865 /** "GEN_CLUST_INDEX" is the name reserved for InnoDB default
866 system clustered index when there is no primary key. */
867 const char innobase_index_reserve_name[] = "GEN_CLUST_INDEX";
868 
869 namespace dd {
870 class Spatial_reference_system;
871 }
872 
873 /** Data structure for an index. Most fields will be
874 initialized to 0, NULL or FALSE in dict_mem_index_create(). */
875 struct dict_index_t {
876  space_index_t id; /*!< id of the index */
877  mem_heap_t *heap; /*!< memory heap */
878  id_name_t name; /*!< index name */
879  const char *table_name; /*!< table name */
880  dict_table_t *table; /*!< back pointer to table */
881  unsigned space : 32;
882  /*!< space where the index tree is placed */
883  unsigned page : 32; /*!< index tree root page number */
884  unsigned merge_threshold : 6;
885  /*!< In the pessimistic delete, if the page
886  data size drops below this limit in percent,
887  merging it to a neighbor is tried */
888 #define DICT_INDEX_MERGE_THRESHOLD_DEFAULT 50
889  unsigned type : DICT_IT_BITS;
890  /*!< index type (DICT_CLUSTERED, DICT_UNIQUE,
891  DICT_IBUF, DICT_CORRUPT) */
892 #define MAX_KEY_LENGTH_BITS 12
893  unsigned trx_id_offset : MAX_KEY_LENGTH_BITS;
894  /*!< position of the trx id column
895  in a clustered index record, if the fields
896  before it are known to be of a fixed size,
897  0 otherwise */
898 #if (1 << MAX_KEY_LENGTH_BITS) < MAX_KEY_LENGTH
899 #error(1<<MAX_KEY_LENGTH_BITS) < MAX_KEY_LENGTH
900 #endif
901  unsigned n_user_defined_cols : 10;
902  /*!< number of columns the user defined to
903  be in the index: in the internal
904  representation we add more columns */
905  unsigned allow_duplicates : 1;
906  /*!< if true, allow duplicate values
907  even if index is created with unique
908  constraint */
909  unsigned nulls_equal : 1;
910  /*!< if true, SQL NULL == SQL NULL */
911  unsigned disable_ahi : 1;
912  /*!< if true, then disable AHI. Currently
913  limited to intrinsic temporary table and SDI
914  table as index id is not unique for such table
915  which is one of the validation criterion for
916  ahi. */
917  unsigned n_uniq : 10; /*!< number of fields from the beginning
918  which are enough to determine an index
919  entry uniquely */
920  unsigned n_def : 10; /*!< number of fields defined so far */
921  unsigned n_fields : 10; /*!< number of fields in the index */
922  unsigned n_nullable : 10; /*!< number of nullable fields */
923  unsigned n_instant_nullable : 10;
924  /*!< number of nullable fields before first
925  instant ADD COLUMN applied to this table.
926  This is valid only when has_instant_cols() is true */
927  unsigned cached : 1; /*!< TRUE if the index object is in the
928  dictionary cache */
929  unsigned to_be_dropped : 1;
930  /*!< TRUE if the index is to be dropped;
931  protected by dict_operation_lock */
932  unsigned online_status : 2;
933  /*!< enum online_index_status.
934  Transitions from ONLINE_INDEX_COMPLETE (to
935  ONLINE_INDEX_CREATION) are protected
936  by dict_operation_lock and
937  dict_sys->mutex. Other changes are
938  protected by index->lock. */
939  unsigned uncommitted : 1;
940  /*!< a flag that is set for secondary indexes
941  that have not been committed to the
942  data dictionary yet */
943  unsigned instant_cols : 1;
944  /*!< TRUE if the index is clustered index and it has some
945  instant columns */
946  uint32_t srid; /* spatial reference id */
947  bool srid_is_valid;
948  /* says whether SRID is valid - it cane be
949  undefined */
950  std::unique_ptr<dd::Spatial_reference_system> rtr_srs;
951  /*!< Cached spatial reference system dictionary
952  entry used by R-tree indexes. */
953 
954 #ifdef UNIV_DEBUG
955  uint32_t magic_n; /*!< magic number */
956 /** Value of dict_index_t::magic_n */
957 #define DICT_INDEX_MAGIC_N 76789786
958 #endif
959  dict_field_t *fields; /*!< array of field descriptions */
960 #ifndef UNIV_HOTBACKUP
961  st_mysql_ftparser *parser; /*!< fulltext parser plugin */
962  bool is_ngram;
963  /*!< true if it's ngram parser */
964  bool has_new_v_col;
965  /*!< whether it has a newly added virtual
966  column in ALTER */
967  bool hidden; /*!< if the index is an hidden index */
968 #endif /* !UNIV_HOTBACKUP */
970  indexes; /*!< list of indexes of the table */
971  btr_search_t *search_info;
972  /*!< info used in optimistic searches */
973 #ifndef UNIV_HOTBACKUP
974  row_log_t *online_log;
975  /*!< the log of modifications
976  during online index creation;
977  valid when online_status is
978  ONLINE_INDEX_CREATION */
979  /*----------------------*/
980  /** Statistics for query optimization */
981  /* @{ */
982  ib_uint64_t *stat_n_diff_key_vals;
983  /*!< approximate number of different
984  key values for this index, for each
985  n-column prefix where 1 <= n <=
986  dict_get_n_unique(index) (the array is
987  indexed from 0 to n_uniq-1); we
988  periodically calculate new
989  estimates */
990  ib_uint64_t *stat_n_sample_sizes;
991  /*!< number of pages that were sampled
992  to calculate each of stat_n_diff_key_vals[],
993  e.g. stat_n_sample_sizes[3] pages were sampled
994  to get the number stat_n_diff_key_vals[3]. */
995  ib_uint64_t *stat_n_non_null_key_vals;
996  /* approximate number of non-null key values
997  for this index, for each column where
998  1 <= n <= dict_get_n_unique(index) (the array
999  is indexed from 0 to n_uniq-1); This
1000  is used when innodb_stats_method is
1001  "nulls_ignored". */
1002  ulint stat_index_size;
1003  /*!< approximate index size in
1004  database pages */
1005 #endif /* !UNIV_HOTBACKUP */
1006  ulint stat_n_leaf_pages;
1007  /*!< approximate number of leaf pages in the
1008  index tree */
1009  /* @} */
1010  last_ops_cur_t *last_ins_cur;
1011  /*!< cache the last insert position.
1012  Currently limited to auto-generated
1013  clustered index on intrinsic table only. */
1014  last_ops_cur_t *last_sel_cur;
1015  /*!< cache the last selected position
1016  Currently limited to intrinsic table only. */
1017  rec_cache_t rec_cache;
1018  /*!< cache the field that needs to be
1019  re-computed on each insert.
1020  Limited to intrinsic table as this is common
1021  share and can't be used without protection
1022  if table is accessible to multiple-threads. */
1023  rtr_ssn_t rtr_ssn; /*!< Node sequence number for RTree */
1024  rtr_info_track_t *rtr_track; /*!< tracking all R-Tree search cursors */
1025  trx_id_t trx_id; /*!< id of the transaction that created this
1026  index, or 0 if the index existed
1027  when InnoDB was started up */
1028  zip_pad_info_t zip_pad; /*!< Information about state of
1029  compression failures and successes */
1030  rw_lock_t lock; /*!< read-write lock protecting the
1031  upper levels of the index tree */
1032  bool fill_dd; /*!< Flag whether need to fill dd tables
1033  when it's a fulltext index. */
1035  /** Determine if the index has been committed to the
1036  data dictionary.
1037  @return whether the index definition has been committed */
1038  bool is_committed() const {
1039  ut_ad(!uncommitted || !(type & DICT_CLUSTERED));
1040  return (UNIV_LIKELY(!uncommitted));
1041  }
1043  /** Flag an index committed or uncommitted.
1044  @param[in] committed whether the index is committed */
1045  void set_committed(bool committed) {
1046  ut_ad(!to_be_dropped);
1047  ut_ad(committed || !(type & DICT_CLUSTERED));
1048  uncommitted = !committed;
1049  }
1050 
1051  /** Get the next index.
1052  @return next index
1053  @retval NULL if this was the last index */
1054  const dict_index_t *next() const {
1055  const dict_index_t *next = UT_LIST_GET_NEXT(indexes, this);
1056  ut_ad(magic_n == DICT_INDEX_MAGIC_N);
1057  return (next);
1058  }
1059  /** Get the next index.
1060  @return next index
1061  @retval NULL if this was the last index */
1062  dict_index_t *next() {
1063  return (const_cast<dict_index_t *>(
1064  const_cast<const dict_index_t *>(this)->next()));
1065  }
1067  /** Check whether the index is corrupted.
1068  @return true if index is corrupted, otherwise false */
1069  bool is_corrupted() const {
1070  ut_ad(magic_n == DICT_INDEX_MAGIC_N);
1071 
1072  return (type & DICT_CORRUPT);
1073  }
1074 
1075  /* Check whether the index is the clustered index
1076  @return nonzero for clustered index, zero for other indexes */
1077 
1078  bool is_clustered() const {
1079  ut_ad(magic_n == DICT_INDEX_MAGIC_N);
1080 
1081  return (type & DICT_CLUSTERED);
1082  }
1083 
1084  /** Check whether the index is the multi-value index
1085  @return nonzero for multi-value index, zero for other indexes */
1086  bool is_multi_value() const {
1087  ut_ad(magic_n == DICT_INDEX_MAGIC_N);
1088 
1089  return (type & DICT_MULTI_VALUE);
1090  }
1091 
1092  /** Returns the minimum data size of an index record.
1093  @return minimum data size in bytes */
1094  ulint get_min_size() const {
1095  ulint size = 0;
1096 
1097  for (unsigned i = 0; i < n_fields; i++) {
1098  size += get_col(i)->get_min_size();
1099  }
1100 
1101  return (size);
1102  }
1103 
1104  /** Check whether index can be used by transaction
1105  @param[in] trx transaction*/
1106  bool is_usable(const trx_t *trx) const;
1107 
1108  /** Check whether index has any instantly added columns
1109  @return true if this is instant affected, otherwise false */
1110  bool has_instant_cols() const { return (instant_cols); }
1111 
1112  /** Returns the number of nullable fields before specified
1113  nth field
1114  @param[in] nth nth field to check */
1115  uint32_t get_n_nullable_before(uint32_t nth) const {
1116  uint32_t nullable = n_nullable;
1117 
1118  ut_ad(nth <= n_fields);
1120  for (uint32_t i = nth; i < n_fields; ++i) {
1121  if (get_field(i)->col->is_nullable()) {
1122  --nullable;
1123  }
1124  }
1125 
1126  return (nullable);
1127  }
1128 
1129  /** Returns the number of fields before first instant ADD COLUMN */
1130  uint32_t get_instant_fields() const;
1131 
1132  /** Adds a field definition to an index. NOTE: does not take a copy
1133  of the column name if the field is a column. The memory occupied
1134  by the column name may be released only after publishing the index.
1135  @param[in] name_arg column name
1136  @param[in] prefix_len 0 or the column prefix length in a MySQL index
1137  like INDEX (textcol(25))
1138  @param[in] is_ascending true=ASC, false=DESC */
1139  void add_field(const char *name_arg, ulint prefix_len, bool is_ascending) {
1140  dict_field_t *field;
1141 
1142  ut_ad(magic_n == DICT_INDEX_MAGIC_N);
1144  n_def++;
1145 
1146  field = get_field(n_def - 1);
1147 
1148  field->name = name_arg;
1149  field->prefix_len = (unsigned int)prefix_len;
1150  field->is_ascending = is_ascending;
1151  }
1152 
1153  /** Gets the nth field of an index.
1154  @param[in] pos position of field
1155  @return pointer to field object */
1156  dict_field_t *get_field(ulint pos) const {
1157  ut_ad(pos < n_def);
1158  ut_ad(magic_n == DICT_INDEX_MAGIC_N);
1159 
1160  return (fields + pos);
1161  }
1162 
1163  /** Gets pointer to the nth column in an index.
1164  @param[in] pos position of the field
1165  @return column */
1166  const dict_col_t *get_col(ulint pos) const { return (get_field(pos)->col); }
1167 
1168  /** Gets the column number the nth field in an index.
1169  @param[in] pos position of the field
1170  @return column number */
1171  ulint get_col_no(ulint pos) const;
1172 
1173  /** Returns the position of a system column in an index.
1174  @param[in] type DATA_ROW_ID, ...
1175  @return position, ULINT_UNDEFINED if not contained */
1176  ulint get_sys_col_pos(ulint type) const;
1177 
1178  /** Looks for column n in an index.
1179  @param[in] n column number
1180  @param[in] inc_prefix true=consider column prefixes too
1181  @param[in] is_virtual true==virtual column
1182  @return position in internal representation of the index;
1183  ULINT_UNDEFINED if not contained */
1184  ulint get_col_pos(ulint n, bool inc_prefix = false,
1185  bool is_virtual = false) const;
1186 
1187  /** Get the default value of nth field and its length if exists.
1188  If not exists, both the return value is nullptr and length is 0.
1189  @param[in] nth nth field to get
1190  @param[in,out] length length of the default value
1191  @return the default value data of nth field */
1192  const byte *get_nth_default(ulint nth, ulint *length) const {
1193  ut_ad(nth < n_fields);
1194  ut_ad(get_instant_fields() <= nth);
1195  const dict_col_t *col = get_col(nth);
1196  if (col->instant_default == nullptr) {
1197  *length = 0;
1198  return (nullptr);
1199  }
1200 
1201  *length = col->instant_default->len;
1202  ut_ad(*length == 0 || *length == UNIV_SQL_NULL ||
1203  col->instant_default->value != nullptr);
1204  return (col->instant_default->value);
1205  }
1206 
1207  /** Sets srid and srid_is_valid values
1208  @param[in] srid_value value of SRID, may be garbage
1209  if srid_is_valid_value = false
1210  @param[in] srid_is_valid_value value of srid_is_valid */
1211  void fill_srid_value(uint32_t srid_value, bool srid_is_valid_value) {
1212  srid_is_valid = srid_is_valid_value;
1213  srid = srid_value;
1214  }
1216  /** Check if the underlying table is compressed.
1217  @return true if compressed, false otherwise. */
1218  bool is_compressed() const;
1219 
1220  /** Check if a multi-value index is built on specified multi-value
1221  virtual column. Please note that there could be only one multi-value
1222  virtual column on the multi-value index, but not necessary the first
1223  field of the index.
1224  @param[in] mv_col multi-value virtual column
1225  @return non-zero means the column is on the index and this is the
1226  nth position of the column, zero means it's not on the index */
1227  uint32_t has_multi_value_col(const dict_v_col_t *mv_col) const {
1228  ut_ad(is_multi_value());
1229  for (uint32_t i = 0; i < n_fields; ++i) {
1230  const dict_col_t *col = get_col(i);
1231  if (mv_col->m_col.ind == col->ind) {
1232  return (i + 1);
1233  }
1234 
1235  /* Only one multi-value field, if not match then no match. */
1236  if (col->is_multi_value()) {
1237  break;
1238  }
1239  }
1240 
1241  return (0);
1242  }
1243 
1244  public:
1245  /** Get the page size of the tablespace to which this index belongs.
1246  @return the page size. */
1247  page_size_t get_page_size() const;
1248 
1249  /** Get the space id of the tablespace to which this index belongs.
1250  @return the space id. */
1251  space_id_t space_id() const { return space; }
1252 };
1253 
1254 /** The status of online index creation */
1256  /** the index is complete and ready for access */
1258  /** the index is being created, online
1259  (allowing concurrent modifications) */
1261  /** secondary index creation was aborted and the index
1262  should be dropped as soon as index->table->n_ref_count reaches 0,
1263  or online table rebuild was aborted and the clustered index
1264  of the original table should soon be restored to
1265  ONLINE_INDEX_COMPLETE */
1267  /** the online index creation was aborted, the index was
1268  dropped from the data dictionary and the tablespace, and it
1269  should be dropped from the data dictionary cache as soon as
1270  index->table->n_ref_count reaches 0. */
1272 };
1273 
1274 /** Set to store the virtual columns which are affected by Foreign
1275 key constraint. */
1276 typedef std::set<dict_v_col_t *, std::less<dict_v_col_t *>,
1278  dict_vcol_set;
1279 
1280 /** Data structure for a foreign key constraint; an example:
1281 FOREIGN KEY (A, B) REFERENCES TABLE2 (C, D). Most fields will be
1282 initialized to 0, NULL or FALSE in dict_mem_foreign_create(). */
1283 struct dict_foreign_t {
1284  mem_heap_t *heap; /*!< this object is allocated from
1285  this memory heap */
1286  char *id; /*!< id of the constraint as a
1287  null-terminated string */
1288  unsigned n_fields : 10; /*!< number of indexes' first fields
1289  for which the foreign key
1290  constraint is defined: we allow the
1291  indexes to contain more fields than
1292  mentioned in the constraint, as long
1293  as the first fields are as mentioned */
1294  unsigned type : 6; /*!< 0 or DICT_FOREIGN_ON_DELETE_CASCADE
1295  or DICT_FOREIGN_ON_DELETE_SET_NULL */
1296  char *foreign_table_name; /*!< foreign table name */
1297  char *foreign_table_name_lookup;
1298  /*!< foreign table name used for dict lookup */
1299  dict_table_t *foreign_table; /*!< table where the foreign key is */
1300  const char **foreign_col_names; /*!< names of the columns in the
1301  foreign key */
1302  char *referenced_table_name; /*!< referenced table name */
1303  char *referenced_table_name_lookup;
1304  /*!< referenced table name for dict lookup*/
1305  dict_table_t *referenced_table; /*!< table where the referenced key
1306  is */
1307  const char **referenced_col_names; /*!< names of the referenced
1308  columns in the referenced table */
1309  dict_index_t *foreign_index; /*!< foreign index; we require that
1310  both tables contain explicitly defined
1311  indexes for the constraint: InnoDB
1312  does not generate new indexes
1313  implicitly */
1314  dict_index_t *referenced_index; /*!< referenced index */
1315 
1316  dict_vcol_set *v_cols; /*!< set of virtual columns affected
1317  by foreign key constraint. */
1318 };
1319 
1320 std::ostream &operator<<(std::ostream &out, const dict_foreign_t &foreign);
1321 
1322 struct dict_foreign_print {
1323  dict_foreign_print(std::ostream &out) : m_out(out) {}
1324 
1325  void operator()(const dict_foreign_t *foreign) { m_out << *foreign; }
1327  private:
1328  std::ostream &m_out;
1329 };
1330 
1331 /** Compare two dict_foreign_t objects using their ids. Used in the ordering
1332 of dict_table_t::foreign_set and dict_table_t::referenced_set. It returns
1333 true if the first argument is considered to go before the second in the
1334 strict weak ordering it defines, and false otherwise. */
1335 struct dict_foreign_compare {
1336  bool operator()(const dict_foreign_t *lhs, const dict_foreign_t *rhs) const {
1337  return (ut_strcmp(lhs->id, rhs->id) < 0);
1338  }
1339 };
1341 /** A function object to find a foreign key with the given index as the
1342 referenced index. Return the foreign key with matching criteria or NULL */
1343 struct dict_foreign_with_index {
1344  dict_foreign_with_index(const dict_index_t *index) : m_index(index) {}
1345 
1346  bool operator()(const dict_foreign_t *foreign) const {
1347  return (foreign->referenced_index == m_index);
1348  }
1349 
1350  const dict_index_t *m_index;
1351 };
1352 
1353 /* A function object to check if the foreign constraint is between different
1354 tables. Returns true if foreign key constraint is between different tables,
1355 false otherwise. */
1357  bool operator()(const dict_foreign_t *foreign) const {
1358  return (foreign->foreign_table != foreign->referenced_table);
1359  }
1360 };
1365 
1366 std::ostream &operator<<(std::ostream &out, const dict_foreign_set &fk_set);
1367 
1368 /** Function object to check if a foreign key object is there
1369 in the given foreign key set or not. It returns true if the
1370 foreign key is not found, false otherwise */
1371 struct dict_foreign_not_exists {
1372  dict_foreign_not_exists(const dict_foreign_set &obj_) : m_foreigns(obj_) {}
1373 
1374  /* Return true if the given foreign key is not found */
1375  bool operator()(dict_foreign_t *const &foreign) const {
1376  return (m_foreigns.find(foreign) == m_foreigns.end());
1377  }
1378 
1379  private:
1380  const dict_foreign_set &m_foreigns;
1381 };
1382 
1383 /** Validate the search order in the foreign key set.
1384 @param[in] fk_set the foreign key set to be validated
1385 @return true if search order is fine in the set, false otherwise. */
1386 bool dict_foreign_set_validate(const dict_foreign_set &fk_set);
1387 
1388 /** Validate the search order in the foreign key sets of the table
1389 (foreign_set and referenced_set).
1390 @param[in] table table whose foreign key sets are to be validated
1391 @return true if foreign key sets are fine, false otherwise. */
1392 bool dict_foreign_set_validate(const dict_table_t &table);
1393 
1394 /** Frees a foreign key struct. */
1395 inline void dict_foreign_free(
1396  dict_foreign_t *foreign) /*!< in, own: foreign key struct */
1397 {
1398  if (foreign->v_cols != nullptr) {
1399  UT_DELETE(foreign->v_cols);
1400  }
1401 
1402  mem_heap_free(foreign->heap);
1403 }
1404 
1405 /** The destructor will free all the foreign key constraints in the set
1406 by calling dict_foreign_free() on each of the foreign key constraints.
1407 This is used to free the allocated memory when a local set goes out
1408 of scope. */
1409 struct dict_foreign_set_free {
1410  dict_foreign_set_free(const dict_foreign_set &foreign_set)
1411  : m_foreign_set(foreign_set) {}
1412 
1414  std::for_each(m_foreign_set.begin(), m_foreign_set.end(),
1416  }
1418  const dict_foreign_set &m_foreign_set;
1419 };
1420 
1421 /** The flags for ON_UPDATE and ON_DELETE can be ORed; the default is that
1422 a foreign key constraint is enforced, therefore RESTRICT just means no flag */
1423 /* @{ */
1424 #define DICT_FOREIGN_ON_DELETE_CASCADE 1 /*!< ON DELETE CASCADE */
1425 #define DICT_FOREIGN_ON_DELETE_SET_NULL 2 /*!< ON DELETE SET NULL */
1426 #define DICT_FOREIGN_ON_UPDATE_CASCADE 4 /*!< ON UPDATE CASCADE */
1427 #define DICT_FOREIGN_ON_UPDATE_SET_NULL 8 /*!< ON UPDATE SET NULL */
1428 #define DICT_FOREIGN_ON_DELETE_NO_ACTION 16 /*!< ON DELETE NO ACTION */
1429 #define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32 /*!< ON UPDATE NO ACTION */
1430 /* @} */
1432 /** Display an identifier.
1433 @param[in,out] s output stream
1434 @param[in] id_name SQL identifier (other than table name)
1435 @return the output stream */
1436 std::ostream &operator<<(std::ostream &s, const id_name_t &id_name);
1437 
1438 /** Display a table name.
1439 @param[in,out] s output stream
1440 @param[in] table_name table name
1441 @return the output stream */
1442 std::ostream &operator<<(std::ostream &s, const table_name_t &table_name);
1443 
1444 #ifndef UNIV_HOTBACKUP
1445 /** List of locks that different transactions have acquired on a table. This
1446 list has a list node that is embedded in a nested union/structure. We have to
1447 generate a specific template for it. */
1448 
1451 #endif /* !UNIV_HOTBACKUP */
1452 
1453 /** mysql template structure defined in row0mysql.cc */
1455 
1456 /** Structure defines template related to virtual columns and
1457 their base columns */
1458 struct dict_vcol_templ_t {
1459  /** number of regular columns */
1460  ulint n_col;
1461 
1462  /** number of virtual columns */
1463  ulint n_v_col;
1465  /** array of templates for virtual col and their base columns */
1466  mysql_row_templ_t **vtempl;
1468  /** table's database name */
1469  std::string db_name;
1471  /** table name */
1472  std::string tb_name;
1474  /** share->table_name */
1475  std::string share_name;
1477  /** MySQL record length */
1478  ulint rec_len;
1480  /** default column value if any */
1481  byte *default_rec;
1482 };
1483 
1484 /** The dirty status of tables, used to indicate if a table has some
1485 dynamic metadata changed to be written back */
1486 enum table_dirty_status {
1487  /** Some persistent metadata is now dirty in memory, need to be
1488  written back to DDTableBuffer table and(or directly to) DD table.
1489  There could be some exceptions, when it's marked as dirty, but
1490  the metadata has already been written back to DDTableBuffer.
1491  For example, if a corrupted index is found and marked as corrupted,
1492  then it gets dropped. At this time, the dirty_status is still of
1493  this dirty value. Also a concurrent checkpoint make this bit
1494  out-of-date for other working threads, which still think the
1495  status is dirty and write-back is necessary.
1496  There could be either one row or no row for this table in
1497  DDTableBuffer table */
1498  METADATA_DIRTY = 0,
1499  /** Some persistent metadata is buffered in DDTableBuffer table,
1500  need to be written back to DD table. There is must be one row in
1501  DDTableBuffer table for this table */
1503  /** All persistent metadata are up to date. There is no row
1504  for this table in DDTableBuffer table */
1506 };
1507 
1508 #ifndef UNIV_HOTBACKUP
1509 /** A vector to collect prebuilt from different readers working on the same
1510 temp table */
1511 typedef std::vector<row_prebuilt_t *> temp_prebuilt_vec;
1512 #endif /* !UNIV_HOTBACKUP */
1513 
1514 /** Data structure for a database table. Most fields will be
1515 initialized to 0, NULL or FALSE in dict_mem_table_create(). */
1516 struct dict_table_t {
1517  /** Check if the table is compressed.
1518  @return true if compressed, false otherwise. */
1519  bool is_compressed() const { return (DICT_TF_GET_ZIP_SSIZE(flags) != 0); }
1521  /** Get reference count.
1522  @return current value of n_ref_count */
1523  inline uint64_t get_ref_count() const;
1524 
1525  /** Acquire the table handle. */
1526  inline void acquire();
1527 
1528  /** Acquire the table handle, with lock() and unlock() the table.
1529  This function needs to be called for opening table when the table
1530  is in memory and later the stats information would be initialized */
1531  inline void acquire_with_lock();
1532 
1533  /** Release the table handle. */
1534  inline void release();
1535 
1536  /** Lock the table handle. */
1537  inline void lock();
1538 
1539  /** Unlock the table handle. */
1540  inline void unlock();
1541 
1542 #ifndef UNIV_HOTBACKUP
1543  /** Get schema and table name in system character set.
1544  @param[out] schema schema name
1545  @param[out] table table name */
1546  void get_table_name(std::string &schema, std::string &table);
1547 
1548  /** Mutex of the table for concurrency access. */
1549  ib_mutex_t *mutex;
1550 
1551  /** Creation state of mutex. */
1552  volatile os_once::state_t mutex_created;
1553 #endif /* !UNIV_HOTBACKUP */
1554 
1555  /** Id of the table. */
1557 
1558  /** Memory heap. If you allocate from this heap after the table has
1559  been created then be sure to account the allocation into
1560  dict_sys->size. When closing the table we do something like
1561  dict_sys->size -= mem_heap_get_size(table->heap) and if that is going
1562  to become negative then we would assert. Something like this should do:
1563  old_size = mem_heap_get_size()
1564  mem_heap_alloc()
1565  new_size = mem_heap_get_size()
1566  dict_sys->size += new_size - old_size. */
1567  mem_heap_t *heap;
1568 
1569  /** Table name. */
1572  /** Truncate name. */
1573  table_name_t trunc_name;
1575  /** NULL or the directory path specified by DATA DIRECTORY. */
1576  char *data_dir_path;
1578  /** NULL or the tablespace name that this table is assigned to,
1579  specified by the TABLESPACE option.*/
1580  id_name_t tablespace;
1581 
1582  /** Space where the clustered index of the table is placed. */
1583  space_id_t space;
1585  /** dd::Tablespace::id of the table */
1586  dd::Object_id dd_space_id;
1588  /** Stores information about:
1589  1 row format (redundant or compact),
1590  2 compressed page size (zip shift size),
1591  3 whether using atomic blobs,
1592  4 whether the table has been created with the option DATA DIRECTORY.
1593  Use DICT_TF_GET_COMPACT(), DICT_TF_GET_ZIP_SSIZE(),
1594  DICT_TF_HAS_ATOMIC_BLOBS() and DICT_TF_HAS_DATA_DIR() to parse this
1595  flag. */
1596  unsigned flags : DICT_TF_BITS;
1597 
1598  /** Stores information about:
1599  1 whether the table has been created using CREATE TEMPORARY TABLE,
1600  2 whether the table has an internally defined DOC ID column,
1601  3 whether the table has a FTS index,
1602  4 whether DOC ID column need to be added to the FTS index,
1603  5 whether the table is being created its own tablespace,
1604  6 whether the table has been DISCARDed,
1605  7 whether the aux FTS tables names are in hex.
1606  8 whether the table is instinc table.
1607  9 whether the table has encryption setting.
1608  Use DICT_TF2_FLAG_IS_SET() to parse this flag. */
1609  unsigned flags2 : DICT_TF2_BITS;
1610 
1611  /** TRUE if the table is an intermediate table during copy alter
1612  operation or a partition/subpartition which is required for copying
1613  data and skip the undo log for insertion of row in the table.
1614  This variable will be set and unset during extra(), or during the
1615  process of altering partitions */
1616  unsigned skip_alter_undo : 1;
1617 
1618  /** TRUE if this is in a single-table tablespace and the .ibd file is
1619  missing. Then we must return in ha_innodb.cc an error if the user
1620  tries to query such an orphaned table. */
1621  unsigned ibd_file_missing : 1;
1622 
1623  /** TRUE if the table object has been added to the dictionary cache. */
1624  unsigned cached : 1;
1626  /** TRUE if the table is to be dropped, but not yet actually dropped
1627  (could in the background drop list). It is turned on at the beginning
1628  of row_drop_table_for_mysql() and turned off just before we start to
1629  update system tables for the drop. It is protected by
1630  dict_operation_lock. */
1631  unsigned to_be_dropped : 1;
1632 
1633  /** Number of non-virtual columns defined so far. */
1634  unsigned n_def : 10;
1636  /** Number of non-virtual columns. */
1637  unsigned n_cols : 10;
1639  /** Number of non-virtual columns before first instant ADD COLUMN,
1640  including the system columns like n_cols. */
1641  unsigned n_instant_cols : 10;
1642 
1643  /** Number of total columns (inlcude virtual and non-virtual) */
1644  unsigned n_t_cols : 10;
1646  /** Number of total columns defined so far. */
1647  unsigned n_t_def : 10;
1649  /** Number of virtual columns defined so far. */
1650  unsigned n_v_def : 10;
1652  /** Number of virtual columns. */
1653  unsigned n_v_cols : 10;
1655  /** Number of multi-value virtual columns. */
1656  unsigned n_m_v_cols : 10;
1658  /** TRUE if this table is expected to be kept in memory. This table
1659  could be a table that has FK relationships or is undergoing DDL */
1660  unsigned can_be_evicted : 1;
1661 
1662  /** TRUE if this table is not evictable(can_be_evicted) and this is
1663  because of DDL operation */
1664  unsigned ddl_not_evictable : 1;
1665 
1666  /** TRUE if some indexes should be dropped after ONLINE_INDEX_ABORTED
1667  or ONLINE_INDEX_ABORTED_DROPPED. */
1668  unsigned drop_aborted : 1;
1669 
1670  /** Array of column descriptions. */
1671  dict_col_t *cols;
1673  /** Array of virtual column descriptions. */
1674  dict_v_col_t *v_cols;
1676  /** List of stored column descriptions. It is used only for foreign key
1677  check during create table and copy alter operations.
1678  During copy alter, s_cols list is filled during create table operation
1679  and need to preserve till rename table operation. That is the
1680  reason s_cols is a part of dict_table_t */
1681  dict_s_col_list *s_cols;
1682 
1683  /** Column names packed in a character string
1684  "name1\0name2\0...nameN\0". Until the string contains n_cols, it will
1685  be allocated from a temporary heap. The final string will be allocated
1686  from table->heap. */
1687  const char *col_names;
1688 
1689  /** Virtual column names */
1690  const char *v_col_names;
1692  /** True if the table belongs to a system database (mysql, information_schema
1693  or performance_schema) */
1694  bool is_system_table;
1695 
1696  /** Hash chain node. */
1697  hash_node_t name_hash;
1699  /** Hash chain node. */
1700  hash_node_t id_hash;
1702  /** The FTS_DOC_ID_INDEX, or NULL if no fulltext indexes exist */
1703  dict_index_t *fts_doc_id_index;
1705  /** List of indexes of the table. */
1708  /** List of foreign key constraints in the table. These refer to
1709  columns in other tables. */
1710  UT_LIST_BASE_NODE_T(dict_foreign_t) foreign_list;
1711 
1712  /** List of foreign key constraints which refer to this table. */
1713  UT_LIST_BASE_NODE_T(dict_foreign_t) referenced_list;
1714 
1715  /** Node of the LRU list of tables. */
1716  UT_LIST_NODE_T(dict_table_t) table_LRU;
1717 
1718  /** metadata version number of dd::Table::se_private_data() */
1719  uint64_t version;
1720 
1721  /** table dynamic metadata status, protected by dict_persist->mutex */
1722  std::atomic<table_dirty_status> dirty_status;
1724 #ifndef UNIV_HOTBACKUP
1725  /** Node of the dirty table list of tables, which is protected
1726  by dict_persist->mutex */
1727  UT_LIST_NODE_T(dict_table_t) dirty_dict_tables;
1728 #endif /* !UNIV_HOTBACKUP */
1729 
1730 #ifdef UNIV_DEBUG
1731  /** This field is used to mark if a table is in the
1732  dirty_dict_tables_list. if the dirty_status is not of
1733  METADATA_CLEAN, the table should be in the list, otherwise not.
1734  This field should be protected by dict_persist->mutex too. */
1735  bool in_dirty_dict_tables_list;
1736 #endif /* UNIV_DEBUG */
1737 
1738  /** Maximum recursive level we support when loading tables chained
1739  together with FK constraints. If exceeds this level, we will stop
1740  loading child table into memory along with its parent table. */
1741  unsigned fk_max_recusive_level : 8;
1742 
1743  /** Count of how many foreign key check operations are currently being
1744  performed on the table. We cannot drop the table while there are
1745  foreign key checks running on it. */
1746  ulint n_foreign_key_checks_running;
1747 
1748  /** Transaction id that last touched the table definition. Either when
1749  loading the definition or CREATE TABLE, or ALTER TABLE (prepare,
1750  commit, and rollback phases). */
1751  trx_id_t def_trx_id;
1752 
1753  /*!< set of foreign key constraints in the table; these refer to
1754  columns in other tables */
1755  dict_foreign_set foreign_set;
1756 
1757  /*!< set of foreign key constraints which refer to this table */
1758  dict_foreign_set referenced_set;
1760 #ifdef UNIV_DEBUG
1761  /** This field is used to specify in simulations tables which are so
1762  big that disk should be accessed. Disk access is simulated by putting
1763  the thread to sleep for a while. NOTE that this flag is not stored to
1764  the data dictionary on disk, and the database will forget about value
1765  TRUE if it has to reload the table definition from disk. */
1766  ibool does_not_fit_in_memory;
1767 #endif /* UNIV_DEBUG */
1768 
1769  /** TRUE if the maximum length of a single row exceeds BIG_ROW_SIZE.
1770  Initialized in dict_table_add_to_cache(). */
1771  unsigned big_rows : 1;
1772 
1773 #ifndef UNIV_HOTBACKUP
1774  /** Statistics for query optimization. @{ */
1776  /** Creation state of 'stats_latch'. */
1777  volatile os_once::state_t stats_latch_created;
1778 
1779  /** This latch protects:
1780  "dict_table_t::stat_initialized",
1781  "dict_table_t::stat_n_rows (*)",
1782  "dict_table_t::stat_clustered_index_size",
1783  "dict_table_t::stat_sum_of_other_index_sizes",
1784  "dict_table_t::stat_modified_counter (*)",
1785  "dict_table_t::indexes*::stat_n_diff_key_vals[]",
1786  "dict_table_t::indexes*::stat_index_size",
1787  "dict_table_t::indexes*::stat_n_leaf_pages".
1788  (*) Those are not always protected for
1789  performance reasons. */
1790  rw_lock_t *stats_latch;
1791 
1792  /** TRUE if statistics have been calculated the first time after
1793  database startup or table creation. */
1794  unsigned stat_initialized : 1;
1795 
1796  /** Timestamp of last recalc of the stats. */
1797  ib_time_monotonic_t stats_last_recalc;
1799 /** The two bits below are set in the 'stat_persistent' member. They
1800 have the following meaning:
1801 1. _ON=0, _OFF=0, no explicit persistent stats setting for this table,
1802 the value of the global srv_stats_persistent is used to determine
1803 whether the table has persistent stats enabled or not
1804 2. _ON=0, _OFF=1, persistent stats are explicitly disabled for this
1805 table, regardless of the value of the global srv_stats_persistent
1806 3. _ON=1, _OFF=0, persistent stats are explicitly enabled for this
1807 table, regardless of the value of the global srv_stats_persistent
1808 4. _ON=1, _OFF=1, not allowed, we assert if this ever happens. */
1809 #define DICT_STATS_PERSISTENT_ON (1 << 1)
1810 #define DICT_STATS_PERSISTENT_OFF (1 << 2)
1811 
1812  /** Indicates whether the table uses persistent stats or not. See
1813  DICT_STATS_PERSISTENT_ON and DICT_STATS_PERSISTENT_OFF. */
1814  ib_uint32_t stat_persistent;
1815 
1816 /** The two bits below are set in the 'stats_auto_recalc' member. They
1817 have the following meaning:
1818 1. _ON=0, _OFF=0, no explicit auto recalc setting for this table, the
1819 value of the global srv_stats_persistent_auto_recalc is used to
1820 determine whether the table has auto recalc enabled or not
1821 2. _ON=0, _OFF=1, auto recalc is explicitly disabled for this table,
1822 regardless of the value of the global srv_stats_persistent_auto_recalc
1823 3. _ON=1, _OFF=0, auto recalc is explicitly enabled for this table,
1824 regardless of the value of the global srv_stats_persistent_auto_recalc
1825 4. _ON=1, _OFF=1, not allowed, we assert if this ever happens. */
1826 #define DICT_STATS_AUTO_RECALC_ON (1 << 1)
1827 #define DICT_STATS_AUTO_RECALC_OFF (1 << 2)
1828 
1829  /** Indicates whether the table uses automatic recalc for persistent
1830  stats or not. See DICT_STATS_AUTO_RECALC_ON and
1831  DICT_STATS_AUTO_RECALC_OFF. */
1832  ib_uint32_t stats_auto_recalc;
1833 
1834  /** The number of pages to sample for this table during persistent
1835  stats estimation. If this is 0, then the value of the global
1836  srv_stats_persistent_sample_pages will be used instead. */
1837  ulint stats_sample_pages;
1838 
1839  /** Approximate number of rows in the table. We periodically calculate
1840  new estimates. */
1841  ib_uint64_t stat_n_rows;
1842 
1843  /** Approximate clustered index size in database pages. */
1844  ulint stat_clustered_index_size;
1846  /** Approximate size of other indexes in database pages. */
1847  ulint stat_sum_of_other_index_sizes;
1849  /** If FTS AUX table, parent table id */
1850  table_id_t parent_id;
1852  /** How many rows are modified since last stats recalc. When a row is
1853  inserted, updated, or deleted, we add 1 to this number; we calculate
1854  new estimates for the table and the indexes if the table has changed
1855  too much, see row_update_statistics_if_needed(). The counter is reset
1856  to zero at statistics calculation. This counter is not protected by
1857  any latch, because this is only used for heuristics. */
1858  ib_uint64_t stat_modified_counter;
1859 
1860 /** Background stats thread is not working on this table. */
1861 #define BG_STAT_NONE 0
1863 /** Set in 'stats_bg_flag' when the background stats code is working
1864 on this table. The DROP TABLE code waits for this to be cleared before
1865 proceeding. */
1866 #define BG_STAT_IN_PROGRESS (1 << 0)
1867 
1868 /** Set in 'stats_bg_flag' when DROP TABLE starts waiting on
1869 BG_STAT_IN_PROGRESS to be cleared. The background stats thread will
1870 detect this and will eventually quit sooner. */
1871 #define BG_STAT_SHOULD_QUIT (1 << 1)
1872 
1873  /** The state of the background stats thread wrt this table.
1874  See BG_STAT_NONE, BG_STAT_IN_PROGRESS and BG_STAT_SHOULD_QUIT.
1875  Writes are covered by dict_sys->mutex. Dirty reads are possible. */
1876  byte stats_bg_flag;
1877 
1878  /* @} */
1879 #endif /* !UNIV_HOTBACKUP */
1881  /** AUTOINC related members. @{ */
1882 
1883  /* The actual collection of tables locked during AUTOINC read/write is
1884  kept in trx_t. In order to quickly determine whether a transaction has
1885  locked the AUTOINC lock we keep a pointer to the transaction here in
1886  the 'autoinc_trx' member. This is to avoid acquiring the
1887  lock_sys_t::mutex and scanning the vector in trx_t.
1888  When an AUTOINC lock has to wait, the corresponding lock instance is
1889  created on the trx lock heap rather than use the pre-allocated instance
1890  in autoinc_lock below. */
1891 
1892  /** A buffer for an AUTOINC lock for this table. We allocate the
1893  memory here so that individual transactions can get it and release it
1894  without a need to allocate space from the lock heap of the trx:
1895  otherwise the lock heap would grow rapidly if we do a large insert
1896  from a select. */
1897 #ifndef UNIV_HOTBACKUP
1898  lock_t *autoinc_lock;
1899 
1900  /** Creation state of autoinc_mutex member */
1901  volatile os_once::state_t autoinc_mutex_created;
1902 #endif /* !UNIV_HOTBACKUP */
1903 
1904  /** Mutex protecting the autoincrement counter. */
1905  ib_mutex_t *autoinc_mutex;
1906 
1907  /** Autoinc counter value to give to the next inserted row. */
1908  ib_uint64_t autoinc;
1910  /** Mutex protecting the persisted autoincrement counter. */
1911  ib_mutex_t *autoinc_persisted_mutex;
1913  /** Autoinc counter value that has been persisted in redo logs or
1914  DDTableBuffer. It's mainly used when we want to write counter back
1915  to DDTableBuffer.
1916  This is different from the 'autoinc' above, which could be bigger
1917  than this one, because 'autoinc' will get updated right after
1918  some counters are allocated, but we will write the counter to redo
1919  logs and update this counter later. Once all allocated counters
1920  have been written to redo logs, 'autoinc' should be exact the next
1921  counter of this persisted one.
1922  We want this counter because when we need to write the counter back
1923  to DDTableBuffer, we had better keep it consistency with the counter
1924  that has been written to redo logs. Besides, we can't read the 'autoinc'
1925  directly easily, because the autoinc_lock is required and there could
1926  be a deadlock.
1927  This variable is protected by autoinc_persisted_mutex. */
1928  ib_uint64_t autoinc_persisted;
1929 
1930  /** The position of autoinc counter field in clustered index. This would
1931  be set when CREATE/ALTER/OPEN TABLE and IMPORT TABLESPACE, and used in
1932  modifications to clustered index, such as INSERT/UPDATE. There should
1933  be no conflict to access it, so no protection is needed. */
1934  ulint autoinc_field_no;
1935 
1936  /** The transaction that currently holds the the AUTOINC lock on this
1937  table. Protected by lock_sys->mutex. */
1938  const trx_t *autoinc_trx;
1939 
1940  /* @} */
1941 
1942 #ifndef UNIV_HOTBACKUP
1943  /** FTS specific state variables. */
1944  fts_t *fts;
1945 #endif /* !UNIV_HOTBACKUP */
1946 
1947  /** Quiescing states, protected by the dict_index_t::lock. ie. we can
1948  only change the state if we acquire all the latches (dict_index_t::lock)
1949  in X mode of this table's indexes. */
1950  ib_quiesce_t quiesce;
1951 
1952  /** Count of the number of record locks on this table. We use this to
1953  determine whether we can evict the table from the dictionary cache.
1954  It is protected by lock_sys->mutex. */
1955  ulint n_rec_locks;
1956 
1957 #ifndef UNIV_DEBUG
1958  private:
1959 #endif
1960  /** Count of how many handles are opened to this table. Dropping of the
1961  table is NOT allowed until this count gets to zero. MySQL does NOT
1962  itself check the number of open handles at DROP. */
1963  std::atomic<uint64_t> n_ref_count;
1964 
1965  public:
1966 #ifndef UNIV_HOTBACKUP
1967  /** List of locks on the table. Protected by lock_sys->mutex. */
1968  table_lock_list_t locks;
1969  /** count_by_mode[M] = number of locks in this->locks with
1970  lock->type_mode&LOCK_MODE_MASK == M.
1971  Used to quickly verify that there are no LOCK_S or LOCK_X, which are the only
1972  modes incompatible with LOCK_IS and LOCK_IX, to avoid costly iteration over
1973  this->locks when adding LOCK_IS or LOCK_IX.
1974  We use count_by_mode[LOCK_AUTO_INC] to track the number of granted and pending
1975  autoinc locks on this table. This value is set after acquiring the
1976  lock_sys_t::mutex but we peek the contents to determine whether other
1977  transactions have acquired the AUTOINC lock or not. Of course only one
1978  transaction can be granted the lock but there can be multiple
1979  waiters.
1980  Protected by lock_sys->mutex. */
1981  ulong count_by_mode[LOCK_NUM];
1982 #endif /* !UNIV_HOTBACKUP */
1983 
1984  /** Timestamp of the last modification of this table. */
1985  time_t update_time;
1986 
1987  /** row-id counter for use by intrinsic table for getting row-id.
1988  Given intrinsic table semantics, row-id can be locally maintained
1989  instead of getting it from central generator which involves mutex
1990  locking. */
1991  ib_uint64_t sess_row_id;
1992 
1993  /** trx_id counter for use by intrinsic table for getting trx-id.
1994  Intrinsic table are not shared so don't need a central trx-id
1995  but just need a increased counter to track consistent view while
1996  proceeding SELECT as part of UPDATE. */
1997  ib_uint64_t sess_trx_id;
1998 
1999 #ifdef UNIV_DEBUG
2000 /** Value of 'magic_n'. */
2001 #define DICT_TABLE_MAGIC_N 76333786
2002 
2003  /** Magic number. */
2004  ulint magic_n;
2005 #endif /* UNIV_DEBUG */
2006  /** mysql_row_templ_t for base columns used for compute the virtual
2007  columns */
2009 
2010  /** encryption key, it's only for export/import */
2011  byte *encryption_key;
2013  /** encryption iv, it's only for export/import */
2014  byte *encryption_iv;
2016  /** remove the dict_table_t from cache after DDL operation */
2017  bool discard_after_ddl;
2019  /** refresh/reload FK info */
2020  bool refresh_fk;
2022 #ifndef UNIV_HOTBACKUP
2023  /** multiple cursors can be active on this temporary table */
2024  temp_prebuilt_vec *temp_prebuilt;
2025 #endif /* !UNIV_HOTBACKUP */
2026 
2027  /** TRUE only for dictionary tables like mysql/tables,
2028  mysql/columns, mysql/tablespaces, etc. This flag is used
2029  to do non-locking reads on DD tables. */
2030  bool is_dd_table;
2031 
2032  /** true if this table is explicitly put to non-LRU list
2033  during table creation */
2034  bool explicitly_non_lru;
2035 
2036  /** @return the clustered index */
2037  const dict_index_t *first_index() const {
2039  const dict_index_t *first = UT_LIST_GET_FIRST(indexes);
2040  return (first);
2041  }
2042  /** @return the clustered index */
2043  dict_index_t *first_index() {
2044  return (const_cast<dict_index_t *>(
2045  const_cast<const dict_table_t *>(this)->first_index()));
2046  }
2048  /** @return if there was any instantly added column.
2049  This will be true after one or more instant ADD COLUMN, however,
2050  it would become false after ALTER TABLE which rebuilds or copies
2051  the old table.
2052  If this is true, all instantly added columns should have default
2053  values, and records in the table may have REC_INFO_INSTANT_FLAG set. */
2054  bool has_instant_cols() const {
2055  ut_ad(n_instant_cols <= n_cols);
2056 
2057  return (n_instant_cols < n_cols);
2058  }
2059 
2060  /** Set the number of columns when the first instant ADD COLUMN happens.
2061  @param[in] instant_cols number of fields when first instant
2062  ADD COLUMN happens, without system
2063  columns */
2064  void set_instant_cols(uint16_t instant_cols) {
2065  n_instant_cols = static_cast<unsigned>(instant_cols) + get_n_sys_cols();
2066  }
2067 
2068  /** Get the number of user columns when the first instant ADD COLUMN
2069  happens.
2070  @return the number of user columns as described above */
2071  uint16_t get_instant_cols() const {
2072  return static_cast<uint16_t>(n_instant_cols - get_n_sys_cols());
2073  }
2074 
2075  /** Check whether the table is corrupted.
2076  @return true if the table is corrupted, otherwise false */
2077  bool is_corrupted() const {
2078  ut_ad(magic_n == DICT_TABLE_MAGIC_N);
2079 
2080  const dict_index_t *index = first_index();
2082  /* It is possible that this table is only half created, in which case
2083  the clustered index may be NULL. If the clustered index is corrupted,
2084  the table is corrupt. We do not consider the table corrupt if only
2085  a secondary index is corrupt. */
2086  ut_ad(index == nullptr || index->is_clustered());
2087 
2088  return (index != nullptr && index->type & DICT_CORRUPT);
2089  }
2090 
2091  /** Returns a column's name.
2092  @param[in] col_nr column number
2093  @return column name. NOTE: not guaranteed to stay valid if table is
2094  modified in any way (columns added, etc.). */
2095  const char *get_col_name(ulint col_nr) const {
2096  ut_ad(col_nr < n_def);
2097  ut_ad(magic_n == DICT_TABLE_MAGIC_N);
2098 
2099  const char *s = col_names;
2100  if (s) {
2101  for (ulint i = 0; i < col_nr; i++) {
2102  s += strlen(s) + 1;
2103  }
2104  }
2105 
2106  return (s);
2107  }
2108 
2109  /**Gets the nth column of a table.
2110  @param[in] pos position of column
2111  @return pointer to column object */
2112  dict_col_t *get_col(ulint pos) const {
2113  ut_ad(pos < n_def);
2114  ut_ad(magic_n == DICT_TABLE_MAGIC_N);
2115 
2116  return (cols + pos);
2117  }
2118 
2119  /** Gets the number of user-defined non-virtual columns in a table
2120  in the dictionary cache.
2121  @return number of user-defined (e.g., not ROW_ID) non-virtual columns
2122  of a table */
2123  uint16_t get_n_user_cols() const {
2124  ut_ad(magic_n == DICT_TABLE_MAGIC_N);
2125 
2126  return (static_cast<uint16_t>(n_cols) - get_n_sys_cols());
2127  }
2128 
2129  /** Gets the number of system columns in a table.
2130  For intrinsic table on ROW_ID column is added for all other
2131  tables TRX_ID and ROLL_PTR are all also appeneded.
2132  @return number of system (e.g., ROW_ID) columns of a table */
2133  uint16_t get_n_sys_cols() const {
2134  ut_ad(magic_n == DICT_TABLE_MAGIC_N);
2135 
2136  return (is_intrinsic() ? DATA_ITT_N_SYS_COLS : DATA_N_SYS_COLS);
2137  }
2138 
2139  /** Gets the number of all non-virtual columns (also system) in a table
2140  in the dictionary cache.
2141  @return number of non-virtual columns of a table */
2142  ulint get_n_cols() const {
2143  ut_ad(magic_n == DICT_TABLE_MAGIC_N);
2144 
2145  return (n_cols);
2146  }
2147 
2148  /** Gets the given system column of a table.
2149  @param[in] sys DATA_ROW_ID, ...
2150  @return pointer to column object */
2151  dict_col_t *get_sys_col(ulint sys) const {
2152  dict_col_t *col;
2153 
2154  ut_ad(sys < get_n_sys_cols());
2156 
2157  col = get_col(n_cols - get_n_sys_cols() + sys);
2158  ut_ad(col->mtype == DATA_SYS);
2159  ut_ad(col->prtype == (sys | DATA_NOT_NULL));
2160 
2161  return (col);
2162  }
2163 
2164  /** Determine if this is a temporary table. */
2165  bool is_temporary() const {
2166  ut_ad(magic_n == DICT_TABLE_MAGIC_N);
2167  return (flags2 & DICT_TF2_TEMPORARY);
2168  }
2170  /** Determine if this is a FTS AUX table. */
2171  bool is_fts_aux() const {
2172  ut_ad(magic_n == DICT_TABLE_MAGIC_N);
2173  return (flags2 & DICT_TF2_AUX);
2174  }
2176  /** Determine whether the table is intrinsic.
2177  An intrinsic table is a special kind of temporary table that
2178  is invisible to the end user. It can be created internally by InnoDB,
2179  the MySQL server layer or other modules connected to InnoDB in order
2180  to gather and use data as part of a larger task. Since access to it
2181  must be as fast as possible, it does not need UNDO semantics, system
2182  fields DB_TRX_ID & DB_ROLL_PTR, doublewrite, checksum, insert buffer,
2183  use of the shared data dictionary, locking, or even a transaction.
2184  In short, these are not ACID tables at all, just temporary data stored
2185  and manipulated during a larger process.*/
2186  bool is_intrinsic() const {
2187  if (flags2 & DICT_TF2_INTRINSIC) {
2188  ut_ad(is_temporary());
2189  return (true);
2190  }
2191 
2192  return (false);
2193  }
2194 
2195  /* GAP locks are skipped for DD tables and SDI tables
2196  @return true if table is DD table or SDI table, else false */
2197  inline bool skip_gap_locks() const;
2198 
2199  /** Determine if the table can support instant ADD COLUMN */
2200  inline bool support_instant_add() const;
2201 };
2202 
2203 inline bool dict_index_t::is_compressed() const {
2204  return (table->is_compressed());
2205 }
2206 
2207 /** Persistent dynamic metadata type, there should be 1 to 1
2208 relationship between the metadata and the type. Please keep them in order
2209 so that we can iterate over it */
2210 enum persistent_type_t {
2211  /** The smallest type, which should be 1 less than the first
2212  true type */
2213  PM_SMALLEST_TYPE = 0,
2215  /** Persistent Metadata type for corrupted indexes */
2216  PM_INDEX_CORRUPTED = 1,
2218  /** Persistent Metadata type for autoinc counter */
2219  PM_TABLE_AUTO_INC = 2,
2221  /* TODO: Will add following types
2222  PM_TABLE_UPDATE_TIME = 3,
2223  Maybe something tablespace related
2224  PM_TABLESPACE_SIZE = 4,
2225  PM_TABLESPACE_MAX_TRX_ID = 5, */
2226 
2227  /** The biggest type, which should be 1 bigger than the last
2228  true type */
2229  PM_BIGGEST_TYPE = 3
2230 };
2231 
2232 typedef std::vector<index_id_t, ut_allocator<index_id_t>> corrupted_ids_t;
2234 /** Persistent dynamic metadata for a table */
2236  public:
2237  /** Constructor
2238  @param[in] id table id
2239  @param[in] version table dynamic metadata version */
2241  : m_id(id), m_version(version), m_corrupted_ids(), m_autoinc(0) {}
2242 
2243  /** Get the corrupted indexes' IDs
2244  @return the vector of indexes' IDs */
2245  const corrupted_ids_t &get_corrupted_indexes() const {
2246  return (m_corrupted_ids);
2247  }
2248 
2249  /** Add a corrupted index id and space id
2250  @param[in] id corrupted index id */
2251  void add_corrupted_index(const index_id_t id) {
2252  m_corrupted_ids.push_back(id);
2253  }
2254 
2255  /** Set the dynamic metadata version.
2256  @param[in] version dynamic metadata version */
2257  void set_version(uint64_t version) { m_version = version; }
2258 
2259  /** Get the dynamic metadata version */
2260  uint64_t get_version() const { return (m_version); }
2262  /** Get the table id of the metadata
2263  @return table id */
2264  table_id_t get_table_id() const { return (m_id); }
2265 
2266  /** Set the autoinc counter of the table if it's bigger
2267  @param[in] autoinc autoinc counter */
2268  void set_autoinc_if_bigger(uint64_t autoinc) {
2269  /* We only set the biggest autoinc counter. Callers don't
2270  guarantee passing a bigger number in. */
2271  if (autoinc > m_autoinc) {
2272  m_autoinc = autoinc;
2273  }
2274  }
2275 
2276  /** Set the autoinc counter of the table
2277  @param[in] autoinc autoinc counter */
2278  void set_autoinc(uint64_t autoinc) { m_autoinc = autoinc; }
2279 
2280  /** Get the autoinc counter of the table
2281  @return the autoinc counter */
2282  uint64_t get_autoinc() const { return (m_autoinc); }
2283 
2284  private:
2285  /** Table ID which this metadata belongs to */
2287 
2288  /** Table dynamic metadata version of the change */
2289  uint64_t m_version;
2291  /** Storing the corrupted indexes' ID if exist, or else empty */
2292  corrupted_ids_t m_corrupted_ids;
2294  /** Autoinc counter of the table */
2295  uint64_t m_autoinc;
2297  /* TODO: We will add update_time, etc. here and APIs accordingly */
2298 };
2300 /** Interface for persistent dynamic table metadata. */
2301 class Persister {
2302  public:
2303  /** Virtual desctructor */
2304  virtual ~Persister() {}
2306  /** Write the dynamic metadata of a table, we can pre-calculate
2307  the size by calling get_write_size()
2308  @param[in] metadata persistent data
2309  @param[out] buffer write buffer
2310  @param[in] size size of write buffer, should be
2311  at least get_write_size()
2312  @return the length of bytes written */
2313  virtual ulint write(const PersistentTableMetadata &metadata, byte *buffer,
2314  ulint size) const = 0;
2315 
2316  /** Pre-calculate the size of metadata to be written
2317  @param[in] metadata metadata to be written
2318  @return the size of metadata */
2319  virtual ulint get_write_size(
2320  const PersistentTableMetadata &metadata) const = 0;
2321 
2322  /** Read the dynamic metadata from buffer, and store them to
2323  metadata object
2324  @param[out] metadata metadata where we store the read data
2325  @param[in] buffer buffer to read
2326  @param[in] size size of buffer
2327  @param[out] corrupt true if we found something wrong in
2328  the buffer except incomplete buffer,
2329  otherwise false
2330  @return the bytes we read from the buffer if the buffer data
2331  is complete and we get everything, 0 if the buffer is incompleted */
2332  virtual ulint read(PersistentTableMetadata &metadata, const byte *buffer,
2333  ulint size, bool *corrupt) const = 0;
2334 
2335  /** Write MLOG_TABLE_DYNAMIC_META for persistent dynamic
2336  metadata of table
2337  @param[in] id table id
2338  @param[in] metadata metadata used to write the log
2339  @param[in,out] mtr mini-transaction */
2340  void write_log(table_id_t id, const PersistentTableMetadata &metadata,
2341  mtr_t *mtr) const;
2342 };
2343 
2344 /** Persister used for corrupted indexes */
2345 class CorruptedIndexPersister : public Persister {
2346  public:
2347  /** Write the corrupted indexes of a table, we can pre-calculate
2348  the size by calling get_write_size()
2349  @param[in] metadata persistent metadata
2350  @param[out] buffer write buffer
2351  @param[in] size size of write buffer, should be
2352  at least get_write_size()
2353  @return the length of bytes written */
2355  ulint size) const;
2356 
2357  /** Pre-calculate the size of metadata to be written
2358  @param[in] metadata metadata to be written
2359  @return the size of metadata */
2360  ulint get_write_size(const PersistentTableMetadata &metadata) const;
2361 
2362  /** Read the corrupted indexes from buffer, and store them to
2363  metadata object
2364  @param[out] metadata metadata where we store the read data
2365  @param[in] buffer buffer to read
2366  @param[in] size size of buffer
2367  @param[out] corrupt true if we found something wrong in
2368  the buffer except incomplete buffer,
2369  otherwise false
2370  @return the bytes we read from the buffer if the buffer data
2371  is complete and we get everything, 0 if the buffer is incomplete */
2372  ulint read(PersistentTableMetadata &metadata, const byte *buffer, ulint size,
2373  bool *corrupt) const;
2374 
2375  private:
2376  /** The length of index_id_t we will write */
2377  static const size_t INDEX_ID_LENGTH = 12;
2378 };
2379 
2380 /** Persister used for autoinc counters */
2381 class AutoIncPersister : public Persister {
2382  public:
2383  /** Write the autoinc counter of a table, we can pre-calculate
2384  the size by calling get_write_size()
2385  @param[in] metadata persistent metadata
2386  @param[out] buffer write buffer
2387  @param[in] size size of write buffer, should be
2388  at least get_write_size()
2389  @return the length of bytes written */
2391  ulint size) const;
2392 
2393  /** Pre-calculate the size of metadata to be written
2394  @param[in] metadata metadata to be written
2395  @return the size of metadata */
2396  inline ulint get_write_size(const PersistentTableMetadata &metadata) const {
2397  /* We just return the max possible size that would be used
2398  if the counter exists, so we don't calculate every time.
2399  Here we need 1 byte for dynamic metadata type and 11 bytes
2400  for the max possible size of counter. */
2401  return (12);
2402  }
2403 
2404  /** Read the autoinc counter from buffer, and store them to
2405  metadata object
2406  @param[out] metadata metadata where we store the read data
2407  @param[in] buffer buffer to read
2408  @param[in] size size of buffer
2409  @param[out] corrupt true if we found something wrong in
2410  the buffer except incomplete buffer,
2411  otherwise false
2412  @return the bytes we read from the buffer if the buffer data
2413  is complete and we get everything, 0 if the buffer is incomplete */
2414  ulint read(PersistentTableMetadata &metadata, const byte *buffer, ulint size,
2415  bool *corrupt) const;
2416 };
2417 
2418 /** Container of persisters used in the system. Currently we don't need
2419 to protect this object since we only initialize it at very beginning and
2420 destroy it in the end. During the server running, we only get the persisters */
2421 class Persisters {
2422  typedef std::map<
2423  persistent_type_t, Persister *, std::less<persistent_type_t>,
2426 
2427  public:
2428  /** Constructor */
2429  Persisters() : m_persisters() {}
2430 
2431  /** Destructor */
2432  ~Persisters();
2434  /** Get the persister object with specified type
2435  @param[in] type persister type
2436  @return Persister object required or NULL if not found */
2437  Persister *get(persistent_type_t type) const;
2438 
2439  /** Add a specified persister of type, we will allocate the Persister
2440  if there is no such persister exist, otherwise do nothing and return
2441  the existing one
2442  @param[in] type persister type
2443  @return the persister of type */
2444  Persister *add(persistent_type_t type);
2445 
2446  /** Remove a specified persister of type, we will free the Persister
2447  @param[in] type persister type */
2448  void remove(persistent_type_t type);
2449 
2450  /** Serialize the metadata to a buffer
2451  @param[in] metadata metadata to serialize
2452  @param[out] buffer buffer to store the serialized metadata
2453  @return the length of serialized metadata */
2455 
2456  private:
2457  /** A map to store all persisters needed */
2458  persisters_t m_persisters;
2459 };
2460 
2461 #ifndef UNIV_HOTBACKUP
2462 /** Initialise the table lock list. */
2464  table_lock_list_t *locks); /*!< List to initialise */
2465 
2466 /** A function object to add the foreign key constraint to the referenced set
2467 of the referenced table, if it exists in the dictionary cache. */
2469  void operator()(dict_foreign_t *foreign) const {
2470  if (dict_table_t *table = foreign->referenced_table) {
2471  std::pair<dict_foreign_set::iterator, bool> ret =
2472  table->referenced_set.insert(foreign);
2473  ut_a(ret.second);
2474  }
2475  }
2476 };
2477 
2478 /** Request for lazy creation of the mutex of a given table.
2479 This function is only called from either single threaded environment
2480 or from a thread that has not shared the table object with other threads.
2481 @param[in,out] table table whose mutex is to be created */
2482 inline void dict_table_mutex_create_lazy(dict_table_t *table) {
2483  table->mutex = nullptr;
2485 }
2487 /** Destroy the mutex of a given table.
2488 This function is only called from either single threaded environment
2489 or from a thread that has not shared the table object with other threads.
2490 @param[in,out] table table whose mutex is to be created */
2491 inline void dict_table_mutex_destroy(dict_table_t *table) {
2492  if (table->mutex_created == os_once::DONE) {
2493  if (table->mutex != nullptr) {
2494  mutex_free(table->mutex);
2495  UT_DELETE(table->mutex);
2496  }
2497  }
2498 }
2499 
2500 /** Destroy the autoinc latch of the given table.
2501 This function is only called from either single threaded environment
2502 or from a thread that has not shared the table object with other threads.
2503 @param[in,out] table table whose stats latch to destroy */
2504 inline void dict_table_autoinc_destroy(dict_table_t *table) {
2505  if (table->autoinc_mutex_created == os_once::DONE) {
2506  if (table->autoinc_mutex != nullptr) {
2507  mutex_free(table->autoinc_mutex);
2509  }
2510 
2511  if (table->autoinc_persisted_mutex != nullptr) {
2514  }
2515  }
2516 }
2517 
2518 /** Request for lazy creation of the autoinc latch of a given table.
2519 This function is only called from either single threaded environment
2520 or from a thread that has not shared the table object with other threads.
2521 @param[in,out] table table whose autoinc latch is to be created. */
2522 inline void dict_table_autoinc_create_lazy(dict_table_t *table) {
2523  table->autoinc_mutex = nullptr;
2524  table->autoinc_persisted_mutex = nullptr;
2527 
2528 /** Request a lazy creation of dict_index_t::zip_pad::mutex.
2529 This function is only called from either single threaded environment
2530 or from a thread that has not shared the table object with other threads.
2531 @param[in,out] index index whose zip_pad mutex is to be created */
2533  index->zip_pad.mutex = nullptr;
2535 }
2537 /** Destroy the zip_pad_mutex of the given index.
2538 This function is only called from either single threaded environment
2539 or from a thread that has not shared the table object with other threads.
2540 @param[in,out] index index whose stats latch to destroy */
2541 inline void dict_index_zip_pad_mutex_destroy(dict_index_t *index) {
2542  if (index->zip_pad.mutex_created == os_once::DONE &&
2543  index->zip_pad.mutex != nullptr) {
2544  mutex_free(index->zip_pad.mutex);
2546  }
2547 }
2548 #endif /* !UNIV_HOTBACKUP */
2549 
2550 /** Release the zip_pad_mutex of a given index.
2551 @param[in,out] index index whose zip_pad_mutex is to be released */
2552 inline void dict_index_zip_pad_unlock(dict_index_t *index) {
2553 #ifndef UNIV_HOTBACKUP
2554  mutex_exit(index->zip_pad.mutex);
2555 #endif /* !UNIV_HOTBACKUP */
2557 
2558 #ifdef UNIV_DEBUG
2559 /** Check if the current thread owns the autoinc_mutex of a given table.
2560 @param[in] table the autoinc_mutex belongs to this table
2561 @return true, if the current thread owns the autoinc_mutex, false otherwise.*/
2562 inline bool dict_table_autoinc_own(const dict_table_t *table) {
2563  return (mutex_own(table->autoinc_mutex));
2564 }
2565 #endif /* UNIV_DEBUG */
2567 #include "dict0mem.ic"
2568 
2569 #endif /* dict0mem_h */
Allocator class for allocating memory from inside std::* containers.
Definition: ut0new.h:571
ib_mutex_t * mutex
Mutex of the table for concurrency access.
Definition: dict0mem.h:1553
Record manager global types.
unsigned mtype
main data type
Definition: dict0mem.h:482
bool read(T *ap, const GV &gv, const char *key)
Definition: sdi_impl.h:339
void dict_index_zip_pad_mutex_destroy(dict_index_t *index)
Destroy the zip_pad_mutex of the given index.
Definition: dict0mem.h:2545
Definition: lock0types.h:59
unsigned len
length; for MySQL data this is field->pack_length(), except that for a >= 5.0.3 type true VARCHAR thi...
Definition: data0type.h:509
void dict_mem_foreign_table_name_lookup_set(dict_foreign_t *foreign, ibool do_alloc)
Sets the foreign_table_name_lookup pointer based on the value of lower_case_table_names.
Definition: dict0mem.cc:374
Data types.
ib_uint32_t state_t
Control variables&#39; state type.
Definition: os0once.h:66
void set(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1)
Definition: suite_stubs.c:105
ulong zip_pad_max
Maximum percentage of a page that can be allowed as a pad to avoid compression failures.
Definition: dict0dict.cc:181
unsigned is_ascending
0=DESC, 1=ASC
Definition: dict0mem.h:734
UNIV_INLINE ulint dtype_get_min_size_low(ulint mtype, ulint prtype, ulint len, ulint mbminmaxlen)
Returns the minimum size of a data type.
Not used in gis index.
Definition: dict0types.h:335
Persistent dynamic metadata for a table.
Definition: dict0mem.h:2239
The structure used in the spin lock implementation of a read-write lock.
Definition: sync0rw.h:556
size_t len
Length of default value.
Definition: dict0mem.h:458
const char * db_name
Definition: rules_table_service.cc:54
void add(ENGINE_HANDLE *h, ENGINE_HANDLE_V1 *h1)
Definition: suite_stubs.c:69
dict_col_t m_col
column structure
Definition: dict0mem.h:644
R-tree header file.
Data dictionary memory object creation.
SysMutex * mutex
mutex protecting the info
Definition: dict0mem.h:778
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)
Adds a virtual column definition to a table.
Definition: dict0mem.cc:105
volatile os_once::state_t mutex_created
Creation state of mutex member.
Definition: dict0mem.h:787
Buffer for logging modifications during online index creation.
Definition: row0log.cc:176
char buffer[STRING_BUFFER]
Definition: test_sql_9_sessions.cc:57
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:723
#define MAX_KEY_LENGTH_BITS
Definition: dict0mem.h:896
File containing constants that can be used throughout the server.
persistent_type_t
Persistent dynamic metadata type, there should be 1 to 1 relationship between the metadata and the ty...
Definition: dict0mem.h:2214
Lock struct; protected by lock_sys->mutex.
Definition: lock0priv.h:132
Definition: trx0trx.h:800
volatile os_once::state_t autoinc_mutex_created
Creation state of autoinc_mutex member.
Definition: dict0mem.h:1905
unsigned prtype
precise type; MySQL data type, charset code, flags to indicate nullability, signedness, whether this is a binary string, whether this is a true VARCHAR where MySQL uses 2 bytes to store the length
Definition: data0type.h:498
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:2566
Definition: gis0type.h:159
UNIV_INLINE 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.
pthread_mutex_t mutex
Definition: memcached.c:384
The buffer control block structure.
Definition: buf0buf.h:1321
static const state_t NEVER_DONE
Not yet executed.
Definition: os0once.h:69
#define UT_LIST_GET_FIRST(BASE)
Definition: innodb_utility.h:115
The transaction lock system global types.
#define DATA_NOT_NULL
Definition: data0type.h:199
bool operator==(const Uuid &a, const Uuid &b)
Definition: uuid.h:169
void dict_mem_foreign_fill_vcol_set(dict_foreign_t *foreign)
Fills the dependent virtual columns in a set.
Definition: dict0mem.cc:507
#define DICT_TF_GET_ZIP_SSIZE(flags)
Return the value of the ZIP_SSIZE field.
Definition: dict0mem.h:227
#define DICT_TF2_AUX
FTS AUX hidden table bit.
Definition: dict0mem.h:285
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:734
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:686
Index information put in a list of virtual column structure.
Definition: dict0mem.h:630
std::set< dict_foreign_t *, dict_foreign_compare, ut_allocator< dict_foreign_t * > > dict_foreign_set
Definition: dict0mem.h:1368
#define UT_LIST_GET_NEXT(NAME, N)
Definition: innodb_utility.h:111
std::ostream & operator<<(std::ostream &out, const dict_foreign_t &foreign)
Definition: dict0mem.cc:798
Some persistent metadata is buffered in DDTableBuffer table, need to be written back to DD table...
Definition: dict0mem.h:1506
unsigned long id[MAX_DEAD]
Definition: xcom_base.c:426
Data structure for a database table.
Definition: dict0mem.h:1520
ut_list_base< lock_t, ut_list_node< lock_t > lock_table_t::* > table_lock_list_t
List of locks that different transactions have acquired on a table.
Definition: dict0mem.h:1454
unsigned mbminmaxlen
minimum and maximum length of a character, in bytes; DATA_MBMINMAXLEN(mbminlen,mbmaxlen); mbminlen=DA...
Definition: data0type.h:517
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:2536
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:1515
id_name_t name
name of the column
Definition: dict0mem.h:722
Data structure for newly added virtual column in a table.
Definition: dict0mem.h:662
int64_t ib_time_monotonic_t
Time stamp read from the monotonic clock (returned by ut_time_monotonic()).
Definition: ut0ut.h:89
dict_index_t * referenced_index
referenced index
Definition: dict0mem.h:1318
Used in both spatial index and regular index.
Definition: dict0types.h:338
#define DATA_GEOMETRY_MTYPE(mtype)
Definition: data0type.h:262
bool dict_foreign_set_validate(const dict_foreign_set &fk_set)
Validate the search order in the foreign key set.
Definition: dict0mem.cc:771
void dict_table_mutex_destroy(dict_table_t *table)
Destroy the mutex of a given table.
Definition: dict0mem.h:2495
Data structure for a foreign key constraint; an example: FOREIGN KEY (A, B) REFERENCES TABLE2 (C...
Definition: dict0mem.h:1287
The search info struct in an index.
Definition: btr0sea.h:233
unsigned ind
table column position (starting from 0)
Definition: dict0mem.h:504
the index is complete and ready for access
Definition: dict0mem.h:1261
byte * value
Default value in bytes.
Definition: dict0mem.h:456
Some persistent metadata is now dirty in memory, need to be written back to DDTableBuffer table and(o...
Definition: dict0mem.h:1502
ib_quiesce_t
Quiescing states for flushing tables to disk.
Definition: dict0types.h:294
#define DICT_TF_BITS
Width of all the currently known table flags.
Definition: dict0mem.h:183
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:343
ulong zip_failure_threshold_pct
Percentage of compression failures that are allowed in a single round.
Definition: dict0dict.cc:177
void write(W *w, const T &t, const char *key, size_t key_sz)
Definition: sdi_impl.h:333
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:323
Container of persisters used in the system.
Definition: dict0mem.h:2425
unsigned prtype
precise type; MySQL data type, charset code, flags to indicate nullability, signedness, whether this is a binary string, whether this is a true VARCHAR where MySQL uses 2 bytes to store the length
Definition: dict0mem.h:475
#define DICT_CORRUPT
bit to store the corrupted flag \ in SYS_INDEXES.TYPE
Definition: dict0mem.h:93
Data structure for a column in a table.
Definition: dict0mem.h:465
#define DATA_MBMAXLEN(mbminmaxlen)
Definition: data0type.h:255
Definition: row0mysql.h:479
All persistent metadata are up to date.
Definition: dict0mem.h:1509
Query graph global types.
Full text search header file.
The two-way list base node.
Definition: ut0lst.h:71
SQL identifier name wrapper for pretty-printing.
Definition: dict0mem.h:417
bool is_clustered() const
Definition: dict0mem.h:1082
secondary index creation was aborted and the index should be dropped as soon as index->table->n_ref_c...
Definition: dict0mem.h:1270
Persistent Metadata type for corrupted indexes.
Definition: dict0mem.h:2220
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:543
unsigned mtype
main data type
Definition: data0type.h:505
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:530
#define DICT_INDEX_MAGIC_N
Value of dict_index_t::magic_n.
Definition: dict0mem.h:961
Only used in spatial index.
Definition: dict0types.h:341
#define DICT_MULTI_VALUE
Definition: dict0mem.h:108
Globally unique index identifier.
Definition: dict0types.h:220
#define DATA_MBMAX
Definition: data0type.h:236
The index tree general types.
int page
Definition: ctype-mb.cc:1234
Data dictionary global types.
dict_vcol_set * v_cols
set of virtual columns affected by foreign key constraint.
Definition: dict0mem.h:1320
char * pos
Definition: do_ctype.cc:76
Memory primitives.
unsigned type
index type (DICT_CLUSTERED, DICT_UNIQUE, DICT_IBUF, DICT_CORRUPT)
Definition: dict0mem.h:893
Compare two dict_foreign_t objects using their ids.
Definition: dict0mem.h:1339
UNIV_INLINE ulint dtype_get_max_size_low(ulint mtype, ulint len)
Returns the maximum size of a data type.
#define UT_DELETE(ptr)
Destroy, deallocate and trace the deallocation of an object created by UT_NEW() or UT_NEW_NOKEY()...
Definition: ut0new.h:1023
Table name wrapper for pretty-printing.
Definition: dict0mem.h:446
static std::mutex lock
Definition: net_ns.cc:55
bool is_multi_value() const
Check if a column is a multi-value virtual column.
Definition: dict0mem.h:530
#define mutex_free(M)
Definition: ut0mutex.h:124
byte rec_t
Definition: rem0types.h:39
void for_each(const Shards< COUNT > &shards, Function &&f) noexcept
Iterate over the shards.
Definition: ut0counter.h:305
void dict_table_mutex_create_lazy(dict_table_t *table)
Request for lazy creation of the mutex of a given table.
Definition: dict0mem.h:2486
The destructor will free all the foreign key constraints in the set by calling dict_foreign_free() on...
Definition: dict0mem.h:1413
ib_mutex_t * autoinc_mutex
Mutex protecting the autoincrement counter.
Definition: dict0mem.h:1909
The read-write lock (for threads, not for database transactions)
#define DATA_MULTI_VALUE
Definition: data0type.h:223
#define DICT_CLUSTERED
Type flags of an index: OR&#39;ing of the flags is allowed to define a combination of types...
Definition: dict0mem.h:85
void * hash_node_t
Definition: innodb_config.h:42
dict_foreign_t * dict_mem_foreign_create(void)
Creates and initializes a foreign constraint memory object.
Definition: dict0mem.cc:351
A class that aids executing a given function exactly once in a multi-threaded environment.
A table lock.
Definition: lock0priv.h:51
Row operation global types.
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:871
Data structure for a field in an index.
Definition: dict0mem.h:718
Instrumented memory allocator.
id_name_t()
Default constructor.
Definition: dict0mem.h:420
#define DICT_TABLE_MAGIC_N
Value of &#39;magic_n&#39;.
Definition: dict0mem.h:2005
void dict_table_autoinc_destroy(dict_table_t *table)
Destroy the autoinc latch of the given table.
Definition: dict0mem.h:2508
struct Parser parser
case opt name
Definition: sslopt-case.h:32
char * id
id of the constraint as a null-terminated string
Definition: dict0mem.h:1290
#define ut_a(EXPR)
Abort execution if EXPR does not evaluate to nonzero.
Definition: ut0dbg.h:53
unsigned long long Object_id
Definition: object_id.h:30
The biggest type, which should be 1 bigger than the last true type.
Definition: dict0mem.h:2233
UNIV_INLINE ulint dtype_get_fixed_size_low(ulint mtype, ulint prtype, ulint len, ulint mbminmaxlen, ulint comp)
Returns the size of a fixed size data type, 0 if not a fixed size type.
Definition: gis0type.h:151
Utilities for byte operations.
#define DICT_TF2_INTRINSIC
Intrinsic table bit Intrinsic table is table created internally by MySQL modules viz.
Definition: dict0mem.h:279
Transaction system global type definitions.
The smallest type, which should be 1 less than the first true type.
Definition: dict0mem.h:2217
const string version("\ersion\)
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:473
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:215
Definition: data0type.h:497
Persistent Metadata type for autoinc counter.
Definition: dict0mem.h:2223
#define DICT_TF2_BITS
Table Flags set number 2.
Definition: dict0mem.h:251
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:2526
dict_table_t * referenced_table
table where the referenced key is
Definition: dict0mem.h:1309
Function object to check if a foreign key object is there in the given foreign key set or not...
Definition: dict0mem.h:1375
bool operator!=(const unexpected< E1 > &a, const unexpected< E2 > &b)
Definition: expected.h:1060
Definition: plugin_ftparser.h:211
A function object to find a foreign key with the given index as the referenced index.
Definition: dict0mem.h:1347
dict_foreign_set referenced_set
Definition: dict0mem.h:1762
dict_table_t * foreign_table
table where the foreign key is
Definition: dict0mem.h:1303
#define DICT_IT_BITS
number of bits used for \ SYS_INDEXES.TYPE
Definition: dict0mem.h:110
int n
Definition: xcom_base.c:425
The memory management.
uint32 space_id_t
Tablespace identifier.
Definition: api0api.h:59
Structure defines template related to virtual columns and their base columns.
Definition: dict0mem.h:1462
const string metadata("\etadata\)
#define DATA_VIRTUAL
Definition: data0type.h:222
#define DATA_MBMINMAXLEN(mbminlen, mbmaxlen)
Definition: data0type.h:248
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:65
Persister used for autoinc counters.
Definition: dict0mem.h:2385
Page size descriptor.
Definition: page0size.h:49
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:144
#define UT_LIST_BASE_NODE_T(TYPE)
Definition: innodb_utility.h:47
#define mtr_commit(m)
Commit a mini-transaction.
Definition: mtr0mtr.h:59
Definition: dict0mem.h:1326
ib_id_t space_index_t
Index identifier (unique within a tablespace).
Definition: dict0types.h:217
void lock_table_lock_list_init(table_lock_list_t *locks)
Initialise the table lock list.
#define DATA_MBMINLEN(mbminmaxlen)
Definition: data0type.h:252
UNIV_INLINE void mem_heap_free(mem_heap_t *heap)
Frees the space occupied by a memory heap.
#define DATA_SYS
Definition: data0type.h:74
ib_mutex_t * autoinc_persisted_mutex
Mutex protecting the persisted autoincrement counter.
Definition: dict0mem.h:1915
void dict_foreign_free(dict_foreign_t *foreign)
Frees a foreign key struct.
Definition: dict0mem.h:1399
Data structure for a virtual column in a table.
Definition: dict0mem.h:642
Cache position of last inserted or selected record by caching record and holding reference to the blo...
Definition: dict0mem.h:833
Data structure for a stored column in a table.
Definition: dict0mem.h:674
void dict_mem_referenced_table_name_lookup_set(dict_foreign_t *foreign, ibool do_alloc)
Sets the referenced_table_name_lookup pointer based on the value of lower_case_table_names.
Definition: dict0mem.cc:398
#define mutex_exit(M)
Definition: ut0mutex.h:122
Persister used for corrupted indexes.
Definition: dict0mem.h:2349
zip_pad_info_t zip_pad
Information about state of compression failures and successes.
Definition: dict0mem.h:1032
Interface for persistent dynamic table metadata.
Definition: dict0mem.h:2305
Random numbers and hashing.
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:639
const char * m_name
The name in internal representation.
Definition: dict0mem.h:442
volatile os_once::state_t mutex_created
Creation state of mutex.
Definition: dict0mem.h:1556
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:1490
mem_heap_t * heap
this object is allocated from this memory heap
Definition: dict0mem.h:1288
#define DATA_ITT_N_SYS_COLS
Definition: data0type.h:190
void dict_mem_init(void)
Initialize dict memory variables.
Definition: dict0mem.cc:756
The state of the FTS sub system.
Definition: fts0fts.h:362
const string value("\alue\)
If key is fixed length key then cache the record offsets on first computation.
Definition: dict0mem.h:795
The version of the current data dictionary table definitions.
Definition: dictionary_client.h:39
const char * operator()() const
Explicit type conversion.
Definition: dict0mem.h:438
Red black tree instance.
Definition: ut0rbt.h:74
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:2429
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:1282
static double cached
Definition: xcom_statistics.c:97
#define mutex_own(M)
Checks that the current thread owns the mutex.
Definition: ut0mutex.h:156
A function object to add the foreign key constraint to the referenced set of the referenced table...
Definition: dict0mem.h:2472
static int flags[50]
Definition: hp_test1.cc:39
The simple hash table utility.
unsigned char byte
Blob class.
Definition: common.h:159
static const state_t DONE
Finished execution.
Definition: os0once.h:75
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:169
Definition: dict0mem.h:1360
The database buffer pool high-level routines.
#define DICT_TF2_TEMPORARY
TEMPORARY; TRUE for tables from CREATE TEMPORARY TABLE.
Definition: dict0mem.h:256
bool get_field(MEM_ROOT *mem, Field *field, String *res)
Allocate string field in MEM_ROOT and return it as String.
Definition: table.cc:3525
Data structure for default value of a column in a table.
Definition: dict0mem.h:452
bool is_compressed() const
Check if the underlying table is compressed.
Definition: dict0mem.h:2207
#define DATA_N_SYS_COLS
Definition: data0type.h:188
#define UT_LIST_NODE_T(TYPE)
Definition: innodb_utility.h:40
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
uint64_t uint64
Definition: my_inttypes.h:68
bool is_compressed() const
Check if the table is compressed.
Definition: dict0mem.h:1523
Data structure to hold information about about how much space in an uncompressed page should be left ...
Definition: dict0mem.h:777
void dict_index_zip_pad_unlock(dict_index_t *index)
Release the zip_pad_mutex of a given index.
Definition: dict0mem.h:2556
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:160
void dict_mem_index_free(dict_index_t *index)
Frees an index memory object.
Definition: dict0mem.cc:690
UNIV_INLINE int ut_strcmp(const char *str1, const char *str2)
Wrapper for strcmp(3).
id_name_t & operator=(const char *name)
Assignment operator.
Definition: dict0mem.h:427
Dialog Client Authentication nullptr
Definition: dialog.cc:353
std::vector< index_id_t, ut_allocator< index_id_t > > corrupted_ids_t
Definition: dict0mem.h:2236
the online index creation was aborted, the index was dropped from the data dictionary and the tablesp...
Definition: dict0mem.h:1275
the index is being created, online (allowing concurrent modifications)
Definition: dict0mem.h:1264
spatial_status_t
whether a col is used in spatial index or regular index Note: the spatial status is part of persisten...
Definition: dict0types.h:330
const char * table_name
Definition: rules_table_service.cc:55
online_index_status
The status of online index creation.
Definition: dict0mem.h:1259
Data structure for an index.
Definition: dict0mem.h:879