InnoDB Plugin  1.0
Data Structures | Macros | Enumerations | Functions | Variables
dict0dict.h File Reference
#include "univ.i"
#include "db0err.h"
#include "dict0types.h"
#include "dict0mem.h"
#include "data0type.h"
#include "data0data.h"
#include "mem0mem.h"
#include "rem0types.h"
#include "ut0mem.h"
#include "ut0lst.h"
#include "hash0hash.h"
#include "ut0rnd.h"
#include "ut0byte.h"
#include "trx0types.h"
#include "row0types.h"
#include "sync0sync.h"
#include "sync0rw.h"
#include "dict0dict.ic"
Include dependency graph for dict0dict.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dict_sys_t
struct  dict_col_meta_t
struct  dict_table_schema_t

Macros

#define dict_table_skip_corrupt_index(index)
#define dict_table_next_uncorrupted_index(index)
#define MAX_NUM_FK_COLUMNS   500

Enumerations

enum  dict_table_op_t { DICT_TABLE_OP_NORMAL = 0, DICT_TABLE_OP_DROP_ORPHAN, DICT_TABLE_OP_LOAD_TABLESPACE }
enum  check_name { CHECK_ALL_COMPLETE, CHECK_ABORTED_OK, CHECK_PARTIAL_OK }

Functions

