#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, dict_err_ignore_t ignore_err) |
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 734 of file dict0load.cc.
References btr_pcur_close(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), btr_pcur_open_at_index_side(), btr_pcur_store_position(), BTR_SEARCH_LEAF, dict_hdr_get(), dict_sys, dict_table_get_low(), dict_table_is_comp(), DICT_TF2_TEMPORARY, fil_open_single_table_tablespace(), fil_set_max_space_id_if_bigger(), fil_space_for_table_exists_in_mem(), 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().
Referenced by innobase_start_or_create_for_mysql().
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 84 of file dict0load.cc.
References btr_pcur_close(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), BTR_SEARCH_LEAF, dfield_set_data(), dict_index_copy_types(), dict_sys, 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().
Referenced by row_drop_database_for_mysql().
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 290 of file dict0load.cc.
References BTR_SEARCH_LEAF.
Referenced by dict_print().
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 877 of file dict0load.cc.
References dict_mem_fill_column_struct(), dict_mem_table_add_col(), dtype_form_prtype(), dtype_get_charset_coll(), dtype_is_binary_string_type(), dtype_is_string_type(), 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.
Referenced by dict_process_sys_columns_rec().
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 1081 of file dict0load.cc.
References dict_mem_index_add_field(), 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.
Referenced by dict_process_sys_fields_rec().
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 2257 of file dict0load.cc.
References btr_pcur_close(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), btr_pcur_store_position(), BTR_SEARCH_LEAF, cmp_data_data(), dfield_get_len(), dfield_set_data(), dict_index_copy_types(), dict_sys, 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().
Referenced by dict_load_table(), row_merge_rename_tables(), row_rename_table_for_mysql(), and row_table_add_foreign_constraints().
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 1279 of file dict0load.cc.
References dict_mem_fill_index_struct(), dict_mem_index_create(), 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.
Referenced by dict_process_sys_indexes_rec().
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 1984 of file dict0load.cc.
References DICT_ERR_IGNORE_NONE, dict_sys, mem_heap_create, mem_heap_free, dict_sys_struct::mutex, and ut_ad.
Referenced by dict_boot().
UNIV_INTERN dict_table_t* dict_load_table | ( | const char * | name, |
ibool | cached, | ||
dict_err_ignore_t | ignore_err | ||
) |
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 |
ignore_err | in: error to be ignored when loading table and its indexes' definition |
Definition at line 1710 of file dict0load.cc.
References btr_pcur_close(), btr_pcur_is_on_user_rec(), BTR_SEARCH_LEAF, dfield_set_data(), dict_index_copy_types(), dict_load_foreigns(), dict_load_table_low(), dict_sys, dict_table_add_system_columns(), dict_table_add_to_cache(), dict_table_get_low(), dict_table_is_comp(), dict_table_remove_from_cache(), DICT_TF2_SHIFT, DICT_TF2_TEMPORARY, DICT_TF_BITS, DICT_TF_COMPACT, dtuple_create(), fil_open_single_table_tablespace(), fil_space_for_table_exists_in_mem(), 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().
Referenced by dict_load_table_on_id(), row_drop_table_for_mysql(), and row_mysql_drop_temp_tables().
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 1558 of file dict0load.cc.
References dict_mem_table_create(), 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().
Referenced by dict_load_table(), and dict_process_sys_tables_rec().
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 1890 of file dict0load.cc.
References btr_pcur_close(), btr_pcur_is_on_user_rec(), btr_pcur_move_to_next_user_rec(), BTR_SEARCH_LEAF, dfield_set_data(), DICT_ERR_IGNORE_NONE, dict_index_copy_types(), dict_load_table(), dict_sys, 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 166 of file dict0load.cc.
References dict_getnext_system(), dict_process_sys_tables_rec(), dict_startscan_system(), dict_sys, DICT_TABLE_LOAD_FROM_CACHE, dict_table_print_low(), 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().
Referenced by srv_monitor_thread().
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 397 of file dict0load.cc.
References dict_load_column_low().
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 419 of file dict0load.cc.
References dict_load_field_low(), 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 529 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 454 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 371 of file dict0load.cc.
References dict_load_index_low(), 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 313 of file dict0load.cc.
References dict_load_table_low(), dict_table_get_low(), DICT_TABLE_LOAD_FROM_CACHE, DICT_TABLE_UPDATE_STATS, dict_update_statistics(), mem_heap_strdupl(), rec_get_deleted_flag(), and ut_a.
Referenced by dict_print().
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 260 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.
Referenced by dict_print().