Drizzled Public API Documentation

dict0dict.h File Reference
#include "univ.i"
#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 "sync0sync.h"
#include "sync0rw.h"

Go to the source code of this file.

Classes

struct  dict_sys_struct
 

Macros

#define dict0dict_h
 
#define dict_table_get_first_index(table)   UT_LIST_GET_FIRST((table)->indexes)
 
#define dict_table_get_next_index(index)   UT_LIST_GET_NEXT(indexes, index)
 
#define dict_table_get_nth_col(table, pos)   ((table)->cols + (pos))
 
#define dict_table_get_sys_col(table, sys)   ((table)->cols + (table)->n_cols + (sys) - DATA_N_SYS_COLS)
 
#define dict_index_get_nth_field(index, pos)   ((index)->fields + (pos))
 

Functions

UNIV_INTERN void dict_casedn_str (char *a)
 
UNIV_INTERN ulint dict_get_db_name_len (const char *name)
 
const char * dict_remove_db_name (const char *name)
 
UNIV_INTERN dict_table_tdict_table_get_on_id (table_id_t table_id, trx_t *trx)
 
UNIV_INTERN void dict_table_decrement_handle_count (dict_table_t *table, ibool dict_locked)
 
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_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, mem_heap_t *heap)
 
UNIV_INTERN void dict_table_remove_from_cache (dict_table_t *table)
 
UNIV_INTERN ibool 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 ulint dict_foreign_add_to_cache (dict_foreign_t *foreign, ibool check_charsets)
 
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 void dict_table_replace_index_in_foreign_list (dict_table_t *table, dict_index_t *index, const trx_t *trx)
 
UNIV_INTERN dict_foreign_tdict_table_get_foreign_constraint (dict_table_t *table, dict_index_t *index)
 
UNIV_INTERN ulint dict_create_foreign_constraints (trx_t *trx, const char *sql_string, size_t sql_length, const char *name, ibool reject_fks)
 
UNIV_INTERN ulint 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_get (const char *table_name, ibool inc_mysql_count)
 
UNIV_INTERN dict_index_tdict_index_get_on_id_low (dict_table_t *table, index_id_t index_id)
 
UNIV_INLINE dict_table_tdict_table_check_if_in_cache_low (const char *table_name)
 
UNIV_INLINE dict_table_tdict_table_get_low_ignore_err (const char *table_name, dict_err_ignore_t ignore_err)
 
UNIV_INLINE dict_table_tdict_table_get_low (const char *table_name)
 
UNIV_INLINE dict_table_tdict_table_get_on_id_low (table_id_t table_id)
 
UNIV_INTERN dict_index_tdict_foreign_find_equiv_index (dict_foreign_t *foreign)
 
UNIV_INTERN dict_index_tdict_table_get_index_by_max_id (dict_table_t *table, const char *name, const char **columns, ulint n_cols)
 
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_table_print_low (dict_table_t *table)
 
UNIV_INTERN void dict_table_print_by_name (const char *name)
 
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, trx_t *trx, const dict_index_t *index)
 
UNIV_INLINE ulint dict_index_is_clust (const dict_index_t *index) __attribute__((pure))
 
UNIV_INLINE ulint dict_index_is_unique (const dict_index_t *index) __attribute__((pure))
 
UNIV_INLINE ulint dict_index_is_ibuf (const dict_index_t *index) __attribute__((pure))
 
UNIV_INLINE ulint dict_index_is_sec_or_ibuf (const dict_index_t *index) __attribute__((pure))
 
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 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 void dict_table_set_format (dict_table_t *table, ulint format)
 
UNIV_INLINE ulint dict_table_flags_to_zip_size (ulint flags) __attribute__((const ))
 
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_INTERN void dict_table_copy_types (dtuple_t *tuple, const dict_table_t *table)
 
UNIV_INTERN dict_index_tdict_index_find_on_id_low (index_id_t id)
 
UNIV_INTERN ulint 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 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_INTERN ulint dict_index_get_nth_col_pos (const dict_index_t *index, ulint n)
 
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 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 void dict_index_set_page (dict_index_t *index, ulint page)
 
UNIV_INLINE rw_lock_tdict_index_get_lock (dict_index_t *index)
 
UNIV_INLINE ulint dict_index_get_space_reserve (void)
 
UNIV_INTERN ulint dict_index_calc_min_rec_len (const dict_index_t *index)
 
UNIV_INTERN void dict_update_statistics (dict_table_t *table, ibool only_calc_if_missing_stats)
 
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 ibool dict_tables_have_same_db (const char *name1, const char *name2)
 
UNIV_INTERN void dict_index_remove_from_cache (dict_table_t *table, dict_index_t *index)
 
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_INTERN void dict_ind_init (void)
 
UNIV_INTERN void dict_close (void)
 

Variables

FILE * dict_foreign_err_file
 
mutex_t dict_foreign_err_mutex
 
dict_sys_tdict_sys
 