UNIV_INTERN void dict_casedn_str (char *a))
UNIV_INTERN ulint dict_get_db_name_len (const char *name))
UNIV_INTERN char * dict_get_referenced_table (const char *name, const char *database_name, ulint database_name_len, const char *table_name, ulint table_name_len, dict_table_t **table, mem_heap_t *heap)
void dict_foreign_free (dict_foreign_t *foreign)
UNIV_INTERN ulint dict_table_get_highest_foreign_id (dict_table_t *table)
UNIV_INTERN const char * dict_remove_db_name (const char *name))
UNIV_INTERN dict_table_tdict_table_open_on_id (table_id_t table_id, ibool dict_locked, dict_table_op_t table_op))
UNIV_INTERN void dict_table_close (dict_table_t *table, ibool dict_locked, ibool try_drop))
UNIV_INTERN void dict_init (void)
UNIV_INTERN void dict_load_space_id_list (void)
UNIV_INLINE ulint dict_col_get_mbminlen (const dict_col_t *col))
UNIV_INLINE ulint dict_col_get_mbmaxlen (const dict_col_t *col))
UNIV_INLINE void dict_col_set_mbminmaxlen (dict_col_t *col, ulint mbminlen, ulint mbmaxlen))
UNIV_INLINE void dict_col_copy_type (const dict_col_t *col, dtype_t *type))
UNIV_INLINE ulint dict_max_field_len_store_undo (dict_table_t *table, const dict_col_t *col))
UNIV_INLINE ibool dict_col_type_assert_equal (const dict_col_t *col, const dtype_t *type))
UNIV_INLINE ulint dict_col_get_min_size (const dict_col_t *col))
UNIV_INLINE ulint dict_col_get_max_size (const dict_col_t *col))
UNIV_INLINE ulint dict_col_get_fixed_size (const dict_col_t *col, ulint comp))
UNIV_INLINE ulint dict_col_get_sql_null_size (const dict_col_t *col, ulint comp))
UNIV_INLINE ulint dict_col_get_no (const dict_col_t *col))
UNIV_INLINE ulint dict_col_get_clust_pos (const dict_col_t *col, const dict_index_t *clust_index))
UNIV_INTERN ibool dict_col_name_is_reserved (const char *name))
UNIV_INTERN void dict_table_autoinc_lock (dict_table_t *table))
UNIV_INTERN void dict_table_autoinc_initialize (dict_table_t *table, ib_uint64_t value))
UNIV_INTERN ib_uint64_t dict_table_autoinc_read (const dict_table_t *table))
UNIV_INTERN void dict_table_autoinc_update_if_greater (dict_table_t *table, ib_uint64_t value))
UNIV_INTERN void dict_table_autoinc_unlock (dict_table_t *table))
UNIV_INTERN void dict_table_add_system_columns (dict_table_t *table, mem_heap_t *heap))
UNIV_INTERN void dict_table_add_to_cache (dict_table_t *table, ibool can_be_evicted, mem_heap_t *heap))
UNIV_INTERN void dict_table_remove_from_cache (dict_table_t *table))
UNIV_INTERN dberr_t dict_table_rename_in_cache (dict_table_t *table, const char *new_name, ibool rename_also_foreigns))
UNIV_INTERN void dict_index_remove_from_cache (dict_table_t *table, dict_index_t *index))
UNIV_INTERN void dict_table_change_id_in_cache (dict_table_t *table, table_id_t new_id))
UNIV_INTERN void dict_foreign_remove_from_cache (dict_foreign_t *foreign))
UNIV_INTERN dberr_t dict_foreign_add_to_cache (dict_foreign_t *foreign, const char **col_names, bool check_charsets, dict_err_ignore_t ignore_err)
UNIV_INTERN dict_foreign_tdict_table_get_referenced_constraint (dict_table_t *table, dict_index_t *index))
UNIV_INTERN ibool dict_table_is_referenced_by_foreign_key (const dict_table_t *table))
UNIV_INTERN bool dict_foreign_replace_index (dict_table_t *table, const char **col_names, const dict_index_t *index)
UNIV_INTERN ibool dict_str_starts_with_keyword (THD *thd, const char *str, const char *keyword))
UNIV_INTERN dict_foreign_tdict_table_get_foreign_constraint (dict_table_t *table, dict_index_t *index))
UNIV_INTERN dberr_t dict_create_foreign_constraints (trx_t *trx, const char *sql_string, size_t sql_length, const char *name, ibool reject_fks))
UNIV_INTERN dberr_t dict_foreign_parse_drop_constraints (mem_heap_t *heap, trx_t *trx, dict_table_t *table, ulint *n, const char ***constraints_to_drop))
UNIV_INTERN dict_table_tdict_table_open_on_name (const char *table_name, ibool dict_locked, ibool try_drop, dict_err_ignore_t ignore_err))
UNIV_INTERN dict_index_tdict_foreign_find_index (const dict_table_t *table, const char **col_names, const char **columns, ulint n_cols, const dict_index_t *types_idx, bool check_charsets, ulint check_null)
UNIV_INTERN const char * dict_table_get_col_name (const dict_table_t *table, ulint col_nr))
UNIV_INTERN void dict_table_print (dict_table_t *table))
UNIV_INTERN void dict_print_info_on_foreign_keys (ibool create_table_format, FILE *file, trx_t *trx, dict_table_t *table))
UNIV_INTERN void dict_print_info_on_foreign_key_in_create_format (FILE *file, trx_t *trx, dict_foreign_t *foreign, ibool add_newline)))
UNIV_INTERN void dict_index_name_print (FILE *file, const trx_t *trx, const dict_index_t *index)))
UNIV_INTERN bool dict_foreign_qualify_index (const dict_table_t *table, const char **col_names, const char **columns, ulint n_cols, const dict_index_t *index, const dict_index_t *types_idx, bool check_charsets, ulint check_null)
UNIV_INLINE dict_index_tdict_table_get_first_index (const dict_table_t *table))
UNIV_INLINE dict_index_tdict_table_get_last_index (const dict_table_t *table))
UNIV_INLINE dict_index_tdict_table_get_next_index (const dict_index_t *index))
UNIV_INLINE ulint dict_index_is_clust (const dict_index_t *index))
UNIV_INLINE ulint dict_index_is_unique (const dict_index_t *index))
UNIV_INLINE ulint dict_index_is_ibuf (const dict_index_t *index))
UNIV_INLINE ulint dict_index_is_sec_or_ibuf (const dict_index_t *index))
UNIV_INTERN ulint dict_table_get_all_fts_indexes (dict_table_t *table, ib_vector_t *indexes))
UNIV_INLINE ulint dict_table_get_n_user_cols (const dict_table_t *table))
UNIV_INLINE ulint dict_table_get_n_sys_cols (const dict_table_t *table))
UNIV_INLINE ulint dict_table_get_n_cols (const dict_table_t *table))
UNIV_INLINE ib_uint64_t dict_table_get_n_rows (const dict_table_t *table))
UNIV_INLINE void dict_table_n_rows_inc (dict_table_t *table))
UNIV_INLINE void dict_table_n_rows_dec (dict_table_t *table))
UNIV_INLINE dict_col_tdict_table_get_nth_col (const dict_table_t *table, ulint pos))
UNIV_INLINE dict_col_tdict_table_get_sys_col (const dict_table_t *table, ulint sys))
UNIV_INLINE ulint dict_table_get_sys_col_no (const dict_table_t *table, ulint sys))
UNIV_INLINE ulint dict_index_get_min_size (const dict_index_t *index))
UNIV_INLINE ibool dict_table_is_comp (const dict_table_t *table))
UNIV_INLINE ulint dict_table_get_format (const dict_table_t *table))
UNIV_INLINE ulint dict_tf_get_format (ulint flags))
UNIV_INLINE void dict_tf_set (ulint *flags, rec_format_t format, ulint zip_ssize, bool remote_path))
UNIV_INLINE ulint dict_tf_to_fsp_flags (ulint flags))
UNIV_INLINE ulint dict_tf_get_zip_size (ulint flags))
UNIV_INLINE ulint dict_table_zip_size (const dict_table_t *table))
UNIV_INLINE void dict_table_x_lock_indexes (dict_table_t *table))
UNIV_INLINE void dict_table_x_unlock_indexes (dict_table_t *table))
UNIV_INTERN ibool dict_table_col_in_clustered_key (const dict_table_t *table, ulint n))
UNIV_INLINE ibool dict_table_has_fts_index (dict_table_t *table))
UNIV_INTERN void dict_table_copy_types (dtuple_t *tuple, const dict_table_t *table))
UNIV_INTERN void dict_table_wait_for_bg_threads_to_exit (dict_table_t *table, ulint delay))
UNIV_INTERN dict_index_tdict_index_find_on_id_low (index_id_t id))
UNIV_INTERN ulint dict_make_room_in_cache (ulint max_tables, ulint pct_check)
UNIV_INTERN dberr_t dict_index_add_to_cache (dict_table_t *table, dict_index_t *index, ulint page_no, ibool strict))
UNIV_INLINE ulint dict_index_get_n_fields (const dict_index_t *index))
UNIV_INLINE ulint dict_index_get_n_unique (const dict_index_t *index))
UNIV_INLINE ulint dict_index_get_n_unique_in_tree (const dict_index_t *index))
UNIV_INLINE ulint dict_index_get_n_ordering_defined_by_user (const dict_index_t *index))
UNIV_INLINE dict_field_tdict_index_get_nth_field (const dict_index_t *index, ulint pos))
UNIV_INLINE const dict_col_tdict_index_get_nth_col (const dict_index_t *index, ulint pos))
UNIV_INLINE ulint dict_index_get_nth_col_no (const dict_index_t *index, ulint pos))
UNIV_INLINE ulint dict_index_get_nth_col_pos (const dict_index_t *index, ulint n))
UNIV_INTERN ulint dict_index_get_nth_col_or_prefix_pos (const dict_index_t *index, ulint n, ibool inc_prefix))
UNIV_INTERN ibool dict_index_contains_col_or_prefix (const dict_index_t *index, ulint n))
UNIV_INTERN ulint dict_index_get_nth_field_pos (const dict_index_t *index, const dict_index_t *index2, ulint n))
UNIV_INTERN ulint dict_table_get_nth_col_pos (const dict_table_t *table, ulint n))
UNIV_INLINE ulint dict_index_get_sys_col_pos (const dict_index_t *index, ulint type))
UNIV_INTERN void dict_index_add_col (dict_index_t *index, const dict_table_t *table, dict_col_t *col, ulint prefix_len))
UNIV_INTERN void dict_index_copy_types (dtuple_t *tuple, const dict_index_t *index, ulint n_fields))
UNIV_INLINE const dict_col_tdict_field_get_col (const dict_field_t *field))
UNIV_INTERN dict_index_tdict_index_get_if_in_cache_low (index_id_t index_id))
UNIV_INTERN dict_index_tdict_index_get_if_in_cache (index_id_t index_id))
UNIV_INTERN ibool dict_index_check_search_tuple (const dict_index_t *index, const dtuple_t *tuple))
UNIV_INTERN void dict_table_check_for_dup_indexes (const dict_table_t *table, enum check_name check))
UNIV_INTERN dtuple_tdict_index_build_node_ptr (const dict_index_t *index, const rec_t *rec, ulint page_no, mem_heap_t *heap, ulint level))
UNIV_INTERN rec_t * dict_index_copy_rec_order_prefix (const dict_index_t *index, const rec_t *rec, ulint *n_fields, byte **buf, ulint *buf_size))
UNIV_INTERN dtuple_tdict_index_build_data_tuple (dict_index_t *index, rec_t *rec, ulint n_fields, mem_heap_t *heap))
UNIV_INLINE ulint dict_index_get_space (const dict_index_t *index))
UNIV_INLINE void dict_index_set_space (dict_index_t *index, ulint space))
UNIV_INLINE ulint dict_index_get_page (const dict_index_t *tree))
UNIV_INLINE rw_lock_tdict_index_get_lock (dict_index_t *index))
UNIV_INLINE ulint dict_index_get_space_reserve (void)
UNIV_INLINE enum
online_index_status 
dict_index_get_online_status (const dict_index_t *index))
UNIV_INLINE void dict_index_set_online_status (dict_index_t *index, enum online_index_status status))
UNIV_INLINE bool dict_index_is_online_ddl (const dict_index_t *index))
UNIV_INTERN ulint dict_index_calc_min_rec_len (const dict_index_t *index))
UNIV_INTERN void dict_mutex_enter_for_mysql (void)
UNIV_INTERN void dict_mutex_exit_for_mysql (void)
void dict_table_stats_latch_create (dict_table_t *table, bool enabled)
void dict_table_stats_latch_destroy (dict_table_t *table)
UNIV_INTERN void dict_table_stats_lock (dict_table_t *table, ulint latch_mode)
UNIV_INTERN void dict_table_stats_unlock (dict_table_t *table, ulint latch_mode)
UNIV_INTERN ibool dict_tables_have_same_db (const char *name1, const char *name2))
UNIV_INTERN dict_index_tdict_table_get_index_on_name (dict_table_t *table, const char *name))
UNIV_INTERN dict_index_tdict_table_get_index_on_name_and_min_id (dict_table_t *table, const char *name))
UNIV_INLINE ulint dict_table_is_fts_column (ib_vector_t *indexes, ulint col_no))
UNIV_INTERN void dict_table_move_from_lru_to_non_lru (dict_table_t *table))
UNIV_INTERN void dict_table_move_from_non_lru_to_lru (dict_table_t *table))
UNIV_INTERN void dict_move_to_mru (dict_table_t *table))
UNIV_INTERN void dict_ind_init (void)
UNIV_INTERN void dict_fs2utf8 (const char *db_and_table, char *db_utf8, size_t db_utf8_size, char *table_utf8, size_t table_utf8_size))
UNIV_INTERN void dict_close (void)
UNIV_INLINE ulint dict_table_is_corrupted (const dict_table_t *table))
UNIV_INLINE ulint dict_index_is_corrupted (const dict_index_t *index))
UNIV_INTERN void dict_set_corrupted (dict_index_t *index, trx_t *trx, const char *ctx) UNIV_COLD)
UNIV_INTERN void dict_set_corrupted_index_cache_only (dict_index_t *index, dict_table_t *table))
UNIV_INTERN ibool dict_set_corrupted_by_space (ulint space_id)
UNIV_INLINE bool dict_tf_is_valid (ulint flags))
UNIV_INLINE bool dict_table_is_discarded (const dict_table_t *table))
UNIV_INLINE bool dict_table_is_temporary (const dict_table_t *table))
UNIV_INTERN void dict_index_zip_success (dict_index_t *index))
UNIV_INTERN void dict_index_zip_failure (dict_index_t *index))
UNIV_INTERN ulint dict_index_zip_pad_optimal_page_size (dict_index_t *index))
UNIV_INTERN const char * dict_tf_to_row_format_string (ulint table_flag)
UNIV_INLINE dict_index_tdict_table_get_index_on_first_col (const dict_table_t *table, ulint col_index)
UNIV_INTERN dberr_t dict_table_schema_check (dict_table_schema_t *req_schema, char *errstr, size_t errstr_sz))

