MySQL 8.0.31
Source Code Documentation
dict0crea.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 1996, 2022, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is also distributed with certain software (including but not
10limited to OpenSSL) that is licensed under separate terms, as designated in a
11particular file or component or in included license documentation. The authors
12of MySQL hereby grant you an additional permission to link the program and
13your derivative works with the separately licensed software that they have
14included with MySQL.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
25*****************************************************************************/
26
27/** @file include/dict0crea.h
28 Database object creation
29
30 Created 1/8/1996 Heikki Tuuri
31 *******************************************************/
32
33#ifndef dict0crea_h
34#define dict0crea_h
35
36#include "dict0dict.h"
37#include "dict0types.h"
38#include "fsp0space.h"
39#include "mtr0mtr.h"
40#include "que0types.h"
41#include "row0types.h"
42#include "sql/handler.h"
43#include "univ.i"
44
45/** Build a table definition without updating SYSTEM TABLES
46@param[in,out] table dict table object
47@param[in] create_info HA_CREATE_INFO object
48@param[in,out] trx transaction instance
49@return DB_SUCCESS or error code */
51 const HA_CREATE_INFO *create_info, trx_t *trx);
52
53/** Builds a tablespace to store various objects.
54@param[in,out] trx DD transaction
55@param[in,out] tablespace Tablespace object describing what to build.
56@return DB_SUCCESS or error code. */
58
59/** Builds a tablespace to contain a table, using file-per-table=1.
60@param[in,out] table Table to build in its own tablespace.
61@param[in] create_info HA_CREATE_INFO object
62@param[in,out] trx Transaction
63@return DB_SUCCESS or error code */
65 const HA_CREATE_INFO *create_info,
66 trx_t *trx);
67
68/** Assign a new table ID and put it into the table cache and the transaction.
69@param[in,out] table Table that needs an ID */
71
72/** Builds an index definition but doesn't update sys_table. */
73void dict_build_index_def(const dict_table_t *table, /*!< in: table */
74 dict_index_t *index, /*!< in/out: index */
75 trx_t *trx); /*!< in/out: InnoDB transaction
76 handle */
77/** Creates an index tree for the index if it is not a member of a cluster.
78 @param[in,out] index InnoDB index object
79 @param[in,out] trx transaction
80 @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */
82
83/** Drop an index tree belonging to a temporary table.
84@param[in] index index in a temporary table
85@param[in] root_page_no index root page number */
87 page_no_t root_page_no);
88
89/** Generate a foreign key constraint name when it was not named by the user.
90A generated constraint has a name of the format dbname/tablename_ibfk_NUMBER,
91where the numbers start from 1, and are given locally for this table, that is,
92the number is not global, as it used to be before MySQL 4.0.18.
93@param[in,out] id_nr number to use in id generation; incremented if used
94@param[in] name table name
95@param[in,out] foreign foreign key */
96static inline dberr_t dict_create_add_foreign_id(ulint *id_nr, const char *name,
97 dict_foreign_t *foreign);
98
99/** Check if a foreign constraint is on columns served as base columns
100of any stored column. This is to prevent creating SET NULL or CASCADE
101constraint on such columns
102@param[in] local_fk_set set of foreign key objects, to be added to
103the dictionary tables
104@param[in] table table to which the foreign key objects in
105local_fk_set belong to
106@return true if yes, otherwise, false */
107bool dict_foreigns_has_s_base_col(const dict_foreign_set &local_fk_set,
108 const dict_table_t *table);
109
110/* Table create node structure */
112 que_common_t common; /*!< node type: QUE_NODE_TABLE_CREATE */
113 dict_table_t *table; /*!< table to create, built as a
114 memory data structure with
115 dict_mem_... functions */
116 ins_node_t *tab_def; /*!< child node which does the insert of
117 the table definition; the row to be
118 inserted is built by the parent node */
119 ins_node_t *col_def; /*!< child node which does the inserts
120 of the column definitions; the row to
121 be inserted is built by the parent
122 node */
123 ins_node_t *v_col_def; /*!< child node which does the inserts
124 of the sys_virtual row definitions;
125 the row to be inserted is built by
126 the parent node */
127 /*----------------------*/
128 /* Local storage for this graph node */
129 ulint state; /*!< node execution state */
130 ulint col_no; /*!< next column definition to insert */
131 ulint base_col_no; /*!< next base column to insert */
132 mem_heap_t *heap; /*!< memory heap used as auxiliary
133 storage */
134};
135
136/** Create in-memory tablespace dictionary index & table
137@param[in] space tablespace id
138@param[in] space_discarded true if space is discarded
139@param[in] in_flags space flags to use when space_discarded is true
140@param[in] is_create true when creating SDI index
141@return in-memory index structure for tablespace dictionary or NULL */
142dict_index_t *dict_sdi_create_idx_in_mem(space_id_t space, bool space_discarded,
143 uint32_t in_flags, bool is_create);
144
145/* Index create node struct */
146
148 que_common_t common; /*!< node type: QUE_NODE_INDEX_CREATE */
149 dict_index_t *index; /*!< index to create, built as a
150 memory data structure with
151 dict_mem_... functions */
152 ins_node_t *ind_def; /*!< child node which does the insert of
153 the index definition; the row to be
154 inserted is built by the parent node */
155 ins_node_t *field_def; /*!< child node which does the inserts
156 of the field definitions; the row to
157 be inserted is built by the parent
158 node */
159 /*----------------------*/
160 /* Local storage for this graph node */
161 ulint state; /*!< node execution state */
162 ulint page_no; /* root page number of the index */
163 dict_table_t *table; /*!< table which owns the index */
164 dtuple_t *ind_row; /* index definition row built */
165 ulint field_no; /* next field definition to insert */
166 mem_heap_t *heap; /*!< memory heap used as auxiliary
167 storage */
168 const dict_add_v_col_t *add_v; /*!< new virtual columns that being
169 added along with an add index call */
170};
171
172/** Compose a column number for a virtual column, stored in the "POS" field
173of Sys_columns. The column number includes both its virtual column sequence
174(the "nth" virtual column) and its actual column position in original table
175@param[in] v_pos virtual column sequence
176@param[in] col_pos column position in original table definition
177@return composed column position number */
178static inline ulint dict_create_v_col_pos(ulint v_pos, ulint col_pos);
179
180/** Get the column number for a virtual column (the column position in
181original table), stored in the "POS" field of Sys_columns
182@param[in] pos virtual column position
183@return column position in original table */
185
186/** Get a virtual column sequence (the "nth" virtual column) for a
187virtual column, stord in the "POS" field of Sys_columns
188@param[in] pos virtual column position
189@return virtual column sequence */
191
192#include "dict0crea.ic"
193
194#endif
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:50
uint32_t page_no_t
Page number.
Definition: api0api.h:48
Data structure that contains the information about shared tablespaces.
Definition: fsp0space.h:46
dberr_t
Definition: db0err.h:38
dberr_t dict_build_tablespace(trx_t *trx, Tablespace *tablespace)
Builds a tablespace to store various objects.
Definition: dict0crea.cc:94
dict_index_t * dict_sdi_create_idx_in_mem(space_id_t space, bool space_discarded, uint32_t in_flags, bool is_create)
Create in-memory tablespace dictionary index & table.
Definition: dict0crea.cc:651
void dict_drop_temporary_table_index(const dict_index_t *index, page_no_t root_page_no)
Drop an index tree belonging to a temporary table.
Definition: dict0crea.cc:452
static ulint dict_get_v_col_pos(ulint pos)
Get a virtual column sequence (the "nth" virtual column) for a virtual column, stord in the "POS" fie...
void dict_table_assign_new_id(dict_table_t *table)
Assign a new table ID and put it into the table cache and the transaction.
Definition: dict0crea.cc:634
static ulint dict_create_v_col_pos(ulint v_pos, ulint col_pos)
Compose a column number for a virtual column, stored in the "POS" field of Sys_columns.
static dberr_t dict_create_add_foreign_id(ulint *id_nr, const char *name, dict_foreign_t *foreign)
Generate a foreign key constraint name when it was not named by the user.
dberr_t dict_create_index_tree_in_mem(dict_index_t *index, trx_t *trx)
Creates an index tree for the index if it is not a member of a cluster.
Definition: dict0crea.cc:389
bool dict_foreigns_has_s_base_col(const dict_foreign_set &local_fk_set, const dict_table_t *table)
Check if a foreign constraint is on columns served as base columns of any stored column.
Definition: dict0crea.cc:570
dberr_t dict_build_table_def(dict_table_t *table, const HA_CREATE_INFO *create_info, trx_t *trx)
Build a table definition without updating SYSTEM TABLES.
Definition: dict0crea.cc:61
void dict_build_index_def(const dict_table_t *table, dict_index_t *index, trx_t *trx)
Builds an index definition but doesn't update sys_table.
Definition: dict0crea.cc:350
dberr_t dict_build_tablespace_for_table(dict_table_t *table, const HA_CREATE_INFO *create_info, trx_t *trx)
Builds a tablespace to contain a table, using file-per-table=1.
Definition: dict0crea.cc:178
static ulint dict_get_v_col_mysql_pos(ulint pos)
Get the column number for a virtual column (the column position in original table),...
Database object creation.
Data dictionary system.
std::set< dict_foreign_t *, dict_foreign_compare, ut::allocator< dict_foreign_t * > > dict_foreign_set
Definition: dict0mem.h:1722
Data dictionary global types.
char * pos
Definition: do_ctype.cc:76
General shared tablespace implementation.
Mini-transaction buffer.
Query graph global types.
Row operation global types.
case opt name
Definition: sslopt-case.h:32
Definition: handler.h:2987
Data structure for newly added virtual column in a table.
Definition: dict0mem.h:810
Data structure for a foreign key constraint; an example: FOREIGN KEY (A, B) REFERENCES TABLE2 (C,...
Definition: dict0mem.h:1641
Data structure for an index.
Definition: dict0mem.h:1021
Data structure for a database table.
Definition: dict0mem.h:1884
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:681
Definition: dict0crea.h:147
const dict_add_v_col_t * add_v
new virtual columns that being added along with an add index call
Definition: dict0crea.h:168
ulint page_no
Definition: dict0crea.h:162
ulint field_no
Definition: dict0crea.h:165
mem_heap_t * heap
memory heap used as auxiliary storage
Definition: dict0crea.h:166
ins_node_t * field_def
child node which does the inserts of the field definitions; the row to be inserted is built by the pa...
Definition: dict0crea.h:155
ulint state
node execution state
Definition: dict0crea.h:161
que_common_t common
node type: QUE_NODE_INDEX_CREATE
Definition: dict0crea.h:148
dict_index_t * index
index to create, built as a memory data structure with dict_mem_... functions
Definition: dict0crea.h:149
ins_node_t * ind_def
child node which does the insert of the index definition; the row to be inserted is built by the pare...
Definition: dict0crea.h:152
dtuple_t * ind_row
Definition: dict0crea.h:164
dict_table_t * table
table which owns the index
Definition: dict0crea.h:163
Definition: row0ins.h:161
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:299
Definition: que0types.h:50
Definition: dict0crea.h:111
ins_node_t * col_def
child node which does the inserts of the column definitions; the row to be inserted is built by the p...
Definition: dict0crea.h:119
que_common_t common
node type: QUE_NODE_TABLE_CREATE
Definition: dict0crea.h:112
ulint state
node execution state
Definition: dict0crea.h:129
ulint base_col_no
next base column to insert
Definition: dict0crea.h:131
dict_table_t * table
table to create, built as a memory data structure with dict_mem_... functions
Definition: dict0crea.h:113
ulint col_no
next column definition to insert
Definition: dict0crea.h:130
ins_node_t * tab_def
child node which does the insert of the table definition; the row to be inserted is built by the pare...
Definition: dict0crea.h:116
ins_node_t * v_col_def
child node which does the inserts of the sys_virtual row definitions; the row to be inserted is built...
Definition: dict0crea.h:123
mem_heap_t * heap
memory heap used as auxiliary storage
Definition: dict0crea.h:132
Definition: trx0trx.h:680
Version control for database, common definitions, and include files.
unsigned long int ulint
Definition: univ.i:407