MySQL 8.0.39
Source Code Documentation
ha_innodb.h File Reference
#include <assert.h>
#include <sys/types.h>
#include "create_field.h"
#include "field.h"
#include "handler.h"
#include "mysql/components/services/clone_protocol_service.h"
#include "row0pread-adapter.h"
#include "row0pread-histogram.h"
#include "trx0trx.h"

Go to the source code of this file.

Classes

struct  innodb_idx_translate_t
 
struct  INNOBASE_SHARE
 InnoDB table share. More...
 
class  ha_innobase
 The class defining a handle to an InnoDB table. More...
 
struct  new_ft_info
 Structure Returned by ha_innobase::ft_init_ext() More...
 
class  create_table_info_t
 Class for handling create table information. More...
 
class  innobase_basic_ddl
 Class of basic DDL implementation, for CREATE/DROP/RENAME TABLE. More...
 
class  innobase_truncate< Table >
 Class to handle TRUNCATE for one InnoDB table or one partition. More...
 

Namespaces

namespace  dd
 The version of the current data dictionary table definitions.
 
namespace  dd::cache
 

Typedefs

typedef struct new_ft_info NEW_FT_INFO
 Structure Returned by ha_innobase::ft_init_ext() More...
 
typedef void(* my_gcolumn_templatecallback_t) (const TABLE *, void *)
 Callback function definition, used by MySQL server layer to initialized the table virtual columns' template. More...
 

Enumerations

enum  fts_doc_id_index_enum { FTS_INCORRECT_DOC_ID_INDEX , FTS_EXIST_DOC_ID_INDEX , FTS_NOT_EXIST_DOC_ID_INDEX }
 Some defines for innobase_fts_check_doc_id_index() return value. More...
 

Functions

ulong thd_parallel_read_threads (THD *thd)
 Return the number of read threads for this session. More...
 
void innobase_register_trx (handlerton *hton, THD *thd, trx_t *trx)
 Allocates an InnoDB transaction for a MySQL handler object for DML. More...
 
trx_tinnobase_trx_allocate (THD *thd)
 Allocates an InnoDB transaction for a MySQL handler object. More...
 
trx_t::isolation_level_t innobase_trx_map_isolation_level (enum_tx_isolation iso)
 Maps a MySQL trx isolation level code to the InnoDB isolation level code. More...
 
bool innobase_match_index_columns (const KEY *key_info, const dict_index_t *index_info)
 Match index columns between MySQL and InnoDB. More...
 
bool innobase_index_name_is_reserved (THD *thd, const KEY *key_info, ulint num_of_keys)
 This function checks each index name for a table against reserved system default primary index name 'GEN_CLUST_INDEX'. More...
 
static bool tablespace_is_file_per_table (const HA_CREATE_INFO *create_info)
 Check if the explicit tablespace targeted is file_per_table. More...
 
static bool tablespace_is_shared_space (const HA_CREATE_INFO *create_info)
 Check if table will be explicitly put in an existing shared general or system tablespace. More...
 
static bool tablespace_is_general_space (const HA_CREATE_INFO *create_info)
 Check if table will be explicitly put in a general tablespace. More...
 
static bool is_shared_tablespace (const char *tablespace_name)
 Check if tablespace is shared tablespace. More...
 
static int validate_autoextend_size_value (uint64_t ext_size)
 Validate AUTOEXTEND_SIZE attribute for a tablespace. More...
 
void innobase_parse_hint_from_comment (THD *thd, dict_table_t *table, const TABLE_SHARE *table_share)
 Parse hint for table and its indexes, and update the information in dictionary. More...
 
trx_t *& thd_to_trx (THD *thd)
 Obtain the InnoDB transaction of a MySQL thread. More...
 
bool innobase_fts_load_stopword (dict_table_t *table, trx_t *trx, THD *thd)
 Initialize the table FTS stopword list. More...
 
fts_doc_id_index_enum innobase_fts_check_doc_id_index (const dict_table_t *table, const TABLE *altered_table, ulint *fts_doc_col_no)
 Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME on the Doc ID column. More...
 
fts_doc_id_index_enum innobase_fts_check_doc_id_index_in_def (ulint n_key, const KEY *key_info)
 Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME on the Doc ID column in MySQL create index definition. More...
 
void innobase_copy_frm_flags_from_table_share (dict_table_t *innodb_table, const TABLE_SHARE *table_share)
 Copy table flags from MySQL's TABLE_SHARE into an InnoDB table object. More...
 
void innodb_base_col_setup (dict_table_t *table, const Field *field, dict_v_col_t *v_col)
 Set up base columns for virtual column. More...
 