Variables

UNIV_INTERN dberr_t warn_unused_result
FILE * dict_foreign_err_file
ib_mutex_t dict_foreign_err_mutex
dict_sys_tdict_sys
rw_lock_t dict_operation_lock
dict_index_tdict_ind_redundant
dict_index_tdict_ind_compact

Detailed Description

Data dictionary system

Created 1/8/1996 Heikki Tuuri

Macro Definition Documentation

#define dict_table_next_uncorrupted_index (   index)
Value:
do { \
index = dict_table_get_next_index(index); \
dict_table_skip_corrupt_index(index); \
} while (0)
#define dict_table_skip_corrupt_index (   index)
Value:
while (index && dict_index_is_corrupted(index)) { \
index = dict_table_get_next_index(index); \
}
#define MAX_NUM_FK_COLUMNS   500
Maximum number of columns in a foreign key constraint. Please Note MySQL

has a much lower limit on the number of columns allowed in a foreign key constraint

Enumeration Type Documentation

enum check_name

Whether and when to allow temporary index names

Enumerator:
CHECK_ALL_COMPLETE 

Require all indexes to be complete.

CHECK_ABORTED_OK 

Allow aborted online index creation.

CHECK_PARTIAL_OK 

Allow partial indexes to exist.

Operation to perform when opening a table

Enumerator:
DICT_TABLE_OP_NORMAL 

Expect the tablespace to exist.

DICT_TABLE_OP_DROP_ORPHAN 

Drop any orphan indexes after an aborted online index creation

DICT_TABLE_OP_LOAD_TABLESPACE 

Silently load the tablespace if it does not exist, and do not load the definitions of incomplete indexes.

Function Documentation

UNIV_INTERN void dict_casedn_str ( char *  a)

Makes all characters in a NUL-terminated UTF-8 string lower case.

Parameters
ain/out: string to put in lower case
UNIV_INTERN void dict_close ( void  )

Closes the data dictionary module.

UNIV_INLINE void dict_col_copy_type ( const dict_col_t col,
dtype_t type 
)

Gets the column data type.

Parameters
colin: column
typeout: data type
UNIV_INLINE ulint dict_col_get_clust_pos ( const dict_col_t col,
const dict_index_t clust_index 
)

Gets the column position in the clustered index.

Parameters
colin: table column
clust_indexin: clustered index
UNIV_INLINE ulint dict_col_get_fixed_size ( const dict_col_t col,
ulint  comp 
)

Returns the size of a fixed size column, 0 if not a fixed size column.

Returns
fixed size, or 0
Parameters
colin: column
compin: nonzero=ROW_FORMAT=COMPACT
UNIV_INLINE ulint dict_col_get_max_size ( const dict_col_t col)

Returns the maximum size of the column.

Returns
maximum size
Parameters
colin: column
UNIV_INLINE ulint dict_col_get_mbmaxlen ( const dict_col_t col)

Gets the maximum number of bytes per character.

Returns
maximum multi-byte char size, in bytes
Parameters
colin: column
UNIV_INLINE ulint dict_col_get_mbminlen ( const dict_col_t col)

Gets the minimum number of bytes per character.

Returns
minimum multi-byte char size, in bytes
Parameters
colin: column
UNIV_INLINE ulint dict_col_get_min_size ( const dict_col_t col)

Returns the minimum size of the column.

Returns
minimum size
Parameters
colin: column
UNIV_INLINE ulint dict_col_get_no ( const dict_col_t col)

Gets the column number.

Returns
col->ind, table column position (starting from 0)
Parameters
colin: column
UNIV_INLINE ulint dict_col_get_sql_null_size ( const dict_col_t col,
ulint  comp 
)

Returns the ROW_FORMAT=REDUNDANT stored SQL NULL size of a column. For fixed length types it is the fixed length of the type, otherwise 0.

Returns
SQL null storage size in ROW_FORMAT=REDUNDANT
Parameters
colin: column
compin: nonzero=ROW_FORMAT=COMPACT
UNIV_INTERN ibool dict_col_name_is_reserved ( const char *  name)

If the given column name is reserved for InnoDB system columns, return TRUE.

Returns
TRUE if name is reserved
Parameters
namein: column name
UNIV_INLINE void dict_col_set_mbminmaxlen ( dict_col_t col,
ulint  mbminlen,
ulint  mbmaxlen 
)

Sets the minimum and maximum number of bytes per character.

Parameters
colin/out: column
mbminlenin: minimum multi-byte character size, in bytes
mbmaxlenin: minimum multi-byte character size, in bytes
UNIV_INLINE ibool dict_col_type_assert_equal ( const dict_col_t col,
const dtype_t type 
)

Assert that a column and a data type match.

Returns
TRUE
Parameters
colin: column
typein: data type
UNIV_INTERN dberr_t dict_create_foreign_constraints ( trx_t trx,
const char *  sql_string,
size_t  sql_length,
const char *  name,
ibool  reject_fks 
)

Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function should be called after the indexes for a table have been created. Each foreign key constraint must be accompanied with indexes in bot participating tables. The indexes are allowed to contain more fields than mentioned in the constraint.

Returns
error code or DB_SUCCESS
Parameters
trxin: transaction
sql_stringin: table create statement where foreign keys are declared like: FOREIGN KEY (a, b) REFERENCES table2(c, d), table2 can be written also with the database name before it: test.table2; the default database id the database of parameter name
sql_lengthin: length of sql_string
namein: table full name in the normalized form database_name/table_name
reject_fksin: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found.
UNIV_INLINE const dict_col_t* dict_field_get_col ( const dict_field_t field)

