#include "univ.i"
#include "dict0types.h"
#include "ut0byte.h"
#include "mem0mem.h"
#include "btr0types.h"
Go to the source code of this file.
Typedefs | |
typedef enum dict_system_table_id | dict_system_id_t |
typedef enum dict_table_info | dict_table_info_t |
typedef void(* | dict_print_callback )(void *ptr, const char *) |
Enumerations | |
enum | dict_system_table_id { SYS_TABLES = 0, SYS_INDEXES, SYS_COLUMNS, SYS_FIELDS, SYS_FOREIGN, SYS_FOREIGN_COLS, SYS_NUM_SYSTEM_TABLES } |
enum | dict_table_info { DICT_TABLE_LOAD_FROM_RECORD = 0, DICT_TABLE_LOAD_FROM_CACHE = 1, DICT_TABLE_UPDATE_STATS = 2 } |
Functions | |
UNIV_INTERN void | dict_check_tablespaces_and_store_max_id (ibool in_crash_recovery) |
UNIV_INTERN char * | dict_get_first_table_name_in_db (const char *name) |
UNIV_INTERN const char * | dict_load_table_low (const char *name, const rec_t *rec, dict_table_t **table) |
UNIV_INTERN const char * | dict_load_column_low (dict_table_t *table, mem_heap_t *heap, dict_col_t *column, table_id_t *table_id, const char **col_name, const rec_t *rec) |
UNIV_INTERN const char * | dict_load_index_low (byte *table_id, const char *table_name, mem_heap_t *heap, const rec_t *rec, ibool allocate, dict_index_t **index) |
UNIV_INTERN const char * | dict_load_field_low (byte *index_id, dict_index_t *index, dict_field_t *sys_field, ulint *pos, byte *last_index_id, mem_heap_t *heap, const rec_t *rec) |
UNIV_INTERN dict_table_t * | dict_load_table (const char *name, ibool cached) |
UNIV_INTERN dict_table_t * | dict_load_table_on_id (table_id_t table_id) |
UNIV_INTERN void | dict_load_sys_table (dict_table_t *table) |
UNIV_INTERN ulint | dict_load_foreigns (const char *table_name, ibool check_recursive, ibool check_charsets) |
UNIV_INTERN void | dict_print (void) |
UNIV_INTERN void | dict_print_with_callback (dict_print_callback, void *) |
UNIV_INTERN const rec_t * | dict_startscan_system (btr_pcur_t *pcur, mtr_t *mtr, dict_system_id_t system_id) |
UNIV_INTERN const rec_t * | dict_getnext_system (btr_pcur_t *pcur, mtr_t *mtr) |
UNIV_INTERN const char * | dict_process_sys_tables_rec (mem_heap_t *heap, const rec_t *rec, dict_table_t **table, dict_table_info_t status) |
UNIV_INTERN const char * | dict_process_sys_indexes_rec (mem_heap_t *heap, const rec_t *rec, dict_index_t *index, table_id_t *table_id) |
UNIV_INTERN const char * | dict_process_sys_columns_rec (mem_heap_t *heap, const rec_t *rec, dict_col_t *column, table_id_t *table_id, const char **col_name) |
UNIV_INTERN const char * | dict_process_sys_fields_rec (mem_heap_t *heap, const rec_t *rec, dict_field_t *sys_field, ulint *pos, index_id_t *index_id, index_id_t last_id) |
UNIV_INTERN const char * | dict_process_sys_foreign_rec (mem_heap_t *heap, const rec_t *rec, dict_foreign_t *foreign) |
UNIV_INTERN const char * | dict_process_sys_foreign_col_rec (mem_heap_t *heap, const rec_t *rec, const char **name, const char **for_col_name, const char **ref_col_name, ulint *pos) |
Loads to the memory cache database object definitions from dictionary tables
Created 4/24/1996 Heikki Tuuri
Definition in file dict0load.h.
enum dict_system_table_id |
enum that defines all 6 system table IDs
Definition at line 38 of file dict0load.h.
enum dict_table_info |
Status bit for dict_process_sys_tables_rec()
Definition at line 53 of file dict0load.h.
UNIV_INTERN void dict_check_tablespaces_and_store_max_id | ( | ibool | in_crash_recovery) |
In a crash recovery we already have all the tablespace objects created. This function compares the space id information in the InnoDB data dictionary to what we already read with fil_load_single_table_tablespaces().
In a normal startup, we create the tablespace objects for every table in InnoDB's data dictionary, if the corresponding .ibd file exists. We also scan the biggest space id, and store it to fil_system. in: are we doing a crash recovery
In a crash recovery we already have all the tablespace objects created. This function compares the space id information in the InnoDB data dictionary to what we already read with fil_load_single_table_tablespaces().
In a normal startup, we create the tablespace objects for every table in InnoDB's data dictionary, if the corresponding .ibd file exists. We also scan the biggest space id, and store it to fil_system.
in_crash_recovery | in: are we doing a crash recovery |
Definition at line 723 of file dict0load.cc.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), btr_pcur_open_at_index_side(), BTR_SEARCH_LEAF, dict_table_get_low(), dict_table_is_comp(), DICT_TF2_TEMPORARY, dict_table_struct::indexes, mach_read_from_4(), mem_free, mem_strdupl(), MLOG_4BYTES, mtr_commit(), mtr_read_ulint(), mtr_start(), dict_sys_struct::mutex, rec_get_deleted_flag(), ut_a, UT_LIST_GET_FIRST, ut_print_filename(), and ut_print_timestamp().
UNIV_INTERN char* dict_get_first_table_name_in_db | ( | const char * | name) |
Finds the first table name in the given database.
Finds the first table name in the given database.
name | in: database name which ends in '/' |
Definition at line 83 of file dict0load.cc.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), BTR_SEARCH_LEAF, dfield_set_data(), dict_table_get_low(), dict_table_is_comp(), dtuple_create(), dict_table_struct::indexes, mem_heap_create, mem_heap_free, mem_strdupl(), mtr_commit(), mtr_start(), dict_sys_struct::mutex, rec_get_deleted_flag(), ut_a, ut_ad, UT_LIST_GET_FIRST, ut_memcmp(), and ut_strlen().
UNIV_INTERN const rec_t* dict_getnext_system | ( | btr_pcur_t * | pcur, |
mtr_t * | mtr | ||
) |
This function get the next system table record as we scan the table.
This function gets the next system table record as it scans the table.
pcur | in/out: persistent cursor to the record |
mtr | in: the mini-transaction |
Definition at line 289 of file dict0load.cc.
References BTR_SEARCH_LEAF.
UNIV_INTERN const char* dict_load_column_low | ( | dict_table_t * | table, |
mem_heap_t * | heap, | ||
dict_col_t * | column, | ||
table_id_t * | table_id, | ||
const char ** | col_name, | ||
const rec_t * | rec | ||
) |
Loads a table column definition from a SYS_COLUMNS record to dict_table_t.
Loads a table column definition from a SYS_COLUMNS record to dict_table_t.
table | in/out: table, could be NULL if we just populate a dict_column_t struct with information from a SYS_COLUMNS record |
heap | in/out: memory heap for temporary storage |
column | out: dict_column_t to fill, or NULL if table != NULL |
table_id | out: table id |
col_name | out: column name |
rec | in: SYS_COLUMNS record |
Definition at line 866 of file dict0load.cc.
References dtype_get_charset_coll(), dict_table_struct::id, mach_read_from_4(), mach_read_from_8(), mem_heap_strdupl(), dict_table_struct::n_def, rec_get_deleted_flag(), rec_get_n_fields_old(), rec_get_nth_field_offs_old(), and ut_ad.
UNIV_INTERN const char* dict_load_field_low | ( | byte * | index_id, |
dict_index_t * | index, | ||
dict_field_t * | sys_field, | ||
ulint * | pos, | ||
byte * | last_index_id, | ||
mem_heap_t * | heap, | ||
const rec_t * | rec | ||
) |
Loads an index field definition from a SYS_FIELDS record to dict_index_t.
Loads an index field definition from a SYS_FIELDS record to dict_index_t.
index_id | in/out: index id (8 bytes) an "in" value if index != NULL and "out" if index == NULL |
index | in/out: index, could be NULL if we just populate a dict_field_t struct with information from a SYS_FIELDSS record |
sys_field | out: dict_field_t to be filled |
pos | out: Field position |
last_index_id | in: last index id |
heap | in/out: memory heap for temporary storage |
rec | in: SYS_FIELDS record |
Definition at line 1070 of file dict0load.cc.
References mach_read_from_4(), mem_heap_strdupl(), dict_index_struct::n_def, dict_field_struct::name, dict_field_struct::prefix_len, rec_get_deleted_flag(), rec_get_n_fields_old(), rec_get_nth_field_offs_old(), and ut_a.
UNIV_INTERN ulint dict_load_foreigns | ( | const char * | table_name, |
ibool | check_recursive, | ||
ibool | check_charsets | ||
) |
Loads foreign key constraints where the table is either the foreign key holder or where the table is referenced by a foreign key. Adds these constraints to the data dictionary. Note that we know that the dictionary cache already contains all constraints where the other relevant table is already in the dictionary cache.
Loads foreign key constraints where the table is either the foreign key holder or where the table is referenced by a foreign key. Adds these constraints to the data dictionary. Note that we know that the dictionary cache already contains all constraints where the other relevant table is already in the dictionary cache.
table_name | in: table name |
check_recursive | in: Whether to check recursive load of tables chained by FK |
check_charsets | in: TRUE=check charset compatibility |
Definition at line 2223 of file dict0load.cc.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), BTR_SEARCH_LEAF, cmp_data_data(), dfield_get_len(), dfield_set_data(), dict_table_get_low(), dict_table_is_comp(), dtuple_create(), mem_heap_create, mem_heap_free, mem_heap_strdupl(), mtr_commit(), mtr_start(), dict_sys_struct::mutex, rec_get_deleted_flag(), ut_a, ut_ad, ut_memcmp(), and ut_strlen().
UNIV_INTERN const char* dict_load_index_low | ( | byte * | table_id, |
const char * | table_name, | ||
mem_heap_t * | heap, | ||
const rec_t * | rec, | ||
ibool | allocate, | ||
dict_index_t ** | index | ||
) |
Loads an index definition from a SYS_INDEXES record to dict_index_t. If allocate=TRUE, we will create a dict_index_t structure and fill it accordingly. If allocated=FALSE, the dict_index_t will be supplied by the caller and filled with information read from the record.
Loads an index definition from a SYS_INDEXES record to dict_index_t. If allocate=TRUE, we will create a dict_index_t structure and fill it accordingly. If allocated=FALSE, the dict_index_t will be supplied by the caller and filled with information read from the record.
table_id | in/out: table id (8 bytes), an "in" value if allocate=TRUE and "out" when allocate=FALSE |
table_name | in: table name |
heap | in/out: temporary memory heap |
rec | in: SYS_INDEXES record |
allocate | in: TRUE=allocate *index, FALSE=fill in a pre-allocated *index |
index | out,own: index, or NULL |
Definition at line 1268 of file dict0load.cc.
References dict_mem_fill_index_struct(), mach_read_from_4(), mach_read_from_8(), mem_heap_strdupl(), rec_get_deleted_flag(), rec_get_n_fields_old(), rec_get_nth_field_offs_old(), ut_a, and ut_ad.
UNIV_INTERN void dict_load_sys_table | ( | dict_table_t * | table) |
This function is called when the database is booted. Loads system table index definitions except for the clustered index which is added to the dictionary cache at booting before calling this function. in: system table
This function is called when the database is booted. Loads system table index definitions except for the clustered index which is added to the dictionary cache at booting before calling this function.
table | in: system table |
Definition at line 1953 of file dict0load.cc.
References mem_heap_create, mem_heap_free, dict_sys_struct::mutex, and ut_ad.
UNIV_INTERN dict_table_t* dict_load_table | ( | const char * | name, |
ibool | cached | ||
) |
Loads a table definition and also all its index definitions, and also the cluster definition if the table is a member in a cluster. Also loads all foreign key constraints where the foreign key is in the table or where a foreign key references columns in this table.
Loads a table definition and also all its index definitions, and also the cluster definition if the table is a member in a cluster. Also loads all foreign key constraints where the foreign key is in the table or where a foreign key references columns in this table. Adds all these to the data dictionary cache.
name | in: table name in the databasename/tablename format |
cached | in: TRUE=add to cache, FALSE=do not |
Definition at line 1684 of file dict0load.cc.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), BTR_SEARCH_LEAF, dfield_set_data(), dict_table_get_low(), dict_table_is_comp(), DICT_TF2_SHIFT, DICT_TF2_TEMPORARY, DICT_TF_BITS, DICT_TF_COMPACT, dtuple_create(), dict_table_struct::fk_max_recusive_level, dict_table_struct::flags, dict_table_struct::ibd_file_missing, dict_table_struct::indexes, mem_heap_create, mem_heap_empty(), mem_heap_free, mtr_commit(), mtr_start(), dict_sys_struct::mutex, dict_table_struct::name, rec_get_deleted_flag(), dict_table_struct::space, ut_a, ut_ad, UT_LIST_GET_FIRST, ut_memcmp(), ut_print_filename(), ut_print_timestamp(), and ut_strlen().
UNIV_INTERN const char* dict_load_table_low | ( | const char * | name, |
const rec_t * | rec, | ||
dict_table_t ** | table | ||
) |
Loads a table definition from a SYS_TABLES record to dict_table_t. Does not load any columns or indexes.
Loads a table definition from a SYS_TABLES record to dict_table_t. Does not load any columns or indexes.
name | in: table name |
rec | in: SYS_TABLES record |
table | out,own: table, or NULL |
Definition at line 1532 of file dict0load.cc.
References DICT_TF2_BITS, DICT_TF2_SHIFT, DICT_TF_COMPACT, mach_read_from_4(), mach_read_from_8(), rec_get_deleted_flag(), rec_get_n_fields_old(), rec_get_nth_field_offs_old(), ut_ad, ut_print_filename(), and ut_print_timestamp().
UNIV_INTERN dict_table_t* dict_load_table_on_id | ( | table_id_t | table_id) |
Loads a table object based on the table id.
Loads a table object based on the table id.
table_id | in: table id |
Definition at line 1861 of file dict0load.cc.
References btr_pcur_close(), btr_pcur_get_rec(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), BTR_SEARCH_LEAF, dfield_set_data(), dict_table_is_comp(), dtuple_create(), mach_read_from_8(), mach_write_to_8(), mem_heap_create, mem_heap_free, mem_heap_strdupl(), mtr_commit(), mtr_start(), dict_sys_struct::mutex, rec_get_deleted_flag(), dict_sys_struct::sys_tables, ut_a, and ut_ad.
UNIV_INTERN void dict_print | ( | void | ) |
Prints to the standard output information on all tables found in the data dictionary system table.
Definition at line 165 of file dict0load.cc.
References DICT_TABLE_LOAD_FROM_CACHE, DICT_TABLE_UPDATE_STATS, mem_heap_create, mem_heap_empty(), mem_heap_free, mtr_commit(), mtr_start(), dict_sys_struct::mutex, and ut_print_timestamp().
UNIV_INTERN const char* dict_process_sys_columns_rec | ( | mem_heap_t * | heap, |
const rec_t * | rec, | ||
dict_col_t * | column, | ||
table_id_t * | table_id, | ||
const char ** | col_name | ||
) |
This function parses a SYS_COLUMNS record and populate a dict_column_t structure with the information from the record.
This function parses a SYS_COLUMNS record and populate a dict_column_t structure with the information from the record.
heap | in/out: heap memory |
rec | in: current SYS_COLUMNS rec |
column | out: dict_col_t to be filled |
table_id | out: table id |
col_name | out: column name |
Definition at line 396 of file dict0load.cc.
UNIV_INTERN const char* dict_process_sys_fields_rec | ( | mem_heap_t * | heap, |
const rec_t * | rec, | ||
dict_field_t * | sys_field, | ||
ulint * | pos, | ||
index_id_t * | index_id, | ||
index_id_t | last_id | ||
) |
This function parses a SYS_FIELDS record and populate a dict_field_t structure with the information from the record.
This function parses a SYS_FIELDS record and populates a dict_field_t structure with the information from the record.
heap | in/out: heap memory |
rec | in: current SYS_FIELDS rec |
sys_field | out: dict_field_t to be filled |
pos | out: Field position |
index_id | out: current index id |
last_id | in: previous index id |
Definition at line 418 of file dict0load.cc.
References mach_read_from_8(), mach_write_to_8(), and mem_heap_alloc().
UNIV_INTERN const char* dict_process_sys_foreign_col_rec | ( | mem_heap_t * | heap, |
const rec_t * | rec, | ||
const char ** | name, | ||
const char ** | for_col_name, | ||
const char ** | ref_col_name, | ||
ulint * | pos | ||
) |
This function parses a SYS_FOREIGN_COLS record and extract necessary information from the record and return to caller.
This function parses a SYS_FOREIGN_COLS record and extract necessary information from the record and return to caller.
heap | in/out: heap memory |
rec | in: current SYS_FOREIGN_COLS rec |
name | out: foreign key constraint name |
for_col_name | out: referencing column name |
ref_col_name | out: referenced column name in referenced table |
pos | out: column position |
Definition at line 518 of file dict0load.cc.
References mach_read_from_4(), mem_heap_strdupl(), rec_get_deleted_flag(), rec_get_n_fields_old(), and rec_get_nth_field_offs_old().
UNIV_INTERN const char* dict_process_sys_foreign_rec | ( | mem_heap_t * | heap, |
const rec_t * | rec, | ||
dict_foreign_t * | foreign | ||
) |
This function parses a SYS_FOREIGN record and populate a dict_foreign_t structure with the information from the record. For detail information about SYS_FOREIGN fields, please refer to dict_load_foreign() function
This function parses a SYS_FOREIGN record and populate a dict_foreign_t structure with the information from the record. For detail information about SYS_FOREIGN fields, please refer to dict_load_foreign() function
heap | in/out: heap memory |
rec | in: current SYS_FOREIGN rec |
foreign | out: dict_foreign_t struct to be filled |
Definition at line 452 of file dict0load.cc.
References dict_foreign_struct::foreign_table_name, dict_foreign_struct::id, mach_read_from_4(), mem_heap_strdupl(), dict_foreign_struct::n_fields, rec_get_deleted_flag(), rec_get_n_fields_old(), rec_get_nth_field_offs_old(), dict_foreign_struct::referenced_table_name, and dict_foreign_struct::type.
UNIV_INTERN const char* dict_process_sys_indexes_rec | ( | mem_heap_t * | heap, |
const rec_t * | rec, | ||
dict_index_t * | index, | ||
table_id_t * | table_id | ||
) |
This function parses a SYS_INDEXES record and populate a dict_index_t structure with the information from the record. For detail information about SYS_INDEXES fields, please refer to dict_boot() function.
This function parses a SYS_INDEXES record and populate a dict_index_t structure with the information from the record. For detail information about SYS_INDEXES fields, please refer to dict_boot() function.
heap | in/out: heap memory |
rec | in: current SYS_INDEXES rec |
index | out: index to be filled |
table_id | out: index table id |
Definition at line 370 of file dict0load.cc.
References mach_read_from_8(), and mem_heap_alloc().
UNIV_INTERN const char* dict_process_sys_tables_rec | ( | mem_heap_t * | heap, |
const rec_t * | rec, | ||
dict_table_t ** | table, | ||
dict_table_info_t | status | ||
) |
This function processes one SYS_TABLES record and populate the dict_table_t struct for the table. Extracted out of dict_print() to be used by both monitor table output and information schema innodb_sys_tables output.
This function processes one SYS_TABLES record and populate the dict_table_t struct for the table. Extracted out of dict_print() to be used by both monitor table output and information schema innodb_sys_tables output.
heap | in/out: temporary memory heap |
rec | in: SYS_TABLES record |
table | out: dict_table_t to fill |
status | in: status bit controls options such as whether we shall look for dict_table_t from cache first |
Definition at line 312 of file dict0load.cc.
References dict_table_get_low(), DICT_TABLE_LOAD_FROM_CACHE, DICT_TABLE_UPDATE_STATS, mem_heap_strdupl(), rec_get_deleted_flag(), and ut_a.
UNIV_INTERN const rec_t* dict_startscan_system | ( | btr_pcur_t * | pcur, |
mtr_t * | mtr, | ||
dict_system_id_t | system_id | ||
) |
This function opens a system table, and return the first record.
This function opens a system table, and return the first record.
pcur | out: persistent cursor to the record |
mtr | in: the mini-transaction |
system_id | in: which system table to open |
Definition at line 259 of file dict0load.cc.
References btr_pcur_open_at_index_side(), BTR_SEARCH_LEAF, dict_table_get_low(), dict_table_struct::indexes, ut_a, and UT_LIST_GET_FIRST.