rw_lock_t dict_operation_lock
 the data dictionary rw-latch protecting dict_sys More...
 
dict_index_tdict_ind_redundant
 
dict_index_tdict_ind_compact
 

Detailed Description

Data dictionary system

Created 1/8/1996 Heikki Tuuri

Definition in file dict0dict.h.

Function Documentation

UNIV_INTERN void dict_casedn_str ( char *  a)

Makes all characters in a NUL-terminated UTF-8 string lower case. in/out: string to put in lower case

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

Parameters
ain/out: string to put in lower case

Definition at line 192 of file dict0dict.cc.

References innobase_casedn_str().

UNIV_INTERN void dict_close ( void  )

Closes the data dictionary module.

Definition at line 4983 of file dict0dict.cc.

Referenced by innobase_shutdown_for_mysql().

UNIV_INLINE void dict_col_copy_type ( const dict_col_t col,
dtype_t type 
)

Gets the column data type. out: data type

Parameters
colin: column

Referenced by calc_row_difference(), dict_index_copy_types(), and dict_table_copy_types().

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. in: clustered index

Parameters
colin: table column

Referenced by build_template(), calc_row_difference(), dict_index_get_nth_col_pos(), row_upd_index_replace_new_col_vals(), and row_upd_replace().

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 in: nonzero=ROW_FORMAT=COMPACT
Parameters
colin: column

Referenced by btr_index_rec_validate(), dict_index_add_col(), dict_index_add_to_cache(), and dict_index_calc_min_rec_len().

UNIV_INLINE ulint dict_col_get_max_size ( const dict_col_t col)

Returns the maximum size of the column.

Returns
maximum size in: column

Referenced by dict_index_add_to_cache(), and dict_table_add_to_cache().

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 in: column

Referenced by build_template().

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 in: column

Referenced by build_template().

UNIV_INLINE ulint dict_col_get_min_size ( const dict_col_t col)

Returns the minimum size of the column.

Returns
minimum size in: 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) in: column

Referenced by dict_index_add_col(), dict_table_get_index_by_max_id(), row_build(), row_build_index_entry(), and trx_undo_rec_get_partial_row().

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 in: nonzero=ROW_FORMAT=COMPACT
Parameters
colin: column

Referenced by row_upd_changes_field_size_or_external().

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 in: column 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 1285 of file dict0dict.cc.

References innobase_strcasecmp().

Referenced by create_table_def().

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. in: minimum multi-byte character size, in bytes

Parameters
colin/out: column
mbminlenin: minimum multi-byte character size, in bytes

Referenced by dict_mem_fill_column_struct().

UNIV_INTERN ulint 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 in: if TRUE, fail with error code DB_CANNOT_ADD_CONSTRAINT if any foreign keys are found.

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 3846 of file dict0dict.cc.

References mem_free, mem_heap_create, mem_heap_free, trx_struct::mysql_thd, and ut_a.

Referenced by row_table_add_foreign_constraints().

UNIV_INTERN ulint dict_foreign_add_to_cache ( dict_foreign_t foreign,
ibool  check_charsets 
)

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 in: TRUE=check charset compatibility

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
check_charsetsin: TRUE=check charset compatibility

Definition at line 2598 of file dict0dict.cc.

References DICT_FOREIGN_ON_DELETE_SET_NULL, DICT_FOREIGN_ON_UPDATE_SET_NULL, dict_sys, dict_table_check_if_in_cache_low(), dict_foreign_struct::foreign_col_names, dict_foreign_struct::foreign_index, dict_table_struct::foreign_list, dict_foreign_struct::foreign_table, dict_foreign_struct::foreign_table_name_lookup, dict_foreign_struct::heap, dict_foreign_struct::id, mem_heap_free, dict_sys_struct::mutex, dict_foreign_struct::n_fields, dict_foreign_struct::referenced_col_names, dict_foreign_struct::referenced_index, dict_table_struct::referenced_list, dict_foreign_struct::referenced_table, dict_foreign_struct::referenced_table_name_lookup, dict_foreign_struct::type, ut_a, ut_ad, UT_LIST_ADD_LAST, and UT_LIST_REMOVE.

UNIV_INTERN dict_index_t* dict_foreign_find_equiv_index ( dict_foreign_t foreign)

Find an index that is equivalent to the one passed in and is not marked for deletion.

Returns
index equivalent to foreign->foreign_index, or NULL in: foreign key

Find an index that is equivalent to the one passed in and is not marked for deletion.

Returns
index equivalent to foreign->foreign_index, or NULL
Parameters
foreignin: foreign key

Definition at line 2472 of file dict0dict.cc.

References dict_foreign_struct::foreign_col_names, dict_foreign_struct::foreign_index, dict_foreign_struct::foreign_table, dict_foreign_struct::n_fields, and ut_a.

Referenced by dict_table_replace_index_in_foreign_list().

UNIV_INTERN ulint 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 out: id's of the 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 3891 of file dict0dict.cc.