Gets the field column.

Returns
field->col, pointer to the table column
Parameters
fieldin: index field
UNIV_INTERN dberr_t dict_foreign_add_to_cache ( dict_foreign_t foreign,
const char **  col_names,
bool  check_charsets,
dict_err_ignore_t  ignore_err 
)

Adds a foreign key constraint object to the dictionary cache. May free the object if there already is an object with the same identifier in. At least one of foreign table or referenced table must already be in the dictionary cache!

Returns
DB_SUCCESS or error code
Parameters
foreignin, own: foreign key constraint
col_namesin: column names, or NULL to use foreign->foreign_table->col_names
check_charsetsin: whether to check charset compatibility
ignore_errin: error to be ignored
UNIV_INTERN dict_index_t* dict_foreign_find_index ( const dict_table_t table,
const char **  col_names,
const char **  columns,
ulint  n_cols,
const dict_index_t types_idx,
bool  check_charsets,
ulint  check_null 
)

Tries to find an index whose first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx.

Returns
matching index, NULL if not found
Parameters
tablein: table
col_namesin: column names, or NULL to use table->col_names
columnsin: array of column names
n_colsin: number of columns
types_idxin: NULL or an index whose types the column types must match
check_charsetsin: whether to check charsets. only has an effect if types_idx != NULL
check_nullin: nonzero if none of the columns must be declared NOT NULL
void dict_foreign_free ( dict_foreign_t foreign)
inline

Frees a foreign key struct. in, own: foreign key struct

Frees a foreign key struct.

Parameters
foreignin, own: foreign key struct
UNIV_INTERN dberr_t dict_foreign_parse_drop_constraints ( mem_heap_t heap,
trx_t trx,
dict_table_t table,
ulint *  n,
const char ***  constraints_to_drop 
)

Parses the CONSTRAINT id's to be dropped in an ALTER TABLE statement.

Returns
DB_SUCCESS or DB_CANNOT_DROP_CONSTRAINT if syntax error or the constraint id does not match
Parameters
heapin: heap from which we can allocate memory
trxin: transaction
tablein: table
nout: number of constraints to drop
constraints_to_dropout: id's of the constraints to drop
UNIV_INTERN bool dict_foreign_qualify_index ( const dict_table_t table,
const char **  col_names,
const char **  columns,
ulint  n_cols,
const dict_index_t index,
const dict_index_t types_idx,
bool  check_charsets,
ulint  check_null 
)

Tries to find an index whose first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx.

Returns
matching index, NULL if not found
Parameters
tablein: table
col_namesin: column names, or NULL to use table->col_names
columnsin: array of column names
n_colsin: number of columns
indexin: index to check
types_idxin: NULL or an index whose types the column types must match
check_charsetsin: whether to check charsets. only has an effect if types_idx != NULL
check_nullin: nonzero if none of the columns must be declared NOT NULL
UNIV_INTERN void dict_foreign_remove_from_cache ( dict_foreign_t foreign)

Removes a foreign constraint struct from the dictionary cache.

Parameters
foreignin, own: foreign constraint
UNIV_INTERN bool dict_foreign_replace_index ( dict_table_t table,
const char **  col_names,
const dict_index_t index 
)

Replace the index passed in with another equivalent index in the foreign key lists of the table.

Returns
whether all replacements were found
Parameters
tablein/out: table
col_namesin: column names, or NULL to use table->col_names
indexin: index to be replaced
UNIV_INTERN void dict_fs2utf8 ( const char *  db_and_table,
char *  db_utf8,
size_t  db_utf8_size,
char *  table_utf8,
size_t  table_utf8_size 
)

Converts a database and table name from filesystem encoding (e.g. d/a@1Kc, same format as used in dict_table_t::name) in two strings in UTF8 encoding (e.g. dцb and aюbØc). The output buffers must be at least MAX_DB_UTF8_LEN and MAX_TABLE_UTF8_LEN bytes.

Parameters
db_and_tablein: database and table names, e.g. d/a@1Kc
db_utf8out: database name, e.g. dцb
db_utf8_sizein: dbname_utf8 size
table_utf8out: table name, e.g. aюbØc
table_utf8_sizein: table_utf8 size
UNIV_INTERN ulint dict_get_db_name_len ( const char *  name)

Get the database name length in a table name.

Returns
database name length
Parameters
namein: table name in the form dbname '/' tablename
UNIV_INTERN char* dict_get_referenced_table ( const char *  name,
const char *  database_name,
ulint  database_name_len,
const char *  table_name,
ulint  table_name_len,
dict_table_t **  table,
mem_heap_t heap 
)

Open a table from its database and table name, this is currently used by foreign constraint parser to get the referenced table.

Returns
complete table name with database and table name, allocated from heap memory passed in in: heap memory
Parameters
namein: foreign key table name
database_namein: table db name
database_name_lenin: db name length
table_namein: table name
table_name_lenin: table name length
tableout: table object or NULL
UNIV_INTERN void dict_ind_init ( void  )

Inits dict_ind_redundant and dict_ind_compact.

UNIV_INTERN void dict_index_add_col ( dict_index_t index,
const dict_table_t table,
dict_col_t col,
ulint  prefix_len 
)

Adds a column to index.

Parameters
indexin/out: index
tablein: table
colin: column
prefix_lenin: column prefix length
UNIV_INTERN dberr_t dict_index_add_to_cache ( dict_table_t table,
dict_index_t index,
ulint  page_no,
ibool  strict 
)

Adds an index to the dictionary cache.

Returns
DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION
Parameters
tablein: table on which the index is
indexin, own: index; NOTE! The index memory object is freed in this function!
page_noin: root page number of the index
strictin: TRUE=refuse to create the index if records could be too big to fit in an B-tree page
UNIV_INTERN dtuple_t* dict_index_build_data_tuple ( dict_index_t index,
rec_t *  rec,
ulint  n_fields,
mem_heap_t heap 
)

Builds a typed data tuple out of a physical record.

Returns
own: data tuple
Parameters
indexin: index
recin: record for which to build data tuple
n_fieldsin: number of data fields
heapin: memory heap where tuple created
UNIV_INTERN dtuple_t* dict_index_build_node_ptr ( const dict_index_t index,
const rec_t *  rec,
ulint  page_no,
mem_heap_t heap,
ulint  level 
)

Builds a node pointer out of a physical record and a page number.

Returns
own: node pointer
Parameters
indexin: index
recin: record for which to build node pointer
page_noin: page number to put in node pointer
heapin: memory heap where pointer created
levelin: level of rec in tree: 0 means leaf level
UNIV_INTERN ulint dict_index_calc_min_rec_len ( const dict_index_t index)

Calculates the minimum record length in an index.

Parameters
indexin: index
UNIV_INTERN ibool dict_index_check_search_tuple ( const dict_index_t index,
const dtuple_t tuple 
)

Checks that a tuple has n_fields_cmp value in a sensible range, so that no comparison can occur with the page number field in a node pointer.

Returns
TRUE if ok
Parameters
indexin: index tree
tuplein: tuple used in a search
UNIV_INTERN ibool dict_index_contains_col_or_prefix ( const dict_index_t index,
ulint  n 
)

Returns TRUE if the index contains a column or a prefix of that column.

Returns
TRUE if contains the column or its prefix
Parameters
indexin: index
nin: column number
UNIV_INTERN rec_t* dict_index_copy_rec_order_prefix ( const dict_index_t index,
const rec_t *  rec,
ulint *  n_fields,
byte **  buf,
ulint *  buf_size 
)

