MySQL 9.1.0
Source Code Documentation
dict0dict.h File Reference

Data dictionary system. More...

#include <set>
#include <vector>
#include <deque>
#include "data0data.h"
#include "data0type.h"
#include "dict/dict.h"
#include "dict0mem.h"
#include "dict0types.h"
#include "fsp0fsp.h"
#include "fsp0sysspace.h"
#include "hash0hash.h"
#include "mem0mem.h"
#include "rem0types.h"
#include "row0types.h"
#include "sql/dd/object_id.h"
#include "srv0mon.h"
#include "sync0rw.h"
#include "trx0types.h"
#include "univ.i"
#include "ut0byte.h"
#include "ut0mem.h"
#include "ut0new.h"
#include "ut0rnd.h"
#include "dict0dict.ic"

Go to the source code of this file.

Classes

struct  dict_sys_t
 
struct  dict_persist_t
 Structure for persisting dynamic metadata of data dictionary. More...
 
class  dict_persist_t::Enable_immediate
 Write dynamic metadata to DD buffer table immediately when such data is generated. More...
 
class  DDTableBuffer
 Wrapper for the mysql.innodb_dynamic_metadata used to buffer the persistent dynamic metadata. More...
 

Macros

#define dict_sys_mutex_enter()   mutex_enter(&dict_sys->mutex)
 
#define dict_sys_mutex_exit()   mutex_exit(&dict_sys->mutex)
 
#define dict_sys_mutex_own()   mutex_own(&dict_sys->mutex)
 
#define dict_sys_mutex_free()   mutex_free(&dict_sys->mutex)
 

Enumerations

enum  dict_table_op_t { DICT_TABLE_OP_NORMAL = 0 , DICT_TABLE_OP_DROP_ORPHAN , DICT_TABLE_OP_LOAD_TABLESPACE }
 Operation to perform when opening a table. More...
 
enum  check_name { CHECK_ALL_COMPLETE , CHECK_ABORTED_OK , CHECK_PARTIAL_OK }
 Whether and when to allow temporary index names. More...
 

Functions

ulint dict_get_db_name_len (const char *name)
 Get the database name length in a table name. More...
 
void dict_foreign_free (dict_foreign_t *foreign)
 Frees a foreign key struct. More...
 
ulint dict_table_get_highest_foreign_id (dict_table_t *table)
 Finds the highest [number] for foreign key constraints of the table. More...
 
const char * dict_remove_db_name (const char *name)
 Return the end of table name where we have removed dbname and '/'. More...
 
void dict_table_close (dict_table_t *table, bool dict_locked, bool try_drop)
 Decrements the count of open handles to a table. More...
 
void dict_table_close_and_drop (trx_t *trx, dict_table_t *table)
 Closes the only open handle to a table and drops a table while assuring that dict_sys->mutex is held the whole time. More...
 
void dict_init (void)
 Inits the data dictionary module. More...
 
void dict_close (void)
 Closes the data dictionary module. More...
 
void dict_persist_init (void)
 Inits the structure for persisting dynamic metadata. More...
 
void dict_persist_close (void)
 Clear the structure. More...
 
void dict_table_persist_to_dd_table_buffer (dict_table_t *table)
 Write back the dirty persistent dynamic metadata of the table to DDTableBuffer. More...
 
void dict_table_read_dynamic_metadata (const byte *buffer, ulint size, PersistentTableMetadata *metadata)
 Read persistent dynamic metadata stored in a buffer. More...
 
static ulint dict_max_field_len_store_undo (dict_table_t *table, const dict_col_t *col)
 Determine bytes of column prefix to be stored in the undo log. More...
 
static ulint dict_max_v_field_len_store_undo (dict_table_t *table, ulint col_no)
 Determine maximum bytes of a virtual column need to be stored in the undo log. More...
 
static ulint dict_col_get_no (const dict_col_t *col)
 Gets the column number. More...
 
static 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. More...
 
static ulint dict_col_get_index_pos (const dict_col_t *col, const dict_index_t *index)
 Gets the column position in the given index. More...
 
bool dict_col_name_is_reserved (const char *name)
 If the given column name is reserved for InnoDB system columns, return true. More...
 
void dict_table_autoinc_lock (dict_table_t *table)
 Acquire the autoinc lock. More...
 
void dict_table_autoinc_initialize (dict_table_t *table, uint64_t value)
 Unconditionally set the autoinc counter. More...
 
uint64_t dict_table_autoinc_read (const dict_table_t *table)
 Reads the next autoinc value (== autoinc counter value), 0 if not yet initialized. More...
 
void dict_table_autoinc_update_if_greater (dict_table_t *table, uint64_t value)
 Updates the autoinc counter if the value supplied is greater than the current value. More...
 
void dict_table_autoinc_unlock (dict_table_t *table)
 Release the autoinc lock. More...
 
static void dict_table_autoinc_persisted_update (dict_table_t *table, uint64_t autoinc)
 Update the persisted autoinc counter to specified one, we should hold autoinc_persisted_mutex. More...
 
static void dict_table_autoinc_set_col_pos (dict_table_t *table, ulint pos)
 Set the column position of autoinc column in clustered index for a table. More...
 
bool dict_table_autoinc_log (dict_table_t *table, uint64_t value, mtr_t *mtr)
 Write redo logs for autoinc counter that is to be inserted, or to update some existing smaller one to bigger. More...
 
static bool dict_table_has_autoinc_col (const dict_table_t *table)
 Check if a table has an autoinc counter column. More...
 
void dict_table_add_system_columns (dict_table_t *table, mem_heap_t *heap)
 Adds system columns to a table object. More...
 
void dict_table_set_big_rows (dict_table_t *table)
 Mark if table has big rows. More...
 
void dict_table_add_to_cache (dict_table_t *table, bool can_be_evicted)
 Adds a table object to the dictionary cache. More...
 
void dict_table_remove_from_cache (dict_table_t *table)
 Removes a table object from the dictionary cache. More...
 
void dict_partitioned_table_remove_from_cache (const char *name)
 Try to invalidate an entry from the dict cache, for a partitioned table, if any table found. More...
 
void dict_table_remove_from_cache_debug (dict_table_t *table, bool lru_evict)
 Removes a table object from the dictionary cache, for debug purpose. More...
 
dberr_t dict_table_rename_in_cache (dict_table_t *table, const char *new_name, bool rename_also_foreigns)
 Renames a table object. More...
 
void dict_index_remove_from_cache (dict_table_t *table, dict_index_t *index)
 Removes an index from the dictionary cache. More...
 
std::vector< table_id_tdict_get_all_table_ids ()
 Gathers ids of all tables in cache at the moment. More...
 
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. More...
 
void dict_foreign_remove_from_cache (dict_foreign_t *foreign)
 Removes a foreign constraint struct from the dictionary cache. More...
 
dberr_t dict_foreign_add_to_cache (dict_foreign_t *foreign, const char **col_names, bool check_charsets, bool can_free_fk, dict_err_ignore_t ignore_err)
 Adds a foreign key constraint object to the dictionary cache. More...
 
bool dict_table_is_referenced_by_foreign_key (const dict_table_t *table)
 Checks if a table is referenced by foreign keys. More...
 
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. More...
 
dict_table_tdict_table_open_on_name (const char *table_name, bool dict_locked, bool try_drop, dict_err_ignore_t ignore_err)
 Returns a table object and increments its open handle count. More...
 
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)
 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. More...
 
const char * dict_table_get_v_col_name (const dict_table_t *table, ulint col_nr)
 Returns a virtual column's name. More...
 
ulint dict_table_has_column (const dict_table_t *table, const char *col_name, ulint col_nr=0)
 Check if the table has a given (non_virtual) column. More...
 
void dict_print_info_on_foreign_key_in_create_format (FILE *file, trx_t *trx, dict_foreign_t *foreign, bool add_newline)
 Outputs info on a foreign key of a table in a format suitable for CREATE TABLE. More...
 
bool dict_foreign_qualify_index (const dict_table_t *table, const char **col_names, const char **columns, ulint n_cols, const dict_index_t *index, const dict_index_t *types_idx, bool check_charsets, ulint check_null)
 Tries to find an index whose first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx. More...
 
static void dict_table_skip_corrupt_index (dict_index_t *&index)
 
static void dict_table_next_uncorrupted_index (dict_index_t *&index)
 
static bool dict_index_is_auto_gen_clust (const dict_index_t *index)
 Check if index is auto-generated clustered index. More...
 
static ulint dict_index_is_unique (const dict_index_t *index)
 Check whether the index is unique. More...
 
static ulint dict_index_is_spatial (const dict_index_t *index)
 Check whether the index is a Spatial Index. More...
 
static ulint dict_index_has_virtual (const dict_index_t *index)
 Check whether the index contains a virtual column. More...
 
static ulint dict_index_is_ibuf (const dict_index_t *index)
 Check whether the index is the insert buffer tree. More...
 
static bool dict_index_has_desc (const dict_index_t *index)
 Check whether the index consists of descending columns only. More...
 
static 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. More...
 
ulint dict_table_get_all_fts_indexes (dict_table_t *table, ib_vector_t *indexes)
 Get all the FTS indexes on a table. More...
 
static ulint dict_table_get_n_tot_u_cols (const dict_table_t *table)
 
static ulint dict_table_get_n_v_cols (const dict_table_t *table)
 Gets the number of virtual columns in a table in the dictionary cache. More...
 
static bool dict_table_has_indexed_v_cols (const dict_table_t *table)
 Check if a table has indexed virtual columns. More...
 
static uint64_t dict_table_get_n_rows (const dict_table_t *table)
 Gets the approximately estimated number of rows in the table. More...
 
static void dict_table_n_rows_inc (dict_table_t *table)
 Increment the number of rows in the table by one. More...
 
