Drizzled Public API Documentation

dict0load.h File Reference
#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_tdict_load_table (const char *name, ibool cached)
UNIV_INTERN dict_table_tdict_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)

Detailed Description

Loads to the memory cache database object definitions from dictionary tables

Created 4/24/1996 Heikki Tuuri

Definition in file dict0load.h.


Enumeration Type Documentation

enum that defines all 6 system table IDs

Definition at line 38 of file dict0load.h.

Status bit for dict_process_sys_tables_rec()

Enumerator:
DICT_TABLE_LOAD_FROM_RECORD 

Directly populate a dict_table_t structure with information from a SYS_TABLES record

DICT_TABLE_LOAD_FROM_CACHE 

Check first whether dict_table_t is in the cache, if so, return it

DICT_TABLE_UPDATE_STATS 

whether to update statistics when loading SYS_TABLES information.

Definition at line 53 of file dict0load.h.


Function Documentation

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.

Parameters:
in_crash_recoveryin: 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.

Returns:
own: table name, NULL if does not exist; the caller must free the memory in the string! in: database name which ends to '/'

Finds the first table name in the given database.

Returns:
own: table name, NULL if does not exist; the caller must free the memory in the string!
Parameters:
namein: 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.

Returns:
the record if found, NULL if end of scan. in: the mini-transaction

This function gets the next system table record as it scans the table.

Returns:
the next record if found, NULL if end of scan
Parameters:
pcurin/out: persistent cursor to the record
mtrin: 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.

Returns:
error message, or NULL on success in: SYS_COLUMNS record

Loads a table column definition from a SYS_COLUMNS record to dict_table_t.

Returns:
error message, or NULL on success
Parameters:
tablein/out: table, could be NULL if we just populate a dict_column_t struct with information from a SYS_COLUMNS record
heapin/out: memory heap for temporary storage
columnout: dict_column_t to fill, or NULL if table != NULL
table_idout: table id
col_nameout: column name
recin: 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.

Returns:
error message, or NULL on success in: SYS_FIELDS record

Loads an index field definition from a SYS_FIELDS record to dict_index_t.

Returns:
error message, or NULL on success
Parameters:
index_idin/out: index id (8 bytes) an "in" value if index != NULL and "out" if index == NULL
indexin/out: index, could be NULL if we just populate a dict_field_t struct with information from a SYS_FIELDSS record
sys_fieldout: dict_field_t to be filled
posout: Field position
last_index_idin: last index id
heapin/out: memory heap for temporary storage
recin: 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.

Returns:
DB_SUCCESS or error code in: TRUE=check charsets compatibility

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.

Returns:
DB_SUCCESS or error code
Parameters:
table_namein: table name
check_recursivein: Whether to check recursive load of tables chained by FK
check_charsetsin: 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.

Returns:
error message, or NULL on success out,own: index, or NULL

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.

Returns:
error message, or NULL on success
Parameters:
table_idin/out: table id (8 bytes), an "in" value if allocate=TRUE and "out" when allocate=FALSE
table_namein: table name
heapin/out: temporary memory heap
recin: SYS_INDEXES record
allocatein: TRUE=allocate *index, FALSE=fill in a pre-allocated *index
indexout,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.

Parameters:
tablein: 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.

Returns:
table, NULL if does not exist; if the table is stored in an .ibd file, but the file does not exist, then we set the ibd_file_missing flag TRUE in the table object we return in: TRUE=add to cache, FALSE=do not

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.

Returns:
table, NULL if does not exist; if the table is stored in an .ibd file, but the file does not exist, then we set the ibd_file_missing flag TRUE in the table object we return
Parameters:
namein: table name in the databasename/tablename format
cachedin: 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.

Returns:
error message, or NULL on success out,own: table, or NULL

Loads a table definition from a SYS_TABLES record to dict_table_t. Does not load any columns or indexes.

Returns:
error message, or NULL on success
Parameters:
namein: table name
recin: SYS_TABLES record
tableout,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.

Returns:
table; NULL if table does not exist in: table id

Loads a table object based on the table id.

Returns:
table; NULL if table does not exist
Parameters:
table_idin: 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.

Returns:
error message, or NULL on success out: column name

This function parses a SYS_COLUMNS record and populate a dict_column_t structure with the information from the record.

Returns:
error message, or NULL on success
Parameters:
heapin/out: heap memory
recin: current SYS_COLUMNS rec
columnout: dict_col_t to be filled
table_idout: table id
col_nameout: 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.

Returns:
error message, or NULL on success in: previous index id

This function parses a SYS_FIELDS record and populates a dict_field_t structure with the information from the record.

Returns:
error message, or NULL on success
Parameters:
heapin/out: heap memory
recin: current SYS_FIELDS rec
sys_fieldout: dict_field_t to be filled
posout: Field position
index_idout: current index id
last_idin: 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.

Returns:
error message, or NULL on success out: column position

This function parses a SYS_FOREIGN_COLS record and extract necessary information from the record and return to caller.

Returns:
error message, or NULL on success
Parameters:
heapin/out: heap memory
recin: current SYS_FOREIGN_COLS rec
nameout: foreign key constraint name
for_col_nameout: referencing column name
ref_col_nameout: referenced column name in referenced table
posout: 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

Returns:
error message, or NULL on success out: dict_foreign_t to be filled

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

Returns:
error message, or NULL on success
Parameters:
heapin/out: heap memory
recin: current SYS_FOREIGN rec
foreignout: 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.

Returns:
error message, or NULL on success out: 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.

Returns:
error message, or NULL on success
Parameters:
heapin/out: heap memory
recin: current SYS_INDEXES rec
indexout: index to be filled
table_idout: 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.

Returns:
error message, or NULL on success in: status bit controls options such as whether we shall look for dict_table_t from cache first

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.

Returns:
error message, or NULL on success
Parameters:
heapin/out: temporary memory heap
recin: SYS_TABLES record
tableout: dict_table_t to fill
statusin: 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.

Returns:
first record of the system table in: which system table to open

This function opens a system table, and return the first record.

Returns:
first record of the system table
Parameters:
pcurout: persistent cursor to the record
mtrin: the mini-transaction
system_idin: 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.