Copies an initial segment of a physical record, long enough to specify an index entry uniquely.

Returns
pointer to the prefix record
Parameters
indexin: index
recin: record for which to copy prefix
n_fieldsout: number of fields copied
bufin/out: memory buffer for the copied prefix, or NULL
buf_sizein/out: buffer size
UNIV_INTERN void dict_index_copy_types ( dtuple_t tuple,
const dict_index_t index,
ulint  n_fields 
)

Copies types of fields contained in index to tuple.

Parameters
tuplein/out: data tuple
indexin: index
n_fieldsin: number of field types to copy
UNIV_INTERN dict_index_t* dict_index_find_on_id_low ( index_id_t  id)

Looks for an index with the given id. NOTE that we do not reserve the dictionary mutex: this function is for emergency purposes like printing info of a corrupt database page!

Returns
index or NULL if not found from cache
Parameters
idin: index id
UNIV_INTERN dict_index_t* dict_index_get_if_in_cache ( index_id_t  index_id)

Returns an index object if it is found in the dictionary cache.

Returns
index, NULL if not found
Parameters
index_idin: index id
UNIV_INTERN dict_index_t* dict_index_get_if_in_cache_low ( index_id_t  index_id)

Returns an index object if it is found in the dictionary cache. Assumes that dict_sys->mutex is already being held.

Returns
index, NULL if not found
Parameters
index_idin: index id
UNIV_INLINE rw_lock_t* dict_index_get_lock ( dict_index_t index)

Gets the read-write lock of the index tree.

Returns
read-write lock
Parameters
indexin: index
UNIV_INLINE ulint dict_index_get_min_size ( const dict_index_t index)

Returns the minimum data size of an index record.

Returns
minimum data size in bytes
Parameters
indexin: index
UNIV_INLINE ulint dict_index_get_n_fields ( const dict_index_t index)

Gets the number of fields in the internal representation of an index, including fields added by the dictionary system.

Returns
number of fields
Parameters
indexin: an internal representation of index (in the dictionary cache)
UNIV_INLINE ulint dict_index_get_n_ordering_defined_by_user ( const dict_index_t index)

Gets the number of user-defined ordering fields in the index. In the internal representation we add the row id to the ordering fields to make all indexes unique, but this function returns the number of fields the user defined in the index as ordering fields.

Returns
number of fields

Gets the number of user-defined ordering fields in the index. In the internal representation of clustered indexes we add the row id to the ordering fields to make a clustered index unique, but this function returns the number of fields the user defined in the index as ordering fields.

Returns
number of fields
Parameters
indexin: an internal representation of index (in the dictionary cache)
UNIV_INLINE ulint dict_index_get_n_unique ( const dict_index_t index)

Gets the number of fields in the internal representation of an index that uniquely determine the position of an index entry in the index, if we do not take multiversioning into account: in the B-tree use the value returned by dict_index_get_n_unique_in_tree.

Returns
number of fields
Parameters
indexin: an internal representation of index (in the dictionary cache)
UNIV_INLINE ulint dict_index_get_n_unique_in_tree ( const dict_index_t index)

Gets the number of fields in the internal representation of an index which uniquely determine the position of an index entry in the index, if we also take multiversioning into account.

Returns
number of fields
Parameters
indexin: an internal representation of index (in the dictionary cache)
UNIV_INLINE const dict_col_t* dict_index_get_nth_col ( const dict_index_t index,
ulint  pos 
)

Gets pointer to the nth column in an index.

Returns
column
Parameters
indexin: index
posin: position of the field
UNIV_INLINE ulint dict_index_get_nth_col_no ( const dict_index_t index,
ulint  pos 
)

Gets the column number of the nth field in an index.

Returns
column number

Gets the column number the nth field in an index.

Returns
column number
Parameters
indexin: index
posin: position of the field
UNIV_INTERN ulint dict_index_get_nth_col_or_prefix_pos ( const dict_index_t index,
ulint  n,
ibool  inc_prefix 
)

Looks for column n in an index.

Returns
position in internal representation of the index; ULINT_UNDEFINED if not contained
Parameters
indexin: index
nin: column number
inc_prefixin: TRUE=consider column prefixes too
UNIV_INLINE ulint dict_index_get_nth_col_pos ( const dict_index_t index,
ulint  n 
)

Looks for column n in an index.

Returns
position in internal representation of the index; ULINT_UNDEFINED if not contained
Parameters
indexin: index
nin: column number
UNIV_INLINE dict_field_t* dict_index_get_nth_field ( const dict_index_t index,
ulint  pos 
)

Gets the nth field of an index.

Returns
pointer to field object
Parameters
indexin: index
posin: position of field
UNIV_INTERN ulint dict_index_get_nth_field_pos ( const dict_index_t index,
const dict_index_t index2,
ulint  n 
)

Looks for a matching field in an index. The column has to be the same. The column in index must be complete, or must contain a prefix longer than the column in index2. That is, we must be able to construct the prefix in index2 from the prefix in index.

Returns
position in internal representation of the index; ULINT_UNDEFINED if not contained
Parameters
indexin: index from which to search
index2in: index
nin: field number in index2
UNIV_INLINE enum online_index_status dict_index_get_online_status ( const dict_index_t index)

Gets the status of online index creation.

Returns
the status
Parameters
indexin: secondary index
UNIV_INLINE ulint dict_index_get_page ( const dict_index_t index)

Gets the page number of the root of the index tree.

Returns
page number
Parameters
indexin: index
UNIV_INLINE ulint dict_index_get_space ( const dict_index_t index)

Gets the space id of the root of the index tree.

Returns
space id
Parameters
indexin: index
UNIV_INLINE ulint dict_index_get_space_reserve ( void  )

Returns free space reserved for future updates of records. This is relevant only in the case of many consecutive inserts, as updates which make the records bigger might fragment the index.

Returns
number of free bytes on page, reserved for updates
UNIV_INLINE ulint dict_index_get_sys_col_pos ( const dict_index_t index,
ulint  type 
)

Returns the position of a system column in an index.

Returns
position, ULINT_UNDEFINED if not contained
Parameters
indexin: index
typein: DATA_ROW_ID, ...
UNIV_INLINE ulint dict_index_is_clust ( const dict_index_t index)

Check whether the index is the clustered index.

Returns
nonzero for clustered index, zero for other indexes
Parameters
indexin: index
UNIV_INLINE ulint dict_index_is_corrupted ( const dict_index_t index)

Check whether the index is corrupted.

Returns
nonzero for corrupted index, zero for valid indexes
Parameters
indexin: index
UNIV_INLINE ulint dict_index_is_ibuf ( const dict_index_t index)

Check whether the index is the insert buffer tree.

Returns
nonzero for insert buffer, zero for other indexes
Parameters
indexin: index
UNIV_INLINE bool dict_index_is_online_ddl ( const dict_index_t index)

Determines if a secondary index is being or has been created online, or if the table is being rebuilt online, allowing concurrent modifications to the table.

Return values
trueif the index is being or has been built online, or if this is a clustered index and the table is being or has been rebuilt online
falseif the index has been created or the table has been rebuilt completely
Parameters
indexin: index
UNIV_INLINE ulint dict_index_is_sec_or_ibuf ( const dict_index_t index)

Check whether the index is a secondary index or the insert buffer tree.