static void dict_table_n_rows_dec (dict_table_t *table)
 Decrement the number of rows in the table by one. More...
 
dict_v_col_tdict_table_get_nth_v_col_mysql (const dict_table_t *table, ulint col_nr)
 Get nth virtual column according to its original MySQL table position. More...
 
static dict_v_col_tdict_table_get_nth_v_col (const dict_table_t *table, ulint pos)
 Gets the nth virtual column of a table. More...
 
static ulint dict_table_get_sys_col_no (const dict_table_t *table, ulint sys)
 Gets the given system column number of a table. More...
 
static bool dict_table_is_comp (const dict_table_t *table)
 Check whether the table uses the compact page format. More...
 
static bool dict_table_has_atomic_blobs (const dict_table_t *table)
 Determine if a table uses atomic BLOBs (no locally stored prefix). More...
 
static void dict_tf_set (uint32_t *flags, rec_format_t format, uint32_t zip_ssize, bool use_data_dir, bool shared_space)
 Set the various values in a dict_table_t::flags pointer. More...
 
static uint32_t dict_tf_init (bool compact, ulint zip_ssize, bool atomic_blobs, bool data_dir, bool shared_space)
 Initialize a dict_table_t::flags pointer. More...
 
uint32_t dict_tf_to_fsp_flags (uint32_t table_flags)
 Convert a 32 bit integer table flags to the 32 bit FSP Flags. More...
 
static const page_size_t dict_tf_get_page_size (uint32_t flags)
 Extract the page size info from table flags. More...
 
page_no_t dict_table_extent_size (const dict_table_t *table)
 Determine the extent size (in pages) for the given table. More...
 
static const page_size_t dict_table_page_size (const dict_table_t *table)
 Get the table page size. More...
 
static void dict_table_x_lock_indexes (dict_table_t *table)
 Obtain exclusive locks on all index trees of the table. More...
 
static void dict_table_x_unlock_indexes (dict_table_t *table)
 Release the exclusive locks on all index tree. More...
 
static bool dict_table_has_fts_index (dict_table_t *table)
 Check if the table has an FTS index. More...
 
void dict_validate_no_purge_rollback_threads ()
 Validate no active background threads to cause purge or rollback operations. More...
 
bool 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. More...
 
void dict_table_copy_v_types (dtuple_t *tuple, const dict_table_t *table)
 Copies types of virtual columns contained in table to tuple and sets all fields of the tuple to the SQL NULL value. More...
 
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. More...
 
void dict_table_wait_for_bg_threads_to_exit (dict_table_t *table, std::chrono::microseconds delay)
 
const dict_index_tdict_index_find (const index_id_t &id)
 Look up an index among already opened tables. More...
 
ulint dict_make_room_in_cache (ulint max_tables, ulint pct_check)
 Make room in the table cache by evicting an unused table. More...
 
dberr_t dict_index_add_to_cache (dict_table_t *table, dict_index_t *index, page_no_t page_no, bool strict)
 Adds an index to the dictionary cache. More...
 
void dict_index_remove_from_v_col_list (dict_index_t *index)
 Clears the virtual column's index list before index is being freed. More...
 
dberr_t dict_index_add_to_cache_w_vcol (dict_table_t *table, dict_index_t *index, const dict_add_v_col_t *add_v, page_no_t page_no, bool strict)
 Adds an index to the dictionary cache, with possible indexing newly added column. More...
 
static ulint dict_index_get_n_fields (const dict_index_t *index)
 Gets the number of fields in the internal representation of an index, including fields added by the dictionary system. More...
 
static 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. More...
 
static 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. More...
 
static uint16_t dict_index_get_n_unique_in_tree_nonleaf (const dict_index_t *index)
 Gets the number of fields on nonleaf page level 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. More...
 
static 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. More...
 
bool dict_index_contains_col_or_prefix (const dict_index_t *index, ulint n, bool is_virtual)
 Returns true if the index contains a column or a prefix of that column. More...
 
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. More...
 
ulint dict_table_get_nth_col_pos (const dict_table_t *table, ulint n)
 Looks for non-virtual column n position in the clustered index. More...
 
ulint dict_table_mysql_pos_to_innodb (const dict_table_t *table, ulint n)
 Get the innodb column position for a non-virtual column according to its original MySQL table position n. More...
 
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. More...
 
bool dict_index_check_search_tuple (const dict_index_t *index, const dtuple_t *tuple)
 Checks that a tuple has n_fields_cmp value in a sensible range, so that no comparison can occur with the page number field in a node pointer. More...
 
void dict_table_check_for_dup_indexes (const dict_table_t *table, enum check_name check)
 Check for duplicate index entries in a table [using the index name]. More...
 
bool dict_table_is_compressed_temporary (const dict_table_t *table)
 Check if a table is a temporary table with compressed row format, we should always expect false. More...
 
dtuple_tdict_index_build_node_ptr (const dict_index_t *index, const rec_t *rec, page_no_t page_no, mem_heap_t *heap, ulint level)
 Builds a node pointer out of a physical record and a page number. More...
 
rec_tdict_index_copy_rec_order_prefix (const dict_index_t *index, const rec_t *rec, ulint *n_fields, byte **buf, size_t *buf_size)
 Copies an initial segment of a physical record, long enough to specify an index entry uniquely. More...
 
dtuple_tdict_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. More...
 
static space_id_t dict_index_get_space (const dict_index_t *index)
 Gets the space id of the root of the index tree. More...
 
static void dict_index_set_space (dict_index_t *index, space_id_t space)
 Sets the space id of the root of the index tree. More...
 
static page_no_t dict_index_get_page (const dict_index_t *tree)
 Gets the page number of the root of the index tree. More...
 
static rw_lock_tdict_index_get_lock (dict_index_t *index)
 Gets the read-write lock of the index tree. More...
 
static ulint dict_index_get_space_reserve (void)
 Returns free space reserved for future updates of records. More...
 
static enum online_index_status dict_index_get_online_status (const dict_index_t *index)
 Gets the status of online index creation. More...
 
static void dict_index_set_online_status (dict_index_t *index, enum online_index_status status)
 Sets the status of online index creation. More...
 
static bool dict_index_is_online_ddl (const dict_index_t *index)
 Determines if a secondary index is being or has been created online, or if the table is being rebuilt online, allowing concurrent modifications to the table. More...
 
ulint dict_index_calc_min_rec_len (const dict_index_t *index)
 Calculates the minimum record length in an index. More...
 
void dict_mutex_enter_for_mysql (void)
 Reserves the dictionary system mutex for MySQL. More...
 
void dict_mutex_exit_for_mysql (void)
 Releases the dictionary system mutex for MySQL. More...
 
void dict_table_stats_latch_create (dict_table_t *table, bool enabled)
 Create a dict_table_t's stats latch or delay for lazy creation. More...
 
void dict_table_stats_latch_destroy (dict_table_t *table)
 Destroy a dict_table_t's stats latch. More...
 
void dict_table_stats_lock (dict_table_t *table, ulint latch_mode)
 Lock the appropriate latch to protect a given table's statistics. More...
 
void dict_table_stats_unlock (dict_table_t *table, ulint latch_mode)
 Unlock the latch that has been locked by dict_table_stats_lock(). More...
 
bool dict_tables_have_same_db (const char *name1, const char *name2)
 Checks if the database name in two table names is the same. More...
 
dict_index_tdict_table_get_index_on_name (dict_table_t *table, const char *name, bool committed=true)
 Get an index by name. More...
 
const dict_index_tdict_table_get_index_on_name (const dict_table_t *table, const char *name, bool committed=true)
 Get an index by name. More...
 
static ulint dict_table_is_fts_column (ib_vector_t *indexes, ulint col_no, bool is_virtual)
 Check whether a column exists in an FTS index. More...
 
static void dict_table_prevent_eviction (dict_table_t *table)
 Prevent table eviction by moving a table to the non-LRU list from the LRU list if it is not already there. More...
 
static void dict_table_allow_eviction (dict_table_t *table)
 Allow the table to be evicted by moving a table to the LRU list from the non-LRU list if it is not already there. More...
 
static void dict_table_ddl_acquire (dict_table_t *table)
 Move this table to non-LRU list for DDL operations if it's currently not there. More...
 
static void dict_table_ddl_release (dict_table_t *table)
 Move this table to LRU list after DDL operations if it was moved to non-LRU list. More...
 
void dict_table_move_from_lru_to_non_lru (dict_table_t *table)
 Move a table to the non LRU end of the LRU list. More...
 
void dict_table_move_from_non_lru_to_lru (dict_table_t *table)
 Move a table to the LRU end from the non LRU list. More...
 
void dict_move_to_mru (dict_table_t *table)
 Move to the most recently used segment of the LRU list. More...
 
void dict_ind_init (void)
 Inits dict_ind_redundant. More...
 
