00001 /****************************************************** 00002 Database object creation 00003 00004 (c) 1996 Innobase Oy 00005 00006 Created 1/8/1996 Heikki Tuuri 00007 *******************************************************/ 00008 00009 #ifndef dict0crea_h 00010 #define dict0crea_h 00011 00012 #include "univ.i" 00013 #include "dict0types.h" 00014 #include "dict0dict.h" 00015 #include "que0types.h" 00016 #include "row0types.h" 00017 #include "mtr0mtr.h" 00018 00019 /************************************************************************* 00020 Creates a table create graph. */ 00021 00022 tab_node_t* 00023 tab_create_graph_create( 00024 /*====================*/ 00025 /* out, own: table create node */ 00026 dict_table_t* table, /* in: table to create, built as a memory data 00027 structure */ 00028 mem_heap_t* heap); /* in: heap where created */ 00029 /************************************************************************* 00030 Creates an index create graph. */ 00031 00032 ind_node_t* 00033 ind_create_graph_create( 00034 /*====================*/ 00035 /* out, own: index create node */ 00036 dict_index_t* index, /* in: index to create, built as a memory data 00037 structure */ 00038 mem_heap_t* heap); /* in: heap where created */ 00039 /*************************************************************** 00040 Creates a table. This is a high-level function used in SQL execution graphs. */ 00041 00042 que_thr_t* 00043 dict_create_table_step( 00044 /*===================*/ 00045 /* out: query thread to run next or NULL */ 00046 que_thr_t* thr); /* in: query thread */ 00047 /*************************************************************** 00048 Creates an index. This is a high-level function used in SQL execution 00049 graphs. */ 00050 00051 que_thr_t* 00052 dict_create_index_step( 00053 /*===================*/ 00054 /* out: query thread to run next or NULL */ 00055 que_thr_t* thr); /* in: query thread */ 00056 /*********************************************************************** 00057 Truncates the index tree associated with a row in SYS_INDEXES table. */ 00058 00059 ulint 00060 dict_truncate_index_tree( 00061 /*=====================*/ 00062 /* out: new root page number, or 00063 FIL_NULL on failure */ 00064 dict_table_t* table, /* in: the table the index belongs to */ 00065 rec_t* rec, /* in: record in the clustered index of 00066 SYS_INDEXES table */ 00067 mtr_t* mtr); /* in: mtr having the latch 00068 on the record page. The mtr may be 00069 committed and restarted in this call. */ 00070 /*********************************************************************** 00071 Drops the index tree associated with a row in SYS_INDEXES table. */ 00072 00073 void 00074 dict_drop_index_tree( 00075 /*=================*/ 00076 rec_t* rec, /* in: record in the clustered index of SYS_INDEXES 00077 table */ 00078 mtr_t* mtr); /* in: mtr having the latch on the record page */ 00079 /******************************************************************** 00080 Creates the foreign key constraints system tables inside InnoDB 00081 at database creation or database start if they are not found or are 00082 not of the right form. */ 00083 00084 ulint 00085 dict_create_or_check_foreign_constraint_tables(void); 00086 /*================================================*/ 00087 /* out: DB_SUCCESS or error code */ 00088 /************************************************************************ 00089 Adds foreign key definitions to data dictionary tables in the database. We 00090 look at table->foreign_list, and also generate names to constraints that were 00091 not named by the user. A generated constraint has a name of the format 00092 databasename/tablename_ibfk_<number>, where the numbers start from 1, and are 00093 given locally for this table, that is, the number is not global, as in the 00094 old format constraints < 4.0.18 it used to be. */ 00095 00096 ulint 00097 dict_create_add_foreigns_to_dictionary( 00098 /*===================================*/ 00099 /* out: error code or DB_SUCCESS */ 00100 ulint start_id,/* in: if we are actually doing ALTER TABLE 00101 ADD CONSTRAINT, we want to generate constraint 00102 numbers which are bigger than in the table so 00103 far; we number the constraints from 00104 start_id + 1 up; start_id should be set to 0 if 00105 we are creating a new table, or if the table 00106 so far has no constraints for which the name 00107 was generated here */ 00108 dict_table_t* table, /* in: table */ 00109 trx_t* trx); /* in: transaction */ 00110 00111 00112 /* Table create node structure */ 00113 00114 struct tab_node_struct{ 00115 que_common_t common; /* node type: QUE_NODE_TABLE_CREATE */ 00116 dict_table_t* table; /* table to create, built as a memory data 00117 structure with dict_mem_... functions */ 00118 ins_node_t* tab_def; /* child node which does the insert of 00119 the table definition; the row to be inserted 00120 is built by the parent node */ 00121 ins_node_t* col_def; /* child node which does the inserts of 00122 the column definitions; the row to be inserted 00123 is built by the parent node */ 00124 commit_node_t* commit_node; 00125 /* child node which performs a commit after 00126 a successful table creation */ 00127 /*----------------------*/ 00128 /* Local storage for this graph node */ 00129 ulint state; /* node execution state */ 00130 ulint col_no; /* next column definition to insert */ 00131 mem_heap_t* heap; /* memory heap used as auxiliary storage */ 00132 }; 00133 00134 /* Table create node states */ 00135 #define TABLE_BUILD_TABLE_DEF 1 00136 #define TABLE_BUILD_COL_DEF 2 00137 #define TABLE_COMMIT_WORK 3 00138 #define TABLE_ADD_TO_CACHE 4 00139 #define TABLE_COMPLETED 5 00140 00141 /* Index create node struct */ 00142 00143 struct ind_node_struct{ 00144 que_common_t common; /* node type: QUE_NODE_INDEX_CREATE */ 00145 dict_index_t* index; /* index to create, built as a memory data 00146 structure with dict_mem_... functions */ 00147 ins_node_t* ind_def; /* child node which does the insert of 00148 the index definition; the row to be inserted 00149 is built by the parent node */ 00150 ins_node_t* field_def; /* child node which does the inserts of 00151 the field definitions; the row to be inserted 00152 is built by the parent node */ 00153 commit_node_t* commit_node; 00154 /* child node which performs a commit after 00155 a successful index creation */ 00156 /*----------------------*/ 00157 /* Local storage for this graph node */ 00158 ulint state; /* node execution state */ 00159 ulint page_no;/* root page number of the index */ 00160 dict_table_t* table; /* table which owns the index */ 00161 dtuple_t* ind_row;/* index definition row built */ 00162 ulint field_no;/* next field definition to insert */ 00163 mem_heap_t* heap; /* memory heap used as auxiliary storage */ 00164 }; 00165 00166 /* Index create node states */ 00167 #define INDEX_BUILD_INDEX_DEF 1 00168 #define INDEX_BUILD_FIELD_DEF 2 00169 #define INDEX_CREATE_INDEX_TREE 3 00170 #define INDEX_COMMIT_WORK 4 00171 #define INDEX_ADD_TO_CACHE 5 00172 00173 #ifndef UNIV_NONINL 00174 #include "dict0crea.ic" 00175 #endif 00176 00177 #endif
1.4.7