Returns
nonzero for insert buffer, zero for other indexes
Parameters
indexin: index
UNIV_INLINE ulint dict_index_is_unique ( const dict_index_t index)

Check whether the index is unique.

Returns
nonzero for unique index, zero for other indexes
Parameters
indexin: index
UNIV_INTERN void dict_index_name_print ( FILE *  file,
const trx_t trx,
const dict_index_t index 
)

Displays the names of the index and the table.

Parameters
filein: output stream
trxin: transaction
indexin: index to print
UNIV_INTERN void dict_index_remove_from_cache ( dict_table_t table,
dict_index_t index 
)

Removes an index from the dictionary cache.

Removes an index from the cache

Parameters
tablein/out: table
indexin, own: index
UNIV_INLINE void dict_index_set_online_status ( dict_index_t index,
enum online_index_status  status 
)

Sets the status of online index creation.

Parameters
indexin/out: index
statusin: status
UNIV_INLINE void dict_index_set_space ( dict_index_t index,
ulint  space 
)

Sets the space id of the root of the index tree.

Parameters
indexin/out: index
spacein: space id
UNIV_INTERN void dict_index_zip_failure ( dict_index_t index)

This function should be called whenever a page compression attempt fails. Updates the compression padding information.

Parameters
indexin/out: index to be updated.
UNIV_INTERN ulint dict_index_zip_pad_optimal_page_size ( dict_index_t index)

Return the optimal page size, for which page will likely compress.

Returns
page size beyond which page may not compress
Parameters
indexin: index for which page size is requested
UNIV_INTERN void dict_index_zip_success ( dict_index_t index)

This function should be called whenever a page is successfully compressed. Updates the compression padding information.

Parameters
indexin/out: index to be updated.
UNIV_INTERN void dict_init ( void  )

Inits the data dictionary module.

UNIV_INTERN void dict_load_space_id_list ( void  )

Gets the space id of every table of the data dictionary and makes a linear list and a hash table of them to the data dictionary cache. This function can be called at database startup if we did not need to do a crash recovery. In crash recovery we must scan the space id's from the .ibd files in MySQL database directories.

UNIV_INTERN ulint dict_make_room_in_cache ( ulint  max_tables,
ulint  pct_check 
)

Make room in the table cache by evicting an unused table. The unused table should not be part of FK relationship and currently not used in any user transaction. There is no guarantee that it will remove a table.

Returns
number of tables evicted. in: max percent to check
Parameters
max_tablesin: max tables allowed in cache
UNIV_INLINE ulint dict_max_field_len_store_undo ( dict_table_t table,
const dict_col_t col 
)

Determine bytes of column prefix to be stored in the undo log. Please note if the table format is UNIV_FORMAT_A (< UNIV_FORMAT_B), no prefix needs to be stored in the undo log.

Returns
bytes of column prefix to be stored in the undo log
Parameters
tablein: table
colin: column which index prefix is based on
UNIV_INTERN void dict_move_to_mru ( dict_table_t table)

Move to the most recently used segment of the LRU list.

Parameters
tablein: table to move to MRU
UNIV_INTERN void dict_mutex_enter_for_mysql ( void  )

Reserves the dictionary system mutex for MySQL.

UNIV_INTERN void dict_mutex_exit_for_mysql ( void  )

Releases the dictionary system mutex for MySQL.

UNIV_INTERN void dict_print_info_on_foreign_key_in_create_format ( FILE *  file,
trx_t trx,
dict_foreign_t foreign,
ibool  add_newline 
)

Outputs info on a foreign key of a table in a format suitable for CREATE TABLE.

Parameters
filein: file where to print
trxin: transaction
foreignin: foreign key constraint
add_newlinein: whether to add a newline
UNIV_INTERN void dict_print_info_on_foreign_keys ( ibool  create_table_format,
FILE *  file,
trx_t trx,
dict_table_t table 
)

Outputs info on foreign keys of a table.

Parameters
create_table_formatin: if TRUE then print in a format suitable to be inserted into a CREATE TABLE, otherwise in the format of SHOW TABLE STATUS
filein: file where to print
trxin: transaction
tablein: table
UNIV_INTERN const char* dict_remove_db_name ( const char *  name)

Return the end of table name where we have removed dbname and '/'.

Returns
table name
Parameters
namein: table name in the form dbname '/' tablename
UNIV_INTERN void dict_set_corrupted ( dict_index_t index,
trx_t trx,
const char *  ctx 
)

Flags an index and table corrupted both in the data dictionary cache and in the system table SYS_INDEXES.

Parameters
indexin/out: index
trxin/out: transaction
ctxin: context
UNIV_INTERN ibool dict_set_corrupted_by_space ( ulint  space_id)

Flags a table with specified space_id corrupted in the table dictionary cache.

Returns
TRUE if successful in: space ID
UNIV_INTERN void dict_set_corrupted_index_cache_only ( dict_index_t index,
dict_table_t table 
)

Flags an index corrupted in the data dictionary cache only. This is used mostly to mark a corrupted index when index's own dictionary is corrupted, and we force to load such index for repair purpose

Parameters
indexin/out: index
tablein/out: table
UNIV_INTERN ibool dict_str_starts_with_keyword ( THD *  thd,
const char *  str,
const char *  keyword 
)

Determines whether a string starts with the specified keyword.

Returns
TRUE if str starts with keyword
Parameters
thdin: MySQL thread handle
strin: string to scan for keyword
keywordin: keyword to look for
UNIV_INTERN void dict_table_add_system_columns ( dict_table_t table,
mem_heap_t heap 
)

Adds system columns to a table object.

Parameters
tablein/out: table
heapin: temporary heap
UNIV_INTERN void dict_table_add_to_cache ( dict_table_t table,
ibool  can_be_evicted,
mem_heap_t heap 
)

Adds a table object to the dictionary cache.

Parameters
tablein: table
can_be_evictedin: TRUE if can be evicted
heapin: temporary heap
UNIV_INTERN void dict_table_autoinc_initialize ( dict_table_t table,
ib_uint64_t  value 
)

Unconditionally set the autoinc counter.

Parameters
tablein/out: table
valuein: next value to assign to a row
UNIV_INTERN void dict_table_autoinc_lock ( dict_table_t table)

Acquire the autoinc lock.

Parameters
tablein/out: table
UNIV_INTERN ib_uint64_t dict_table_autoinc_read ( const dict_table_t table)

Reads the next autoinc value (== autoinc counter value), 0 if not yet initialized.

Returns
value for a new row, or 0
Parameters
tablein: table
UNIV_INTERN void dict_table_autoinc_unlock ( dict_table_t table)

Release the autoinc lock.

Parameters
tablein/out: table
UNIV_INTERN void dict_table_autoinc_update_if_greater ( dict_table_t table,
ib_uint64_t  value 
)

Updates the autoinc counter if the value supplied is greater than the current value.

Parameters
tablein/out: table
valuein: value which was assigned to a row
UNIV_INTERN void dict_table_change_id_in_cache ( dict_table_t table,
table_id_t  new_id 
)

Change the id of a table object in the dictionary cache. This is used in DISCARD TABLESPACE.

Parameters
tablein/out: table object already in cache
new_idin: new id to set
UNIV_INTERN void dict_table_check_for_dup_indexes ( const dict_table_t table,
enum check_name  check 
)

Check for duplicate index entries in a table [using the index name]