void dict_fs2utf8 (const char *db_and_table, char *db_utf8mb3, size_t db_utf8mb3_size, char *table_utf8mb3, size_t table_utf8mb3_size)
 Converts a database and table name from filesystem encoding (e.g. More...
 
void dict_resize ()
 Resize the hash tables based on the current buffer pool size. More...
 
void dict_table_mark_dirty (dict_table_t *table)
 Mark the dirty_status of a table as METADATA_DIRTY, and add it to the dirty_dict_tables list if necessary. More...
 
void dict_set_corrupted (dict_index_t *index) UNIV_COLD
 Flags an index corrupted in the data dictionary cache only. More...
 
void dict_table_load_dynamic_metadata (dict_table_t *table)
 Check if there is any latest persistent dynamic metadata recorded in DDTableBuffer table of the specific table. More...
 
void dict_persist_to_dd_table_buffer ()
 Check if any table has any dirty persistent data, if so write dirty persistent data of table to mysql.innodb_dynamic_metadata accordingly. More...
 
void dict_index_set_merge_threshold (dict_index_t *index, ulint merge_threshold)
 Sets merge_threshold in the SYS_INDEXES. More...
 
void dict_set_merge_threshold_all_debug (uint merge_threshold_all)
 Sets merge_threshold for all indexes in dictionary cache for debug. More...
 
static bool dict_tf_is_valid (uint32_t flags)
 Validate the table flags. More...
 
static bool dict_tf2_is_valid (uint32_t flags, uint32_t flags2)
 Validate both table flags and table flags2 and make sure they are compatible. More...
 
static bool dict_table_is_discarded (const dict_table_t *table)
 Check if the tablespace for the table has been discarded. More...
 
static bool dict_table_is_table_buffer (const dict_table_t *table)
 Check whether the table is DDTableBuffer. More...
 
static bool dict_table_in_shared_tablespace (const dict_table_t *table)
 Check if the table is in a shared tablespace (System or General). More...
 
static bool dict_table_is_locking_disabled (const dict_table_t *table)
 Check whether locking is disabled for this table. More...
 
static void dict_disable_redo_if_temporary (const dict_table_t *table, mtr_t *mtr)
 Turn-off redo-logging if temporary table. More...
 
static row_id_t dict_table_get_next_table_sess_row_id (dict_table_t *table)
 Get table session row-id and increment the row-id counter for next use. More...
 
static trx_id_t dict_table_get_next_table_sess_trx_id (dict_table_t *table)
 Get table session trx-id and increment the trx-id counter for next use. More...
 
static trx_id_t dict_table_get_curr_table_sess_trx_id (const dict_table_t *table)
 Get current session trx-id. More...
 
void dict_index_zip_success (dict_index_t *index)
 This function should be called whenever a page is successfully compressed. More...
 
void dict_index_zip_failure (dict_index_t *index)
 This function should be called whenever a page compression attempt fails. More...
 
ulint dict_index_zip_pad_optimal_page_size (dict_index_t *index)
 Return the optimal page size, for which page will likely compress. More...
 
const char * dict_tf_to_row_format_string (uint32_t table_flag)
 Convert table flag to row format string. More...
 
ulint dict_index_node_ptr_max_size (const dict_index_t *index)
 Return maximum size of the node pointer record. More...
 
static dict_index_tdict_table_get_index_on_first_col (dict_table_t *table, ulint col_index)
 Get index by first field of the index. More...
 
static ulint dict_table_encode_n_col (ulint n_col, ulint n_v_col)
 encode number of columns and number of virtual columns in one 4 bytes value. More...
 
static void dict_table_decode_n_col (uint32_t encoded, uint32_t *n_col, uint32_t *n_v_col)
 Decode number of virtual and non-virtual columns in one 4 bytes value. More...
 
static void dict_free_vc_templ (dict_vcol_templ_t *vc_templ)
 Free the virtual column template. More...
 
const char * dict_table_get_v_col_name_mysql (const dict_table_t *table, ulint col_nr)
 Returns a virtual column's name according to its original MySQL table position. More...
 
static bool dict_table_have_virtual_index (dict_table_t *table)
 Check whether the table have virtual index. More...
 
dict_index_tdict_sdi_get_index (space_id_t tablespace_id)
 Retrieve in-memory index for SDI table. More...
 
dict_table_tdict_sdi_get_table (space_id_t tablespace_id, bool dict_locked, bool is_create)
 Retrieve in-memory table object for SDI table. More...
 
void dict_sdi_remove_from_cache (space_id_t space_id, dict_table_t *sdi_table, bool dict_locked)
 Remove the SDI table from table cache. More...
 
static bool dict_index_is_sdi (const dict_index_t *index)
 Check if the index is SDI index. More...
 
static bool dict_table_is_sdi (uint64_t table_id)
 Check if an table id belongs SDI table. More...
 
void dict_sdi_close_table (dict_table_t *table)
 Close SDI table. More...
 
dberr_t dd_sdi_acquire_exclusive_mdl (THD *thd, space_id_t space_id, MDL_ticket **sdi_mdl)
 Acquire exclusive MDL on SDI tables. More...
 
dberr_t dd_sdi_acquire_shared_mdl (THD *thd, space_id_t space_id, MDL_ticket **sdi_mdl)
 Acquire shared MDL on SDI tables. More...
 
static bool dict_table_is_partition (const dict_table_t *table)
 Check whether the dict_table_t is a partition. More...
 
static void dict_allocate_mem_intrinsic_cache (dict_index_t *index)
 Allocate memory for intrinsic cache elements in the index. More...
 
bool dict_table_is_system (table_id_t table_id)
 
void dict_table_change_id_sys_tables ()
 Change the table_id of SYS_* tables if they have been created after an earlier upgrade. More...
 
std::string dict_table_get_datadir (const dict_table_t *table)
 Get the tablespace data directory if set, otherwise empty string. More...
 
dberr_t dict_set_compression (dict_table_t *table, const char *algorithm, bool is_import_op)
 Set the compression type for the tablespace of a table. More...
 
uint32_t dict_vcol_base_is_foreign_key (dict_v_col_t *vcol, dict_foreign_t *foreign)
 
void get_field_max_size (const dict_table_t *table, const dict_index_t *index, const dict_field_t *field, size_t &rec_max_size)
 Get maximum possible size needed for a field. More...
 
void get_permissible_max_size (const dict_table_t *table, const dict_index_t *index, size_t &page_rec_max, size_t &page_ptr_max)
 Get the maximum size of a record permissible on an index page. More...
 
bool dict_index_validate_max_rec_size (const dict_table_t *table, const dict_index_t *index, bool strict, const size_t page_rec_max, const size_t page_ptr_max, size_t &rec_max_size)
 validate that maximum possible size of a row is within permissible limit. More...
 

Variables

constexpr uint32_t DICT_HEAP_SIZE = 100
 initial memory heap size when creating a table or index object More...
 
const uint32_t SDI_VERSION = 1
 SDI version. More...
 
const space_id_t SYSTEM_TABLE_SPACE = TRX_SYS_SPACE
 Space id of system tablespace. More...
 
constexpr uint32_t BIG_ROW_SIZE = 1024
 
constexpr uint32_t DICT_INDEX_SPATIAL_NODEPTR_SIZE = 1
 The number of fields in the nonleaf page of spatial index, except the page no field. More...
 
constexpr uint32_t MAX_NUM_FK_COLUMNS = 500
 Maximum number of columns in a foreign key constraint. More...
 
FILE * dict_foreign_err_file
 
ib_mutex_t dict_foreign_err_mutex
 
dict_sys_tdict_sys
 the dictionary system More...
 
rw_lock_tdict_operation_lock
 the data dictionary rw-latch protecting dict_sys More...
 
dict_persist_tdict_persist
 the dictionary persisting structure More...
 
dict_index_tdict_ind_redundant
 dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records More...
 

Detailed Description

Data dictionary system.

Created 1/8/1996 Heikki Tuuri

Macro Definition Documentation

◆ dict_sys_mutex_enter

#define dict_sys_mutex_enter ( )    mutex_enter(&dict_sys->mutex)

◆ dict_sys_mutex_exit

#define dict_sys_mutex_exit ( )    mutex_exit(&dict_sys->mutex)

◆ dict_sys_mutex_free

#define dict_sys_mutex_free ( )    mutex_free(&dict_sys->mutex)

◆ dict_sys_mutex_own

#define dict_sys_mutex_own ( )    mutex_own(&dict_sys->mutex)

Enumeration Type Documentation

◆ check_name

enum check_name

Whether and when to allow temporary index names.

Enumerator
CHECK_ALL_COMPLETE 

Require all indexes to be complete.

CHECK_ABORTED_OK 

Allow aborted online index creation.

CHECK_PARTIAL_OK 

Allow partial indexes to exist.

◆ dict_table_op_t

Operation to perform when opening a table.

Enumerator
DICT_TABLE_OP_NORMAL 

Expect the tablespace to exist.

DICT_TABLE_OP_DROP_ORPHAN 

Drop any orphan indexes after an aborted online index creation.

DICT_TABLE_OP_LOAD_TABLESPACE 

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

Function Documentation

◆ dd_sdi_acquire_exclusive_mdl()

dberr_t dd_sdi_acquire_exclusive_mdl ( THD thd,
space_id_t  space_id,
MDL_ticket **  sdi_mdl 
)

Acquire exclusive MDL on SDI tables.

This is acquired to prevent concurrent DROP table/tablespace when there is purge happening on SDI table records. Purge will acquire shared MDL on SDI table.

Exclusive MDL is transactional(released on trx commit). So for successful acquisition, there should be a valid thd associated with a trx.

Acquisition order of SDI MDL and SDI table has to be in the same order:

  1. dd_sdi_acquire_exclusive_mdl
  2. row_drop_table_from_cache()/innodb_drop_tablespace() ->dict_sdi_remove_from_cache()->dd_table_open_on_id()

In purge:

  1. dd_sdi_acquire_shared_mdl
  2. dd_table_open_on_id()
Parameters
[in]thdserver thread instance
[in]space_idInnoDB tablespace id
[in,out]sdi_mdlMDL ticket on SDI table
Return values
DB_SUCESSon success
DB_LOCK_WAIT_TIMEOUTon error

◆ dd_sdi_acquire_shared_mdl()

dberr_t dd_sdi_acquire_shared_mdl ( THD thd,
space_id_t  space_id,
MDL_ticket **  sdi_mdl 
)

Acquire shared MDL on SDI tables.

This is acquired by purge to prevent concurrent DROP table/tablespace. DROP table/tablespace will acquire exclusive MDL on SDI table

Acquisition order of SDI MDL and SDI table has to be in same order:

  1. dd_sdi_acquire_exclusive_mdl
  2. row_drop_table_from_cache()/innodb_drop_tablespace() ->dict_sdi_remove_from_cache()->dd_table_open_on_id()

In purge:

  1. dd_sdi_acquire_shared_mdl
  2. dd_table_open_on_id()

MDL should be released by caller

Parameters
[in]thdserver thread instance
[in]space_idInnoDB tablespace id
[in,out]sdi_mdlMDL ticket on SDI table
Return values
DB_SUCESSon success
DB_LOCK_WAIT_TIMEOUTon error

◆ dict_allocate_mem_intrinsic_cache()

static void dict_allocate_mem_intrinsic_cache ( dict_index_t index)
inlinestatic

Allocate memory for intrinsic cache elements in the index.

Parameters
[in]indexindex object

◆ dict_close()

void dict_close ( void  )

Closes the data dictionary module.

◆ dict_col_get_clust_pos()

static ulint dict_col_get_clust_pos ( const dict_col_t col,
const dict_index_t clust_index 
)
inlinestatic

Gets the column position in the clustered index.

Parameters
[in]colTable column.
[in]clust_indexClustered index.

◆ dict_col_get_index_pos()

static ulint dict_col_get_index_pos ( const dict_col_t col,
const dict_index_t index 
)
inlinestatic

Gets the column position in the given index.

Parameters
[in]coltable column
[in]indexindex to be searched for column
Returns
position of column in the given index.

◆ dict_col_get_no()

static ulint dict_col_get_no ( const dict_col_t col)
inlinestatic

Gets the column number.

Returns
col->ind, table column position (starting from 0) in: column

◆ dict_col_name_is_reserved()

bool 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
true if name is reserved
Parameters
namein: column name

◆ dict_disable_redo_if_temporary()

static void dict_disable_redo_if_temporary ( const dict_table_t table,
mtr_t mtr 
)
inlinestatic

Turn-off redo-logging if temporary table.

Parameters
[in]tableTable to check
[out]mtrMini-transaction

◆ dict_foreign_add_to_cache()

dberr_t dict_foreign_add_to_cache ( dict_foreign_t foreign,
const char **  col_names,
bool  check_charsets,
bool  can_free_fk,
dict_err_ignore_t  ignore_err 
)

Adds a foreign key constraint object to the dictionary cache.

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

Returns
DB_SUCCESS or error code in: error to be ignored

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
can_free_fkin: whether free existing FK
ignore_errin: error to be ignored

◆ dict_foreign_find_index()

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 in: nonzero if none of the columns must be declared NOT NULL
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

◆ dict_foreign_free()

void dict_foreign_free ( dict_foreign_t foreign)
inline

Frees a foreign key struct.

in, own: foreign key struct

Parameters
foreignin, own: foreign key struct

◆ dict_foreign_qualify_index()

bool dict_foreign_qualify_index ( const dict_table_t table,
const char **  col_names,
const char **  columns,
ulint  n_cols,
const dict_index_t index,
const dict_index_t types_idx,
bool  check_charsets,
ulint  check_null 
)

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

Returns
matching index, NULL if not found in: nonzero if none of the columns must be declared NOT 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
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

◆ dict_foreign_remove_from_cache()

void dict_foreign_remove_from_cache ( dict_foreign_t foreign)

Removes a foreign constraint struct from the dictionary cache.

in, own: foreign constraint

Parameters
foreignin, own: foreign constraint

◆ dict_foreign_replace_index()

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 in: index to be replaced
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

◆ dict_free_vc_templ()

static void dict_free_vc_templ ( dict_vcol_templ_t vc_templ)
inlinestatic

Free the virtual column template.

Parameters
[in,out]vc_templvirtual column template

◆ dict_fs2utf8()

void dict_fs2utf8 ( const char *  db_and_table,
char *  db_utf8mb3,
size_t  db_utf8mb3_size,
char *  table_utf8mb3,
size_t  table_utf8mb3_size 
)

Converts a database and table name from filesystem encoding (e.g.

"@code d@i1b/a@q1b@1Kc @endcode", same format as used in dict_table_t::name) in two strings in UTF8MB3 encoding (e.g. dцb and aюbØc). The output buffers must be at least MAX_DB_UTF8MB3_LEN and MAX_TABLE_UTF8MB3_LEN bytes.

Parameters
[in]db_and_tabledatabase and table names, e.g. "@code d@i1b/a@q1b@1Kc @endcode"
[out]db_utf8mb3database name, e.g. dцb
[in]db_utf8mb3_sizedb_utf8mb3 size
[out]table_utf8mb3table name, e.g. aюbØc
[in]table_utf8mb3_sizetable_utf8mb3 size

◆ dict_get_all_table_ids()

std::vector< table_id_t > dict_get_all_table_ids ( )

Gathers ids of all tables in cache at the moment.

Returns
ids of all tables

◆ dict_get_db_name_len()

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
database name length
Parameters
namein: table name in the form dbname '/' tablename

◆ dict_ind_init()

void dict_ind_init ( void  )

Inits dict_ind_redundant.

◆ dict_index_add_to_cache()

dberr_t dict_index_add_to_cache ( dict_table_t table,
dict_index_t index,
page_no_t  page_no,
bool  strict 
)

Adds an index to the dictionary cache.

Parameters
[in,out]tabletable on which the index is
[in,out]indexindex; NOTE! The index memory object is freed in this function!
[in]page_noroot page number of the index
[in]stricttrue=refuse to create the index if records could be too big to fit in an B-tree page
Returns
DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION

◆ dict_index_add_to_cache_w_vcol()

dberr_t dict_index_add_to_cache_w_vcol ( dict_table_t table,
dict_index_t index,
const dict_add_v_col_t add_v,
page_no_t  page_no,
bool  strict 
)

Adds an index to the dictionary cache, with possible indexing newly added column.

Parameters
[in,out]tabletable on which the index is
[in,out]indexindex; NOTE! The index memory object is freed in this function!
[in]add_vnew virtual column that being added along with an add index call
[in]page_noroot page number of the index
[in]stricttrue=refuse to create the index if records could be too big to fit in an B-tree page
Returns
DB_SUCCESS, DB_TOO_BIG_RECORD, or DB_CORRUPTION

◆ dict_index_build_data_tuple()

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

◆ dict_index_build_node_ptr()

dtuple_t * dict_index_build_node_ptr ( const dict_index_t index,
const rec_t rec,
page_no_t  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
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

◆ dict_index_calc_min_rec_len()

ulint dict_index_calc_min_rec_len ( const dict_index_t index)

Calculates the minimum record length in an index.

in: index

Parameters
indexin: index

◆ dict_index_check_search_tuple()

bool dict_index_check_search_tuple ( const dict_index_t index,
const dtuple_t tuple 
)

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

Returns
true if ok in: tuple used in a search
true if ok
Parameters
indexin: index tree
tuplein: tuple used in a search

◆ dict_index_contains_col_or_prefix()

bool dict_index_contains_col_or_prefix ( const dict_index_t index,
ulint  n,
bool  is_virtual 
)

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

Parameters
[in]indexindex
[in]ncolumn number
[in]is_virtualwhether it is a virtual col
Returns
true if contains the column or its prefix

◆ dict_index_copy_rec_order_prefix()

rec_t * dict_index_copy_rec_order_prefix ( const dict_index_t index,
const rec_t rec,
ulint n_fields,
byte **  buf,
size_t *  buf_size 
)

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

In case buf is nullptr or the buf_size is not enough to store the prefix, the new buffer will be allocated.

Parameters
[in]indexindex
[in]recrecord for which to copy prefix
[out]n_fieldsnumber of fields copied
[in,out]bufmemory buffer for the copied prefix, or nullptr
[in,out]buf_sizebuffer size, size of allocated buffer
Returns
pointer to the prefix record

◆ dict_index_copy_types()

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
[in,out]tupleData tuple
[in]indexIndex
[in]n_fieldsNumber of field types to copy

◆ dict_index_find()

const dict_index_t * dict_index_find ( const index_id_t id)

Look up an index among already opened tables.

Does not attempt to open tables that are not available in the dictionary cache. This behaviour is fine for information schema's scenarios - use dd_table_open_on_id() if you need to access index meta-data reliably.

Parameters
[in]idindex identifier
Returns
index or NULL if not found

◆ dict_index_get_lock()

static rw_lock_t * dict_index_get_lock ( dict_index_t index)
inlinestatic

Gets the read-write lock of the index tree.

Returns
read-write lock in: index

◆ dict_index_get_n_fields()

static ulint dict_index_get_n_fields ( const dict_index_t index)
inlinestatic

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

Returns
number of fields in: an internal representation of index (in the dictionary cache)

◆ dict_index_get_n_ordering_defined_by_user()

static ulint dict_index_get_n_ordering_defined_by_user ( const dict_index_t index)
inlinestatic

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)

◆ dict_index_get_n_unique()

static ulint dict_index_get_n_unique ( const dict_index_t index)
inlinestatic

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)