Referenced by row_rename_table_for_mysql().

UNIV_INTERN ulint dict_get_db_name_len ( const char *  name)

Get the database name length in a table name.

Returns
database name length in: table name in the form dbname '/' tablename

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 246 of file dict0dict.cc.

Referenced by dict_print_info_on_foreign_key_in_create_format(), dict_table_rename_in_cache(), and row_rename_table_for_mysql().

UNIV_INTERN void dict_ind_init ( void  )

Inits dict_ind_redundant and dict_ind_compact.

Definition at line 4792 of file dict0dict.cc.

Referenced by srv_init().

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. in: column prefix length

Adds a column to index.

Parameters
indexin/out: index
tablein: table
colin: column
prefix_lenin: column prefix length

Definition at line 1859 of file dict0dict.cc.

References dict_field_struct::col, dict_col_get_fixed_size(), dict_col_get_no(), DICT_MAX_INDEX_COL_LEN, dict_mem_index_add_field(), dict_table_get_col_name(), dict_table_is_comp(), dict_field_struct::fixed_len, dict_index_struct::n_def, dict_index_struct::n_nullable, and dict_col_struct::prtype.

Referenced by mlog_parse_index().

UNIV_INTERN ulint 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 in: TRUE=refuse to create the index if records could be too big to fit in an B-tree page

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 1567 of file dict0dict.cc.

References BTR_EXTERN_FIELD_REF_SIZE, btr_search_info_create(), dict_col_get_fixed_size(), dict_col_get_max_size(), dict_field_get_col(), dict_index_get_n_unique(), dict_index_is_clust(), dict_mem_index_free(), dict_sys, dict_table_get_format(), DICT_TF_FORMAT_51, DICT_TF_FORMAT_ZIP, DICT_UNIVERSAL, dict_index_struct::heap, dict_table_struct::indexes, dict_index_struct::lock, mem_heap_alloc(), mem_heap_get_size(), mem_heap_zalloc(), dict_sys_struct::mutex, dict_index_struct::n_def, dict_index_struct::n_fields, dict_index_struct::n_uniq, dict_table_struct::name, dict_col_struct::ord_part, dict_index_struct::page, dict_field_struct::prefix_len, rw_lock_create, dict_index_struct::search_info, dict_sys_struct::size, dict_index_struct::stat_index_size, dict_index_struct::stat_n_diff_key_vals, dict_index_struct::stat_n_leaf_pages, dict_index_struct::table, dict_index_struct::table_name, dict_index_struct::type, ut_a, ut_ad, UT_LIST_ADD_LAST, and UT_LIST_GET_LEN.

Referenced by dict_boot(), and dict_create_index_step().

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 in: memory heap where tuple created

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 4189 of file dict0dict.cc.

References dict_index_copy_types(), dict_table_is_comp(), dtuple_check_typed(), dtuple_create(), rec_copy_prefix_to_dtuple(), rec_get_n_fields_old(), dict_index_struct::table, and ut_ad.

Referenced by btr_pcur_restore_position_func().

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 in: level of rec in tree: 0 means leaf 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 4089 of file dict0dict.cc.

References dfield_set_data(), dict_index_copy_types(), dict_index_get_n_unique_in_tree(), dict_table_is_comp(), DICT_UNIVERSAL, dtuple_check_typed(), dtuple_create(), dtuple_get_info_bits(), dtuple_set_info_bits(), dtuple_set_n_fields_cmp(), dtype_set(), mach_write_to_4(), mem_heap_alloc(), rec_copy_prefix_to_dtuple(), rec_get_n_fields_old(), dict_index_struct::table, dict_index_struct::type, ut_a, and ut_ad.

Referenced by btr_root_raise_and_insert().

UNIV_INTERN ulint dict_index_calc_min_rec_len ( const dict_index_t index)

Calculates the minimum record length in an index. in: index

Calculates the minimum record length in an index.

Parameters
indexin: index

Definition at line 4216 of file dict0dict.cc.

References dict_col_get_fixed_size(), dict_index_get_n_fields(), dict_index_get_nth_col(), dict_table_is_comp(), dict_col_struct::len, dict_col_struct::prtype, dict_index_struct::table, and UT_BITS_IN_BYTES.

Referenced by ha_innobase::estimate_rows_upper_bound().

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 in: column number

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 542 of file dict0dict.cc.

References dict_field_struct::col, dict_index_get_n_fields(), dict_index_is_clust(), dict_index_struct::table, and ut_ad.

Referenced by build_template().

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 in/out: buffer 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 4159 of file dict0dict.cc.

References dict_index_get_n_unique_in_tree(), dict_table_is_comp(), DICT_UNIVERSAL, rec_copy_prefix_to_buf(), rec_get_n_fields_old(), dict_index_struct::table, dict_index_struct::type, and ut_a.

Referenced by btr_pcur_store_position().

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. in: number of field types to copy

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 1932 of file dict0dict.cc.

