1/*****************************************************************************
2
3Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
4Copyright (c) 2013, 2017, MariaDB Corporation.
5
6This program is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free Software
8Foundation; version 2 of the License.
9
10This program is distributed in the hope that it will be useful, but WITHOUT
11ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15this program; if not, write to the Free Software Foundation, Inc.,
1651 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
17
18*****************************************************************************/
19
20/**************************************************//**
21@file include/dict0types.h
22Data dictionary global types
23
24Created 1/8/1996 Heikki Tuuri
25*******************************************************/
26
27#ifndef dict0types_h
28#define dict0types_h
29
30#include <ut0mutex.h>
31#include <rem0types.h>
32
33struct dict_sys_t;
34struct dict_col_t;
35struct dict_field_t;
36struct dict_index_t;
37struct dict_table_t;
38struct dict_foreign_t;
39struct dict_v_col_t;
40
41struct ind_node_t;
42struct tab_node_t;
43struct dict_add_v_col_t;
44
45/* Space id and page no where the dictionary header resides */
46#define DICT_HDR_SPACE 0 /* the SYSTEM tablespace */
47#define DICT_HDR_PAGE_NO FSP_DICT_HDR_PAGE_NO
48
49/* The ibuf table and indexes's ID are assigned as the number
50DICT_IBUF_ID_MIN plus the space id */
51#define DICT_IBUF_ID_MIN 0xFFFFFFFF00000000ULL
52
53typedef ib_id_t table_id_t;
54typedef ib_id_t index_id_t;
55
56/** Maximum transaction identifier */
57#define TRX_ID_MAX IB_ID_MAX
58
59/** The bit pattern corresponding to TRX_ID_MAX */
60extern const byte trx_id_max_bytes[8];
61extern const byte timestamp_max_bytes[7];
62
63/** Error to ignore when we load table dictionary into memory. However,
64the table and index will be marked as "corrupted", and caller will
65be responsible to deal with corrupted table or index.
66Note: please define the IGNORE_ERR_* as bits, so their value can
67be or-ed together */
68enum dict_err_ignore_t {
69 DICT_ERR_IGNORE_NONE = 0, /*!< no error to ignore */
70 DICT_ERR_IGNORE_INDEX_ROOT = 1, /*!< ignore error if index root
71 page is FIL_NULL or incorrect value */
72 DICT_ERR_IGNORE_CORRUPT = 2, /*!< skip corrupted indexes */
73 DICT_ERR_IGNORE_FK_NOKEY = 4, /*!< ignore error if any foreign
74 key is missing */
75 DICT_ERR_IGNORE_RECOVER_LOCK = 8,
76 /*!< Used when recovering table locks
77 for resurrected transactions.
78 Silently load a missing
79 tablespace, and do not load
80 incomplete index definitions. */
81 DICT_ERR_IGNORE_ALL = 0xFFFF /*!< ignore all errors */
82};
83
84/** Quiescing states for flushing tables to disk. */
85enum ib_quiesce_t {
86 QUIESCE_NONE,
87 QUIESCE_START, /*!< Initialise, prepare to start */
88 QUIESCE_COMPLETE /*!< All done */
89};
90
91#ifndef UNIV_INNOCHECKSUM
92typedef ib_mutex_t DictSysMutex;
93#endif /* !UNIV_INNOCHECKSUM */
94
95/** Prefix for tmp tables, adopted from sql/table.h */
96#define TEMP_FILE_PREFIX "#sql"
97#define TEMP_FILE_PREFIX_LENGTH 4
98#define TEMP_FILE_PREFIX_INNODB "#sql-ib"
99
100#define TEMP_TABLE_PREFIX "#sql"
101#define TEMP_TABLE_PATH_PREFIX "/" TEMP_TABLE_PREFIX
102
103/** Table name wrapper for pretty-printing */
104struct table_name_t
105{
106 /** The name in internal representation */
107 char* m_name;
108
109 /** @return the end of the schema name */
110 const char* dbend() const
111 {
112 const char* sep = strchr(m_name, '/');
113 ut_ad(sep);
114 return sep;
115 }
116
117 /** @return the length of the schema name, in bytes */
118 size_t dblen() const { return size_t(dbend() - m_name); }
119
120 /** Determine the filename-safe encoded table name.
121 @return the filename-safe encoded table name */
122 const char* basename() const { return dbend() + 1; }
123
124 /** The start of the table basename suffix for partitioned tables */
125 static const char part_suffix[4];
126
127 /** Determine the partition or subpartition name suffix.
128 @return the partition name
129 @retval NULL if the table is not partitioned */
130 const char* part() const { return strstr(basename(), part_suffix); }
131};
132
133#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
134/** Flag to control insert buffer debugging. */
135extern uint ibuf_debug;
136#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
137
138/** Shift for spatial status */
139#define SPATIAL_STATUS_SHIFT 12
140
141/** Mask to encode/decode spatial status. */
142#define SPATIAL_STATUS_MASK (3U << SPATIAL_STATUS_SHIFT)
143
144#if SPATIAL_STATUS_MASK < REC_VERSION_56_MAX_INDEX_COL_LEN
145# error SPATIAL_STATUS_MASK < REC_VERSION_56_MAX_INDEX_COL_LEN
146#endif
147
148/** whether a col is used in spatial index or regular index
149Note: the spatial status is part of persistent undo log,
150so we should not modify the values in MySQL 5.7 */
151enum spatial_status_t {
152 /* Unkown status (undo format in 5.7.9) */
153 SPATIAL_UNKNOWN = 0,
154
155 /** Not used in gis index. */
156 SPATIAL_NONE = 1,
157
158 /** Used in both spatial index and regular index. */
159 SPATIAL_MIXED = 2,
160
161 /** Only used in spatial index. */
162 SPATIAL_ONLY = 3
163};
164
165#endif
166