Parameters
tablein: Check for dup indexes in this table
checkin: whether and when to allow temporary index names
UNIV_INTERN void dict_table_close ( dict_table_t table,
ibool  dict_locked,
ibool  try_drop 
)

Decrements the count of open handles to a table.

Parameters
tablein/out: table
dict_lockedin: TRUE=data dictionary locked
try_dropin: TRUE=try to drop any orphan indexes after an aborted online index creation
UNIV_INTERN ibool dict_table_col_in_clustered_key ( const dict_table_t table,
ulint  n 
)

Checks if a column is in the ordering columns of the clustered index of a table. Column prefixes are treated like whole columns.

Returns
TRUE if the column, or its prefix, is in the clustered key
Parameters
tablein: table
nin: column number
UNIV_INTERN void dict_table_copy_types ( dtuple_t tuple,
const dict_table_t table 
)

Copies types of columns contained in table to tuple and sets all fields of the tuple to the SQL NULL value. This function should be called right after dtuple_create().

Parameters
tuplein/out: data tuple
tablein: table
UNIV_INTERN const char* dict_table_get_col_name ( const dict_table_t table,
ulint  col_nr 
)

Returns a column's name.

Returns
column name. NOTE: not guaranteed to stay valid if table is modified in any way (columns added, etc.).
Parameters
tablein: table
col_nrin: column number
UNIV_INLINE dict_index_t* dict_table_get_first_index ( const dict_table_t table)

Gets the first index on the table (the clustered index).

Returns
index, NULL if none exists
Parameters
tablein: table
UNIV_INTERN dict_foreign_t* dict_table_get_foreign_constraint ( dict_table_t table,
dict_index_t index 
)

Checks if a index is defined for a foreign key constraint. Index is a part of a foreign key constraint if the index is referenced by foreign key or index is a foreign key index

Returns
pointer to foreign key struct if index is defined for foreign key, otherwise NULL
Parameters
tablein: InnoDB table
indexin: InnoDB index
UNIV_INLINE ulint dict_table_get_format ( const dict_table_t table)

Determine the file format of a table.

Returns
file format version
Parameters
tablein: table
UNIV_INTERN ulint dict_table_get_highest_foreign_id ( dict_table_t table)

Finds the highest [number] for foreign key constraints of the table. Looks only at the >= 4.0.18-format id's, which are of the form databasename/tablename_ibfk_[number].

Returns
highest number, 0 if table has no new format foreign key constraints in: table in the dictionary memory cache
UNIV_INLINE dict_index_t* dict_table_get_index_on_first_col ( const dict_table_t table,
ulint  col_index 
)

Get index by first field of the index

Returns
index which is having first field matches with the field present in field_index position of table in: position of column in table

Get index by first field of the index

Returns
index which is having first field matches with the field present in field_index position of table
Parameters
tablein: table
col_indexin: position of column in table
UNIV_INTERN dict_index_t* dict_table_get_index_on_name ( dict_table_t table,
const char *  name 
)

Get index by name

Returns
index, NULL if does not exist
Parameters
tablein: table
namein: name of the index to find
UNIV_INTERN dict_index_t* dict_table_get_index_on_name_and_min_id ( dict_table_t table,
const char *  name 
)

In case there is more than one index with the same name return the index with the min(id).

Returns
index, NULL if does not exist
Parameters
tablein: table
namein: name of the index to find
UNIV_INLINE dict_index_t* dict_table_get_last_index ( const dict_table_t table)

Gets the last index on the table.

Returns
index, NULL if none exists
Parameters
tablein: table
UNIV_INLINE ulint dict_table_get_n_cols ( const dict_table_t table)

Gets the number of all columns (also system) in a table in the dictionary cache.

Returns
number of columns of a table
Parameters
tablein: table
UNIV_INLINE ib_uint64_t dict_table_get_n_rows ( const dict_table_t table)

Gets the approximately estimated number of rows in the table.

Returns
estimated number of rows
Parameters
tablein: table
UNIV_INLINE ulint dict_table_get_n_sys_cols ( const dict_table_t table)

Gets the number of system columns in a table in the dictionary cache.

Returns
number of system (e.g., ROW_ID) columns of a table

Gets the number of system columns in a table in the dictionary cache.

Returns
number of system (e.g., ROW_ID) columns of a table

< in: table

Parameters
tablein: table
UNIV_INLINE ulint dict_table_get_n_user_cols ( const dict_table_t table)

Gets the number of user-defined columns in a table in the dictionary cache.

Returns
number of user-defined (e.g., not ROW_ID) columns of a table
Parameters
tablein: table
UNIV_INLINE dict_index_t* dict_table_get_next_index ( const dict_index_t index)

Gets the next index on the table.

Returns
index, NULL if none left
Parameters
indexin: index
UNIV_INLINE dict_col_t* dict_table_get_nth_col ( const dict_table_t table,
ulint  pos 
)

Gets the nth column of a table.

Returns
pointer to column object
Parameters
tablein: table
posin: position of column
UNIV_INTERN ulint dict_table_get_nth_col_pos ( const dict_table_t table,
ulint  n 
)

Looks for column n position in the clustered index.

Returns
position in internal representation of the clustered index
Parameters
tablein: table
nin: column number
UNIV_INTERN dict_foreign_t* dict_table_get_referenced_constraint ( dict_table_t table,
dict_index_t index 
)

Check if the index is referenced by a foreign key, if TRUE return the matching instance NULL otherwise.

Returns
pointer to foreign key struct if index is defined for foreign key, otherwise NULL
Parameters
tablein: InnoDB table
indexin: InnoDB index
UNIV_INLINE dict_col_t* dict_table_get_sys_col ( const dict_table_t table,
ulint  sys 
)

Gets the given system column of a table.

Returns
pointer to column object
Parameters
tablein: table
sysin: DATA_ROW_ID, ...
UNIV_INLINE ulint dict_table_get_sys_col_no ( const dict_table_t table,
ulint  sys 
)

Gets the given system column number of a table.

Returns
column number
Parameters
tablein: table
sysin: DATA_ROW_ID, ...
UNIV_INLINE ibool dict_table_has_fts_index ( dict_table_t table)

Check if the table has an FTS index.

Returns
TRUE if table has an FTS index
Parameters
tablein: table
UNIV_INLINE ibool dict_table_is_comp ( const dict_table_t table)

Check whether the table uses the compact page format.

Returns
TRUE if table uses the compact page format
Parameters
tablein: table
UNIV_INLINE ulint dict_table_is_corrupted ( const dict_table_t table)

Check whether the table is corrupted.

Returns
nonzero for corrupted table, zero for valid tables
Parameters
tablein: table
UNIV_INLINE bool dict_table_is_discarded ( const dict_table_t table)

Check if the tablespace for the table has been discarded.

Returns
true if the tablespace has been discarded.
Parameters
tablein: table to check
UNIV_INLINE ulint dict_table_is_fts_column ( ib_vector_t indexes,
ulint  col_no 
)

Check whether a column exists in an FTS index.

Returns
ULINT_UNDEFINED if no match else the offset within the vector
Parameters
indexesin: vector containing only FTS indexes
col_noin: col number to search for
UNIV_INTERN ibool dict_table_is_referenced_by_foreign_key ( const dict_table_t table)

Checks if a table is referenced by foreign keys.

Returns
TRUE if table is referenced by a foreign key
Parameters
tablein: InnoDB table
UNIV_INLINE bool dict_table_is_temporary ( const dict_table_t table)