◆ dict_index_get_n_unique_in_tree()

static ulint dict_index_get_n_unique_in_tree ( const dict_index_t index)
inlinestatic

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)

◆ dict_index_get_n_unique_in_tree_nonleaf()

static uint16_t dict_index_get_n_unique_in_tree_nonleaf ( const dict_index_t index)
inlinestatic

Gets the number of fields on nonleaf page level 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.

Note, it doesn't include page no field.

Parameters
[in]indexindex
Returns
number of fields

◆ dict_index_get_nth_field_pos()

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

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

◆ dict_index_get_online_status()

static enum online_index_status dict_index_get_online_status ( const dict_index_t index)
inlinestatic

Gets the status of online index creation.

Returns
the status in: secondary index

◆ dict_index_get_page()

static page_no_t dict_index_get_page ( const dict_index_t tree)
inlinestatic

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

Returns
page number in: index

◆ dict_index_get_space()

static space_id_t dict_index_get_space ( const dict_index_t index)
inlinestatic

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

Returns
space id in: index

◆ dict_index_get_space_reserve()

static ulint dict_index_get_space_reserve ( void  )
inlinestatic

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

◆ dict_index_has_desc()

static bool dict_index_has_desc ( const dict_index_t index)
inlinestatic

Check whether the index consists of descending columns only.

