diff options
Diffstat (limited to 'storage/xtradb/dict/dict0crea.c')
-rw-r--r-- | storage/xtradb/dict/dict0crea.c | 228 |
1 files changed, 112 insertions, 116 deletions
diff --git a/storage/xtradb/dict/dict0crea.c b/storage/xtradb/dict/dict0crea.c index 01d092005c3..f548d89bc68 100644 --- a/storage/xtradb/dict/dict0crea.c +++ b/storage/xtradb/dict/dict0crea.c @@ -16,7 +16,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA *****************************************************************************/ -/****************************************************** +/**************************************************//** +@file dict/dict0crea.c Database object creation Created 1/8/1996 Heikki Tuuri @@ -42,16 +43,16 @@ Created 1/8/1996 Heikki Tuuri #include "usr0sess.h" #include "ut0vec.h" -/********************************************************************* +/*****************************************************************//** Based on a table object, this function builds the entry to be inserted -in the SYS_TABLES system table. */ +in the SYS_TABLES system table. +@return the tuple which should be inserted */ static dtuple_t* dict_create_sys_tables_tuple( /*=========================*/ - /* out: the tuple which should be inserted */ - dict_table_t* table, /* in: table */ - mem_heap_t* heap) /* in: memory heap from which the memory for + dict_table_t* table, /*!< in: table */ + mem_heap_t* heap) /*!< in: memory heap from which the memory for the built tuple is allocated */ { dict_table_t* sys_tables; @@ -134,17 +135,17 @@ dict_create_sys_tables_tuple( return(entry); } -/********************************************************************* +/*****************************************************************//** Based on a table object, this function builds the entry to be inserted -in the SYS_COLUMNS system table. */ +in the SYS_COLUMNS system table. +@return the tuple which should be inserted */ static dtuple_t* dict_create_sys_columns_tuple( /*==========================*/ - /* out: the tuple which should be inserted */ - dict_table_t* table, /* in: table */ - ulint i, /* in: column number */ - mem_heap_t* heap) /* in: memory heap from which the memory for + dict_table_t* table, /*!< in: table */ + ulint i, /*!< in: column number */ + mem_heap_t* heap) /*!< in: memory heap from which the memory for the built tuple is allocated */ { dict_table_t* sys_columns; @@ -216,15 +217,15 @@ dict_create_sys_columns_tuple( return(entry); } -/******************************************************************* -Builds a table definition to insert. */ +/***************************************************************//** +Builds a table definition to insert. +@return DB_SUCCESS or error code */ static ulint dict_build_table_def_step( /*======================*/ - /* out: DB_SUCCESS or error code */ - que_thr_t* thr, /* in: query thread */ - tab_node_t* node) /* in: table create node */ + que_thr_t* thr, /*!< in: query thread */ + tab_node_t* node) /*!< in: table create node */ { dict_table_t* table; dtuple_t* row; @@ -295,14 +296,14 @@ dict_build_table_def_step( return(DB_SUCCESS); } -/******************************************************************* -Builds a column definition to insert. */ +/***************************************************************//** +Builds a column definition to insert. +@return DB_SUCCESS */ static ulint dict_build_col_def_step( /*====================*/ - /* out: DB_SUCCESS */ - tab_node_t* node) /* in: table create node */ + tab_node_t* node) /*!< in: table create node */ { dtuple_t* row; @@ -313,16 +314,16 @@ dict_build_col_def_step( return(DB_SUCCESS); } -/********************************************************************* +/*****************************************************************//** Based on an index object, this function builds the entry to be inserted -in the SYS_INDEXES system table. */ +in the SYS_INDEXES system table. +@return the tuple which should be inserted */ static dtuple_t* dict_create_sys_indexes_tuple( /*==========================*/ - /* out: the tuple which should be inserted */ - dict_index_t* index, /* in: index */ - mem_heap_t* heap) /* in: memory heap from which the memory for + dict_index_t* index, /*!< in: index */ + mem_heap_t* heap) /*!< in: memory heap from which the memory for the built tuple is allocated */ { dict_table_t* sys_indexes; @@ -403,17 +404,17 @@ dict_create_sys_indexes_tuple( return(entry); } -/********************************************************************* +/*****************************************************************//** Based on an index object, this function builds the entry to be inserted -in the SYS_FIELDS system table. */ +in the SYS_FIELDS system table. +@return the tuple which should be inserted */ static dtuple_t* dict_create_sys_fields_tuple( /*=========================*/ - /* out: the tuple which should be inserted */ - dict_index_t* index, /* in: index */ - ulint i, /* in: field number */ - mem_heap_t* heap) /* in: memory heap from which the memory for + dict_index_t* index, /*!< in: index */ + ulint i, /*!< in: field number */ + mem_heap_t* heap) /*!< in: memory heap from which the memory for the built tuple is allocated */ { dict_table_t* sys_fields; @@ -479,17 +480,17 @@ dict_create_sys_fields_tuple( return(entry); } -/********************************************************************* +/*****************************************************************//** Creates the tuple with which the index entry is searched for writing the index -tree root page number, if such a tree is created. */ +tree root page number, if such a tree is created. +@return the tuple for search */ static dtuple_t* dict_create_search_tuple( /*=====================*/ - /* out: the tuple for search */ - const dtuple_t* tuple, /* in: the tuple inserted in the SYS_INDEXES + const dtuple_t* tuple, /*!< in: the tuple inserted in the SYS_INDEXES table */ - mem_heap_t* heap) /* in: memory heap from which the memory for + mem_heap_t* heap) /*!< in: memory heap from which the memory for the built tuple is allocated */ { dtuple_t* search_tuple; @@ -515,15 +516,15 @@ dict_create_search_tuple( return(search_tuple); } -/******************************************************************* -Builds an index definition row to insert. */ +/***************************************************************//** +Builds an index definition row to insert. +@return DB_SUCCESS or error code */ static ulint dict_build_index_def_step( /*======================*/ - /* out: DB_SUCCESS or error code */ - que_thr_t* thr, /* in: query thread */ - ind_node_t* node) /* in: index create node */ + que_thr_t* thr, /*!< in: query thread */ + ind_node_t* node) /*!< in: index create node */ { dict_table_t* table; dict_index_t* index; @@ -561,22 +562,20 @@ dict_build_index_def_step( ins_node_set_new_row(node->ind_def, row); -#ifdef ROW_MERGE_IS_INDEX_USABLE /* Note that the index was created by this transaction. */ - index->trx_id = trx->id; -#endif /* ROW_MERGE_IS_INDEX_USABLE */ + index->trx_id = (ib_uint64_t) ut_conv_dulint_to_longlong(trx->id); return(DB_SUCCESS); } -/******************************************************************* -Builds a field definition row to insert. */ +/***************************************************************//** +Builds a field definition row to insert. +@return DB_SUCCESS */ static ulint dict_build_field_def_step( /*======================*/ - /* out: DB_SUCCESS */ - ind_node_t* node) /* in: index create node */ + ind_node_t* node) /*!< in: index create node */ { dict_index_t* index; dtuple_t* row; @@ -590,14 +589,14 @@ dict_build_field_def_step( return(DB_SUCCESS); } -/******************************************************************* -Creates an index tree for the index if it is not a member of a cluster. */ +/***************************************************************//** +Creates an index tree for the index if it is not a member of a cluster. +@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ static ulint dict_create_index_tree_step( /*========================*/ - /* out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ - ind_node_t* node) /* in: index create node */ + ind_node_t* node) /*!< in: index create node */ { dict_index_t* index; dict_table_t* sys_indexes; @@ -647,15 +646,15 @@ dict_create_index_tree_step( return(DB_SUCCESS); } -/*********************************************************************** +/*******************************************************************//** Drops the index tree associated with a row in SYS_INDEXES table. */ UNIV_INTERN void dict_drop_index_tree( /*=================*/ - rec_t* rec, /* in/out: record in the clustered index + rec_t* rec, /*!< in/out: record in the clustered index of SYS_INDEXES table */ - mtr_t* mtr) /* in: mtr having the latch on the record page */ + mtr_t* mtr) /*!< in: mtr having the latch on the record page */ { ulint root_page_no; ulint space; @@ -710,23 +709,22 @@ dict_drop_index_tree( FIL_NULL, mtr); } -/*********************************************************************** -Truncates the index tree associated with a row in SYS_INDEXES table. */ +/*******************************************************************//** +Truncates the index tree associated with a row in SYS_INDEXES table. +@return new root page number, or FIL_NULL on failure */ UNIV_INTERN ulint dict_truncate_index_tree( /*=====================*/ - /* out: new root page number, or - FIL_NULL on failure */ - dict_table_t* table, /* in: the table the index belongs to */ - ulint space, /* in: 0=truncate, + dict_table_t* table, /*!< in: the table the index belongs to */ + ulint space, /*!< in: 0=truncate, nonzero=create the index tree in the given tablespace */ - btr_pcur_t* pcur, /* in/out: persistent cursor pointing to + btr_pcur_t* pcur, /*!< in/out: persistent cursor pointing to record in the clustered index of SYS_INDEXES table. The cursor may be repositioned in this call. */ - mtr_t* mtr) /* in: mtr having the latch + mtr_t* mtr) /*!< in: mtr having the latch on the record page. The mtr may be committed and restarted in this call. */ { @@ -846,16 +844,16 @@ create: return(FIL_NULL); } -/************************************************************************* -Creates a table create graph. */ +/*********************************************************************//** +Creates a table create graph. +@return own: table create node */ UNIV_INTERN tab_node_t* tab_create_graph_create( /*====================*/ - /* out, own: table create node */ - dict_table_t* table, /* in: table to create, built as a memory data + dict_table_t* table, /*!< in: table to create, built as a memory data structure */ - mem_heap_t* heap) /* in: heap where created */ + mem_heap_t* heap) /*!< in: heap where created */ { tab_node_t* node; @@ -882,16 +880,16 @@ tab_create_graph_create( return(node); } -/************************************************************************* -Creates an index create graph. */ +/*********************************************************************//** +Creates an index create graph. +@return own: index create node */ UNIV_INTERN ind_node_t* ind_create_graph_create( /*====================*/ - /* out, own: index create node */ - dict_index_t* index, /* in: index to create, built as a memory data + dict_index_t* index, /*!< in: index to create, built as a memory data structure */ - mem_heap_t* heap) /* in: heap where created */ + mem_heap_t* heap) /*!< in: heap where created */ { ind_node_t* node; @@ -919,14 +917,14 @@ ind_create_graph_create( return(node); } -/*************************************************************** -Creates a table. This is a high-level function used in SQL execution graphs. */ +/***********************************************************//** +Creates a table. This is a high-level function used in SQL execution graphs. +@return query thread to run next or NULL */ UNIV_INTERN que_thr_t* dict_create_table_step( /*===================*/ - /* out: query thread to run next or NULL */ - que_thr_t* thr) /* in: query thread */ + que_thr_t* thr) /*!< in: query thread */ { tab_node_t* node; ulint err = DB_ERROR; @@ -1025,15 +1023,15 @@ function_exit: return(thr); } -/*************************************************************** +/***********************************************************//** Creates an index. This is a high-level function used in SQL execution -graphs. */ +graphs. +@return query thread to run next or NULL */ UNIV_INTERN que_thr_t* dict_create_index_step( /*===================*/ - /* out: query thread to run next or NULL */ - que_thr_t* thr) /* in: query thread */ + que_thr_t* thr) /*!< in: query thread */ { ind_node_t* node; ulint err = DB_ERROR; @@ -1156,16 +1154,15 @@ function_exit: return(thr); } -#ifndef UNIV_HOTBACKUP -/******************************************************************** +/****************************************************************//** Creates the foreign key constraints system tables inside InnoDB at database creation or database start if they are not found or are -not of the right form. */ +not of the right form. +@return DB_SUCCESS or error code */ UNIV_INTERN ulint dict_create_or_check_foreign_constraint_tables(void) /*================================================*/ - /* out: DB_SUCCESS or error code */ { dict_table_t* table1; dict_table_t* table2; @@ -1286,18 +1283,18 @@ dict_create_or_check_foreign_constraint_tables(void) return(error); } -/******************************************************************** -Evaluate the given foreign key SQL statement. */ +/****************************************************************//** +Evaluate the given foreign key SQL statement. +@return error code or DB_SUCCESS */ static ulint dict_foreign_eval_sql( /*==================*/ - /* out: error code or DB_SUCCESS */ - pars_info_t* info, /* in: info struct, or NULL */ - const char* sql, /* in: SQL string to evaluate */ - dict_table_t* table, /* in: table */ - dict_foreign_t* foreign,/* in: foreign */ - trx_t* trx) /* in: transaction */ + pars_info_t* info, /*!< in: info struct, or NULL */ + const char* sql, /*!< in: SQL string to evaluate */ + dict_table_t* table, /*!< in: table */ + dict_foreign_t* foreign,/*!< in: foreign */ + trx_t* trx) /*!< in: transaction */ { ulint error; FILE* ef = dict_foreign_err_file; @@ -1351,18 +1348,18 @@ dict_foreign_eval_sql( return(DB_SUCCESS); } -/************************************************************************ +/********************************************************************//** Add a single foreign key field definition to the data dictionary tables in -the database. */ +the database. +@return error code or DB_SUCCESS */ static ulint dict_create_add_foreign_field_to_dictionary( /*========================================*/ - /* out: error code or DB_SUCCESS */ - ulint field_nr, /* in: foreign field number */ - dict_table_t* table, /* in: table */ - dict_foreign_t* foreign, /* in: foreign */ - trx_t* trx) /* in: transaction */ + ulint field_nr, /*!< in: foreign field number */ + dict_table_t* table, /*!< in: table */ + dict_foreign_t* foreign, /*!< in: foreign */ + trx_t* trx) /*!< in: transaction */ { pars_info_t* info = pars_info_create(); @@ -1386,23 +1383,23 @@ dict_create_add_foreign_field_to_dictionary( table, foreign, trx)); } -/************************************************************************ +/********************************************************************//** Add a single foreign key definition to the data dictionary tables in the database. We also generate names to constraints that were not named by the user. A generated constraint has a name of the format -databasename/tablename_ibfk_<number>, where the numbers start from 1, and +databasename/tablename_ibfk_NUMBER, where the numbers start from 1, and are given locally for this table, that is, the number is not global, as in -the old format constraints < 4.0.18 it used to be. */ +the old format constraints < 4.0.18 it used to be. +@return error code or DB_SUCCESS */ static ulint dict_create_add_foreign_to_dictionary( /*==================================*/ - /* out: error code or DB_SUCCESS */ - ulint* id_nr, /* in/out: number to use in id generation; + ulint* id_nr, /*!< in/out: number to use in id generation; incremented if used */ - dict_table_t* table, /* in: table */ - dict_foreign_t* foreign,/* in: foreign */ - trx_t* trx) /* in: transaction */ + dict_table_t* table, /*!< in: table */ + dict_foreign_t* foreign,/*!< in: foreign */ + trx_t* trx) /*!< in: transaction */ { ulint error; ulint i; @@ -1461,14 +1458,14 @@ dict_create_add_foreign_to_dictionary( return(error); } -/************************************************************************ -Adds foreign key definitions to data dictionary tables in the database. */ +/********************************************************************//** +Adds foreign key definitions to data dictionary tables in the database. +@return error code or DB_SUCCESS */ UNIV_INTERN ulint dict_create_add_foreigns_to_dictionary( /*===================================*/ - /* out: error code or DB_SUCCESS */ - ulint start_id,/* in: if we are actually doing ALTER TABLE + ulint start_id,/*!< in: if we are actually doing ALTER TABLE ADD CONSTRAINT, we want to generate constraint numbers which are bigger than in the table so far; we number the constraints from @@ -1476,8 +1473,8 @@ dict_create_add_foreigns_to_dictionary( we are creating a new table, or if the table so far has no constraints for which the name was generated here */ - dict_table_t* table, /* in: table */ - trx_t* trx) /* in: transaction */ + dict_table_t* table, /*!< in: table */ + trx_t* trx) /*!< in: transaction */ { dict_foreign_t* foreign; ulint number = start_id + 1; @@ -1508,4 +1505,3 @@ dict_create_add_foreigns_to_dictionary( return(DB_SUCCESS); } -#endif /* !UNIV_HOTBACKUP */ |