References dict_col_copy_type(), dict_field_get_col(), DICT_UNIVERSAL, dtuple_set_types_binary(), and dict_index_struct::type.

Referenced by ha_innobase::change_active_index(), dict_get_first_table_name_in_db(), dict_index_build_data_tuple(), dict_index_build_node_ptr(), dict_load_foreigns(), dict_load_table(), dict_load_table_on_id(), ha_innobase::records_in_range(), row_build_row_ref(), row_build_row_ref_in_tuple(), row_create_prebuilt(), row_rec_to_index_entry_low(), row_truncate_table_for_mysql(), and trx_undo_rec_get_row_ref().

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 in: index 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

Definition at line 922 of file dict0dict.cc.

References dict_sys, dict_index_struct::id, dict_sys_struct::table_LRU, UT_LIST_GET_FIRST, and UT_LIST_GET_NEXT.

Referenced by buf_page_print(), and dict_index_get_if_in_cache_low().

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 in: 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 4030 of file dict0dict.cc.

References dict_index_find_on_id_low(), dict_sys, dict_sys_struct::mutex, and ut_ad.

Referenced by dict_create_index_step().

UNIV_INLINE rw_lock_t* dict_index_get_lock ( dict_index_t 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 in: index
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 in: an internal representation of index (in the dictionary cache)

Referenced by dict_table_get_index_by_max_id(), row_check_index_for_mysql(), and row_search_max_autoinc().

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 in: an internal representation of index (in the dictionary cache)

Referenced by btr_estimate_number_of_different_key_vals(), cmp_rec_rec_simple(), dict_index_add_to_cache(), dict_table_col_in_clustered_key(), dict_update_statistics(), innodb_rec_per_key(), row_build_row_ref(), row_build_row_ref_in_tuple(), row_create_prebuilt(), row_search_for_mysql(), row_search_on_row_ref(), row_upd_index_replace_new_col_vals_index_pos(), trx_undo_prev_version_build(), trx_undo_rec_get_row_ref(), and trx_undo_rec_skip_row_ref().

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 in: an internal representation of index (in the dictionary cache)

Referenced by btr_estimate_number_of_different_key_vals(), btr_page_split_and_insert(), dict_index_build_node_ptr(), dict_index_copy_rec_order_prefix(), dtuple_convert_big_rec(), mlog_open_and_write_index(), rec_convert_dtuple_to_rec_comp(), rec_copy_prefix_to_buf(), rec_get_converted_size_comp(), rec_get_offsets_func(), rec_get_offsets_reverse(), row_build_index_entry(), and row_rec_to_index_entry_low().

UNIV_INLINE const dict_col_t* dict_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 
)

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

Returns
column number in: position of the field
Parameters
indexin: index
UNIV_INTERN 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 in: column number

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

Definition at line 502 of file dict0dict.cc.

References dict_field_struct::col, dict_col_get_clust_pos(), dict_index_get_n_fields(), dict_index_is_clust(), dict_field_struct::prefix_len, dict_index_struct::table, and ut_ad.

Referenced by build_template(), dict_table_get_nth_col_pos(), innobase_rec_to_mysql(), and opt_find_all_cols().

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 in: field number in index2

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 585 of file dict0dict.cc.

References dict_field_struct::col, dict_index_get_n_fields(), dict_field_struct::prefix_len, and ut_ad.

Referenced by row_build_row_ref(), and row_build_row_ref_in_tuple().

UNIV_INTERN dict_index_t* dict_index_get_on_id_low ( dict_table_t table,
index_id_t  id 
)

Returns a index object, based on table and index id, and memoryfixes it.

Returns
index, NULL if does not exist in: index id

Looks for an index with the given table and index id. NOTE that we do not reserve the dictionary mutex.

Returns
index or NULL if not found from cache
Parameters
tablein: table
idin: index id

Definition at line 473 of file dict0dict.cc.

References dict_index_struct::id.

UNIV_INLINE ulint dict_index_get_page ( const dict_index_t tree)

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

Returns
page number in: index

Referenced by btr_cur_open_at_rnd_pos_func(), btr_cur_search_to_nth_level(), btr_discard_page(), and btr_root_raise_and_insert().

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 in: index

Referenced by btr_compress(), btr_cur_open_at_rnd_pos_func(), btr_cur_search_to_nth_level(), btr_discard_page(), btr_page_alloc(), and btr_root_raise_and_insert().

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 in: DATA_ROW_ID, ...
Parameters
indexin: index

Referenced by page_cur_insert_rec_zip(), page_zip_write_rec(), row_get_trx_id_offset(), row_upd_build_difference_binary(), row_upd_index_entry_sys_field(), row_upd_write_sys_vals_to_log(), and trx_undo_update_rec_get_update().

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