void innodb_base_col_setup_for_stored (const dict_table_t *table, const Field *field, dict_s_col_t *s_col)
 Set up base columns for stored column. More...
 
static bool innobase_is_s_fld (const Field *field)
 whether this is a stored column More...
 
static bool innobase_is_multi_value_fld (const Field *field)
 Whether this is a computed multi-value virtual column. More...
 
static bool normalize_table_name (char *norm_name, const char *name)
 
bool trx_is_registered_for_2pc (const trx_t *trx)
 Note that a transaction has been registered with MySQL. More...
 
int convert_error_code_to_mysql (dberr_t error, uint32_t flags, THD *thd)
 Converts an InnoDB error code to a MySQL error code. More...
 
page_cur_mode_t convert_search_mode_to_innobase (enum ha_rkey_function find_flag)
 Converts a search mode flag understood by MySQL to a flag understood by InnoDB. More...
 
rec_per_key_t innodb_rec_per_key (const dict_index_t *index, ulint i, ha_rows records)
 Calculate Record Per Key value. More...
 
void innobase_build_v_templ (const TABLE *table, const dict_table_t *ib_table, dict_vcol_templ_t *s_templ, const dict_add_v_col_t *add_v, bool locked, const char *share_tbl_name)
 Build template for the virtual columns and their base columns. More...
 
void innobase_build_v_templ_callback (const TABLE *table, void *ib_table)
 Callback used by MySQL server layer to initialize the table virtual columns' template. More...
 
void innobase_discard_table (THD *thd, dict_table_t *table)
 Drop the statistics for a specified table, and mark it as discard after DDL. More...
 

Variables

const char innobase_index_reserve_name []
 "GEN_CLUST_INDEX" is the name reserved for InnoDB default system clustered index when there is no primary key. More...
 
const mysql_service_clone_protocol_tclone_protocol_svc
 Clone protocol service. More...
 
const struct _ft_vft ft_vft_result
 
constexpr uint32_t SIZE_MB = 1024 * 1024
 
bool innobase_stats_on_metadata
 

Typedef Documentation

◆ my_gcolumn_templatecallback_t

typedef void(* my_gcolumn_templatecallback_t) (const TABLE *, void *)

Callback function definition, used by MySQL server layer to initialized the table virtual columns' template.

◆ NEW_FT_INFO

typedef struct new_ft_info NEW_FT_INFO

Structure Returned by ha_innobase::ft_init_ext()

Enumeration Type Documentation

◆ fts_doc_id_index_enum

Some defines for innobase_fts_check_doc_id_index() return value.

Enumerator
FTS_INCORRECT_DOC_ID_INDEX 
FTS_EXIST_DOC_ID_INDEX 
FTS_NOT_EXIST_DOC_ID_INDEX 

Function Documentation

◆ convert_error_code_to_mysql()

int convert_error_code_to_mysql ( dberr_t  error,
uint32_t  flags,
THD thd 
)

Converts an InnoDB error code to a MySQL error code.

Also tells to MySQL about a possible transaction rollback inside InnoDB caused by a lock wait timeout or a deadlock.

Parameters
[in]errorInnoDB error code.
[in]flagsInnoDB table flags or 0.
[in]thdMySQL thread or NULL.
Returns
MySQL error code

◆ convert_search_mode_to_innobase()

page_cur_mode_t convert_search_mode_to_innobase ( enum ha_rkey_function  find_flag)

Converts a search mode flag understood by MySQL to a flag understood by InnoDB.

Parameters
[in]find_flagMySQL search mode flag.
Returns
InnoDB search mode flag.

◆ innobase_build_v_templ()

void innobase_build_v_templ ( const TABLE table,
const dict_table_t ib_table,
dict_vcol_templ_t s_templ,
const dict_add_v_col_t add_v,
bool  locked,
const char *  share_tbl_name 
)

Build template for the virtual columns and their base columns.

This is done when the table first opened.

Parameters
[in]tableMySQL TABLE
[in]ib_tableInnoDB dict_table_t
[in,out]s_templInnoDB template structure
[in]add_vnew virtual columns added along with add index call
[in]lockedtrue if dict_sys mutex is held
[in]share_tbl_nameoriginal MySQL table name

◆ innobase_build_v_templ_callback()

void innobase_build_v_templ_callback ( const TABLE table,
void *  ib_table 
)

Callback used by MySQL server layer to initialize the table virtual columns' template.

Parameters
[in]tableMySQL TABLE
[in,out]ib_tableInnoDB table

◆ innobase_copy_frm_flags_from_table_share()

void innobase_copy_frm_flags_from_table_share ( dict_table_t innodb_table,
const TABLE_SHARE table_share 
)

Copy table flags from MySQL's TABLE_SHARE into an InnoDB table object.

