MySQL  8.0.18
Source Code Documentation
ha_innodb.h File Reference
#include <sys/types.h>
#include "handler.h"
#include "my_dbug.h"
#include "row0pread-adapter.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

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

Macros

#define innobase_is_s_fld(field)   ((field)->gcol_info && (field)->stored_in_db)
 whether this is a stored column More...
 
#define innobase_is_v_fld(field)   ((field)->gcol_info && !(field)->stored_in_db)
 whether this is a computed virtual column More...
 
#define innobase_is_multi_value_fld(field)   (field->is_array())
 Whether this is a computed multi-value virtual column. More...
 
#define normalize_table_name(norm_name, name)   create_table_info_t::normalize_table_name_low(norm_name, name, FALSE)
 Always normalize table name to lower case on Windows. More...
 

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...
 
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...
 
UNIV_INLINE bool tablespace_is_file_per_table (const HA_CREATE_INFO *create_info)
 Check if the explicit tablespace targeted is file_per_table. More...
 
UNIV_INLINE 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...
 
UNIV_INLINE bool tablespace_is_general_space (const HA_CREATE_INFO *create_info)
 Check if table will be explicitly put in a general tablespace. More...
 
UNIV_INLINE bool is_shared_tablespace (const char *tablespace_name)
 Check if tablespace is shared 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...
 
ibool 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...
 
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 initialized the table virtual columns' template 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 struct _ft_vft ft_vft_result
 
bool innobase_stats_on_metadata
 

Macro Definition Documentation

◆ innobase_is_multi_value_fld

#define innobase_is_multi_value_fld (   field)    (field->is_array())

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

#define innobase_is_s_fld (   field)    ((field)->gcol_info && (field)->stored_in_db)

whether this is a stored column

◆ innobase_is_v_fld

#define innobase_is_v_fld (   field)    ((field)->gcol_info && !(field)->stored_in_db)

whether this is a computed virtual column

◆ normalize_table_name

#define normalize_table_name (   norm_name,
  name 
)    create_table_info_t::normalize_table_name_low(norm_name, name, FALSE)

Always normalize table name to lower case on Windows.

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

Converts an InnoDB error code to a MySQL error code.

Parameters
[in]errorInnoDB error code
[in]flagsInnoDB table flags, or 0
[in]thduser thread handle or NULL
Returns
MySQL error code

◆ convert_search_mode_to_innobase()

page_cur_mode_t convert_search_mode_to_innobase ( 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.

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 innobase_share_mutex is held
[in]share_tbl_nameoriginal MySQL table name

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 initialized the table virtual columns' template

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

callback used by MySQL server layer to initialized 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



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.

Parameters
innodb_tablein/out: InnoDB table
table_sharein: table share

◆ 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


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


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
Parameters
n_keyin: Number of keys
key_infoin: Key definition

◆ innobase_fts_load_stopword()

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


Initialize the table FTS stopword list

Returns
true if success


Initialize the table FTS stopword list

Returns
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
Parameters
thdin/out: MySQL connection
key_infoin: Indexes to be created
num_of_keysin: Number of indexes to be created.

◆ 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
[in]thdconnection
[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

◆ 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
[in]tableInnoDB table
[in]fieldMySQL field
[in,out]v_colvirtual column

◆ 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

Excludes the NULL value if innodb_stats_method is set to "nulls_ignored"

Parameters
[in]indexdict_index_t structure
[in]icolumn we are calculating rec per key
[in]recordsestimated total records
Returns
estimated record per key value

◆ is_shared_tablespace()

UNIV_INLINE bool is_shared_tablespace ( const char *  tablespace_name)

Check if tablespace is shared tablespace.

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

◆ tablespace_is_file_per_table()

UNIV_INLINE bool tablespace_is_file_per_table ( const HA_CREATE_INFO create_info)

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

UNIV_INLINE bool tablespace_is_general_space ( const HA_CREATE_INFO create_info)

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

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

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

Variable Documentation

◆ ft_vft_result

const struct _ft_vft ft_vft_result

◆ innobase_index_reserve_name

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.

◆ innobase_stats_on_metadata

bool innobase_stats_on_metadata