Referenced by btr_compress(), btr_cur_del_mark_set_clust_rec(), btr_cur_optimistic_update(), btr_cur_search_to_nth_level(), btr_cur_update_alloc_zip(), btr_cur_update_in_place(), btr_page_split_and_insert(), btr_root_raise_and_insert(), dict_index_add_to_cache(), dict_index_contains_col_or_prefix(), dict_index_get_nth_col_pos(), dict_update_statistics(), ha_innobase::doOpen(), dtuple_convert_big_rec(), ibuf_insert(), lock_clust_rec_cons_read_sees(), lock_clust_rec_modify_check_and_lock(), lock_clust_rec_read_check_and_lock(), lock_rec_insert_check_and_lock(), lock_sec_rec_modify_check_and_lock(), lock_sec_rec_read_check_and_lock(), opt_find_all_cols(), page_cur_insert_rec_zip(), page_zip_copy_recs(), page_zip_reorganize(), page_zip_write_rec(), pars_update_statement(), rec_init_offsets_comp_ordinary(), row_build(), row_build_index_entry(), row_build_row_ref(), row_build_row_ref_in_tuple(), row_get_clust_rec(), row_get_trx_id_offset(), row_purge_poss_sec(), row_search_for_mysql(), row_unlock_for_mysql(), row_upd_build_difference_binary(), row_upd_build_sec_rec_difference_binary(), row_upd_index_entry_sys_field(), row_upd_replace(), row_upd_write_sys_vals_to_log(), row_vers_build_for_consistent_read(), row_vers_build_for_semi_consistent_read(), trx_undo_prev_version_build(), trx_undo_rec_get_partial_row(), trx_undo_rec_get_row_ref(), trx_undo_rec_skip_row_ref(), trx_undo_report_row_operation(), and trx_undo_update_rec_get_update().

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

Referenced by page_copy_rec_list_end(), and page_copy_rec_list_start().

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

Referenced by row_check_index_for_mysql(), and row_search_for_mysql().

UNIV_INTERN void dict_index_name_print ( FILE *  file,
trx_t trx,
const dict_index_t index 
)

Displays the names of the index and the table. in: index to print

Displays the names of the index and the table.

Parameters
filein: output stream
trxin: transaction
indexin: index to print

Definition at line 4775 of file dict0dict.cc.

References dict_index_struct::name, dict_index_struct::table_name, and ut_print_name().

Referenced by buf_page_print(), lock_check_trx_id_sanity(), lock_rec_print(), opt_print_query_plan(), row_check_index_for_mysql(), row_create_index_for_mysql(), row_search_for_mysql(), row_sel_convert_mysql_key_to_innobase(), and trx_undo_update_rec_get_update().

UNIV_INTERN void dict_index_remove_from_cache ( dict_table_t table,
dict_index_t index 
)
UNIV_INLINE void dict_index_set_page ( dict_index_t index,
ulint  page 
)

Sets the page number of the root of index tree. in: page number

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

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

Parameters
indexin/out: index
UNIV_INTERN void dict_init ( void  )

Inits the data dictionary module.

Definition at line 704 of file dict0dict.cc.

Referenced by dict_boot().

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 void dict_mutex_enter_for_mysql ( void  )

Reserves the dictionary system mutex for MySQL.

Definition at line 267 of file dict0dict.cc.

UNIV_INTERN void dict_mutex_exit_for_mysql ( void  )

Releases the dictionary system mutex for MySQL.

Definition at line 277 of file dict0dict.cc.

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. in: whether to add a 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 4588 of file dict0dict.cc.

References DICT_FOREIGN_ON_DELETE_CASCADE, DICT_FOREIGN_ON_DELETE_NO_ACTION, DICT_FOREIGN_ON_DELETE_SET_NULL, DICT_FOREIGN_ON_UPDATE_CASCADE, DICT_FOREIGN_ON_UPDATE_NO_ACTION, DICT_FOREIGN_ON_UPDATE_SET_NULL, dict_get_db_name_len(), dict_remove_db_name(), dict_tables_have_same_db(), dict_foreign_struct::foreign_col_names, dict_foreign_struct::foreign_table_name_lookup, dict_foreign_struct::id, dict_foreign_struct::referenced_col_names, dict_foreign_struct::referenced_table_name, dict_foreign_struct::referenced_table_name_lookup, dict_foreign_struct::type, and ut_print_name().

Referenced by row_ins_check_foreign_constraint().

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. in: 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 4685 of file dict0dict.cc.

Referenced by ha_innobase::get_foreign_key_create_info(), and ha_innobase::update_table_comment().

const char* dict_remove_db_name ( const char *  name)

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

Returns
table name in: table name in the form dbname '/' tablename

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 225 of file dict0dict.cc.

Referenced by dict_print_info_on_foreign_key_in_create_format(), and dict_table_rename_in_cache().

UNIV_INTERN void dict_table_add_system_columns ( dict_table_t table,
mem_heap_t heap 
)

Adds system columns to a table object. in: temporary heap

Adds system columns to a table object.

Parameters
tablein/out: table
heapin: temporary heap

Definition at line 780 of file dict0dict.cc.