Those flags are stored in .frm file and end up in the MySQL table object, but are frequently used inside InnoDB so we keep their copies into the InnoDB table object. in: table share

Those flags are stored in .frm file and end up in the MySQL table object, but are frequently used inside InnoDB so we keep their copies into the InnoDB table object.

Parameters
innodb_tablein/out: InnoDB table
table_sharein: table share

◆ innobase_discard_table()

void innobase_discard_table ( THD thd,
dict_table_t table 
)

Drop the statistics for a specified table, and mark it as discard after DDL.

Parameters
[in,out]thdTHD object
[in,out]tableInnoDB table object

◆ innobase_fts_check_doc_id_index()

fts_doc_id_index_enum innobase_fts_check_doc_id_index ( const dict_table_t table,
const TABLE altered_table,
ulint fts_doc_col_no 
)

Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME on the Doc ID column.

Returns
the status of the FTS_DOC_ID index out: The column number for Doc ID
the status of the FTS_DOC_ID index
Parameters
tablein: table definition
altered_tablein: MySQL table that is being altered
fts_doc_col_noout: The column number for Doc ID, or ULINT_UNDEFINED if it is being created in ha_alter_info

◆ innobase_fts_check_doc_id_index_in_def()

fts_doc_id_index_enum innobase_fts_check_doc_id_index_in_def ( ulint  n_key,
const KEY key_info 
)

Check whether the table has a unique index with FTS_DOC_ID_INDEX_NAME on the Doc ID column in MySQL create index definition.

Returns
FTS_EXIST_DOC_ID_INDEX if there exists the FTS_DOC_ID index, FTS_INCORRECT_DOC_ID_INDEX if the FTS_DOC_ID index is of wrong format in: Key definitions
FTS_EXIST_DOC_ID_INDEX if there exists the FTS_DOC_ID index, FTS_INCORRECT_DOC_ID_INDEX if the FTS_DOC_ID index is of wrong format
Parameters
n_keyin: Number of keys
key_infoin: Key definition

◆ innobase_fts_load_stopword()

bool innobase_fts_load_stopword ( dict_table_t table,
trx_t trx,
THD thd 
)

Initialize the table FTS stopword list.

Returns
true if success in: current thread
true if success
Parameters
tablein: Table has the FTS
trxin: transaction
thdin: current thread

◆ innobase_index_name_is_reserved()

bool innobase_index_name_is_reserved ( THD thd,
const KEY key_info,
ulint  num_of_keys 
)

This function checks each index name for a table against reserved system default primary index name 'GEN_CLUST_INDEX'.

If a name matches, this function pushes an warning message to the client, and returns true.

Returns
true if the index name matches the reserved name in: Number of indexes to be created.

If a name matches, this function pushes an warning message to the client, and returns true.

Returns
true if the index name matches the reserved name
Parameters
thdin/out: MySQL connection
key_infoin: Indexes to be created
num_of_keysin: Number of indexes to be created.

◆ innobase_is_multi_value_fld()

static bool innobase_is_multi_value_fld ( const Field field)
inlinestatic

Whether this is a computed multi-value virtual column.

This condition check should be equal to the following one: (innobase_is_v_fld(field) && (field)->gcol_info->expr_item && field->gcol_info->expr_item->returns_array())

◆ innobase_is_s_fld()

static bool innobase_is_s_fld ( const Field field)
inlinestatic

whether this is a stored column

◆ innobase_match_index_columns()

bool innobase_match_index_columns ( const KEY key_info,
const dict_index_t index_info 
)

Match index columns between MySQL and InnoDB.

This function checks whether the index column information is consistent between KEY info from mysql and that from innodb index.

Parameters
[in]key_infoIndex info from mysql
[in]index_infoIndex info from InnoDB
Returns
true if all column types match.

◆ innobase_parse_hint_from_comment()

void innobase_parse_hint_from_comment ( THD thd,
dict_table_t table,
const TABLE_SHARE table_share 
)

Parse hint for table and its indexes, and update the information in dictionary.

Parameters
[in]thdConnection thread
[in,out]tableTarget table
[in]table_shareTable definition

◆ innobase_register_trx()

void innobase_register_trx ( handlerton hton,
THD thd,
trx_t trx 
)

Allocates an InnoDB transaction for a MySQL handler object for DML.

Parameters
[in]htonInnobase handlerton.
[in]thdMySQL thd (connection) object.
[in]trxtransaction to register.

Allocates an InnoDB transaction for a MySQL handler object for DML.

This MUST be called for every transaction for which the user may call commit or rollback. Calling this several times to register the same transaction is allowed, too. This function also registers the current SQL statement.

◆ innobase_trx_allocate()