Parameters
[in]indexindex tree
Return values
trueif index has any descending column
falseif index has only ascending columns

◆ dict_index_has_virtual()

static ulint dict_index_has_virtual ( const dict_index_t index)
inlinestatic

Check whether the index contains a virtual column.

Parameters
[in]indexindex
Returns
nonzero for index on virtual column, zero for other indexes

◆ dict_index_is_auto_gen_clust()

static bool dict_index_is_auto_gen_clust ( const dict_index_t index)
inlinestatic

Check if index is auto-generated clustered index.

Parameters
[in]indexindex
Returns
true if index is auto-generated clustered index.

◆ dict_index_is_ibuf()

static ulint dict_index_is_ibuf ( const dict_index_t index)
inlinestatic

Check whether the index is the insert buffer tree.

Returns
nonzero for insert buffer, zero for other indexes in: index

◆ dict_index_is_online_ddl()

static bool dict_index_is_online_ddl ( const dict_index_t index)
inlinestatic

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

Return values
trueif the index is being or has been built online, or if this is a clustered index and the table is being or has been rebuilt online
falseif the index has been created or the table has been rebuilt completely in: index

◆ dict_index_is_sdi()

static bool dict_index_is_sdi ( const dict_index_t index)
inlinestatic

Check if the index is SDI index.

Parameters
[in]indexin-memory index structure
Returns
true if index is SDI index else false

◆ dict_index_is_sec_or_ibuf()

static ulint dict_index_is_sec_or_ibuf ( const dict_index_t index)
inlinestatic

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

Returns
nonzero for insert buffer, zero for other indexes in: index

◆ dict_index_is_spatial()

static ulint dict_index_is_spatial ( const dict_index_t index)
inlinestatic

Check whether the index is a Spatial Index.

Returns
nonzero for Spatial Index, zero for other indexes in: index

◆ dict_index_is_unique()

static ulint dict_index_is_unique ( const dict_index_t index)
inlinestatic

Check whether the index is unique.

Returns
nonzero for unique index, zero for other indexes in: index

◆ dict_index_node_ptr_max_size()

ulint dict_index_node_ptr_max_size ( const dict_index_t index)

Return maximum size of the node pointer record.

Returns
maximum size of the record in bytes in: index
maximum size of the record in bytes
Parameters
indexin: index

◆ dict_index_remove_from_cache()

void dict_index_remove_from_cache ( dict_table_t table,
dict_index_t index 
)

Removes an index from the dictionary cache.

Parameters
[in,out]tabletable whose index to remove
[in,out]indexindex to remove, this object is destroyed and must not be accessed by the caller afterwards
Parameters
tablein/out: table
indexin, own: index

◆ dict_index_remove_from_v_col_list()

void dict_index_remove_from_v_col_list ( dict_index_t index)

Clears the virtual column's index list before index is being freed.

Parameters
[in]indexIndex being freed

◆ dict_index_set_merge_threshold()

void dict_index_set_merge_threshold ( dict_index_t index,
ulint  merge_threshold 
)

Sets merge_threshold in the SYS_INDEXES.

Parameters
[in,out]indexindex
[in]merge_thresholdvalue to set

◆ dict_index_set_online_status()

static void dict_index_set_online_status ( dict_index_t index,
enum online_index_status  status 
)
inlinestatic

Sets the status of online index creation.

Parameters
[in,out]indexindex
[in]statusstatus

◆ dict_index_set_space()

static void dict_index_set_space ( dict_index_t index,
space_id_t  space 
)
inlinestatic

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

Parameters
[in,out]indexindex
[in]spacespace id

◆ dict_index_validate_max_rec_size()

bool dict_index_validate_max_rec_size ( const dict_table_t table,
const dict_index_t index,
bool  strict,
const size_t  page_rec_max,
const size_t  page_ptr_max,
size_t &  rec_max_size 
)

validate that maximum possible size of a row is within permissible limit.

Parameters
[in]tableinnodb table definition cache
[in]indexindex
[in]stricttrue if error is to be reported
[in]page_rec_maxmaximum size of possible record on leaf page
[in]page_ptr_maxmaximum size of possible record on non-leaf page
[out]rec_max_sizemaximum size of record on page
Returns
true if max record size is within limit, false otherwise.

◆ dict_index_zip_failure()

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. in/out: index to be updated.

Updates the compression padding information.

Parameters
indexin/out: index to be updated.

◆ dict_index_zip_pad_optimal_page_size()

ulint dict_index_zip_pad_optimal_page_size ( dict_index_t index)

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

Returns
page size beyond which page may not compress in: index for which page size is requested
page size beyond which page might not compress
Parameters
indexin: index for which page size is requested

◆ dict_index_zip_success()

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. in/out: index to be updated.

Updates the compression padding information.

Parameters
indexin/out: index to be updated.

◆ dict_init()

void dict_init ( void  )

Inits the data dictionary module.

◆ dict_make_room_in_cache()

ulint dict_make_room_in_cache ( ulint  max_tables,
ulint  pct_check 
)

Make room in the table cache by evicting an unused table.

The unused table should not be part of FK relationship and currently not used in any user transaction. There is no guarantee that it will remove a table.

Returns
number of tables evicted. in: max percent to check

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

◆ dict_max_field_len_store_undo()

static ulint dict_max_field_len_store_undo ( dict_table_t table,
const dict_col_t col 
)
inlinestatic

Determine bytes of column prefix to be stored in the undo log.

Please note that if !dict_table_has_atomic_blobs(table), no prefix needs to be stored in the undo log.

Parameters
[in]tableTable.
[in]colColumn which index prefix is based on.
Returns
bytes of column prefix to be stored in the undo log

◆ dict_max_v_field_len_store_undo()

static ulint dict_max_v_field_len_store_undo ( dict_table_t table,
ulint  col_no 
)
inlinestatic

Determine maximum bytes of a virtual column need to be stored in the undo log.

Parameters
[in]tabledict_table_t for the table
[in]col_novirtual column number
Returns
maximum bytes of virtual column to be stored in the undo log

◆ dict_move_to_mru()

void dict_move_to_mru ( dict_table_t table)

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

in: table to move to MRU

Parameters
tablein: table to move to MRU

◆ dict_mutex_enter_for_mysql()

void dict_mutex_enter_for_mysql ( void  )

Reserves the dictionary system mutex for MySQL.

◆ dict_mutex_exit_for_mysql()

void dict_mutex_exit_for_mysql ( void  )

Releases the dictionary system mutex for MySQL.

◆ dict_partitioned_table_remove_from_cache()

void dict_partitioned_table_remove_from_cache ( const char *  name)

Try to invalidate an entry from the dict cache, for a partitioned table, if any table found.

Parameters
[in]nameTable name

◆ dict_persist_close()

void dict_persist_close ( void  )

Clear the structure.

◆ dict_persist_init()

void dict_persist_init ( void  )

Inits the structure for persisting dynamic metadata.

◆ dict_persist_to_dd_table_buffer()

void dict_persist_to_dd_table_buffer ( )

Check if any table has any dirty persistent data, if so write dirty persistent data of table to mysql.innodb_dynamic_metadata accordingly.

◆ dict_print_info_on_foreign_key_in_create_format()

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

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

Parameters
[in]fileFile where to print
[in]trxTransaction
[in]foreignForeign key constraint
[in]add_newlineWhether to add a newline

◆ dict_remove_db_name()

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
table name
Parameters
namein: table name in the form dbname '/' tablename

◆ dict_resize()

void dict_resize ( )

Resize the hash tables based on the current buffer pool size.

◆ dict_sdi_close_table()

void dict_sdi_close_table ( dict_table_t table)

Close SDI table.

Parameters
[in]tablethe in-memory SDI table object

◆ dict_sdi_get_index()

dict_index_t * dict_sdi_get_index ( space_id_t  tablespace_id)

Retrieve in-memory index for SDI table.

Parameters
[in]tablespace_idinnodb tablespace ID
Returns
dict_index_t structure or NULL

◆ dict_sdi_get_table()

dict_table_t * dict_sdi_get_table ( space_id_t  tablespace_id,
bool  dict_locked,
bool  is_create 
)

Retrieve in-memory table object for SDI table.

Parameters
[in]tablespace_idinnodb tablespace ID
[in]dict_lockedtrue if dict_sys mutex is acquired
[in]is_createtrue when creating SDI Index
Returns
dict_table_t structure

◆ dict_sdi_remove_from_cache()

void dict_sdi_remove_from_cache ( space_id_t  space_id,
dict_table_t sdi_table,
bool  dict_locked 
)

Remove the SDI table from table cache.

Parameters
[in]space_idInnoDB tablespace ID
[in]sdi_tableSDI table
[in]dict_lockedtrue if dict_sys mutex acquired

◆ dict_set_compression()

dberr_t dict_set_compression ( dict_table_t table,
const char *  algorithm,
bool  is_import_op 
)

Set the compression type for the tablespace of a table.

Parameters
[in]tableThe table that should be compressed
[in]algorithmText representation of the algorithm
[in]is_import_opTrue if it's being set during import operation
Returns
DB_SUCCESS or error code

◆ dict_set_corrupted()