References dict_table_struct::cached, dict_mem_table_add_col(), dict_table_struct::n_cols, dict_table_struct::n_def, and ut_ad.

Referenced by dict_load_table(), dict_table_add_to_cache(), and mlog_parse_index().

UNIV_INTERN void dict_table_autoinc_initialize ( dict_table_t table,
ib_uint64_t  value 
)

Unconditionally set the autoinc counter. in: next value to assign to a row

Unconditionally set the autoinc counter.

Parameters
tablein/out: table
valuein: next value to assign to a row

Definition at line 412 of file dict0dict.cc.

References dict_table_struct::autoinc, dict_table_struct::autoinc_mutex, and ut_ad.

Referenced by InnobaseEngine::doCreateTable(), ha_innobase::innobase_initialize_autoinc(), ha_innobase::innobase_reset_autoinc(), and row_truncate_table_for_mysql().

UNIV_INTERN void dict_table_autoinc_lock ( dict_table_t 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 in: 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 428 of file dict0dict.cc.

References dict_table_struct::autoinc, dict_table_struct::autoinc_mutex, and ut_ad.

Referenced by ha_innobase::doOpen(), ha_innobase::innobase_get_autoinc(), and ha_innobase::innobase_peek_autoinc().

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. in: value which was assigned to a row

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 442 of file dict0dict.cc.

References dict_table_struct::autoinc, dict_table_struct::autoinc_mutex, and ut_ad.

Referenced by ha_innobase::doUpdateRecord(), ha_innobase::get_auto_increment(), and ha_innobase::innobase_set_max_autoinc().

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. in: new id to set

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 1192 of file dict0dict.cc.

References dict_sys, HASH_DELETE, HASH_INSERT, dict_table_struct::id, dict_sys_struct::mutex, dict_sys_struct::table_id_hash, ut_ad, and ut_fold_ull().

Referenced by row_discard_tablespace_for_mysql(), and row_truncate_table_for_mysql().

UNIV_INLINE dict_table_t* dict_table_check_if_in_cache_low ( const char *  table_name)

Checks if a table is in the dictionary cache.

Returns
table, NULL if not found in: table name

Referenced by dict_foreign_add_to_cache().

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 in: column number

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 669 of file dict0dict.cc.

References dict_field_struct::col, dict_index_get_n_unique(), and ut_ad.

Referenced by build_template().

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(). in: 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 1963 of file dict0dict.cc.

References dfield_set_null(), dict_col_copy_type(), and dtuple_get_n_fields().

Referenced by pars_insert_statement(), row_build(), and trx_undo_rec_get_partial_row().

UNIV_INTERN void dict_table_decrement_handle_count ( dict_table_t table,
ibool  dict_locked 
)

Decrements the count of open MySQL handles to a table. in: TRUE=data dictionary locked

Decrements the count of open MySQL handles to a table.

Parameters
tablein/out: table
dict_lockedin: TRUE=data dictionary locked

Definition at line 348 of file dict0dict.cc.

References dict_sys, dict_sys_struct::mutex, dict_table_struct::n_mysql_handles_opened, ut_a, and ut_ad.

Referenced by ha_innobase::doOpen(), and row_prebuilt_free().

UNIV_INLINE ulint dict_table_flags_to_zip_size ( ulint  flags) const
UNIV_INTERN dict_table_t* dict_table_get ( const char *  table_name,
ibool  inc_mysql_count 
)

Returns a table object and optionally increment its MySQL 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 in: whether to increment the open handle count on the table

Returns a table object and optionally increment its MySQL 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
inc_mysql_countin: whether to increment the open handle count on the table

Definition at line 746 of file dict0dict.cc.

References dict_sys, dict_table_get_low(), dict_update_statistics(), dict_sys_struct::mutex, and dict_table_struct::n_mysql_handles_opened.

Referenced by InnobaseEngine::doCreateTable(), ha_innobase::doOpen(), and row_search_check_if_query_cache_permitted().

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.). in: column number

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 374 of file dict0dict.cc.

References dict_table_struct::col_names, and ut_ad.

Referenced by dict_index_add_col(), dict_table_get_index_by_max_id(), and row_merge_create_temporary_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 in: InnoDB 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 2279 of file dict0dict.cc.

References dict_foreign_struct::foreign_index, dict_table_struct::foreign_list, dict_foreign_struct::referenced_index, ut_ad, UT_LIST_GET_FIRST, and UT_LIST_GET_NEXT.

UNIV_INLINE ulint dict_table_get_format ( const dict_table_t table)
UNIV_INTERN dict_index_t* dict_table_get_index_by_max_id ( dict_table_t table,
const char *  name,
const char **  columns,
ulint  n_cols 
)

Returns an index object by matching on the name and column names and if more than one index matches return the index with the max id

Returns
matching index, NULL if not found in: number of columns

Returns an index object by matching on the name and column names and if more than one index matches return the index with the max id

