InnoDB Plugin  1.0
Enumerations | Functions | Variables
dict0load.h File Reference
#include "univ.i"
#include "dict0types.h"
#include "trx0types.h"
#include "ut0byte.h"
#include "mem0mem.h"
#include "btr0types.h"
#include "dict0load.ic"
Include dependency graph for dict0load.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  dict_system_id_t {
  SYS_TABLES = 0, SYS_INDEXES, SYS_COLUMNS, SYS_FIELDS,
  SYS_FOREIGN, SYS_FOREIGN_COLS, SYS_TABLESPACES, SYS_DATAFILES,
  SYS_NUM_SYSTEM_TABLES
}
enum  dict_table_info_t { DICT_TABLE_LOAD_FROM_RECORD = 0, DICT_TABLE_LOAD_FROM_CACHE = 1 }
enum  dict_check_t { DICT_CHECK_NONE_LOADED = 0, DICT_CHECK_SOME_LOADED, DICT_CHECK_ALL_LOADED }

Functions

UNIV_INTERN void dict_check_tablespaces_and_store_max_id (dict_check_t dict_check)
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 void dict_save_data_dir_path (dict_table_t *table, char *filepath)
UNIV_INTERN void dict_get_and_save_data_dir_path (dict_table_t *table, bool dict_mutex_own)
UNIV_INTERN dict_table_tdict_load_table (const char *name, ibool cached, dict_err_ignore_t ignore_err)
UNIV_INTERN dict_table_tdict_load_table_on_id (table_id_t table_id, dict_err_ignore_t ignore_err)
UNIV_INTERN void dict_load_sys_table (dict_table_t *table)
UNIV_INTERN dberr_t dict_load_foreigns (const char *table_name, const char **col_names, bool check_recursive, bool check_charsets, dict_err_ignore_t ignore_err)
UNIV_INTERN void dict_print (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_and_mtr_commit (mem_heap_t *heap, const rec_t *rec, dict_table_t **table, dict_table_info_t status, mtr_t *mtr)
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)
UNIV_INTERN const char * dict_process_sys_tablespaces (mem_heap_t *heap, const rec_t *rec, ulint *space, const char **name, ulint *flags)
UNIV_INTERN const char * dict_process_sys_datafiles (mem_heap_t *heap, const rec_t *rec, ulint *space, const char **path)
UNIV_INTERN char * dict_get_first_path (ulint space, const char *name)
UNIV_INTERN dberr_t dict_update_filepath (ulint space_id, const char *filepath)
UNIV_INTERN dberr_t dict_insert_tablespace_and_filepath (ulint space, const char *name, const char *filepath, ulint fsp_flags)

Variables

UNIV_INTERN dberr_t warn_unused_result

Detailed Description

Loads to the memory cache database object definitions from dictionary tables

Created 4/24/1996 Heikki Tuuri

Enumeration Type Documentation

Check type for dict_check_tablespaces_and_store_max_id()

Enumerator:
DICT_CHECK_NONE_LOADED 

No user tablespaces have been opened (no crash recovery, no transactions recovered).

DICT_CHECK_SOME_LOADED 

Some user tablespaces may have been opened (no crash recovery; recovered table locks for transactions).

DICT_CHECK_ALL_LOADED 

All user tablespaces have been opened (crash recovery).

enum that defines all system table IDs.

See Also
SYSTEM_TABLE_NAME[]

Status bit for dict_process_sys_tables_rec_and_mtr_commit()

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

Function Documentation

UNIV_INTERN void dict_check_tablespaces_and_store_max_id ( dict_check_t  dict_check)

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: how to check

UNIV_INTERN void dict_get_and_save_data_dir_path ( dict_table_t table,
bool  dict_mutex_own 
)

Make sure the data_file_name is saved in dict_table_t if needed. Try to read it from the file dictionary first, then from SYS_DATAFILES. in: true if dict_sys->mutex is owned already

Parameters
tablein/out: table
UNIV_INTERN char* dict_get_first_path ( ulint  space,
const char *  name 
)

Get the filepath for a spaceid from SYS_DATAFILES. This function provides a temporary heap which is used for the table lookup, but not for the path. The caller must free the memory for the path returned. This function can return NULL if the space ID is not found in SYS_DATAFILES, then the caller will assume that the ibd file is in the normal datadir.