void dict_set_corrupted ( dict_index_t index)

Flags an index corrupted in the data dictionary cache only.

This is used to mark a corrupted index when index's own dictionary is corrupted, and we would force to load such index for repair purpose. Besides, we have to write a redo log. We don't want to hold dict_sys->mutex here, so that we can set index as corrupted in some low-level functions. We would only set the flags from not corrupted to corrupted when server is running, so it should be safe to set it directly.

Parameters
[in,out]indexindex, must not be NULL

◆ dict_set_merge_threshold_all_debug()

void dict_set_merge_threshold_all_debug ( uint  merge_threshold_all)

Sets merge_threshold for all indexes in dictionary cache for debug.

Parameters
[in]merge_threshold_allvalue to set for all indexes

◆ dict_table_add_system_columns()

void dict_table_add_system_columns ( dict_table_t table,
mem_heap_t heap 
)

Adds system columns to a table object.

Parameters
[in,out]tableTable
[in]heapTemporary heap

◆ dict_table_add_to_cache()

void dict_table_add_to_cache ( dict_table_t table,
bool  can_be_evicted 
)

Adds a table object to the dictionary cache.

Parameters
[in,out]tabletable
[in]can_be_evictedtrue if can be evicted

◆ dict_table_allow_eviction()

static void dict_table_allow_eviction ( dict_table_t table)
inlinestatic

Allow the table to be evicted by moving a table to the LRU list from the non-LRU list if it is not already there.

Parameters
[in]tableInnoDB table object can be evicted

◆ dict_table_autoinc_initialize()

void dict_table_autoinc_initialize ( dict_table_t table,
uint64_t  value 
)

Unconditionally set the autoinc counter.

Parameters
[in,out]tableTable
[in]valueNext value to assign to a row

◆ dict_table_autoinc_lock()

void dict_table_autoinc_lock ( dict_table_t table)

Acquire the autoinc lock.

in/out: table

Parameters
tablein/out: table

◆ dict_table_autoinc_log()

bool dict_table_autoinc_log ( dict_table_t table,
uint64_t  value,
mtr_t mtr 
)

Write redo logs for autoinc counter that is to be inserted, or to update some existing smaller one to bigger.

Parameters
[in,out]tableInnoDB table object
[in]valueAUTOINC counter to log
[in,out]mtrMini-transaction
Returns
true if auto increment needs to be persisted to DD table buffer.

◆ dict_table_autoinc_persisted_update()

static void dict_table_autoinc_persisted_update ( dict_table_t table,
uint64_t  autoinc 
)
inlinestatic

Update the persisted autoinc counter to specified one, we should hold autoinc_persisted_mutex.

Parameters
[in,out]tabletable
[in]autoincset autoinc_persisted to this value

◆ dict_table_autoinc_read()

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
value for a new row, or 0
Parameters
tablein: table

◆ dict_table_autoinc_set_col_pos()

static void dict_table_autoinc_set_col_pos ( dict_table_t table,
ulint  pos 
)
inlinestatic

Set the column position of autoinc column in clustered index for a table.

Parameters
[in]tabletable
[in]poscolumn position in table definition

◆ dict_table_autoinc_unlock()

void dict_table_autoinc_unlock ( dict_table_t table)

Release the autoinc lock.

in/out: table

Parameters
tablein/out: table

◆ dict_table_autoinc_update_if_greater()

void dict_table_autoinc_update_if_greater ( dict_table_t table,
uint64_t  value 
)

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

Parameters
[in,out]tableTable
[in]valueValue which was assigned to a row

◆ dict_table_change_id_in_cache()

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

This is used in DISCARD TABLESPACE.

Parameters
tablein/out: table object already in cache
new_idin: new id to set

◆ dict_table_change_id_sys_tables()

void dict_table_change_id_sys_tables ( )

Change the table_id of SYS_* tables if they have been created after an earlier upgrade.

This will update the table_id by adding DICT_MAX_DD_TABLES

This will update the table_id by adding DICT_MAX_DD_TABLES TODO - This function is to be removed by WL#16210.

◆ dict_table_check_for_dup_indexes()

void dict_table_check_for_dup_indexes ( const dict_table_t table,
enum check_name  check 
)

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

Parameters
[in]tableCheck for dup indexes in this table
[in]checkWhether and when to allow temporary index names

◆ dict_table_close()

void dict_table_close ( dict_table_t table,
bool  dict_locked,
bool  try_drop 
)

Decrements the count of open handles to a table.

Parameters
[in,out]tableTable
[in]dict_lockedTrue=data dictionary locked
[in]try_dropTrue=try to drop any orphan indexes after an aborted online index creation

◆ dict_table_close_and_drop()

void dict_table_close_and_drop ( trx_t trx,
dict_table_t table 
)

Closes the only open handle to a table and drops a table while assuring that dict_sys->mutex is held the whole time.

This assures that the table is not evicted after the close when the count of open handles goes to zero. Because dict_sys->mutex is held, we do not need to call dict_table_prevent_eviction().
in/out: table

This assures that the table is not evicted after the close when the count of open handles goes to zero. Because dict_sys->mutex is held, we do not need to call dict_table_prevent_eviction().

Parameters
trxin: data dictionary transaction
tablein/out: table

◆ dict_table_col_in_clustered_key()

bool 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

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

◆ dict_table_copy_types()

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

This function should be called right after dtuple_create().

Parameters
tuplein/out: data tuple
tablein: table

◆ dict_table_copy_v_types()

void dict_table_copy_v_types ( dtuple_t tuple,
const dict_table_t table 
)

Copies types of virtual 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
[in,out]tupledata tuple
[in]tabletable

◆ dict_table_ddl_acquire()

static void dict_table_ddl_acquire ( dict_table_t table)
inlinestatic

Move this table to non-LRU list for DDL operations if it's currently not there.

This also prevents later opening table via DD objects, when the table name in InnoDB doesn't match with DD object.

Parameters
[in,out]tableTable to put in non-LRU list

◆ dict_table_ddl_release()

static void dict_table_ddl_release ( dict_table_t table)
inlinestatic

Move this table to LRU list after DDL operations if it was moved to non-LRU list.

Parameters
[in,out]tableTable to put in LRU list

◆ dict_table_decode_n_col()

static void dict_table_decode_n_col ( uint32_t  encoded,
uint32_t *  n_col,
uint32_t *  n_v_col 
)
inlinestatic

Decode number of virtual and non-virtual columns in one 4 bytes value.

Parameters
[in]encodedencoded value
[in,out]n_colnumber of non-virtual column
[in,out]n_v_colnumber of virtual column

◆ dict_table_encode_n_col()

static ulint dict_table_encode_n_col ( ulint  n_col,
ulint  n_v_col 
)
inlinestatic

encode number of columns and number of virtual columns in one 4 bytes value.

We could do this because the number of columns in InnoDB is limited to 1017

Parameters
[in]n_colnumber of non-virtual column
[in]n_v_colnumber of virtual column
Returns
encoded value

◆ dict_table_extent_size()

page_no_t dict_table_extent_size ( const dict_table_t table)

Determine the extent size (in pages) for the given table.

Parameters
[in]tablethe table whose extent size is being calculated.
Returns
extent size in pages (256, 128 or 64)

◆ dict_table_get_all_fts_indexes()

ulint dict_table_get_all_fts_indexes ( dict_table_t table,
ib_vector_t indexes 
)

Get all the FTS indexes on a table.

Parameters
[in]tabletable
[out]indexesall FTS indexes on this table
Returns
number of FTS indexes

◆ dict_table_get_curr_table_sess_trx_id()

static trx_id_t dict_table_get_curr_table_sess_trx_id ( const dict_table_t table)
inlinestatic

Get current session trx-id.

Parameters
[in]tabletable handler
Returns
table local trx-id.

◆ dict_table_get_datadir()

std::string dict_table_get_datadir ( const dict_table_t table)

Get the tablespace data directory if set, otherwise empty string.

Returns
the data directory

◆ dict_table_get_highest_foreign_id()

ulint dict_table_get_highest_foreign_id ( dict_table_t table)

Finds the highest [number] for foreign key constraints of the table.

Looks only at the >= 4.0.18-format id's, which are of the form databasename/tablename_ibfk_[number].

Returns
highest number, 0 if table has no new format foreign key constraints in: table in the dictionary memory cache

Looks only at the >= 4.0.18-format id's, which are of the form databasename/tablename_ibfk_[number]. TODO: Remove this function once in-place ALTER TABLE code is updated to avoid its use.

Returns
highest number, 0 if table has no new format foreign key constraints
Parameters
tablein: table in the dictionary memory cache

◆ dict_table_get_index_on_first_col()

static dict_index_t * dict_table_get_index_on_first_col ( dict_table_t table,
ulint  col_index 
)
inlinestatic

Get index by first field of the index.

Parameters
[in]tabletable
[in]col_indexposition of column in table
Returns
index which is having first field matches with the field present in field_index position of table

◆ dict_table_get_index_on_name() [1/2]

const dict_index_t * dict_table_get_index_on_name ( const dict_table_t table,
const char *  name,
bool  committed = true 
)
inline

Get an index by name.

Parameters
[in]tablethe table where to look for the index
[in]namethe index name to look for
[in]committedtrue=search for committed, false=search for uncommitted
Returns
index, NULL if does not exist

◆ dict_table_get_index_on_name() [2/2]

dict_index_t * dict_table_get_index_on_name ( dict_table_t table,
const char *  name,
bool  committed 
)

Get an index by name.

Parameters
[in]tablethe table where to look for the index
[in]namethe index name to look for
[in]committedtrue=search for committed, false=search for uncommitted
Returns
index, NULL if does not exist

◆ dict_table_get_n_rows()