trx_t * innobase_trx_allocate ( THD thd)

Allocates an InnoDB transaction for a MySQL handler object.

Returns
InnoDB transaction handle in: user thread handle

Allocates an InnoDB transaction for a MySQL handler object.

Returns
InnoDB transaction handle
Parameters
thdin: user thread handle

◆ innobase_trx_map_isolation_level()

trx_t::isolation_level_t innobase_trx_map_isolation_level ( enum_tx_isolation  iso)

Maps a MySQL trx isolation level code to the InnoDB isolation level code.

Parameters
[in]isoMySQL isolation level code
Returns
InnoDB isolation level

◆ innodb_base_col_setup()

void innodb_base_col_setup ( dict_table_t table,
const Field field,
dict_v_col_t v_col 
)

Set up base columns for virtual column.

Parameters
[in]tablethe InnoDB table
[in]fieldMySQL field
[in,out]v_colvirtual column to be set up

◆ innodb_base_col_setup_for_stored()

void innodb_base_col_setup_for_stored ( const dict_table_t table,
const Field field,
dict_s_col_t s_col 
)

Set up base columns for stored column.

Parameters
[in]tableInnoDB table
[in]fieldMySQL field
[in,out]s_colstored column

◆ innodb_rec_per_key()

rec_per_key_t innodb_rec_per_key ( const dict_index_t index,
ulint  i,
ha_rows  records 
)

Calculate Record Per Key value.

Need to exclude the NULL value if innodb_stats_method is set to "nulls_ignored"

Parameters
[in]indexInnoDB index.
[in]iThe column we are calculating rec per key.
[in]recordsEstimated total records.
Returns
estimated record per key value

◆ is_shared_tablespace()

static bool is_shared_tablespace ( const char *  tablespace_name)
inlinestatic

Check if tablespace is shared tablespace.

Parameters
[in]tablespace_nameName of the tablespace
Returns
true if tablespace is a shared tablespace.

◆ normalize_table_name()

static bool normalize_table_name ( char *  norm_name,
const char *  name 
)
inlinestatic

◆ tablespace_is_file_per_table()

static bool tablespace_is_file_per_table ( const HA_CREATE_INFO create_info)
inlinestatic

Check if the explicit tablespace targeted is file_per_table.

Parameters
[in]create_infoMetadata for the table to create.
Returns
true if the table is intended to use a file_per_table tablespace.

◆ tablespace_is_general_space()

static bool tablespace_is_general_space ( const HA_CREATE_INFO create_info)
inlinestatic

Check if table will be explicitly put in a general tablespace.

Parameters
[in]create_infoMetadata for the table to create.
Returns
true if the table will use a general tablespace.

◆ tablespace_is_shared_space()

static bool tablespace_is_shared_space ( const HA_CREATE_INFO create_info)
inlinestatic

Check if table will be explicitly put in an existing shared general or system tablespace.

Parameters
[in]create_infoMetadata for the table to create.
Returns
true if the table will use a shared general or system tablespace.

◆ thd_parallel_read_threads()

ulong thd_parallel_read_threads ( THD thd)

Return the number of read threads for this session.

Parameters
[in]thdSession instance, or nullptr to query the global innodb_parallel_read_threads value.

◆ thd_to_trx()

trx_t *& thd_to_trx ( THD thd)

Obtain the InnoDB transaction of a MySQL thread.

Parameters
[in,out]thdMySQL thread handler.
Returns
reference to transaction pointer

◆ trx_is_registered_for_2pc()

bool trx_is_registered_for_2pc ( const trx_t trx)
inline

Note that a transaction has been registered with MySQL.

Parameters
[in]trxTransaction.
Returns
true if transaction is registered with MySQL 2PC coordinator

◆ validate_autoextend_size_value()

static int validate_autoextend_size_value ( uint64_t  ext_size)
inlinestatic

Validate AUTOEXTEND_SIZE attribute for a tablespace.

Parameters
[in]ext_sizeValue of autoextend_size attribute
Returns
DB_SUCCESS if the value of AUTOEXTEND_SIZE is valid.

Variable Documentation

◆ clone_protocol_svc

const mysql_service_clone_protocol_t* clone_protocol_svc
extern

Clone protocol service.

◆ ft_vft_result

const struct _ft_vft ft_vft_result
extern

◆ innobase_index_reserve_name

const char innobase_index_reserve_name[]
extern

"GEN_CLUST_INDEX" is the name reserved for InnoDB default system clustered index when there is no primary key.

◆ innobase_stats_on_metadata

bool innobase_stats_on_metadata
extern

◆ SIZE_MB

constexpr uint32_t SIZE_MB = 1024 * 1024
constexpr