MySQL 8.0.40
Source Code Documentation
|
Data dictionary system. More...
#include "data0type.h"
#include "dict0load.h"
#include "fsp0fsp.h"
#include "fsp0sysspace.h"
#include "rem0types.h"
#include "srv0srv.h"
#include "sync0rw.h"
Functions | |
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) |
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... | |
static bool | dict_index_has_desc (const dict_index_t *index) |
Check whether the index consists of descending columns only. More... | |
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 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... | |
static ulint | dict_table_get_n_tot_u_cols (const dict_table_t *table) |
Gets the number of user-defined virtual and non-virtual columns in a table in the dictionary cache. More... | |
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... | |
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) |
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_fts_index (dict_table_t *table) |
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 uint32_t | dict_sys_tables_type_validate (uint32_t type, uint32_t n_cols) |
Validate a SYS_TABLES TYPE field and return it. More... | |
static rec_format_t | dict_tf_get_rec_format (uint32_t flags) |
Determine the page format from dict_table_t::flags The low order bit will be zero for REDUNDANT and 1 for COMPACT. 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... | |
static uint32_t | dict_sys_tables_type_to_tf (uint32_t type, uint32_t n_cols) |
Convert a 32 bit integer from SYS_TABLES.TYPE to dict_table_t::flags The following chart shows the translation of the low order bit. More... | |
static ulint | dict_tf_to_sys_tables_type (uint32_t flags) |
Convert a 32 bit integer table flags to the 32bit integer that is written to a SYS_TABLES.TYPE field. More... | |
static const page_size_t | dict_tf_get_page_size (uint32_t flags) |
Extract the page size info from table flags. 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 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_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... | |
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 *index) |
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... | |
static ulint | dict_table_is_fts_column (ib_vector_t *indexes, ulint col_no, bool is_virtual) |
static ulint | dict_max_field_len_store_undo (dict_table_t *table, const dict_col_t *col) |
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 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... | |
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 bool | dict_table_is_file_per_table (const dict_table_t *table) |
Check if the table is found is a file_per_table tablespace. 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 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_table_mutex_alloc (void *table_void) |
Allocate the mutex of the given table. More... | |
bool | dict_table_has_temp_general_tablespace_name (const char *tablespace_name) |
Check if tablespace name is "innodb_general". 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 bool | dict_table_has_autoinc_col (const dict_table_t *table) |
Check if a table has an autoinc counter column. 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... | |
static ulint | dict_table_encode_n_col (ulint n_col, ulint n_v_col) |
Encode the number of columns and number of virtual columns in a 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... | |
static bool | dict_table_have_virtual_index (dict_table_t *table) |
Check whether the table have virtual index. More... | |
static void | dict_allocate_mem_intrinsic_cache (dict_index_t *index) |
Allocate memory for intrinsic cache elements in the index. More... | |
static uint64_t | dict_sdi_get_table_id (space_id_t space_id) |
Generate a table_id from space id for SDI Index. More... | |
static space_id_t | dict_sdi_get_space_id (table_id_t table_id) |
Extract space_id from table_id for SDI Index. 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 (table_id_t table_id) |
Check if an table id belongs SDI table. More... | |
static space_index_t | dict_sdi_get_index_id () |
Return a SDI Index id for given SDI copy. More... | |
static bool | dict_table_is_partition (const dict_table_t *table) |
Check whether the dict_table_t is a partition. More... | |
Data dictionary system.
Created 1/8/1996 Heikki Tuuri
|
inlinestatic |
Allocate memory for intrinsic cache elements in the index.
[in] | index | index object |
|
inlinestatic |
|
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.
col | in: column |
|
inlinestatic |
Turn-off redo-logging if temporary table.
table | in: table to check |
mtr | out: mini-transaction |
|
inlinestatic |
Free the virtual column template.
[in,out] | vc_templ | virtual column template |
|
inlinestatic |
Gets the read-write lock of the index tree.
index | in: index |
|
inlinestatic |
Gets the number of fields in the internal representation of an index, including fields added by the dictionary system.
index | in: an internal representation of index (in the dictionary cache) |
|
inlinestatic |
Gets the number of user-defined ordering fields in the index.
In the internal representation of clustered indexes we add the row id to the ordering fields to make a clustered index unique, but this function returns the number of fields the user defined in the index as ordering fields.
index | in: an internal representation of index (in the dictionary cache) |
|
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.
index | in: an internal representation of index (in the dictionary cache) |
|
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.
index | in: an internal representation of index (in the dictionary cache) |
|
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 |
|
inlinestatic |
Gets the status of online index creation.
index | in: secondary index |
|
inlinestatic |
Gets the page number of the root of the index tree.
index | in: index |
|
inlinestatic |
Gets the space id of the root of the index tree.
index | in: index |
|
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.
index | in: index |
|
inlinestatic |
Determines if a secondary index is being or has been created online, or if the table is being rebuilt online, allowing concurrent modifications to the table.
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 |
index | 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.
index | in: index |
|
inlinestatic |
Check whether the index is a Spatial Index.
index | in: index |
|
inlinestatic |
Check whether the index is unique.
index | in: index |
|
inlinestatic |
Sets the status of online index creation.
index | in/out: index |
status | in: status |
|
inlinestatic |
Sets the space id of the root of the index tree.
index | in/out: index |
space | in: space id |
|
inlinestatic |
|
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 |
|
inlinestatic |
Return a SDI Index id for given SDI copy.
|
inlinestatic |
Extract space_id from table_id for SDI Index.
[in] | table_id | InnoDB table id |
|
inlinestatic |
Generate a table_id from space id for SDI Index.
[in] | space_id | InnoDB tablespace id |
|
inlinestatic |
Convert a 32 bit integer from SYS_TABLES.TYPE to dict_table_t::flags The following chart shows the translation of the low order bit.
Other bits are the same. ========================= Low order bit ========================== | REDUNDANT | COMPACT | COMPRESSED and DYNAMIC SYS_TABLES.TYPE | 1 | 1 | 1
type | in: SYS_TABLES.TYPE field |
n_cols | in: SYS_TABLES.N_COLS field |
|
inlinestatic |
Validate a SYS_TABLES TYPE field and return it.
type | in: SYS_TABLES.TYPE |
n_cols | in: SYS_TABLES.N_COLS |
|
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 |
|
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 |
|
inlinestatic |
Set the column position of autoinc column in clustered index for a table.
[in] | table | table |
[in] | pos | column position in table definition |
|
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 the number of columns and number of virtual columns in a 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 |
|
inlinestatic |
Get current session trx-id.
[in] | table | table handler |
|
inlinestatic |
Get index by first field of the index.
Decrement the col_index if the virtual column encountered before the col_index of the table.
table | in: table |
col_index | in: position of column in table |
|
inlinestatic |
Gets the approximately estimated number of rows in the table.
table | in: table |
|
inlinestatic |
Gets the number of user-defined virtual and non-virtual columns in a table in the dictionary cache.
[in] | table | table |
|
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 |
|
inlinestatic |
Gets the nth virtual column of a table.
[in] | table | table |
[in] | pos | position of virtual column |
|
inlinestatic |
|
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 |
|
inlinestatic |
|
inlinestatic |
Check if a table has indexed virtual columns.
[in] | table | the table to check |
|
inline |
Check if tablespace name is "innodb_general".
[in] | tablespace_name | tablespace name |
true | if name is "innodb_general" |
false | if name is not "innodb_general" |
|
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.
table | in: table |
|
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.
table | in: table to check |
|
inlinestatic |
Check if the table is found is a file_per_table tablespace.
This test does not use table flags2 since some REDUNDANT tables in the system tablespace may have garbage in the MIX_LEN field where flags2 is stored. These garbage MIX_LEN fields were written before v3.23.52. A patch was added to v3.23.52 which initializes the MIX_LEN field to 0. Since file-per-table tablespaces were added in 4.1, any SYS_TABLES record with a non-zero space ID will have a reliable MIX_LEN field. However, this test does not use flags2 from SYS_TABLES.MIX_LEN. Instead, assume that if the tablespace is not a predefined system tablespace and it is not a general shared tablespace, then it must be file-per-table. Also, during ALTER TABLE, the DICT_TF2_USE_FILE_PER_TABLE flag may not be set on one of the file-per-table tablespaces. This test cannot be done on a table in the process of being created because the space_id will be zero until the tablespace is created.
[in] | table | An existing open table to check |
table | in: table to check |
|
inlinestatic |
|
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. |
|
inlinestatic |
Check if an table id belongs SDI table.
[in] | table_id | dict_table_t id |
|
inlinestatic |
Check whether the table is DDTableBuffer.
See class DDTableBuffer
[in] | table | table to check |
|
inline |
Allocate the mutex of the given table.
This function must not be called concurrently on the same table object.
[in] | table_void | table whose mutex to create |
|
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.
table | 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.
table | in/out: table |
|
inlinestatic |
Get the table page size.
[in] | table | table |
|
inlinestatic |
Prevent table eviction by moving a table to the non-LRU list from the LRU list if it is not already there.
table | in: table to prevent eviction |
|
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.
table | in: table |
|
inlinestatic |
Release the exclusive locks on all index tree.
table | in: table |
|
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 |
Determine the page format from dict_table_t::flags The low order bit will be zero for REDUNDANT and 1 for COMPACT.
For any other row_format, flags is nonzero and DICT_TF_COMPACT will also be set.
flags | in: dict_table_t::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 |
|
inlinestatic |
Convert a 32 bit integer table flags to the 32bit integer that is written to a SYS_TABLES.TYPE field.
The following chart shows the translation of the low order bit. Other bits are the same. ========================= Low order bit ========================== | REDUNDANT | COMPACT | COMPRESSED and DYNAMIC dict_table_t::flags | 0 | 1 | 1
flags | in: dict_table_t::flags |