1
/******************************************************
2
Database object creation
6
Created 1/8/1996 Heikki Tuuri
7
*******************************************************/
13
#include "dict0types.h"
14
#include "dict0dict.h"
15
#include "que0types.h"
16
#include "row0types.h"
19
/*************************************************************************
20
Creates a table create graph. */
23
tab_create_graph_create(
24
/*====================*/
25
/* out, own: table create node */
26
dict_table_t* table, /* in: table to create, built as a memory data
28
mem_heap_t* heap); /* in: heap where created */
29
/*************************************************************************
30
Creates an index create graph. */
33
ind_create_graph_create(
34
/*====================*/
35
/* out, own: index create node */
36
dict_index_t* index, /* in: index to create, built as a memory data
38
mem_heap_t* heap); /* in: heap where created */
39
/***************************************************************
40
Creates a table. This is a high-level function used in SQL execution graphs. */
43
dict_create_table_step(
44
/*===================*/
45
/* out: query thread to run next or NULL */
46
que_thr_t* thr); /* in: query thread */
47
/***************************************************************
48
Creates an index. This is a high-level function used in SQL execution
52
dict_create_index_step(
53
/*===================*/
54
/* out: query thread to run next or NULL */
55
que_thr_t* thr); /* in: query thread */
56
/***********************************************************************
57
Truncates the index tree associated with a row in SYS_INDEXES table. */
60
dict_truncate_index_tree(
61
/*=====================*/
62
/* out: new root page number, or
63
FIL_NULL on failure */
64
dict_table_t* table, /* in: the table the index belongs to */
65
ulint space, /* in: 0=truncate,
66
nonzero=create the index tree in the
68
btr_pcur_t* pcur, /* in/out: persistent cursor pointing to
69
record in the clustered index of
70
SYS_INDEXES table. The cursor may be
71
repositioned in this call. */
72
mtr_t* mtr); /* in: mtr having the latch
73
on the record page. The mtr may be
74
committed and restarted in this call. */
75
/***********************************************************************
76
Drops the index tree associated with a row in SYS_INDEXES table. */
81
rec_t* rec, /* in/out: record in the clustered index
82
of SYS_INDEXES table */
83
mtr_t* mtr); /* in: mtr having the latch on the record page */
84
#ifndef UNIV_HOTBACKUP
85
/********************************************************************
86
Creates the foreign key constraints system tables inside InnoDB
87
at database creation or database start if they are not found or are
88
not of the right form. */
91
dict_create_or_check_foreign_constraint_tables(void);
92
/*================================================*/
93
/* out: DB_SUCCESS or error code */
94
/************************************************************************
95
Adds foreign key definitions to data dictionary tables in the database. We
96
look at table->foreign_list, and also generate names to constraints that were
97
not named by the user. A generated constraint has a name of the format
98
databasename/tablename_ibfk_<number>, where the numbers start from 1, and are
99
given locally for this table, that is, the number is not global, as in the
100
old format constraints < 4.0.18 it used to be. */
103
dict_create_add_foreigns_to_dictionary(
104
/*===================================*/
105
/* out: error code or DB_SUCCESS */
106
ulint start_id,/* in: if we are actually doing ALTER TABLE
107
ADD CONSTRAINT, we want to generate constraint
108
numbers which are bigger than in the table so
109
far; we number the constraints from
110
start_id + 1 up; start_id should be set to 0 if
111
we are creating a new table, or if the table
112
so far has no constraints for which the name
113
was generated here */
114
dict_table_t* table, /* in: table */
115
trx_t* trx); /* in: transaction */
116
#endif /* !UNIV_HOTBACKUP */
118
/* Table create node structure */
120
struct tab_node_struct{
121
que_common_t common; /* node type: QUE_NODE_TABLE_CREATE */
122
dict_table_t* table; /* table to create, built as a memory data
123
structure with dict_mem_... functions */
124
ins_node_t* tab_def; /* child node which does the insert of
125
the table definition; the row to be inserted
126
is built by the parent node */
127
ins_node_t* col_def; /* child node which does the inserts of
128
the column definitions; the row to be inserted
129
is built by the parent node */
130
commit_node_t* commit_node;
131
/* child node which performs a commit after
132
a successful table creation */
133
/*----------------------*/
134
/* Local storage for this graph node */
135
ulint state; /* node execution state */
136
ulint col_no; /* next column definition to insert */
137
mem_heap_t* heap; /* memory heap used as auxiliary storage */
140
/* Table create node states */
141
#define TABLE_BUILD_TABLE_DEF 1
142
#define TABLE_BUILD_COL_DEF 2
143
#define TABLE_COMMIT_WORK 3
144
#define TABLE_ADD_TO_CACHE 4
145
#define TABLE_COMPLETED 5
147
/* Index create node struct */
149
struct ind_node_struct{
150
que_common_t common; /* node type: QUE_NODE_INDEX_CREATE */
151
dict_index_t* index; /* index to create, built as a memory data
152
structure with dict_mem_... functions */
153
ins_node_t* ind_def; /* child node which does the insert of
154
the index definition; the row to be inserted
155
is built by the parent node */
156
ins_node_t* field_def; /* child node which does the inserts of
157
the field definitions; the row to be inserted
158
is built by the parent node */
159
commit_node_t* commit_node;
160
/* child node which performs a commit after
161
a successful index creation */
162
/*----------------------*/
163
/* Local storage for this graph node */
164
ulint state; /* node execution state */
165
ulint page_no;/* root page number of the index */
166
dict_table_t* table; /* table which owns the index */
167
dtuple_t* ind_row;/* index definition row built */
168
ulint field_no;/* next field definition to insert */
169
mem_heap_t* heap; /* memory heap used as auxiliary storage */
172
/* Index create node states */
173
#define INDEX_BUILD_INDEX_DEF 1
174
#define INDEX_BUILD_FIELD_DEF 2
175
#define INDEX_CREATE_INDEX_TREE 3
176
#define INDEX_COMMIT_WORK 4
177
#define INDEX_ADD_TO_CACHE 5
180
#include "dict0crea.ic"