Returns
matching index, NULL if not found
Parameters
tablein: table
namein: the index name to find
columnsin: array of column names
n_colsin: number of columns

Definition at line 2495 of file dict0dict.cc.

References dict_field_struct::col, dict_col_get_no(), dict_index_get_n_ordering_defined_by_user(), dict_table_get_col_name(), dict_index_struct::id, innobase_strcasecmp(), dict_index_struct::name, and ut_strcmp().

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 in: name of the index to find

Get index by name

Returns
index, NULL if does not exist
Parameters
tablein: table
namein: name of the index to find

Definition at line 4848 of file dict0dict.cc.

References dict_index_struct::name, and ut_strcmp().

Referenced by innobase_build_index_translation(), ha_innobase::innobase_get_index(), and innobase_get_mysql_key_number_for_index().

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 in: name of the index to find

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 4909 of file dict0dict.cc.

References dict_index_struct::id, dict_index_struct::name, and ut_strcmp().

UNIV_INLINE dict_table_t* dict_table_get_low_ignore_err ( const char *  table_name,
dict_err_ignore_t  ignore_err 
)

Gets a table; loads it to the dictionary cache if necessary. A low-level function.

Returns
table, NULL if not found in: error to be ignored when loading a table definition
Parameters
table_namein: table name

Referenced by row_drop_table_for_mysql().

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 in: table

Referenced by pars_insert_statement(), row_build(), row_create_prebuilt(), row_create_update_node_for_mysql(), row_upd_replace(), and trx_undo_rec_get_partial_row().

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 in: 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 in: table

Referenced by innobase_rec_to_mysql(), pars_insert_statement(), and row_merge_create_temporary_table().

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 in: column number

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 654 of file dict0dict.cc.

References dict_index_get_nth_col_pos().

UNIV_INTERN dict_table_t* dict_table_get_on_id ( table_id_t  table_id,
trx_t trx 
)

Returns a table object based on table id.

Returns
table, NULL if does not exist in: transaction handle

Returns a table object based on table id.

Returns
table, NULL if does not exist
Parameters
table_idin: table id
trxin: transaction handle

Definition at line 623 of file dict0dict.cc.

References trx_struct::dict_operation_lock_mode, dict_sys, dict_table_get_on_id_low(), dict_sys_struct::mutex, and ut_ad.

UNIV_INLINE dict_table_t* dict_table_get_on_id_low ( table_id_t  table_id)

Returns a table object based on table id.

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

Referenced by dict_table_get_on_id(), and row_merge_drop_temp_indexes().

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 in: InnoDB 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 2248 of file dict0dict.cc.

References dict_foreign_struct::referenced_index, dict_table_struct::referenced_list, ut_ad, UT_LIST_GET_FIRST, and UT_LIST_GET_NEXT.

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 in: DATA_ROW_ID, ...
Parameters
tablein: table
UNIV_INLINE ibool dict_table_is_comp ( const dict_table_t table)
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 in: InnoDB 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 2234 of file dict0dict.cc.

References dict_table_struct::referenced_list, and UT_LIST_GET_LEN.

Referenced by ha_innobase::referenced_by_foreign_key().

UNIV_INTERN void dict_table_print ( dict_table_t table)

Prints a table definition. in: table

Prints a table data.

Parameters
tablein: table

Definition at line 4406 of file dict0dict.cc.

References dict_sys, dict_table_print_low(), and dict_sys_struct::mutex.

UNIV_INTERN void dict_table_print_by_name ( const char *  name)

Prints a table data when we know the table name. in: table name

Prints a table data when we know the table name.

Parameters
namein: table name

Definition at line 4419 of file dict0dict.cc.

References dict_sys, dict_table_get_low(), dict_table_print_low(), dict_sys_struct::mutex, and ut_a.

UNIV_INTERN ibool dict_table_rename_in_cache ( dict_table_t table,
const char *  new_name,
ibool  rename_also_foreigns 
)
UNIV_INTERN void dict_table_replace_index_in_foreign_list ( dict_table_t table,
dict_index_t index,
const trx_t trx 
)

Replace the index in the foreign key list that matches this index's definition with an equivalent index. in: transaction handle

Replace the index passed in with another equivalent index in the tables foreign key list.

Parameters
tablein/out: table
indexin: index to be replaced
trxin: transaction handle

Definition at line 4875 of file dict0dict.cc.

References dict_foreign_find_equiv_index(), dict_foreign_struct::foreign_index, dict_table_struct::foreign_list, ut_a, UT_LIST_GET_FIRST, and UT_LIST_GET_NEXT.

Referenced by row_merge_drop_index().

UNIV_INLINE void dict_table_set_format ( dict_table_t table,
ulint  format 
)

Set the file format of a table. in: file format version

Parameters
tablein/out: table
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. in: RW_S_LATCH or RW_X_LATCH

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 294 of file dict0dict.cc.

References rw_lock_s_lock, ut_ad, and ut_error.