static uint64_t dict_table_get_n_rows ( const dict_table_t table)
inlinestatic

Gets the approximately estimated number of rows in the table.

Returns
estimated number of rows in: table

◆ dict_table_get_n_tot_u_cols()

static ulint dict_table_get_n_tot_u_cols ( const dict_table_t table)
inlinestatic

◆ dict_table_get_n_v_cols()

static ulint dict_table_get_n_v_cols ( const dict_table_t table)
inlinestatic

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

Parameters
[in]tablethe table to check
Returns
number of virtual columns of a table

◆ dict_table_get_next_table_sess_row_id()

static row_id_t dict_table_get_next_table_sess_row_id ( dict_table_t table)
inlinestatic

Get table session row-id and increment the row-id counter for next use.

Parameters
[in,out]tabletable handler
Returns
next table local row-id.

◆ dict_table_get_next_table_sess_trx_id()

static trx_id_t dict_table_get_next_table_sess_trx_id ( dict_table_t table)
inlinestatic

Get table session trx-id and increment the trx-id counter for next use.

Parameters
[in,out]tabletable handler
Returns
next table local trx-id.

◆ dict_table_get_nth_col_pos()

ulint dict_table_get_nth_col_pos ( const dict_table_t table,
ulint  n 
)

Looks for non-virtual column n position in the clustered index.

Returns
position in internal representation of the clustered index in: column number
position in internal representation of the clustered index
Parameters
tablein: table
nin: column number

◆ dict_table_get_nth_v_col()

static dict_v_col_t * dict_table_get_nth_v_col ( const dict_table_t table,
ulint  pos 
)
inlinestatic

Gets the nth virtual column of a table.

Parameters
[in]tabletable
[in]posposition of virtual column
Returns
pointer to virtual column object

◆ dict_table_get_nth_v_col_mysql()

dict_v_col_t * dict_table_get_nth_v_col_mysql ( const dict_table_t table,
ulint  col_nr 
)

Get nth virtual column according to its original MySQL table position.

Parameters
[in]tabletarget table
[in]col_nrcolumn number in MySQL Table definition
Returns
dict_v_col_t ptr

◆ dict_table_get_sys_col_no()

static ulint dict_table_get_sys_col_no ( const dict_table_t table,
ulint  sys 
)
inlinestatic

Gets the given system column number of a table.

Parameters
[in]tableTable.
[in]sysDATA_ROW_ID, ...
Returns
column number

◆ dict_table_get_v_col_name()

const char * dict_table_get_v_col_name ( const dict_table_t table,
ulint  col_nr 
)

Returns a virtual column's name.

Parameters
[in]tabletarget table
[in]col_nrvirtual column number (nth virtual column)
Returns
column name or NULL if column number out of range.

◆ dict_table_get_v_col_name_mysql()

const char * dict_table_get_v_col_name_mysql ( const dict_table_t table,
ulint  col_nr 
)

Returns a virtual column's name according to its original MySQL table position.

Parameters
[in]tabletarget table
[in]col_nrcolumn number (nth column in the table)
Returns
column name.

◆ dict_table_has_atomic_blobs()

static bool dict_table_has_atomic_blobs ( const dict_table_t table)
inlinestatic

Determine if a table uses atomic BLOBs (no locally stored prefix).

Parameters
[in]tableInnoDB table
Returns
whether BLOBs are atomic

◆ dict_table_has_autoinc_col()

static bool dict_table_has_autoinc_col ( const dict_table_t table)
inlinestatic

Check if a table has an autoinc counter column.

Parameters
[in]tabletable
Returns
true if there is an autoinc column in the table, otherwise false.

◆ dict_table_has_column()

ulint dict_table_has_column ( const dict_table_t table,
const char *  col_name,
ulint  col_nr 
)

Check if the table has a given (non_virtual) column.

Parameters
[in]tabletable object
[in]col_namecolumn name
[in]col_nrcolumn number guessed, 0 as default
Returns
column number if the table has the specified column, otherwise table->n_def

The order of column may changed, check it with other columns

◆ dict_table_has_fts_index()

static bool dict_table_has_fts_index ( dict_table_t table)
inlinestatic

Check if the table has an FTS index.

Returns
true if table has an FTS index in: table

◆ dict_table_has_indexed_v_cols()

static bool dict_table_has_indexed_v_cols ( const dict_table_t table)
inlinestatic

Check if a table has indexed virtual columns.

Parameters
[in]tablethe table to check
Returns
true is the table has indexed virtual columns

◆ dict_table_have_virtual_index()

static bool dict_table_have_virtual_index ( dict_table_t table)
inlinestatic

Check whether the table have virtual index.

Parameters
[in]tableInnoDB table
Returns
true if the table have virtual index, false otherwise.

◆ dict_table_in_shared_tablespace()

static bool dict_table_in_shared_tablespace ( const dict_table_t table)
inlinestatic

Check if the table is in a shared tablespace (System or General).

Parameters
[in]tabletable to check
Returns
true if table is a shared tablespace, false if not.

◆ dict_table_is_comp()

static bool dict_table_is_comp ( const dict_table_t table)
inlinestatic

Check whether the table uses the compact page format.

Returns
true if table uses the compact page format in: table

◆ dict_table_is_compressed_temporary()

bool dict_table_is_compressed_temporary ( const dict_table_t table)
inline

Check if a table is a temporary table with compressed row format, we should always expect false.

Parameters
[in]tabletable
Returns
true if it's a compressed temporary table, false otherwise

◆ dict_table_is_discarded()

static bool dict_table_is_discarded ( const dict_table_t table)
inlinestatic

Check if the tablespace for the table has been discarded.

Returns
true if the tablespace has been discarded. in: table to check

◆ dict_table_is_fts_column()

static ulint dict_table_is_fts_column ( ib_vector_t indexes,
ulint  col_no,
bool  is_virtual 
)
inlinestatic

Check whether a column exists in an FTS index.

Parameters
[in]indexesVector containing only FTS indexes
[in]col_noColumn number to search for.
[in]is_virtualWhether it is a virtual column.
Returns
ULINT_UNDEFINED if no match else the offset within the vector.

◆ dict_table_is_locking_disabled()

static bool dict_table_is_locking_disabled ( const dict_table_t table)
inlinestatic

Check whether locking is disabled for this table.

Currently this is done for intrinsic table as their visibility is limited to the connection and the DDTableBuffer as it's protected by dict_persist->mutex.

Parameters
[in]tabletable to check
Returns
true if locking is disabled.

◆ dict_table_is_partition()

static bool dict_table_is_partition ( const dict_table_t table)
inlinestatic

Check whether the dict_table_t is a partition.

A partitioned table on the SQL level is composed of InnoDB tables, where each InnoDB table is a [sub]partition including its secondary indexes which belongs to the partition.

Parameters
[in]tableTable to check.
Returns
true if the dict_table_t is a partition else false.

◆ dict_table_is_referenced_by_foreign_key()

bool 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
true if table is referenced by a foreign key
Parameters
tablein: InnoDB table

◆ dict_table_is_sdi()

static bool dict_table_is_sdi ( uint64_t  table_id)
inlinestatic

Check if an table id belongs SDI table.

Parameters
[in]table_iddict_table_t id
Returns
true if table_id is SDI table_id else false

◆ dict_table_is_system()

bool dict_table_is_system ( table_id_t  table_id)
Returns
true if table is InnoDB SYS_* table
Parameters
[in]table_idtable id

◆ dict_table_is_table_buffer()

static bool dict_table_is_table_buffer ( const dict_table_t table)
inlinestatic

Check whether the table is DDTableBuffer.

See class DDTableBuffer

Parameters
[in]tabletable to check
Returns
true if this is a DDTableBuffer table.

◆ dict_table_load_dynamic_metadata()

void dict_table_load_dynamic_metadata ( dict_table_t table)

Check if there is any latest persistent dynamic metadata recorded in DDTableBuffer table of the specific table.

If so, read the metadata and update the table object accordingly. It's used when loading table.

Parameters
[in]tabletable object

◆ dict_table_mark_dirty()

void dict_table_mark_dirty ( dict_table_t table)

Mark the dirty_status of a table as METADATA_DIRTY, and add it to the dirty_dict_tables list if necessary.

Parameters
[in,out]tabletable

◆ dict_table_move_from_lru_to_non_lru()

void dict_table_move_from_lru_to_non_lru ( dict_table_t table)

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

in: table to move from LRU to non-LRU

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

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

◆ dict_table_move_from_non_lru_to_lru()

void dict_table_move_from_non_lru_to_lru ( dict_table_t table)

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

Parameters
[in]tableInnoDB table object

◆ dict_table_mysql_pos_to_innodb()

ulint dict_table_mysql_pos_to_innodb ( const dict_table_t table,
ulint  n 
)

Get the innodb column position for a non-virtual column according to its original MySQL table position n.

Parameters
[in]tabletable
[in]nMySQL column position
Returns
column position in InnoDB

◆ dict_table_n_rows_dec()

static void dict_table_n_rows_dec ( dict_table_t table)
inlinestatic

Decrement the number of rows in the table by one.

Notice that this operation is not protected by any latch, the number is approximate. in/out: table

◆ dict_table_n_rows_inc()

static void dict_table_n_rows_inc ( dict_table_t table)
inlinestatic

Increment the number of rows in the table by one.

Notice that this operation is not protected by any latch, the number is approximate. in/out: table

◆ dict_table_next_uncorrupted_index()

static void dict_table_next_uncorrupted_index ( dict_index_t *&  index)
inlinestatic

◆ dict_table_open_on_name()

dict_table_t * dict_table_open_on_name ( const char *  table_name,
bool  dict_locked,
bool  try_drop,
dict_err_ignore_t  ignore_err 
)

Returns a table object and increments its open handle count.