Returns
own: A copy of the first datafile found in SYS_DATAFILES.PATH for the given space ID. NULL if space ID is zero or not found. in: tablespace name
Parameters
spacein: space id
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 '/'
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
Parameters
pcurin/out: persistent cursor to the record
UNIV_INTERN dberr_t dict_insert_tablespace_and_filepath ( ulint  space,
const char *  name,
const char *  filepath,
ulint  fsp_flags 
)

Insert records into SYS_TABLESPACES and SYS_DATAFILES.

Returns
DB_SUCCESS if OK, dberr_t if the insert failed in: tablespace flags
Parameters
spacein: space id
namein: talespace name
filepathin: filepath
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
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
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
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_FIELDS 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
UNIV_INTERN dberr_t dict_load_foreigns ( const char *  table_name,
const char **  col_names,
bool  check_recursive,
bool  check_charsets,
dict_err_ignore_t  ignore_err 
)

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
col_namesin: column names, or NULL to use table->col_names
check_recursivein: Whether to check recursive load of tables chained by FK
check_charsetsin: whether to check charset compatibility
ignore_errin: error to be ignored
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
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
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

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.

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: error to be ignored when loading table and its indexes' definition
Parameters
namein: table name in the databasename/tablename format
cachedin: TRUE=add to cache, FALSE=do not
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
Parameters
namein: table name
recin: SYS_TABLES record
UNIV_INTERN dict_table_t* dict_load_table_on_id ( table_id_t  table_id,
dict_err_ignore_t  ignore_err 
)

Loads a table object based on the table id.

Returns
table; NULL if table does not exist in: errors to ignore when loading the table
Parameters
table_idin: table id
UNIV_INTERN void dict_print ( void  )

Prints to the standard output information on all tables found in the data dictionary system table.

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
Parameters
heapin/out: heap memory
recin: current SYS_COLUMNS rec
columnout: dict_col_t to be filled
table_idout: table id
UNIV_INTERN const char* dict_process_sys_datafiles ( mem_heap_t heap,
const rec_t *  rec,
ulint *  space,
const char **  path 
)

This function parses a SYS_DATAFILES record, extracts necessary information from the record and returns to caller.

Returns
error message, or NULL on success out: datafile path
Parameters
heapin/out: heap memory
recin: current SYS_DATAFILES rec
spaceout: pace id
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
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
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
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
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
Parameters
heapin/out: heap memory
recin: current SYS_FOREIGN rec
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
Parameters
heapin/out: heap memory
recin: current SYS_INDEXES rec
indexout: dict_index_t to be filled
UNIV_INTERN const char* dict_process_sys_tables_rec_and_mtr_commit ( mem_heap_t heap,
const rec_t *  rec,
dict_table_t **  table,
dict_table_info_t  status,
mtr_t mtr 
)

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/out: mini-transaction, will be committed
Parameters
heapin: 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
UNIV_INTERN const char* dict_process_sys_tablespaces ( mem_heap_t heap,
const rec_t *  rec,
ulint *  space,
const char **  name,
ulint *  flags 
)

This function parses a SYS_TABLESPACES record, extracts necessary information from the record and returns to caller.

Returns
error message, or NULL on success out: tablespace flags
Parameters
heapin/out: heap memory
recin: current SYS_TABLESPACES rec
spaceout: pace id
nameout: tablespace name
UNIV_INTERN void dict_save_data_dir_path ( dict_table_t table,
char *  filepath 
)

Using the table->heap, copy the null-terminated filepath into table->data_dir_path and put a null byte before the extension. This allows SHOW CREATE TABLE to return the correct DATA DIRECTORY path. Make this data directory path only if it has not yet been saved. in: filepath of tablespace

Parameters
tablein/out: table
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
Parameters
pcurout: persistent cursor to the record
mtrin: the mini-transaction
UNIV_INTERN dberr_t dict_update_filepath ( ulint  space_id,
const char *  filepath 
)

Update the record for space_id in SYS_TABLESPACES to this filepath.

Returns
DB_SUCCESS if OK, dberr_t if the insert failed in: filepath
Parameters
space_idin: space id