MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dict0dict.cc File Reference
#include "dict0dict.h"
#include "fts0fts.h"
#include "fil0fil.h"
#include "buf0buf.h"
#include "data0type.h"
#include "mach0data.h"
#include "dict0boot.h"
#include "dict0mem.h"
#include "dict0crea.h"
#include "dict0stats.h"
#include "trx0undo.h"
#include "btr0btr.h"
#include "btr0cur.h"
#include "btr0sea.h"
#include "page0zip.h"
#include "page0page.h"
#include "pars0pars.h"
#include "pars0sym.h"
#include "que0que.h"
#include "rem0cmp.h"
#include "fts0types.h"
#include "m_ctype.h"
#include "ha_prototypes.h"
#include "srv0mon.h"
#include "srv0start.h"
#include "lock0lock.h"
#include "dict0priv.h"
#include "row0upd.h"
#include "row0mysql.h"
#include "row0merge.h"
#include "row0log.h"
#include "ut0ut.h"
#include "m_string.h"
#include "my_sys.h"
#include "mysqld.h"
#include "strfunc.h"
#include <ctype.h>
Include dependency graph for dict0dict.cc:

Go to the source code of this file.

Macros

#define DICT_HEAP_SIZE   100
#define DICT_POOL_PER_TABLE_HASH   512
#define DICT_POOL_PER_VARYING   4
#define DICT_TABLE_STATS_LATCHES_SIZE   64
#define GET_TABLE_STATS_LATCH(table)
#define BIG_ROW_SIZE   1024

Functions

