MySQL 8.4.2
Source Code Documentation
|
Data dictionary system. More...
#include "debug_sync.h"
#include "my_config.h"
#include <stdlib.h>
#include <strfunc.h>
#include <sys/types.h>
#include <algorithm>
#include <string>
#include "current_thd.h"
#include "dict0dict.h"
#include "fil0fil.h"
#include "fts0fts.h"
#include "ha_prototypes.h"
#include "log0chkp.h"
#include "log0write.h"
#include "my_dbug.h"
#include "clone0api.h"
#include "mysqld.h"
#include "que0types.h"
#include "row0sel.h"
#include <vector>
#include "btr0btr.h"
#include "btr0cur.h"
#include "btr0sea.h"
#include "buf0buf.h"
#include "data0type.h"
#include "dict0boot.h"
#include "dict0crea.h"
#include "dict0dd.h"
#include "dict0mem.h"
#include "dict0priv.h"
#include "dict0stats.h"
#include "fsp0sysspace.h"
#include "fts0types.h"
#include "lock0lock.h"
#include "mach0data.h"
#include "mem0mem.h"
#include "os0once.h"
#include "page0page.h"
#include "page0zip.h"
#include "pars0pars.h"
#include "pars0sym.h"
#include "que0que.h"
#include "rem0cmp.h"
#include "row0ins.h"
#include "row0log.h"
#include "ddl0ddl.h"
#include "row0mysql.h"
#include "row0upd.h"
#include "ha_innodb.h"
#include "srv0mon.h"
#include "srv0start.h"
#include "sync0sync.h"
#include "trx0undo.h"
#include "ut0new.h"
Classes | |
struct | dict_foreign_remove_partial |
Function object to remove a foreign key constraint from the referenced_set of the referenced table. More... | |
Functions | |
static bool | dict_index_find_and_set_cols (const dict_table_t *table, dict_index_t *index, const dict_add_v_col_t *add_v) |
Tries to find column names for the index and sets the col field of the index. More... | |
static dict_index_t * | dict_index_build_internal_clust (const dict_table_t *table, dict_index_t *index) |
Builds the internal dictionary cache representation for a clustered index, containing also system fields not defined by the user. More... | |
static dict_index_t * | dict_index_build_internal_non_clust (const dict_table_t *table, dict_index_t *index) |
Builds the internal dictionary cache representation for a non-clustered index, containing also system fields not defined by the user. More... | |
static dict_index_t * | dict_index_build_internal_fts (dict_table_t *table, dict_index_t *index) |
Builds the internal dictionary cache representation for an FTS index. More... | |
static void | dict_index_remove_from_cache_low (dict_table_t *table, dict_index_t *index, bool lru_evict) |
Removes an index from the dictionary cache. More... | |
static void | dict_persist_update_log_margin (void) |
Calculate and update the redo log margin for current tables which have some changed dynamic metadata in memory and have not been written back to mysql.innodb_dynamic_metadata. More... | |
static void | dict_table_remove_from_cache_low (dict_table_t *table, bool lru_evict) |
Removes a table object from the dictionary cache. More... | |
static bool | dict_lru_validate () |
Validate the dictionary table LRU list. More... | |
static bool | dict_lru_find_table (const dict_table_t *find_table) |
Check if table is in the dictionary table LRU list. More... | |
static bool | dict_non_lru_find_table (const dict_table_t *find_table) |
Check if a table exists in the dict table non-LRU list. 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... | |
const char * | dict_remove_db_name (const char *name) |
Return the end of table name where we have removed dbname and '/'. More... | |
ulint | dict_get_db_name_len (const char *name) |
Get the database name length in a table name. 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... | |
static void | dict_table_stats_latch_alloc (void *table_void) |
Allocate and init a dict_table_t's stats latch. More... | |
static void | dict_table_stats_latch_free (dict_table_t *table) |
Deinit and free a dict_table_t's stats latch. 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... | |
static void | dict_table_try_drop_aborted (dict_table_t *table, table_id_t table_id, ulint ref_count) |
Try to drop any indexes after an aborted index creation. More... | |
static void | dict_table_try_drop_aborted_and_mutex_exit (dict_table_t *table, bool try_drop) |
When opening a table, try to drop any indexes after an aborted index creation. 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... | |
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. More... | |
const char * | dict_table_get_v_col_name (const dict_table_t *table, ulint col_nr) |
Returns a virtual column's name. More... | |
static ulint | dict_table_get_v_col_pos_for_mysql (const dict_table_t *table, ulint col_nr) |
Search virtual column's position in InnoDB according to its position in original table's position. 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... | |
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 void | dict_table_autoinc_alloc (void *table_void) |
Allocate and init the autoinc latch of a given table. More... | |
static void | dict_index_zip_pad_alloc (void *index_void) |
Allocate and init the zip_pad_mutex of a given index. More... | |
void | dict_table_autoinc_lock (dict_table_t *table) |
Acquire the autoinc lock. More... | |
static void | dict_index_zip_pad_lock (dict_index_t *index) |
Acquire the zip_pad_mutex latch. More... | |
void | dict_table_autoinc_initialize (dict_table_t *table, uint64_t value) |
Unconditionally set the autoinc counter. 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... | |
ulint | dict_table_get_all_fts_indexes (dict_table_t *table, ib_vector_t *indexes) |
Get all the FTS indexes on a table. 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... | |
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... | |
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_init (void) |
Inits the data dictionary module. More... | |
void | dict_move_to_mru (dict_table_t *table) |
Move to the most recently used segment of the LRU list. 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 increment its open handle count. 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... | |
static bool | dict_table_can_be_evicted (dict_table_t *table) |
Test whether a table can be evicted from the LRU cache. 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... | |
void | dict_table_move_from_lru_to_non_lru (dict_table_t *table) |
Move a table to the non-LRU list from the LRU list. 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... | |
static const dict_index_t * | dict_table_find_index_on_id (const dict_table_t *table, const index_id_t &id) |
Look up an index in a table. More... | |
const dict_index_t * | dict_index_find (const index_id_t &id) |
Look up an index among already opened tables. 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_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_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... | |
bool | dict_col_name_is_reserved (const char *name) |
If the given column name is reserved for InnoDB system columns, return true. More... | |
ulint | dict_index_node_ptr_max_size (const dict_index_t *index) |
Return maximum size of the node pointer record. 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... | |
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... | |
static bool | dict_index_too_big_for_tree (const dict_table_t *table, const dict_index_t *new_index, bool strict) |
A B-tree page should accommodate at least two records. 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... | |
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... | |
static void | dict_index_try_cache_rec_offsets (dict_index_t *index) |
Check if key part of the index has fixed len and thus rec offsets can be cached. 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... | |
void | dict_index_remove_from_cache (dict_table_t *table, dict_index_t *index) |
Removes an index from the dictionary cache. More... | |
static dict_v_col_t * | dict_duplicate_v_col (const dict_v_col_t *v_col, mem_heap_t *heap) |
Duplicate a virtual column information. More... | |
static void | dict_index_copy (dict_index_t *index1, dict_index_t *index2, const dict_table_t *table, ulint start, ulint end) |
Copies fields contained in index2 to index1. 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... | |
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) |
bool | dict_table_is_referenced_by_foreign_key (const dict_table_t *table) |
Checks if a table is referenced by foreign keys. More... | |
void | dict_foreign_remove_from_cache (dict_foreign_t *foreign) |
Removes a foreign constraint struct from the dictionary cache. More... | |
static dict_foreign_t * | dict_foreign_find (dict_table_t *table, dict_foreign_t *foreign) |
Looks for the foreign constraint from the foreign and referenced lists of a table. 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... | |
static void | dict_foreign_error_report_low (FILE *file, const char *name) |
Report an error in a foreign key definition. More... | |
static void | dict_foreign_error_report (FILE *file, dict_foreign_t *fk, const char *msg) |
Report an error in a foreign key definition. 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... | |
ulint | dict_table_get_highest_foreign_id (dict_table_t *table) |
Finds the highest [number] for foreign key constraints of the table. 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... | |
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... | |
ulint | dict_index_calc_min_rec_len (const dict_index_t *index) |
Calculates the minimum record length in an index. 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... | |
void | dict_persist_init (void) |
Inits the structure for persisting dynamic metadata. More... | |
void | dict_persist_close (void) |
Clear the structure. More... | |
static void | dict_init_dynamic_metadata (dict_table_t *table, PersistentTableMetadata *metadata) |
Initialize the dynamic metadata according to the table object. More... | |
static bool | dict_table_apply_dynamic_metadata (dict_table_t *table, const PersistentTableMetadata *metadata) |
Apply the persistent dynamic metadata read from redo logs or DDTableBuffer to corresponding table during recovery. More... | |
void | dict_table_read_dynamic_metadata (const byte *buffer, ulint size, PersistentTableMetadata *metadata) |
Read persistent dynamic metadata stored in a buffer. 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_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) |
Flags an index corrupted in the data dictionary cache only. More... | |
static void | dict_table_persist_to_dd_table_buffer_low (dict_table_t *table) |
Write the dirty persistent dynamic metadata for a table to DD TABLE BUFFER table. 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_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_set_merge_threshold_list_debug (dict_sys_t::Table_LRU_list_base *list, uint merge_threshold_all) |
Sets merge_threshold for all indexes in the list of tables. More... | |
void | dict_set_merge_threshold_all_debug (uint merge_threshold_all) |
Sets merge_threshold for all indexes in dictionary cache for debug. More... | |
void | dict_ind_init (void) |
Inits dict_ind_redundant. More... | |
void | dict_ind_free (void) |
Frees dict_ind_redundant. More... | |
dict_index_t * | dict_table_get_index_on_name (dict_table_t *table, const char *name, bool committed) |
Get an index by name. 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... | |
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... | |
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_close (void) |
Closes the data dictionary module. 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) |
Check an index to see whether its first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx. More... | |
static void | dict_index_zip_pad_update (zip_pad_info_t *info, ulint zip_threshold) |
Update the state of compression failure padding heuristics. 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... | |
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... | |
const char * | dict_tf_to_row_format_string (uint32_t table_flag) |
Convert table flag to row format string. More... | |
page_no_t | dict_table_extent_size (const dict_table_t *table) |
Determine the extent size (in pages) for the given table. More... | |
void | dict_sdi_close_table (dict_table_t *table) |
Close SDI table. 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... | |
void | dict_table_change_id_sys_tables () |
Change the table_id of SYS_* tables if they have been created after an earlier upgrade. More... | |
bool | dict_table_is_system (table_id_t table_id) |
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... | |
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 | dict_validate_no_purge_rollback_threads () |
Validate no active background threads to cause purge or rollback operations. More... | |
Variables | |
dict_index_t * | dict_ind_redundant |
dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records More... | |
uint | ibuf_debug |
Flag to control insert buffer debugging. More... | |
dict_sys_t * | dict_sys = nullptr |
the dictionary system More... | |
dict_persist_t * | dict_persist = nullptr |
the dictionary persisting structure More... | |
rw_lock_t * | dict_operation_lock |
the data dictionary rw-latch protecting dict_sys More... | |
ulong | zip_failure_threshold_pct = 5 |
Percentage of compression failures that are allowed in a single round. More... | |
ulong | zip_pad_max = 50 |
Maximum percentage of a page that can be allowed as a pad to avoid compression failures. More... | |
constexpr uint32_t | DICT_POOL_PER_TABLE_HASH = 512 |
buffer pool max size per table hash table fixed size in bytes More... | |
static char | dict_ibfk [] = "_ibfk_" |
Identifies generated InnoDB foreign key names. More... | |
static table_id_t | dict_sys_table_id [SYS_NUM_SYSTEM_TABLES] |
Array to store table_ids of INNODB_SYS_* TABLES. More... | |
FILE * | dict_foreign_err_file = nullptr |
ib_mutex_t | dict_foreign_err_mutex |
Data dictionary system.
Created 1/8/1996 Heikki Tuuri
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 |
void dict_close | ( | void | ) |
Closes the data dictionary module.
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 |
|
static |
Duplicate a virtual column information.
[in] | v_col | virtual column information to duplicate |
[in,out] | heap | memory heap |
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 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 |
|
static |
Report an error in a foreign key definition.
file | in: output stream |
fk | in: foreign key constraint |
msg | in: the error message |
|
static |
Report an error in a foreign key definition.
file | in: output stream |
name | in: table name |
|
static |
Looks for the foreign constraint from the foreign and referenced lists of a table.
table | in: table object |
foreign | in: foreign constraint |
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 |
bool dict_foreign_qualify_index | ( | const dict_table_t * | table, |
const char ** | col_names, | ||
const char ** | columns, | ||
ulint | n_cols, | ||
const dict_index_t * | index, | ||
const dict_index_t * | types_idx, | ||
bool | check_charsets, | ||
ulint | check_null | ||
) |
Check an index to see whether its first fields are the columns in the array, in the same order and is not marked for deletion and is not the same as types_idx.
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 |
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 |
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_free | ( | void | ) |
Frees dict_ind_redundant.
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 |
|
static |
Builds the internal dictionary cache representation for a clustered index, containing also system fields not defined by the user.
table | in: table |
index | in: user representation of a clustered index |
|
static |
Builds the internal dictionary cache representation for an FTS index.
table | in: table |
index | in: user representation of an FTS index |
|
static |
Builds the internal dictionary cache representation for a non-clustered index, containing also system fields not defined by the user.
table | in: table |
index | in: user representation of a non-clustered index |
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 |
|
static |
Copies fields contained in index2 to index1.
index1 | in: index to copy to |
index2 | in: index to copy from |
table | in: table |
start | in: first position to copy |
end | in: last position to copy |
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 |
|
static |
Tries to find column names for the index and sets the col field of the index.
[in] | table | table |
[in,out] | index | index |
[in] | add_v | new virtual columns added along with an add index call |
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.
index | in: index from which to search |
index2 | in: index |
n | in: field number in index2 |
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 |
|
static |
Removes an index from the dictionary cache.
in: true if page being evicted to make room in the table LRU list
table | in/out: table |
index | in, own: index |
lru_evict | in: true if index being evicted to make room in the table LRU 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.
[in] | index | Index being freed |
|
static |
A B-tree page should accommodate at least two records.
This function finds out if this is violated for records of maximum possible length of this index.
[in] | table | table |
[in] | new_index | index |
[in] | strict | true=report error if records could be too big to fit in a B-tree page |
|
static |
Check if key part of the index has fixed len and thus rec offsets can be cached.
If so, it initializes rec_cache.offsets and rec_cache.nullable_cols, so that we can avoid calling the costly rec_get_offsets() in many cases. That is:
[in] | index | The index instance for which rec_cache should be computed |
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.
index | in/out: index to be updated. |
|
static |
Allocate and init the zip_pad_mutex of a given index.
This function must not be called concurrently on the same index object.
[in,out] | index_void | index whose zip_pad_mutex to create |
|
static |
Acquire the zip_pad_mutex latch.
[in,out] | index | the index whose zip_pad_mutex to acquire. |
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 |
|
static |
Update the state of compression failure padding heuristics.
This is called whenever a compression operation succeeds or fails. The caller must be holding info->mutex
info | in/out: info to be updated |
zip_threshold | in: zip threshold value |
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.
index | in/out: index to be updated. |
void dict_init | ( | void | ) |
Inits the data dictionary module.
|
static |
Initialize the dynamic metadata according to the table object.
[in] | table | table object |
[in,out] | metadata | metadata to be initialized |
|
static |
Check if table is in the dictionary table LRU list.
[in] | find_table | table to find |
|
static |
Validate the dictionary table LRU list.
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.
max_tables | in: max tables allowed in cache |
pct_check | in: max percent to check |
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.
|
static |
Check if a table exists in the dict table non-LRU list.
[in] | find_table | table to find |
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.
|
static |
Calculate and update the redo log margin for current tables which have some changed dynamic metadata in memory and have not been written back to mysql.innodb_dynamic_metadata.
Update LSN limit, which is used to stop user threads when redo log is running out of space and they do not hold latches (log.free_check_limit_lsn).
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 |
|
inline |
Sets merge_threshold for all indexes in the list of tables.
[in] | list | pointer to the list of tables |
[in] | merge_threshold_all | value to set for all indexes |
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 |
|
static |
Apply the persistent dynamic metadata read from redo logs or DDTableBuffer to corresponding table during recovery.
[in,out] | table | table |
[in] | metadata | structure of persistent metadata |
|
static |
Allocate and init the autoinc latch of a given table.
This function must not be called concurrently on the same table object.
[in,out] | table_void | table whose autoinc latch to create |
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 |
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 |
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 |
|
static |
Test whether a table can be evicted from the LRU cache.
table | in: table to test |
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.
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 TODO - This function is to be removed by WL#16210.
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().
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.
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().
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 |
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. |
|
static |
Look up an index in a table.
[in] | table | table |
[in] | id | index identifier |
NULL | if not found |
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 |
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]. TODO: Remove this function once in-place ALTER TABLE code is updated to avoid its use.
table | in: table in the dictionary memory cache |
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 |
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 |
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 |
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) |
|
static |
Search virtual column's position in InnoDB according to its position in original table's position.
[in] | table | target table |
[in] | col_nr | column number (nth column in the MySQL 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
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 |
bool dict_table_is_system | ( | table_id_t | table_id | ) |
[in] | table_id | table id |
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 list from the LRU list.
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 |
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 increment its open handle count.
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 |
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 |
|
static |
Write the dirty persistent dynamic metadata for a table to DD TABLE BUFFER table.
This is the low level function to write back.
[in,out] | table | table to write |
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 |
|
static |
Removes a table object from the dictionary cache.
in: true if evicting from LRU
table | in, own: table |
lru_evict | in: 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 |
|
static |
Allocate and init a dict_table_t's stats latch.
This function must not be called concurrently on the same table object.
[in,out] | table_void | table whose stats latch to 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.
[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 |
|
static |
Deinit and free a dict_table_t's stats latch.
This function must not be called concurrently on the same table object.
[in,out] | table | table whose stats latch to free |
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 |
|
static |
Try to drop any indexes after an aborted index creation.
This can also be after a server kill during DROP INDEX.
table | in: table, or NULL if it needs to be looked up again |
table_id | in: table identifier |
ref_count | in: expected table->n_ref_count |
|
static |
When opening a table, try to drop any indexes after an aborted index creation.
Release the dict_sys->mutex.
table | in: table (may be NULL) |
try_drop | in: false if should try to drop indexes whose online creation was aborted |
void dict_table_wait_for_bg_threads_to_exit | ( | dict_table_t * | table, |
std::chrono::microseconds | delay | ||
) |
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 |
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_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 |
FILE* dict_foreign_err_file = nullptr |
ib_mutex_t dict_foreign_err_mutex |
|
static |
Identifies generated InnoDB foreign key names.
dict_index_t* dict_ind_redundant |
dummy index for ROW_FORMAT=REDUNDANT supremum and infimum records
rw_lock_t* dict_operation_lock |
the data dictionary rw-latch protecting dict_sys
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_t* dict_persist = nullptr |
the dictionary persisting structure
|
constexpr |
buffer pool max size per table hash table fixed size in bytes
dict_sys_t* dict_sys = nullptr |
the dictionary system
|
static |
Array to store table_ids of INNODB_SYS_* TABLES.
|
extern |
Flag to control insert buffer debugging.
ulong zip_failure_threshold_pct = 5 |
Percentage of compression failures that are allowed in a single round.
ulong zip_pad_max = 50 |
Maximum percentage of a page that can be allowed as a pad to avoid compression failures.