Check if it is a temporary table.

Returns
true if temporary table flag is set.
Parameters
tablein: table to check
UNIV_INTERN void dict_table_move_from_lru_to_non_lru ( dict_table_t table)

Move a table to the non LRU end of the LRU list.

Parameters
tablein: table to move from LRU to non-LRU
UNIV_INTERN void dict_table_move_from_non_lru_to_lru ( dict_table_t table)

Move a table to the LRU list from the non-LRU list.

Parameters
tablein: table to move from non-LRU to LRU
UNIV_INLINE void dict_table_n_rows_dec ( dict_table_t table)

Decrement the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is approximate.

Parameters
tablein/out: table
UNIV_INLINE void dict_table_n_rows_inc ( dict_table_t table)

Increment the number of rows in the table by one. Notice that this operation is not protected by any latch, the number is approximate.

Parameters
tablein/out: table
UNIV_INTERN dict_table_t* dict_table_open_on_id ( table_id_t  table_id,
ibool  dict_locked,
dict_table_op_t  table_op 
)

Returns a table object based on table id.

Returns
table, NULL if does not exist
Parameters
table_idin: table id
dict_lockedin: TRUE=data dictionary locked
table_opin: operation to perform
UNIV_INTERN dict_table_t* dict_table_open_on_name ( const char *  table_name,
ibool  dict_locked,
ibool  try_drop,
dict_err_ignore_t  ignore_err 
)

Returns a table object and increments its open handle count. NOTE! This is a high-level function to be used mainly from outside the 'dict' directory. Inside this directory dict_table_get_low is usually the appropriate function.

Returns
table, NULL if does not exist
Parameters
table_namein: table name
dict_lockedin: TRUE=data dictionary locked
try_dropin: TRUE=try to drop any orphan indexes after an aborted online index creation
ignore_errin: error to be ignored when loading the table
UNIV_INTERN void dict_table_print ( dict_table_t table)

Prints a table data.

Parameters
tablein: table
UNIV_INTERN void dict_table_remove_from_cache ( dict_table_t table)

Removes a table object from the dictionary cache.

Parameters
tablein, own: table
UNIV_INTERN dberr_t dict_table_rename_in_cache ( dict_table_t table,
const char *  new_name,
ibool  rename_also_foreigns 
)

Renames a table object.

Returns
TRUE if success
Parameters
tablein/out: table
new_namein: new name
rename_also_foreignsin: in ALTER TABLE we want to preserve the original table name in constraints which reference it
UNIV_INTERN dberr_t dict_table_schema_check ( dict_table_schema_t req_schema,
char *  errstr,
size_t  errstr_sz 
)

Checks whether a table exists and whether it has the given structure. The table must have the same number of columns with the same names and types. The order of the columns does not matter. The caller must own the dictionary mutex. dict_table_schema_check()

Returns
DB_SUCCESS if the table exists and contains the necessary columns
Parameters
req_schemain/out: required table schema
errstrout: human readable error message if != DB_SUCCESS and != DB_TABLE_NOT_FOUND is returned
errstr_szin: errstr size
void dict_table_stats_latch_create ( dict_table_t table,
bool  enabled 
)
Create a dict_table_t's stats latch or delay for lazy creation.

This function is only called from either single threaded environment or from a thread that has not shared the table object with other threads.

Parameters
[in,out]tabletable whose stats latch to create
[in]enabledif false then the latch is disabled and dict_table_stats_lock()/unlock() become noop on this table.
void dict_table_stats_latch_destroy ( dict_table_t table)
Destroy a dict_table_t's stats latch.

This function is only called from either single threaded environment or from a thread that has not shared the table object with other threads.

Parameters
[in,out]tabletable whose stats latch to destroy
UNIV_INTERN void dict_table_stats_lock ( dict_table_t table,
ulint  latch_mode 
)

Lock the appropriate latch to protect a given table's statistics. table->id is used to pick the corresponding latch from a global array of latches. in: RW_S_LATCH or RW_X_LATCH

Parameters
tablein: table
UNIV_INTERN void dict_table_stats_unlock ( dict_table_t table,
ulint  latch_mode 
)

Unlock the latch that has been locked by dict_table_stats_lock() in: RW_S_LATCH or RW_X_LATCH

Parameters
tablein: table
UNIV_INLINE void dict_table_x_lock_indexes ( dict_table_t table)

Obtain exclusive locks on all index trees of the table. This is to prevent accessing index trees while InnoDB is updating internal metadata for operations such as truncate tables.

Parameters
tablein: table
UNIV_INLINE void dict_table_x_unlock_indexes ( dict_table_t table)

Release the exclusive locks on all index tree.

Parameters
tablein: table
UNIV_INLINE ulint dict_table_zip_size ( const dict_table_t table)

Check whether the table uses the compressed compact page format.

Returns
compressed page size, or 0 if not compressed
Parameters
tablein: table
UNIV_INTERN ibool dict_tables_have_same_db ( const char *  name1,
const char *  name2 
)

Checks if the database name in two table names is the same.

Returns
TRUE if same db name
Parameters
name1in: table name in the form dbname '/' tablename
name2in: table name in the form dbname '/' tablename
UNIV_INLINE ulint dict_tf_get_format ( ulint  flags)

Determine the file format from a dict_table_t::flags.

Returns
file format version
Parameters
flagsin: dict_table_t::flags
UNIV_INLINE ulint dict_tf_get_zip_size ( ulint  flags)

Extract the compressed page size from table flags.

Returns
compressed page size, or 0 if not compressed

Extract the compressed page size from dict_table_t::flags. These flags are in memory, so assert that they are valid.

Returns
compressed page size, or 0 if not compressed
Parameters
flagsin: flags
UNIV_INLINE bool dict_tf_is_valid ( ulint  flags)

Validate the table flags.

Returns
true if valid.
Parameters
flagsin: table flags
UNIV_INLINE void dict_tf_set ( ulint *  flags,
rec_format_t  format,
ulint  zip_ssize,
bool  use_data_dir 
)

Set the various values in a dict_table_t::flags pointer.

Set the file format and zip size in a dict_table_t::flags. If zip size is not needed, it should be 0.

Parameters
flagsin/out: table flags
formatin: file format
zip_ssizein: zip shift size
use_data_dirin: table uses DATA DIRECTORY
UNIV_INLINE ulint dict_tf_to_fsp_flags ( ulint  table_flags)

Convert a 32 bit integer table flags to the 32 bit integer that is written into the tablespace header at the offset FSP_SPACE_FLAGS and is also stored in the fil_space_t::flags field. The following chart shows the translation of the low order bit. Other bits are the same. ========================= Low order bit ========================== | REDUNDANT | COMPACT | COMPRESSED | DYNAMIC dict_table_t::flags | 0 | 1 | 1 | 1

fil_space_t::flags | 0 | 0 | 1 | 1

Returns
tablespace flags (fil_space_t::flags)
Parameters
table_flagsin: dict_table_t::flags
UNIV_INTERN const char* dict_tf_to_row_format_string ( ulint  table_flag)

Convert table flag to row format string.

Returns
row format name in: row format setting

Variable Documentation

dict_index_t* dict_ind_compact

dummy index for ROW_FORMAT=COMPACT supremum and infimum records

dict_index_t* dict_ind_redundant

dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records

rw_lock_t dict_operation_lock

the data dictionary rw-latch protecting dict_sys

dict_sys_t* dict_sys

the dictionary system