NOTE! This is a high-level function to be used mainly from outside the 'dict' directory. Inside this directory dict_table_get_low is usually the appropriate function.

Parameters
[in]table_nameTable name
[in]dict_lockedtrue=data dictionary locked
[in]try_droptrue=try to drop any orphan indexes after an aborted online index creation
[in]ignore_errerror to be ignored when loading the table
Returns
table, NULL if does not exist

Returns a table object and increments its open handle count.

NOTE! This is a high-level function to be used mainly from outside the 'dict' 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

◆ dict_table_page_size()

static const page_size_t dict_table_page_size ( const dict_table_t table)
inlinestatic

Get the table page size.

Parameters
[in]tabletable
Returns
compressed page size, or 0 if not compressed

◆ dict_table_persist_to_dd_table_buffer()

void dict_table_persist_to_dd_table_buffer ( dict_table_t table)

Write back the dirty persistent dynamic metadata of the table to DDTableBuffer.

Parameters
[in,out]tabletable object

◆ dict_table_prevent_eviction()

static void dict_table_prevent_eviction ( dict_table_t table)
inlinestatic

Prevent table eviction by moving a table to the non-LRU list from the LRU list if it is not already there.

in: table to prevent eviction

◆ dict_table_read_dynamic_metadata()

void dict_table_read_dynamic_metadata ( const byte buffer,
ulint  size,
PersistentTableMetadata metadata 
)

Read persistent dynamic metadata stored in a buffer.

Parameters
[in]bufferbuffer to read
[in]sizesize of data in buffer
[in]metadatawhere we store the metadata from buffer

◆ dict_table_remove_from_cache()

void dict_table_remove_from_cache ( dict_table_t table)

Removes a table object from the dictionary cache.

in, own: table

Parameters
tablein, own: table

◆ dict_table_remove_from_cache_debug()

void dict_table_remove_from_cache_debug ( dict_table_t table,
bool  lru_evict 
)

Removes a table object from the dictionary cache, for debug purpose.

Parameters
[in,out]tabletable object
[in]lru_evicttrue if table being evicted to make room in the table LRU list

◆ dict_table_rename_in_cache()

dberr_t dict_table_rename_in_cache ( dict_table_t table,
const char *  new_name,
bool  rename_also_foreigns 
)

Renames a table object.

Returns
true if success in: in ALTER TABLE we want to preserve the original table name in constraints which reference it
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

◆ dict_table_set_big_rows()

void dict_table_set_big_rows ( dict_table_t table)

Mark if table has big rows.

Parameters
[in,out]tabletable handler

◆ dict_table_skip_corrupt_index()

static void dict_table_skip_corrupt_index ( dict_index_t *&  index)
inlinestatic

◆ dict_table_stats_latch_create()

void dict_table_stats_latch_create ( dict_table_t table,
bool  enabled 
)

Create a dict_table_t's stats latch or delay for lazy creation.

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

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

◆ dict_table_stats_latch_destroy()

void dict_table_stats_latch_destroy ( dict_table_t table)

Destroy a dict_table_t's stats latch.

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

Parameters
[in,out]tabletable whose stats latch to destroy

◆ dict_table_stats_lock()

void dict_table_stats_lock ( dict_table_t table,
ulint  latch_mode 
)

Lock the appropriate latch to protect a given table's statistics.

Parameters
[in]tabletable whose stats to lock
[in]latch_modeRW_S_LATCH or RW_X_LATCH

◆ dict_table_stats_unlock()

void dict_table_stats_unlock ( dict_table_t table,
ulint  latch_mode 
)

Unlock the latch that has been locked by dict_table_stats_lock().

Parameters
[in]tabletable whose stats to unlock
[in]latch_modeRW_S_LATCH or RW_X_LATCH

◆ dict_table_wait_for_bg_threads_to_exit()

void dict_table_wait_for_bg_threads_to_exit ( dict_table_t table,
std::chrono::microseconds  delay 
)

◆ dict_table_x_lock_indexes()

static void dict_table_x_lock_indexes ( dict_table_t table)
inlinestatic

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

◆ dict_table_x_unlock_indexes()

static void dict_table_x_unlock_indexes ( dict_table_t table)
inlinestatic

Release the exclusive locks on all index tree.

in: table

◆ dict_tables_have_same_db()

bool 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
true if same db name
Parameters
name1in: table name in the form dbname '/' tablename
name2in: table name in the form dbname '/' tablename

◆ dict_tf2_is_valid()

static bool dict_tf2_is_valid ( uint32_t  flags,
uint32_t  flags2 
)
inlinestatic

Validate both table flags and table flags2 and make sure they are compatible.

Parameters
[in]flagsTable flags
[in]flags2Table flags2
Returns
true if valid.

◆ dict_tf_get_page_size()

static const page_size_t dict_tf_get_page_size ( uint32_t  flags)
inlinestatic

Extract the page size info from table flags.

Parameters
[in]flagsflags
Returns
a structure containing the compressed and uncompressed page sizes and a boolean indicating if the page is compressed.

◆ dict_tf_init()

static uint32_t dict_tf_init ( bool  compact,
ulint  zip_ssize,
bool  atomic_blobs,
bool  data_dir,
bool  shared_space 
)
inlinestatic

Initialize a dict_table_t::flags pointer.

Parameters
[in]compactTable uses Compact or greater
[in]zip_ssizeZip Shift Size (log 2 minus 9)
[in]atomic_blobsTable uses Compressed or Dynamic
[in]data_dirTable uses DATA DIRECTORY
[in]shared_spaceTable uses a General Shared Tablespace

◆ dict_tf_is_valid()

static bool dict_tf_is_valid ( uint32_t  flags)
inlinestatic

Validate the table flags.

Parameters
[in]flagsTable flags
Returns
true if valid.

◆ dict_tf_set()

static void dict_tf_set ( uint32_t *  flags,
rec_format_t  format,
uint32_t  zip_ssize,
bool  use_data_dir,
bool  shared_space 
)
inlinestatic

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

Parameters
[in,out]flagsPointer to a 4 byte Table Flags
[in]formatFile Format
[in]zip_ssizeZip Shift Size
[in]use_data_dirTable uses DATA DIRECTORY
[in]shared_spaceTable uses a General Shared Tablespace

◆ dict_tf_to_fsp_flags()

uint32_t dict_tf_to_fsp_flags ( uint32_t  table_flags)

Convert a 32 bit integer table flags to the 32 bit FSP Flags.

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

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

Parameters
[in]table_flagsdict_table_t::flags
Returns
tablespace flags (fil_space_t::flags)

◆ dict_tf_to_row_format_string()

const char * dict_tf_to_row_format_string ( uint32_t  table_flag)

Convert table flag to row format string.

Returns
row format name in: row format setting
row format name.
Parameters
table_flagin: row format setting

◆ dict_validate_no_purge_rollback_threads()

void dict_validate_no_purge_rollback_threads ( )

Validate no active background threads to cause purge or rollback operations.

◆ dict_vcol_base_is_foreign_key()

uint32_t dict_vcol_base_is_foreign_key ( dict_v_col_t vcol,
dict_foreign_t foreign 
)
Returns
true if all base column of virtual column is foreign key column
Parameters
[in]vcolin-memory virtual column
[in]foreignin-memory Foreign key constraint

◆ get_field_max_size()

void get_field_max_size ( const dict_table_t table,
const dict_index_t index,
const dict_field_t field,
size_t &  rec_max_size 
)

Get maximum possible size needed for a field.

Parameters
[in]tableinnodb table definition cache
[in]indexindex
[in]fieldfield
[out]rec_max_sizemax record size needed

◆ get_permissible_max_size()

void get_permissible_max_size ( const dict_table_t table,
const dict_index_t index,
size_t &  page_rec_max,
size_t &  page_ptr_max 
)

Get the maximum size of a record permissible on an index page.

Parameters
[in]tableinnodb table definition cache
[in]indexindex
[out]page_rec_maxmaximum size of record on a leaf page
[out]page_ptr_maxmaximum size of record on non-leaf page

Variable Documentation

◆ BIG_ROW_SIZE

constexpr uint32_t BIG_ROW_SIZE = 1024
constexpr

◆ dict_foreign_err_file

FILE* dict_foreign_err_file
extern

◆ dict_foreign_err_mutex

ib_mutex_t dict_foreign_err_mutex
extern

◆ DICT_HEAP_SIZE

constexpr uint32_t DICT_HEAP_SIZE = 100
constexpr

initial memory heap size when creating a table or index object

◆ dict_ind_redundant

dict_index_t* dict_ind_redundant
extern

dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records

◆ DICT_INDEX_SPATIAL_NODEPTR_SIZE

constexpr uint32_t DICT_INDEX_SPATIAL_NODEPTR_SIZE = 1
constexpr

The number of fields in the nonleaf page of spatial index, except the page no field.

◆ dict_operation_lock

rw_lock_t* dict_operation_lock
extern

the data dictionary rw-latch protecting dict_sys

table create, drop, etc. reserve this in X-mode; implicit or background 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

◆ dict_persist

dict_persist_t* dict_persist
extern

the dictionary persisting structure

◆ dict_sys

dict_sys_t* dict_sys
extern

the dictionary system

◆ MAX_NUM_FK_COLUMNS

constexpr uint32_t MAX_NUM_FK_COLUMNS = 500
constexpr

Maximum number of columns in a foreign key constraint.

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

◆ SDI_VERSION

const uint32_t SDI_VERSION = 1

SDI version.

Written on Page 1 & 2 at FIL_PAGE_FILE_FLUSH_LSN offset.

◆ SYSTEM_TABLE_SPACE

const space_id_t SYSTEM_TABLE_SPACE = TRX_SYS_SPACE

Space id of system tablespace.