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
btr_pcur_t* pcur, /* in/out: persistent cursor pointing to
66
record in the clustered index of
67
SYS_INDEXES table. The cursor may be
68
repositioned in this call. */
69
mtr_t* mtr); /* in: mtr having the latch
70
on the record page. The mtr may be
71
committed and restarted in this call. */
72
/***********************************************************************
73
Drops the index tree associated with a row in SYS_INDEXES table. */
78
rec_t* rec, /* in: record in the clustered index of SYS_INDEXES
80
mtr_t* mtr); /* in: mtr having the latch on the record page */
81
/********************************************************************
82
Creates the foreign key constraints system tables inside InnoDB
83
at database creation or database start if they are not found or are
84
not of the right form. */
87
dict_create_or_check_foreign_constraint_tables(void);
88
/*================================================*/
89
/* out: DB_SUCCESS or error code */
90
/************************************************************************
91
Adds foreign key definitions to data dictionary tables in the database. We
92
look at table->foreign_list, and also generate names to constraints that were
93
not named by the user. A generated constraint has a name of the format
94
databasename/tablename_ibfk_<number>, where the numbers start from 1, and are
95
given locally for this table, that is, the number is not global, as in the
96
old format constraints < 4.0.18 it used to be. */
99
dict_create_add_foreigns_to_dictionary(
100
/*===================================*/
101
/* out: error code or DB_SUCCESS */
102
ulint start_id,/* in: if we are actually doing ALTER TABLE
103
ADD CONSTRAINT, we want to generate constraint
104
numbers which are bigger than in the table so
105
far; we number the constraints from
106
start_id + 1 up; start_id should be set to 0 if
107
we are creating a new table, or if the table
108
so far has no constraints for which the name
109
was generated here */
110
dict_table_t* table, /* in: table */
111
trx_t* trx); /* in: transaction */
114
/* Table create node structure */
116
struct tab_node_struct{
117
que_common_t common; /* node type: QUE_NODE_TABLE_CREATE */
118
dict_table_t* table; /* table to create, built as a memory data
119
structure with dict_mem_... functions */
120
ins_node_t* tab_def; /* child node which does the insert of
121
the table definition; the row to be inserted
122
is built by the parent node */
123
ins_node_t* col_def; /* child node which does the inserts of
124
the column definitions; the row to be inserted
125
is built by the parent node */
126
commit_node_t* commit_node;
127
/* child node which performs a commit after
128
a successful table creation */
129
/*----------------------*/
130
/* Local storage for this graph node */
131
ulint state; /* node execution state */
132
ulint col_no; /* next column definition to insert */
133
mem_heap_t* heap; /* memory heap used as auxiliary storage */
136
/* Table create node states */
137
#define TABLE_BUILD_TABLE_DEF 1
138
#define TABLE_BUILD_COL_DEF 2
139
#define TABLE_COMMIT_WORK 3
140
#define TABLE_ADD_TO_CACHE 4
141
#define TABLE_COMPLETED 5
143
/* Index create node struct */
145
struct ind_node_struct{
146
que_common_t common; /* node type: QUE_NODE_INDEX_CREATE */
147
dict_index_t* index; /* index to create, built as a memory data
148
structure with dict_mem_... functions */
149
ins_node_t* ind_def; /* child node which does the insert of
150
the index definition; the row to be inserted
151
is built by the parent node */
152
ins_node_t* field_def; /* child node which does the inserts of
153
the field definitions; the row to be inserted
154
is built by the parent node */
155
commit_node_t* commit_node;
156
/* child node which performs a commit after
157
a successful index creation */
158
/*----------------------*/
159
/* Local storage for this graph node */
160
ulint state; /* node execution state */
161
ulint page_no;/* root page number of the index */
162
dict_table_t* table; /* table which owns the index */
163
dtuple_t* ind_row;/* index definition row built */
164
ulint field_no;/* next field definition to insert */
165
mem_heap_t* heap; /* memory heap used as auxiliary storage */
168
/* Index create node states */
169
#define INDEX_BUILD_INDEX_DEF 1
170
#define INDEX_BUILD_FIELD_DEF 2
171
#define INDEX_CREATE_INDEX_TREE 3
172
#define INDEX_COMMIT_WORK 4
173
#define INDEX_ADD_TO_CACHE 5
176
#include "dict0crea.ic"