MySQL 8.0.40
Source Code Documentation
|
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_t > | dict_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_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. More... | |
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. 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_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. More... | |
static dict_v_col_t * | dict_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_t * | dict_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_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. More... | |
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. More... | |
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. 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_t * | dict_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_t * | dict_table_get_index_on_name (dict_table_t *table, const char *name, bool committed=true) |
Get an index by name. More... | |
const dict_index_t * | dict_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_t * | dict_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_t * | dict_sdi_get_index (space_id_t tablespace_id) |
Retrieve in-memory index for SDI table. More... | |
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. 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... | |
void | dict_upgrade_evict_tables_cache () |
Evict all tables that are loaded for applying purge. More... | |
bool | dict_table_is_system (table_id_t table_id) |
bool | dict_sys_table_id_build () |
Build the table_id array of SYS_* tables. More... | |
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_t * | dict_sys |
the dictionary system More... | |
rw_lock_t * | dict_operation_lock |
the data dictionary rw-latch protecting dict_sys More... | |
dict_persist_t * | dict_persist |
the dictionary persisting structure More... | |
dict_index_t * | dict_ind_redundant |
dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records More... | |
Data dictionary system.
Created 1/8/1996 Heikki Tuuri
#define dict_sys_mutex_enter | ( | ) | mutex_enter(&dict_sys->mutex) |
#define dict_sys_mutex_exit | ( | ) | mutex_exit(&dict_sys->mutex) |
#define dict_sys_mutex_free | ( | ) | mutex_free(&dict_sys->mutex) |
enum check_name |
enum dict_table_op_t |
Operation to perform when opening a table.
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:
In purge:
[in] | thd | server thread instance |
[in] | space_id | InnoDB tablespace id |
[in,out] | sdi_mdl | MDL ticket on SDI table |
DB_SUCESS | on success |
DB_LOCK_WAIT_TIMEOUT | on error |
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:
In purge:
MDL should be released by caller
[in] | thd | server thread instance |
[in] | space_id | InnoDB tablespace id |
[in,out] | sdi_mdl | MDL ticket on SDI table |
DB_SUCESS | on success |
DB_LOCK_WAIT_TIMEOUT | on error |
|
inlinestatic |
Allocate memory for intrinsic cache elements in the index.
[in] | index | index object |
void dict_close | ( | void | ) |
Closes the data dictionary module.
|
inlinestatic |
Gets the column position in the clustered index.
[in] | col | Table column. |
[in] | clust_index | Clustered index. |
|
inlinestatic |
Gets the column position in the given index.
[in] | col | table column |
[in] | index | index to be searched for column |
|
inlinestatic |
Gets the column number.
bool dict_col_name_is_reserved | ( | const char * | name | ) |
If the given column name is reserved for InnoDB system columns, return true.
name | in: column name |
|
inlinestatic |
Turn-off redo-logging if temporary table.
[in] | table | Table to check |
[out] | mtr | Mini-transaction |
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!
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!
foreign | in, own: foreign key constraint |
col_names | in: column names, or NULL to use foreign->foreign_table->col_names |
check_charsets | in: whether to check charset compatibility |
can_free_fk | in: whether free existing FK |
ignore_err | in: error to be ignored |
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.
table | in: table |
col_names | in: column names, or NULL to use table->col_names |
columns | in: array of column names |
n_cols | in: number of columns |
types_idx | in: NULL or an index whose types the column types must match |
check_charsets | in: whether to check charsets. only has an effect if types_idx != NULL |
check_null | in: nonzero if none of the columns must be declared NOT NULL |
|
inline |
Frees a foreign key struct.
in, own: foreign key struct
foreign | in, own: foreign key struct |
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.
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.
table | in: table |
col_names | in: column names, or NULL to use table->col_names |
columns | in: array of column names |
n_cols | in: number of columns |
index | in: index to check |
types_idx | in: NULL or an index whose types the column types must match |
check_charsets | in: whether to check charsets. only has an effect if types_idx != NULL |
check_null | in: nonzero if none of the columns must be declared NOT NULL |
void dict_foreign_remove_from_cache | ( | dict_foreign_t * | foreign | ) |
Removes a foreign constraint struct from the dictionary cache.
in, own: foreign constraint
foreign | in, own: foreign constraint |
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.
table | in/out: table |
col_names | in: column names, or NULL to use table->col_names |
index | in: index to be replaced |
|
inlinestatic |
Free the virtual column template.
[in,out] | vc_templ | virtual column template |
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.
[in] | db_and_table | database and table names, e.g. "@code d@i1b/a@q1b@1Kc @endcode" |
[out] | db_utf8mb3 | database name, e.g. dцb |
[in] | db_utf8mb3_size | db_utf8mb3 size |
[out] | table_utf8mb3 | table name, e.g. aюbØc |
[in] | table_utf8mb3_size | table_utf8mb3 size |
std::vector< table_id_t > dict_get_all_table_ids | ( | ) |
Gathers ids of all tables in cache at the moment.
ulint dict_get_db_name_len | ( | const char * | name | ) |
Get the database name length in a table name.
name | in: table name in the form dbname '/' tablename |
void dict_ind_init | ( | void | ) |
Inits dict_ind_redundant.
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.
[in,out] | table | table on which the index is |
[in,out] | index | index; NOTE! The index memory object is freed in this function! |
[in] | page_no | root page number of the index |
[in] | strict | true=refuse to create the index if records could be too big to fit in an B-tree page |
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.
[in,out] | table | table on which the index is |
[in,out] | index | index; NOTE! The index memory object is freed in this function! |
[in] | add_v | new virtual column that being added along with an add index call |
[in] | page_no | root page number of the index |
[in] | strict | true=refuse to create the index if records could be too big to fit in an B-tree page |
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.
index | in: index tree |
rec | in: record for which to build data tuple |
n_fields | in: number of data fields |
heap | in: memory heap where tuple created |
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.
index | in: index |
rec | in: record for which to build node pointer |
page_no | in: page number to put in node pointer |
heap | in: memory heap where pointer created |
level | in: level of rec in tree: 0 means leaf level |
ulint dict_index_calc_min_rec_len | ( | const dict_index_t * | index | ) |
Calculates the minimum record length in an index.
in: index
index | in: index |
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.
index | in: index tree |
tuple | in: tuple used in a search |
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.
[in] | index | index |
[in] | n | column number |
[in] | is_virtual | whether it is a virtual col |
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.
[in] | index | index |
[in] | rec | record for which to copy prefix |
[out] | n_fields | number of fields copied |
[in,out] | buf | memory buffer for the copied prefix, or nullptr |
[in,out] | buf_size | buffer size, size of allocated buffer |
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,out] | tuple | Data tuple |
[in] | index | Index |
[in] | n_fields | Number of field types to copy |
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.
[in] | id | index identifier |
|
inlinestatic |
Gets the read-write lock of the index tree.
|
inlinestatic |
Gets the number of fields in the internal representation of an index, including fields added by the dictionary system.
|
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.
|
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.
|
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.
|
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.
[in] | index | index |
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.
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.
index | in: index from which to search |
index2 | in: index |
n | in: field number in index2 |
|
inlinestatic |
Gets the status of online index creation.
|
inlinestatic |
Gets the page number of the root of the index tree.
|
inlinestatic |
Gets the space id of the root of the index tree.
|
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.
|
inlinestatic |
Check whether the index consists of descending columns only.
[in] | index | index tree |
true | if index has any descending column |
false | if index has only ascending columns |
|
inlinestatic |
Check whether the index contains a virtual column.
[in] | index | index |
|
inlinestatic |
Check if index is auto-generated clustered index.
[in] | index | index |
|
inlinestatic |
Check whether the index is the insert buffer tree.
|
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.
true | if 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 |
false | if the index has been created or the table has been rebuilt completely in: index |
|
inlinestatic |
Check if the index is SDI index.
[in] | index | in-memory index structure |
|
inlinestatic |
Check whether the index is a secondary index or the insert buffer tree.
|
inlinestatic |
Check whether the index is a Spatial Index.
|
inlinestatic |
Check whether the index is unique.
ulint dict_index_node_ptr_max_size | ( | const dict_index_t * | index | ) |
Return maximum size of the node pointer record.
index | in: index |
void dict_index_remove_from_cache | ( | dict_table_t * | table, |
dict_index_t * | index | ||
) |
Removes an index from the dictionary cache.
[in,out] | table | table whose index to remove |
[in,out] | index | index to remove, this object is destroyed and must not be accessed by the caller afterwards |
table | in/out: table |
index | in, own: index |
void dict_index_remove_from_v_col_list | ( | dict_index_t * | index | ) |
Clears the virtual column's index list before index is being freed.
[in] | index | Index being freed |
void dict_index_set_merge_threshold | ( | dict_index_t * | index, |
ulint | merge_threshold | ||
) |
Sets merge_threshold in the SYS_INDEXES.
[in,out] | index | index |
[in] | merge_threshold | value to set |
|
inlinestatic |
Sets the status of online index creation.
[in,out] | index | index |
[in] | status | status |
|
inlinestatic |
Sets the space id of the root of the index tree.
[in,out] | index | index |
[in] | space | space id |
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.
[in] | table | innodb table definition cache |
[in] | index | index |
[in] | strict | true if error is to be reported |
[in] | page_rec_max | maximum size of possible record on leaf page |
[in] | page_ptr_max | maximum size of possible record on non-leaf page |
[out] | rec_max_size | maximum size of record on page |
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.
index | in/out: index to be updated. |
ulint dict_index_zip_pad_optimal_page_size | ( | dict_index_t * | index | ) |
Return the optimal page size, for which page will likely compress.
index | in: index for which page size is requested |
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.
index | in/out: index to be updated. |
void dict_init | ( | void | ) |
Inits the data dictionary module.
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.
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.
max_tables | in: max tables allowed in cache |
pct_check | in: max percent to check |
|
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.
[in] | table | Table. |
[in] | col | Column which index prefix is based on. |
|
inlinestatic |
Determine maximum bytes of a virtual column need to be stored in the undo log.
[in] | table | dict_table_t for the table |
[in] | col_no | virtual column number |
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
table | in: table to move to MRU |
void dict_mutex_enter_for_mysql | ( | void | ) |
Reserves the dictionary system mutex for MySQL.
void dict_mutex_exit_for_mysql | ( | void | ) |
Releases the dictionary system mutex for MySQL.
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.
[in] | name | Table name |
void dict_persist_close | ( | void | ) |
Clear the structure.
void dict_persist_init | ( | void | ) |
Inits the structure for persisting dynamic metadata.
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.
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.
[in] | file | File where to print |
[in] | trx | Transaction |
[in] | foreign | Foreign key constraint |
[in] | add_newline | Whether to add a newline |
const char * dict_remove_db_name | ( | const char * | name | ) |
Return the end of table name where we have removed dbname and '/'.
name | in: table name in the form dbname '/' tablename |
void dict_resize | ( | ) |
Resize the hash tables based on the current buffer pool size.
void dict_sdi_close_table | ( | dict_table_t * | table | ) |
Close SDI table.
[in] | table | the in-memory SDI table object |
dict_index_t * dict_sdi_get_index | ( | space_id_t | tablespace_id | ) |
Retrieve in-memory index for SDI table.
[in] | tablespace_id | innodb tablespace ID |
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.
[in] | tablespace_id | innodb tablespace ID |
[in] | dict_locked | true if dict_sys mutex is acquired |
[in] | is_create | true when creating SDI Index |
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.
[in] | space_id | InnoDB tablespace ID |
[in] | sdi_table | SDI table |
[in] | dict_locked | true if dict_sys mutex acquired |
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.
[in] | table | The table that should be compressed |
[in] | algorithm | Text representation of the algorithm |
[in] | is_import_op | True if it's being set during import operation |
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.
[in,out] | index | index, must not be NULL |
void dict_set_merge_threshold_all_debug | ( | uint | merge_threshold_all | ) |
Sets merge_threshold for all indexes in dictionary cache for debug.
[in] | merge_threshold_all | value to set for all indexes |
bool dict_sys_table_id_build | ( | ) |
Build the table_id array of SYS_* tables.
This array is used to determine if a table is InnoDB SYSTEM table or not.
void dict_table_add_system_columns | ( | dict_table_t * | table, |
mem_heap_t * | heap | ||
) |
Adds system columns to a table object.
[in,out] | table | Table |
[in] | heap | Temporary heap |
void dict_table_add_to_cache | ( | dict_table_t * | table, |
bool | can_be_evicted | ||
) |
Adds a table object to the dictionary cache.
[in,out] | table | table |
[in] | can_be_evicted | true if can be evicted |
|
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.
[in] | table | InnoDB table object can be evicted |
void dict_table_autoinc_initialize | ( | dict_table_t * | table, |
uint64_t | value | ||
) |
Unconditionally set the autoinc counter.
[in,out] | table | Table |
[in] | value | Next value to assign to a row |
void dict_table_autoinc_lock | ( | dict_table_t * | table | ) |
Acquire the autoinc lock.
in/out: table
table | in/out: table |
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.
[in,out] | table | InnoDB table object |
[in] | value | AUTOINC counter to log |
[in,out] | mtr | Mini-transaction |
|
inlinestatic |
Update the persisted autoinc counter to specified one, we should hold autoinc_persisted_mutex.
[in,out] | table | table |
[in] | autoinc | set autoinc_persisted to this value |
uint64_t dict_table_autoinc_read | ( | const dict_table_t * | table | ) |
Reads the next autoinc value (== autoinc counter value), 0 if not yet initialized.
table | in: table |
|
inlinestatic |
Set the column position of autoinc column in clustered index for a table.
[in] | table | table |
[in] | pos | column position in table definition |
void dict_table_autoinc_unlock | ( | dict_table_t * | table | ) |
Release the autoinc lock.
in/out: table
table | in/out: table |
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.
[in,out] | table | Table |
[in] | value | Value which was assigned to a row |
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.
table | in/out: table object already in cache |
new_id | in: new id to set |
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
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].
[in] | table | Check for dup indexes in this table |
[in] | check | Whether and when to allow temporary index names |
void dict_table_close | ( | dict_table_t * | table, |
bool | dict_locked, | ||
bool | try_drop | ||
) |
Decrements the count of open handles to a table.
[in,out] | table | Table |
[in] | dict_locked | True=data dictionary locked |
[in] | try_drop | True=try to drop any orphan indexes after an aborted online index creation |
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().
trx | in: data dictionary transaction |
table | in/out: table |
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.
Column prefixes are treated like whole columns.
table | in: table |
n | in: column number |
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().
tuple | in/out: data tuple |
table | in: table |
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().
[in,out] | tuple | data tuple |
[in] | table | 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.
[in,out] | table | Table to put in non-LRU list |
|
inlinestatic |
Move this table to LRU list after DDL operations if it was moved to non-LRU list.
[in,out] | table | Table to put in LRU list |
|
inlinestatic |
Decode number of virtual and non-virtual columns in one 4 bytes value.
[in] | encoded | encoded value |
[in,out] | n_col | number of non-virtual column |
[in,out] | n_v_col | number of virtual column |
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
[in] | n_col | number of non-virtual column |
[in] | n_v_col | number of virtual column |
page_no_t dict_table_extent_size | ( | const dict_table_t * | table | ) |
Determine the extent size (in pages) for the given table.
[in] | table | the table whose extent size is being calculated. |
ulint dict_table_get_all_fts_indexes | ( | dict_table_t * | table, |
ib_vector_t * | indexes | ||
) |
Get all the FTS indexes on a table.
[in] | table | table |
[out] | indexes | all FTS indexes on this table |
|
inlinestatic |
Get current session trx-id.
[in] | table | table handler |
std::string dict_table_get_datadir | ( | const dict_table_t * | table | ) |
Get the tablespace data directory if set, otherwise empty string.
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].
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.
table | in: table in the dictionary memory cache |
|
inlinestatic |
Get index by first field of the index.
[in] | table | table |
[in] | col_index | position of column in table |
|
inline |
Get an index by name.
[in] | table | the table where to look for the index |
[in] | name | the index name to look for |
[in] | committed | true=search for committed, false=search for uncommitted |
dict_index_t * dict_table_get_index_on_name | ( | dict_table_t * | table, |
const char * | name, | ||
bool | committed | ||
) |
Get an index by name.
[in] | table | the table where to look for the index |
[in] | name | the index name to look for |
[in] | committed | true=search for committed, false=search for uncommitted |
|
inlinestatic |
Gets the approximately estimated number of rows in the table.
|
inlinestatic |
|
inlinestatic |
Gets the number of virtual columns in a table in the dictionary cache.
[in] | table | the table to check |
|
inlinestatic |
Get table session row-id and increment the row-id counter for next use.
[in,out] | table | table handler |
|
inlinestatic |
Get table session trx-id and increment the trx-id counter for next use.
[in,out] | table | table handler |
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.
table | in: table |
n | in: column number |
|
inlinestatic |
Gets the nth virtual column of a table.
[in] | table | table |
[in] | pos | position of virtual column |
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.
[in] | table | target table |
[in] | col_nr | column number in MySQL Table definition |
|
inlinestatic |
Gets the given system column number of a table.
[in] | table | Table. |
[in] | sys | DATA_ROW_ID, ... |
const char * dict_table_get_v_col_name | ( | const dict_table_t * | table, |
ulint | col_nr | ||
) |
Returns a virtual column's name.
[in] | table | target table |
[in] | col_nr | virtual column number (nth virtual column) |
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.
[in] | table | target table |
[in] | col_nr | column number (nth column in the table) |
|
inlinestatic |
Determine if a table uses atomic BLOBs (no locally stored prefix).
[in] | table | InnoDB table |
|
inlinestatic |
Check if a table has an autoinc counter column.
[in] | table | table |
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.
[in] | table | table object |
[in] | col_name | column name |
[in] | col_nr | column number guessed, 0 as default |
The order of column may changed, check it with other columns
|
inlinestatic |
Check if the table has an FTS index.
|
inlinestatic |
Check if a table has indexed virtual columns.
[in] | table | the table to check |
|
inlinestatic |
Check whether the table have virtual index.
[in] | table | InnoDB table |
|
inlinestatic |
Check if the table is in a shared tablespace (System or General).
[in] | table | table to check |
|
inlinestatic |
Check whether the table uses the compact page format.
|
inline |
Check if a table is a temporary table with compressed row format, we should always expect false.
[in] | table | table |
|
inlinestatic |
Check if the tablespace for the table has been discarded.
|
inlinestatic |
Check whether a column exists in an FTS index.
[in] | indexes | Vector containing only FTS indexes |
[in] | col_no | Column number to search for. |
[in] | is_virtual | Whether it is a virtual column. |
|
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.
[in] | table | table to check |
|
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.
[in] | table | Table to check. |
bool dict_table_is_referenced_by_foreign_key | ( | const dict_table_t * | table | ) |
Checks if a table is referenced by foreign keys.
table | in: InnoDB table |
|
inlinestatic |
Check if an table id belongs SDI table.
[in] | table_id | dict_table_t id |
bool dict_table_is_system | ( | table_id_t | table_id | ) |
[in] | table_id | table id |
|
inlinestatic |
Check whether the table is DDTableBuffer.
See class DDTableBuffer
[in] | table | table to check |
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.
[in] | table | table object |
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.
[in,out] | table | table |
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.
table | in: table to move from LRU to non-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.
[in] | table | InnoDB table object |
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.
[in] | table | table |
[in] | n | MySQL column position |
|
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
|
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
|
inlinestatic |
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.
[in] | table_name | Table name |
[in] | dict_locked | true=data dictionary locked |
[in] | try_drop | true=try to drop any orphan indexes after an aborted online index creation |
[in] | ignore_err | error to be ignored when loading the table |
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.
table_name | in: table name |
dict_locked | in: true=data dictionary locked |
try_drop | in: true=try to drop any orphan indexes after an aborted online index creation |
ignore_err | in: error to be ignored when loading a table definition |
|
inlinestatic |
Get the table page size.
[in] | table | table |
void dict_table_persist_to_dd_table_buffer | ( | dict_table_t * | table | ) |
Write back the dirty persistent dynamic metadata of the table to DDTableBuffer.
[in,out] | table | table object |
|
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
void dict_table_read_dynamic_metadata | ( | const byte * | buffer, |
ulint | size, | ||
PersistentTableMetadata * | metadata | ||
) |
Read persistent dynamic metadata stored in a buffer.
[in] | buffer | buffer to read |
[in] | size | size of data in buffer |
[in] | metadata | where we store the metadata from buffer |
void dict_table_remove_from_cache | ( | dict_table_t * | table | ) |
Removes a table object from the dictionary cache.
in, own: table
table | in, own: table |
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.
[in,out] | table | table object |
[in] | lru_evict | true if table being evicted to make room in the table LRU list |
dberr_t dict_table_rename_in_cache | ( | dict_table_t * | table, |
const char * | new_name, | ||
bool | rename_also_foreigns | ||
) |
Renames a table object.
table | in/out: table |
new_name | in: new name |
rename_also_foreigns | in: in ALTER TABLE we want to preserve the original table name in constraints which reference it |
void dict_table_set_big_rows | ( | dict_table_t * | table | ) |
Mark if table has big rows.
[in,out] | table | table handler |
|
inlinestatic |
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.
[in,out] | table | table whose stats latch to create |
[in] | enabled | if false then the latch is disabled and dict_table_stats_lock()/unlock() become noop on this table. |
void dict_table_stats_latch_destroy | ( | dict_table_t * | table | ) |
Destroy a dict_table_t's stats latch.
This function is only called from either single threaded environment or from a thread that has not shared the table object with other threads.
[in,out] | table | table whose stats latch to destroy |
void dict_table_stats_lock | ( | dict_table_t * | table, |
ulint | latch_mode | ||
) |
Lock the appropriate latch to protect a given table's statistics.
[in] | table | table whose stats to lock |
[in] | latch_mode | RW_S_LATCH or RW_X_LATCH |
void dict_table_stats_unlock | ( | dict_table_t * | table, |
ulint | latch_mode | ||
) |
Unlock the latch that has been locked by dict_table_stats_lock().
[in] | table | table whose stats to unlock |
[in] | latch_mode | RW_S_LATCH or RW_X_LATCH |
void dict_table_wait_for_bg_threads_to_exit | ( | dict_table_t * | table, |
std::chrono::microseconds | delay | ||
) |
|
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
|
inlinestatic |
Release the exclusive locks on all index tree.
in: table
bool dict_tables_have_same_db | ( | const char * | name1, |
const char * | name2 | ||
) |
Checks if the database name in two table names is the same.
name1 | in: table name in the form dbname '/' tablename |
name2 | in: table name in the form dbname '/' tablename |
|
inlinestatic |
Validate both table flags and table flags2 and make sure they are compatible.
[in] | flags | Table flags |
[in] | flags2 | Table flags2 |
|
inlinestatic |
Extract the page size info from table flags.
[in] | flags | flags |
|
inlinestatic |
Initialize a dict_table_t::flags pointer.
[in] | compact | Table uses Compact or greater |
[in] | zip_ssize | Zip Shift Size (log 2 minus 9) |
[in] | atomic_blobs | Table uses Compressed or Dynamic |
[in] | data_dir | Table uses DATA DIRECTORY |
[in] | shared_space | Table uses a General Shared Tablespace |
|
inlinestatic |
Validate the table flags.
[in] | flags | Table flags |
|
inlinestatic |
Set the various values in a dict_table_t::flags pointer.
[in,out] | flags | Pointer to a 4 byte Table Flags |
[in] | format | File Format |
[in] | zip_ssize | Zip Shift Size |
[in] | use_data_dir | Table uses DATA DIRECTORY |
[in] | shared_space | Table uses a General Shared Tablespace |
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
[in] | table_flags | dict_table_t::flags |
const char * dict_tf_to_row_format_string | ( | uint32_t | table_flag | ) |
Convert table flag to row format string.
table_flag | in: row format setting |
void dict_upgrade_evict_tables_cache | ( | ) |
Evict all tables that are loaded for applying purge.
Since we move the offset of all table ids during upgrade, these tables cannot exist in cache. Also change table_ids of SYS_* tables if they are upgraded from earlier versions
void dict_validate_no_purge_rollback_threads | ( | ) |
Validate no active background threads to cause purge or rollback operations.
uint32_t dict_vcol_base_is_foreign_key | ( | dict_v_col_t * | vcol, |
dict_foreign_t * | foreign | ||
) |
[in] | vcol | in-memory virtual column |
[in] | foreign | in-memory Foreign key constraint |
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.
[in] | table | innodb table definition cache |
[in] | index | index |
[in] | field | field |
[out] | rec_max_size | max record size needed |
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.
[in] | table | innodb table definition cache |
[in] | index | index |
[out] | page_rec_max | maximum size of record on a leaf page |
[out] | page_ptr_max | maximum size of record on non-leaf page |
|
constexpr |
|
extern |
|
extern |
|
constexpr |
initial memory heap size when creating a table or index object
|
extern |
dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records
|
constexpr |
The number of fields in the nonleaf page of spatial index, except the page no field.
|
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
|
extern |
the dictionary persisting structure
|
extern |
the dictionary system
|
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
const uint32_t SDI_VERSION = 1 |
SDI version.
Written on Page 1 & 2 at FIL_PAGE_FILE_FLUSH_LSN offset.
const space_id_t SYSTEM_TABLE_SPACE = TRX_SYS_SPACE |
Space id of system tablespace.