📄 dict0dict.ic
字号:
/**********************************************************************Data dictionary system(c) 1996 Innobase OyCreated 1/8/1996 Heikki Tuuri***********************************************************************/#include "dict0load.h"#include "trx0undo.h"#include "trx0sys.h"/*************************************************************************Gets the column data type. */UNIV_INLINEdtype_t*dict_col_get_type(/*==============*/ dict_col_t* col){ ut_ad(col); return(&col->type);}/*************************************************************************Gets the column number. */UNIV_INLINEulintdict_col_get_no(/*============*/ dict_col_t* col){ ut_ad(col); return(col->ind);}/*************************************************************************Gets the column position in the clustered index. */UNIV_INLINEulintdict_col_get_clust_pos(/*===================*/ dict_col_t* col){ ut_ad(col); return(col->clust_pos);}/************************************************************************Gets the first index on the table (the clustered index). */UNIV_INLINEdict_index_t*dict_table_get_first_index(/*=======================*/ /* out: index, NULL if none exists */ dict_table_t* table) /* in: table */{ ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); return(UT_LIST_GET_FIRST(table->indexes));}/************************************************************************Gets the next index on the table. */UNIV_INLINEdict_index_t*dict_table_get_next_index(/*======================*/ /* out: index, NULL if none left */ dict_index_t* index) /* in: index */{ ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); return(UT_LIST_GET_NEXT(indexes, index));}/************************************************************************Gets the number of user-defined columns in a table in the dictionarycache. */UNIV_INLINEulintdict_table_get_n_user_cols(/*=======================*/ /* out: number of user-defined (e.g., not ROW_ID) columns of a table */ dict_table_t* table) /* in: table */{ ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(table->cached); return(table->n_cols - DATA_N_SYS_COLS);}/************************************************************************Gets the number of system columns in a table in the dictionary cache. */UNIV_INLINEulintdict_table_get_n_sys_cols(/*======================*/ /* out: number of system (e.g., ROW_ID) columns of a table */ dict_table_t* table __attribute__((unused))) /* in: table */{ ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(table->cached); return(DATA_N_SYS_COLS);}/************************************************************************Gets the number of all columns (also system) in a table in the dictionarycache. */UNIV_INLINEulintdict_table_get_n_cols(/*==================*/ /* out: number of columns of a table */ dict_table_t* table) /* in: table */{ ut_ad(table); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); ut_ad(table->cached); return(table->n_cols);}/************************************************************************Gets the nth column of a table. */UNIV_INLINEdict_col_t*dict_table_get_nth_col(/*===================*/ /* out: pointer to column object */ dict_table_t* table, /* in: table */ ulint pos) /* in: position of column */{ ut_ad(table); ut_ad(pos < table->n_def); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); return((table->cols) + pos);}/************************************************************************Gets the given system column of a table. */UNIV_INLINEdict_col_t*dict_table_get_sys_col(/*===================*/ /* out: pointer to column object */ dict_table_t* table, /* in: table */ ulint sys) /* in: DATA_ROW_ID, ... */{ dict_col_t* col; ut_ad(table); ut_ad(sys < DATA_N_SYS_COLS); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); col = dict_table_get_nth_col(table, table->n_cols - DATA_N_SYS_COLS + sys); ut_ad(col->type.mtype == DATA_SYS); ut_ad(col->type.prtype == (sys | DATA_NOT_NULL)); return(col);}/************************************************************************Gets the given system column number of a table. */UNIV_INLINEulintdict_table_get_sys_col_no(/*======================*/ /* out: column number */ dict_table_t* table, /* in: table */ ulint sys) /* in: DATA_ROW_ID, ... */{ ut_ad(table); ut_ad(sys < DATA_N_SYS_COLS); ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); return(table->n_cols - DATA_N_SYS_COLS + sys);}/************************************************************************Gets the number of fields in the internal representation of an index,including fields added by the dictionary system. */UNIV_INLINEulintdict_index_get_n_fields(/*====================*/ /* out: number of fields */ dict_index_t* index) /* in: an internal representation of index (in the dictionary cache) */{ ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); return(index->n_fields);}/************************************************************************Gets the number of fields in the internal representation of an indexthat uniquely determine the position of an index entry in the index, ifwe do not take multiversioning into account: in the B-tree use the valuereturned by dict_index_get_n_unique_in_tree. */UNIV_INLINEulintdict_index_get_n_unique(/*====================*/ /* out: number of fields */ dict_index_t* index) /* in: an internal representation of index (in the dictionary cache) */{ ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); ut_ad(index->cached); return(index->n_uniq);}/************************************************************************Gets the number of fields in the internal representation of an indexwhich uniquely determine the position of an index entry in the index, ifwe also take multiversioning into account. */UNIV_INLINEulintdict_index_get_n_unique_in_tree(/*============================*/ /* out: number of fields */ dict_index_t* index) /* in: an internal representation of index (in the dictionary cache) */{ ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); ut_ad(index->cached); if (index->type & DICT_CLUSTERED) { return(dict_index_get_n_unique(index)); } return(dict_index_get_n_fields(index));}/************************************************************************Gets the number of user-defined ordering fields in the index. In the internalrepresentation of clustered indexes we add the row id to the ordering fieldsto make a clustered index unique, but this function returns the number offields the user defined in the index as ordering fields. */UNIV_INLINEulintdict_index_get_n_ordering_defined_by_user(/*======================================*/ /* out: number of fields */ dict_index_t* index) /* in: an internal representation of index (in the dictionary cache) */{ return(index->n_user_defined_cols);}/************************************************************************Gets the nth field of an index. */UNIV_INLINEdict_field_t*dict_index_get_nth_field(/*=====================*/ /* out: pointer to field object */ dict_index_t* index, /* in: index */ ulint pos) /* in: position of field */{ ut_ad(index); ut_ad(pos < index->n_def); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); return((index->fields) + pos);}/************************************************************************Returns the position of a system column in an index. */UNIV_INLINEulintdict_index_get_sys_col_pos(/*=======================*/ /* out: position, ULINT_UNDEFINED if not contained */ dict_index_t* index, /* in: index */ ulint type) /* in: DATA_ROW_ID, ... */{ dict_col_t* col; ut_ad(index); ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); ut_ad(!(index->type & DICT_UNIVERSAL)); col = dict_table_get_sys_col(index->table, type); if (index->type & DICT_CLUSTERED) { return(col->clust_pos); } return(dict_index_get_nth_col_pos(index, dict_table_get_sys_col_no(index->table, type)));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -