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