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