UNIV_INTERN void dict_casedn_str (char *a)
UNIV_INTERN ibool dict_tables_have_same_db (const char *name1, const char *name2)
UNIV_INTERN const char * dict_remove_db_name (const char *name)
UNIV_INTERN ulint dict_get_db_name_len (const char *name)
UNIV_INTERN void dict_mutex_enter_for_mysql (void)
UNIV_INTERN void dict_mutex_exit_for_mysql (void)
UNIV_INTERN void dict_table_stats_lock (const dict_table_t *table, ulint latch_mode)
UNIV_INTERN void dict_table_stats_unlock (const dict_table_t *table, ulint latch_mode)
UNIV_INTERN void dict_table_close (dict_table_t *table, ibool dict_locked, ibool try_drop)
UNIV_INTERN const char * dict_table_get_col_name (const dict_table_t *table, ulint col_nr)
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 ulint dict_table_get_all_fts_indexes (dict_table_t *table, ib_vector_t *indexes)
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 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 dict_table_tdict_table_open_on_id (table_id_t table_id, ibool dict_locked, dict_table_op_t table_op)
UNIV_INTERN ulint dict_table_get_nth_col_pos (const dict_table_t *table, ulint n)
UNIV_INTERN ibool dict_table_col_in_clustered_key (const dict_table_t *table, ulint n)
UNIV_INTERN void dict_init (void)
UNIV_INTERN void dict_move_to_mru (dict_table_t *table)
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 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 ulint dict_make_room_in_cache (ulint max_tables, ulint pct_check)
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 dict_index_tdict_index_find_on_id_low (index_id_t id)
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_table_change_id_in_cache (dict_table_t *table, table_id_t new_id)
UNIV_INTERN void dict_table_remove_from_cache (dict_table_t *table)
UNIV_INTERN ibool dict_col_name_is_reserved (const char *name)
UNIV_INTERN dberr_t dict_index_add_to_cache (dict_table_t *table, dict_index_t *index, ulint page_no, ibool strict)
UNIV_INTERN void dict_index_remove_from_cache (dict_table_t *table, dict_index_t *index)
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_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 ibool dict_table_is_referenced_by_foreign_key (const dict_table_t *table)
UNIV_INTERN dict_foreign_tdict_table_get_referenced_constraint (dict_table_t *table, dict_index_t *index)
UNIV_INTERN dict_foreign_tdict_table_get_foreign_constraint (dict_table_t *table, dict_index_t *index)
UNIV_INTERN void dict_foreign_free (dict_foreign_t *foreign)
UNIV_INTERN void dict_foreign_remove_from_cache (dict_foreign_t *foreign)
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 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 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)
UNIV_INTERN ulint dict_table_get_highest_foreign_id (dict_table_t *table)
UNIV_INTERN ibool dict_str_starts_with_keyword (THD *thd, const char *str, const char *keyword)
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_index_tdict_index_get_if_in_cache_low (index_id_t index_id)
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_INTERN ulint dict_index_calc_min_rec_len (const dict_index_t *index)
UNIV_INTERN void dict_table_print (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_print_info_on_foreign_keys (ibool create_table_format, FILE *file, trx_t *trx, dict_table_t *table)
UNIV_INTERN void dict_index_name_print (FILE *file, const trx_t *trx, const dict_index_t *index)
UNIV_INTERN ibool dict_set_corrupted_by_space (ulint space_id)
UNIV_INTERN void dict_set_corrupted (dict_index_t *index, trx_t *trx, const char *ctx)
UNIV_INTERN void dict_set_corrupted_index_cache_only (dict_index_t *index, dict_table_t *table)
UNIV_INTERN void dict_ind_init (void)
UNIV_INTERN dict_index_tdict_table_get_index_on_name (dict_table_t *table, const char *name)
UNIV_INTERN bool dict_foreign_replace_index (dict_table_t *table, const char **col_names, const dict_index_t *index)
UNIV_INTERN dict_index_tdict_table_get_index_on_name_and_min_id (dict_table_t *table, const char *name)
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_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_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_INTERN dberr_t dict_table_schema_check (dict_table_schema_t *req_schema, char *errstr, size_t errstr_sz)

Variables

UNIV_INTERN dict_index_tdict_ind_redundant
UNIV_INTERN dict_index_tdict_ind_compact
UNIV_INTERN dict_sys_tdict_sys = NULL
UNIV_INTERN rw_lock_t dict_operation_lock
 the data dictionary rw-latch protecting dict_sys
UNIV_INTERN ulong zip_failure_threshold_pct = 5
UNIV_INTERN ulong zip_pad_max = 50
UNIV_INTERN FILE * dict_foreign_err_file = NULL
UNIV_INTERN ib_mutex_t dict_foreign_err_mutex

Detailed Description

Data dictionary system

Created 1/8/1996 Heikki Tuuri

Definition in file dict0dict.cc.

Macro Definition Documentation

#define DICT_HEAP_SIZE   100

initial memory heap size when creating a table or index object

Definition at line 114 of file dict0dict.cc.

#define DICT_POOL_PER_TABLE_HASH   512

buffer pool max size per table hash table fixed size in bytes

Definition at line 116 of file dict0dict.cc.

#define DICT_POOL_PER_VARYING   4

buffer pool max size per data dictionary varying size in bytes

Definition at line 118 of file dict0dict.cc.

#define DICT_TABLE_STATS_LATCHES_SIZE   64
array of rw locks protecting

dict_table_t::stat_initialized dict_table_t::stat_n_rows (*) dict_table_t::stat_clustered_index_size dict_table_t::stat_sum_of_other_index_sizes dict_table_t::stat_modified_counter (*) dict_table_t::indexes*::stat_n_diff_key_vals[] dict_table_t::indexes*::stat_index_size dict_table_t::indexes*::stat_n_leaf_pages (*) those are not always protected for performance reasons

Definition at line 134 of file dict0dict.cc.

#define GET_TABLE_STATS_LATCH (   table)
Value:
(&dict_table_stats_latches[ut_fold_ull((ib_uint64_t) table) \

Get the latch that protects the stats of a given table

Definition at line 336 of file dict0dict.cc.

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

Definition at line 255 of file dict0dict.cc.

Here is the call graph for this function:

UNIV_INTERN void dict_close ( void  )

Closes the data dictionary module.

Definition at line 6200 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 1928 of file dict0dict.cc.

Here is the call graph for this function:

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 both 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.

Definition at line 4665 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 the foreign table and the 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

Definition at line 3304 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 3210 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void dict_foreign_free ( dict_foreign_t foreign)

Frees a foreign key struct.

Parameters
foreignin, own: foreign key struct

Definition at line 3129 of file dict0dict.cc.

Here is the caller graph for this function:

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

Definition at line 4710 of file dict0dict.cc.

Here is the call graph for this function:

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 
)

Check an index to see whether its 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
true if the index qualifies, otherwise false
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

Definition at line 6348 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 3140 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 5777 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 6138 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 304 of file dict0dict.cc.

Here is the caller graph for this function:

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
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
heapin/out: heap memory

Definition at line 3715 of file dict0dict.cc.

Here is the call graph for this function:

UNIV_INTERN void dict_ind_init ( void  )

Inits dict_ind_redundant and dict_ind_compact.

Definition at line 5687 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 2595 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 2262 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 tree
recin: record for which to build data tuple
n_fieldsin: number of data fields
heapin: memory heap where tuple created

Definition at line 5019 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 4919 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 5046 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 705 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 4989 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 2668 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 in cache
Parameters
idin: index id

Definition at line 1359 of file dict0dict.cc.

Here is the caller graph for this function:

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

Definition at line 4860 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 662 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 748 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 5469 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 2535 of file dict0dict.cc.

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.

Definition at line 6530 of file dict0dict.cc.

Here is the caller graph for this function:

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 might not compress
Parameters
indexin: index for which page size is requested

Definition at line 6554 of file dict0dict.cc.

Here is the call graph for this function:

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.

Definition at line 6507 of file dict0dict.cc.

Here is the caller graph for this function:

UNIV_INTERN void dict_init ( void  )

Inits the data dictionary module.

Definition at line 880 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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. If the number of tables in the dict_LRU is less than max_tables it will not do anything.
Parameters
max_tablesin: max tables allowed in cache
pct_checkin: max percent to check

Definition at line 1230 of file dict0dict.cc.

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

Definition at line 916 of file dict0dict.cc.

Here is the caller graph for this function:

UNIV_INTERN void dict_mutex_enter_for_mysql ( void  )

Reserves the dictionary system mutex for MySQL.

Definition at line 319 of file dict0dict.cc.

Here is the caller graph for this function:

UNIV_INTERN void dict_mutex_exit_for_mysql ( void  )

Releases the dictionary system mutex for MySQL.

Definition at line 329 of file dict0dict.cc.

Here is the caller graph for this function:

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

Definition at line 5282 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 5379 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 288 of file dict0dict.cc.

Here is the caller graph for this function:

UNIV_INTERN void dict_set_corrupted ( dict_index_t index,
trx_t trx,
const char *  ctx 
)

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

Parameters
indexin/out: index
trxin/out: transaction
ctxin: context

Definition at line 5545 of file dict0dict.cc.

Here is the call graph for this function:

UNIV_INTERN ibool dict_set_corrupted_by_space ( ulint  space_id)

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

Returns
TRUE if successful
Parameters
space_idin: space ID

Definition at line 5521 of file dict0dict.cc.

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

Definition at line 5656 of file dict0dict.cc.

Here is the call graph for this function:

UNIV_INTERN ibool dict_str_starts_with_keyword ( THD *  thd,
const char *  str,
const char *  keyword 
)
Parameters
thdin: MySQL thread handle
strin: string to scan for keyword
keywordin: keyword to look for

Definition at line 4643 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 1017 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1064 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 573 of file dict0dict.cc.

Here is the caller graph for this function:

UNIV_INTERN void dict_table_autoinc_lock ( dict_table_t table)

Acquire the autoinc lock.

Parameters
tablein/out: table

Definition at line 562 of file dict0dict.cc.

Here is the caller graph for this function:

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

Definition at line 616 of file dict0dict.cc.

Here is the caller graph for this function:

UNIV_INTERN void dict_table_autoinc_unlock ( dict_table_t table)

Release the autoinc lock.

Parameters
tablein/out: table

Definition at line 648 of file dict0dict.cc.

Here is the caller graph for this function:

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

Definition at line 630 of file dict0dict.cc.

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

Definition at line 1784 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 470 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 845 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 2699 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint dict_table_get_all_fts_indexes ( dict_table_t table,
ib_vector_t indexes 
)
Parameters
tablein: table
indexesout: all FTS indexes on this table

Definition at line 588 of file dict0dict.cc.

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

Definition at line 535 of file dict0dict.cc.

Here is the caller graph for this function:

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

Definition at line 3102 of file dict0dict.cc.

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
Parameters
tablein: table in the dictionary memory cache

Definition at line 3987 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 5745 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 5848 of file dict0dict.cc.

Here is the call graph for this function:

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

Definition at line 830 of file dict0dict.cc.

Here is the call graph for this function:

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 foreign else return NULL

Returns
pointer to foreign key struct if index is defined for foreign key, otherwise NULL
Parameters
tablein: InnoDB table
indexin: InnoDB index

Definition at line 3071 of file dict0dict.cc.

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

Definition at line 3057 of file dict0dict.cc.

Here is the caller graph for this function:

UNIV_INTERN void dict_table_move_from_lru_to_non_lru ( dict_table_t table)

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

Parameters
tablein: table to move from LRU to non-LRU

Definition at line 1290 of file dict0dict.cc.

Here is the caller graph for this function:

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

Definition at line 1310 of file dict0dict.cc.

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

Definition at line 786 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 increment its open handle count. NOTE! This is a high-level function to be used mainly from outside the 'dict' module. 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 a table definition

Definition at line 941 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void dict_table_print ( dict_table_t table)

Prints a table data.

Parameters
tablein: table

Definition at line 5127 of file dict0dict.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void dict_table_remove_from_cache ( dict_table_t table)

Removes a table object from the dictionary cache.

Parameters
tablein, own: table

Definition at line 1915 of file dict0dict.cc.

Here is the caller graph for this function:

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

Definition at line 1400 of file dict0dict.cc.

Here is the call graph for this function:

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 is returned
errstr_szin: errstr size

Definition at line 5942 of file dict0dict.cc.

Here is the call graph for this function:

UNIV_INTERN void dict_table_stats_lock ( const 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.

Parameters
tablein: table
latch_modein: RW_S_LATCH or RW_X_LATCH

Definition at line 346 of file dict0dict.cc.

Here is the caller graph for this function:

UNIV_INTERN void dict_table_stats_unlock ( const dict_table_t table,
ulint  latch_mode 
)

Unlock the latch that has been locked by dict_table_stats_lock()

Parameters
tablein: table
latch_modein: RW_S_LATCH or RW_X_LATCH

Definition at line 373 of file dict0dict.cc.

Here is the caller graph for this function:

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

Definition at line 267 of file dict0dict.cc.

Here is the caller graph for this function:

UNIV_INTERN const char* dict_tf_to_row_format_string ( ulint  table_flag)

Convert table flag to row format string.

Returns
row format name.
Parameters
table_flagin: row format setting

Definition at line 6597 of file dict0dict.cc.

Here is the caller graph for this function:

Variable Documentation

UNIV_INTERN dict_index_t* dict_ind_compact

dummy index for ROW_FORMAT=COMPACT supremum and infimum records

Definition at line 39 of file dict0dict.cc.

UNIV_INTERN dict_index_t* dict_ind_redundant

dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records

Definition at line 37 of file dict0dict.cc.

UNIV_INTERN rw_lock_t dict_operation_lock

the data dictionary rw-latch protecting dict_sys

table create, drop, etc. reserve this in X-mode; implicit or backround operations purge, rollback, foreign key checks reserve this in S-mode; we cannot trust that MySQL protects implicit or background operations a table drop since MySQL does not know of them; therefore we need this; NOTE: a transaction which reserves this must keep book on the mode in trx_t::dict_operation_lock_mode

Definition at line 90 of file dict0dict.cc.

UNIV_INTERN dict_sys_t* dict_sys = NULL

the dictionary system

Definition at line 80 of file dict0dict.cc.

UNIV_INTERN ulong zip_failure_threshold_pct = 5
Percentage of compression failures that are allowed in a single

round

Definition at line 94 of file dict0dict.cc.

UNIV_INTERN ulong zip_pad_max = 50
Maximum percentage of a page that can be allowed as a pad to avoid

compression failures

Definition at line 98 of file dict0dict.cc.