Referenced by dict_table_print_low(), dict_update_statistics(), and ha_innobase::info().

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() in: RW_S_LATCH or RW_X_LATCH

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 321 of file dict0dict.cc.

References ut_ad, and ut_error.

Referenced by dict_table_print_low(), dict_update_statistics(), and ha_innobase::info().

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. in: table

Referenced by row_truncate_table_for_mysql().

UNIV_INLINE void dict_table_x_unlock_indexes ( dict_table_t table)

Release the exclusive locks on all index tree. in: table

Referenced by row_truncate_table_for_mysql().

UNIV_INLINE ulint dict_table_zip_size ( const dict_table_t 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 in: table name in the form dbname '/' tablename

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 204 of file dict0dict.cc.

Referenced by dict_print_info_on_foreign_key_in_create_format(), and row_drop_table_for_mysql().

UNIV_INTERN void dict_update_statistics ( dict_table_t table,
ibool  only_calc_if_missing_stats 
)

Calculates new estimates for table and index statistics. The statistics are used in query optimization. in: only update/recalc the stats if they have not been initialized yet, otherwise do nothing

Calculates new estimates for table and index statistics. The statistics are used in query optimization.

Parameters
tablein/out: table
only_calc_if_missing_statsin: only update/recalc the stats if they have not been initialized yet, otherwise do nothing

Definition at line 4268 of file dict0dict.cc.

References btr_estimate_number_of_different_key_vals(), btr_get_size(), dict_index_get_n_unique(), dict_index_is_clust(), dict_table_stats_lock(), dict_table_stats_unlock(), dict_table_struct::ibd_file_missing, dict_table_struct::name, SRV_FORCE_NO_IBUF_MERGE, SRV_FORCE_NO_LOG_REDO, dict_table_struct::stat_clustered_index_size, dict_index_struct::stat_index_size, dict_table_struct::stat_initialized, dict_table_struct::stat_modified_counter, dict_index_struct::stat_n_diff_key_vals, dict_index_struct::stat_n_leaf_pages, dict_table_struct::stat_n_rows, dict_table_struct::stat_sum_of_other_index_sizes, and ut_print_timestamp().

Referenced by dict_process_sys_tables_rec(), dict_table_get(), dict_table_print_low(), ha_innobase::info(), and row_truncate_table_for_mysql().

Variable Documentation

dict_index_t* dict_ind_compact

dummy index for ROW_FORMAT=COMPACT supremum and infimum records

Definition at line 35 of file dict0dict.cc.

dict_index_t* dict_ind_redundant

dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records

Definition at line 33 of file dict0dict.cc.

Referenced by fsp_header_init().

rw_lock_t dict_operation_lock

the data dictionary rw-latch protecting dict_sys

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_struct::dict_operation_lock_mode

Definition at line 73 of file dict0dict.cc.

Referenced by row_create_index_for_mysql(), row_create_table_for_mysql(), row_drop_table_for_mysql(), row_ins_check_foreign_constraint(), row_mysql_freeze_data_dictionary_func(), row_mysql_lock_data_dictionary_func(), row_mysql_unfreeze_data_dictionary(), row_mysql_unlock_data_dictionary(), row_table_add_foreign_constraints(), and row_truncate_table_for_mysql().

dict_sys_t* dict_sys

the dictionary system

Definition at line 63 of file dict0dict.cc.

Referenced by dict_boot(), dict_check_tablespaces_and_store_max_id(), dict_create_add_foreigns_to_dictionary(), dict_create_index_step(), dict_create_or_check_foreign_constraint_tables(), dict_create_table_step(), dict_drop_index_tree(), dict_foreign_add_to_cache(), dict_get_first_table_name_in_db(), dict_index_add_to_cache(), dict_index_find_on_id_low(), dict_index_get_if_in_cache_low(), dict_index_remove_from_cache(), dict_load_foreigns(), dict_load_sys_table(), dict_load_table(), dict_load_table_on_id(), dict_print(), dict_table_add_to_cache(), dict_table_change_id_in_cache(), dict_table_decrement_handle_count(), dict_table_get(), dict_table_get_on_id(), dict_table_print(), dict_table_print_by_name(), dict_table_print_low(), dict_table_remove_from_cache(), dict_table_rename_in_cache(), dict_truncate_index_tree(), fsp_get_available_space_in_free_extents(), ha_innobase::get_foreign_key_list(), ind_create_graph_create(), innobase_build_index_translation(), pars_sql(), que_eval_sql(), row_create_index_for_mysql(), row_create_table_for_mysql(), row_drop_table_for_mysql(), row_drop_tables_for_mysql_in_background(), row_merge_create_temporary_table(), row_merge_drop_temp_indexes(), row_merge_rename_tables(), row_mysql_drop_temp_tables(), row_mysql_lock_data_dictionary_func(), row_mysql_unlock_data_dictionary(), row_table_add_foreign_constraints(), row_truncate_table_for_mysql(), srv_printf_innodb_monitor(), and tab_create_graph_create().