MySQL  8.0.14
Source Code Documentation
handler.h File Reference
#include <fcntl.h>
#include <float.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <random>
#include <set>
#include <string>
#include "ft_global.h"
#include "lex_string.h"
#include "m_ctype.h"
#include "map_helpers.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_bitmap.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_double2ulonglong.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_sys.h"
#include "my_thread_local.h"
#include "mysql/components/services/psi_table_bits.h"
#include "sql/dd/object_id.h"
#include "sql/dd/string_type.h"
#include "sql/dd/types/object_table.h"
#include "sql/discrete_interval.h"
#include "sql/key.h"
#include "sql/sql_const.h"
#include "sql/sql_list.h"
#include "sql/sql_plugin_ref.h"
#include "thr_lock.h"
#include "typelib.h"

Go to the source code of this file.

Classes

struct  st_handler_tablename
 
class  st_alter_tablespace
 Legacy struct for passing tablespace information to SEs. More...
 
struct  Ha_clone_file
 File reference for clone. More...
 
class  Ha_clone_cbk
 
struct  Ha_fk_column_type
 Column type description for foreign key columns compatibility check. More...
 
struct  Clone_interface_t
 
struct  handlerton
 handlerton is a singleton structure - one instance per storage engine - to provide access to storage engine functionality that works on the "global" level (unlike handler class that works on a per-table basis). More...
 
struct  HA_CREATE_INFO
 
struct  KEY_PAIR
 Structure describing changes to an index to be caused by ALTER TABLE. More...
 
class  inplace_alter_handler_ctx
 In-place alter handler context. More...
 
class  Alter_inplace_info
 Class describing changes to be done by ALTER TABLE. More...
 
struct  HA_CHECK_OPT
 
struct  HANDLER_BUFFER
 
struct  RANGE_SEQ_IF
 
class  Cost_estimate
 Used to store optimizer cost estimates. More...
 
class  ha_statistics
 
class  Handler_share
 Base class to be used by handlers different shares. More...
 
class  Ft_hints
 Wrapper for struct ft_hints. More...
 
class  handler
 The handler class is the interface for dynamically loadable storage engines. More...
 
class  DsMrr_impl
 
class  ha_tablespace_statistics
 

Namespaces

 dd
 The version of the current data dictionary table definitions.
 
 AQP
 Abstract query plan (AQP) is an interface for examining certain aspects of query plans without accessing mysqld internal classes (JOIN_TAB, QEP_TAB, etc.) directly.
 

Macros

#define HA_ADMIN_ALREADY_DONE   1
 
#define HA_ADMIN_OK   0
 
#define HA_ADMIN_NOT_IMPLEMENTED   -1
 
#define HA_ADMIN_FAILED   -2
 
#define HA_ADMIN_CORRUPT   -3
 
#define HA_ADMIN_INTERNAL_ERROR   -4
 
#define HA_ADMIN_INVALID   -5
 
#define HA_ADMIN_REJECT   -6
 
#define HA_ADMIN_TRY_ALTER   -7
 
#define HA_ADMIN_WRONG_CHECKSUM   -8
 
#define HA_ADMIN_NOT_BASE_TABLE   -9
 
#define HA_ADMIN_NEEDS_UPGRADE   -10
 
#define HA_ADMIN_NEEDS_ALTER   -11
 
#define HA_ADMIN_NEEDS_CHECK   -12
 
#define HA_ADMIN_STATS_UPD_ERR   -13
 
#define HA_ADMIN_NEEDS_DUMP_UPGRADE   -14
 User needs to dump and re-create table to fix pre 5.0 decimal types. More...
 
#define HA_NO_TRANSACTIONS   (1 << 0) /* Doesn't support transactions */
 
#define HA_PARTIAL_COLUMN_READ   (1 << 1) /* read may not return all columns */
 
#define HA_TABLE_SCAN_ON_INDEX   (1 << 2)
 
#define HA_UNUSED3   (1 << 3)
 Not in use. More...
 
#define HA_CAN_GEOMETRY   (1 << 4)
 
#define HA_FAST_KEY_READ   (1 << 5)
 
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE   (1 << 6)
 
#define HA_NULL_IN_KEY   (1 << 7)
 
#define HA_DUPLICATE_POS   (1 << 8)
 
#define HA_NO_BLOBS   (1 << 9) /* Doesn't support blobs */
 
#define HA_CAN_INDEX_BLOBS   (1 << 10)
 
#define HA_AUTO_PART_KEY   (1 << 11)
 
#define HA_REQUIRE_PRIMARY_KEY   (1 << 12)
 
#define HA_STATS_RECORDS_IS_EXACT   (1 << 13)
 
#define HA_UNUSED14   (1 << 14)
 Not in use. More...
 
#define HA_PRIMARY_KEY_IN_READ_INDEX   (1 << 15)
 
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION   (1 << 16)
 
#define HA_CAN_RTREEKEYS   (1 << 17)
 
#define HA_NOT_DELETE_WITH_CACHE   (1 << 18)
 
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE   (1 << 19)
 
#define HA_NO_PREFIX_CHAR_KEYS   (1 << 20)
 
#define HA_CAN_FULLTEXT   (1 << 21)
 
#define HA_CAN_SQL_HANDLER   (1 << 22)
 
#define HA_NO_AUTO_INCREMENT   (1 << 23)
 
#define HA_HAS_CHECKSUM   (1 << 24)
 
#define HA_FILE_BASED   (1 << 26)
 
#define HA_NO_VARCHAR   (1 << 27)
 
#define HA_CAN_BIT_FIELD   (1 << 28)
 
#define HA_ANY_INDEX_MAY_BE_UNIQUE   (1 << 30)
 
#define HA_NO_COPY_ON_ALTER   (1LL << 31)
 
#define HA_COUNT_ROWS_INSTANT   (1LL << 32) /* records() gives exact count*/
 
#define HA_HAS_OWN_BINLOGGING   (1LL << 33)
 
#define HA_BINLOG_ROW_CAPABLE   (1LL << 34)
 
#define HA_BINLOG_STMT_CAPABLE   (1LL << 35)
 
#define HA_DUPLICATE_KEY_NOT_IN_ORDER   (1LL << 36)
 
#define HA_CAN_REPAIR   (1LL << 37)
 
#define HA_BINLOG_FLAGS   (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
 
#define HA_READ_BEFORE_WRITE_REMOVAL   (1LL << 38)
 The handler supports read before write removal optimization. More...
 
#define HA_CAN_FULLTEXT_EXT   (1LL << 39)
 
#define HA_READ_OUT_OF_SYNC   (1LL << 40)
 
#define HA_CAN_EXPORT   (1LL << 41)
 
#define HA_BLOCK_CONST_TABLE   (1LL << 42)
 
#define HA_CAN_FULLTEXT_HINTS   (1LL << 43)
 
#define HA_NO_READ_LOCAL_LOCK   (1LL << 44)
 Storage engine doesn't support LOCK TABLE ... More...
 
#define HA_ATTACHABLE_TRX_COMPATIBLE   (1LL << 45)
 A storage engine is compatible with the attachable transaction requirements means that. More...
 
#define HA_GENERATED_COLUMNS   (1LL << 46)
 Handler supports Generated Columns. More...
 
#define HA_CAN_INDEX_VIRTUAL_GENERATED_COLUMN   (1LL << 47)
 Supports index on virtual generated column. More...
 
#define HA_DESCENDING_INDEX   (1LL << 48)
 Supports descending indexes. More...
 
#define HA_BLOB_PARTIAL_UPDATE   (1LL << 49)
 Supports partial update of BLOB columns. More...
 
#define HA_SUPPORTS_GEOGRAPHIC_GEOMETRY_COLUMN   (1LL << 50)
 If this isn't defined, only columns/indexes with Cartesian coordinate systems (projected SRS or SRID 0) is supported. More...
 
#define HA_SUPPORTS_DEFAULT_EXPRESSION   (1LL << 51)
 Handler supports expressions as DEFAULT for a column. More...
 
#define HA_UPDATE_NOT_SUPPORTED   (1LL << 52)
 Handlers with this flag set do not support UPDATE operations. More...
 
#define HA_DELETE_NOT_SUPPORTED   (1LL << 53)
 Handlers with this flag set do not support DELETE operations. More...
 
#define HA_READ_NEXT   1 /* TODO really use this flag */
 
#define HA_READ_PREV   2
 
#define HA_READ_ORDER   4
 
#define HA_READ_RANGE   8
 
#define HA_ONLY_WHOLE_INDEX   16
 
#define HA_KEYREAD_ONLY   64
 
#define HA_KEY_SCAN_NOT_ROR   128
 
#define HA_DO_INDEX_COND_PUSHDOWN   256 /* Supports Index Condition Pushdown */
 
#define HA_KEY_SWITCH_NONUNIQ   0
 
#define HA_KEY_SWITCH_ALL   1
 
#define HA_KEY_SWITCH_NONUNIQ_SAVE   2
 
#define HA_KEY_SWITCH_ALL_SAVE   3
 
#define HA_SLOT_UNDEF   ((uint)-1)
 
#define HA_OPEN_KEYFILE   1
 
#define HA_OPEN_RNDFILE   2
 
#define HA_GET_INDEX   4
 
#define HA_GET_INFO   8 /* do a handler::info() after open */
 
#define HA_READ_ONLY   16 /* File opened as readonly */
 
#define HA_TRY_READ_ONLY   32
 
#define HA_WAIT_IF_LOCKED   64 /* Wait if locked on open */
 
#define HA_ABORT_IF_LOCKED   128 /* skip if locked on open.*/
 
#define HA_BLOCK_LOCK   256 /* unlock when reading some records */
 
#define HA_OPEN_TEMPORARY   512
 
#define HA_KEY_NULL_LENGTH   1
 
#define HA_KEY_BLOB_LENGTH   2
 
#define HA_LEX_CREATE_TMP_TABLE   1
 
#define HA_LEX_CREATE_IF_NOT_EXISTS   2
 
#define HA_LEX_CREATE_TABLE_LIKE   4
 
#define HA_LEX_CREATE_INTERNAL_TMP_TABLE   8
 
#define HA_MAX_REC_LENGTH   65535U
 
#define HA_CREATE_USED_AUTO   (1L << 0)
 
#define HA_CREATE_USED_RAID   (1L << 1)
 
#define HA_CREATE_USED_UNION   (1L << 2)
 
#define HA_CREATE_USED_INSERT_METHOD   (1L << 3)
 
#define HA_CREATE_USED_MIN_ROWS   (1L << 4)
 
#define HA_CREATE_USED_MAX_ROWS   (1L << 5)
 
#define HA_CREATE_USED_AVG_ROW_LENGTH   (1L << 6)
 
#define HA_CREATE_USED_PACK_KEYS   (1L << 7)
 
#define HA_CREATE_USED_CHARSET   (1L << 8)
 
#define HA_CREATE_USED_DEFAULT_CHARSET   (1L << 9)
 
#define HA_CREATE_USED_DATADIR   (1L << 10)
 
#define HA_CREATE_USED_INDEXDIR   (1L << 11)
 
#define HA_CREATE_USED_ENGINE   (1L << 12)
 
#define HA_CREATE_USED_CHECKSUM   (1L << 13)
 
#define HA_CREATE_USED_DELAY_KEY_WRITE   (1L << 14)
 
#define HA_CREATE_USED_ROW_FORMAT   (1L << 15)
 
#define HA_CREATE_USED_COMMENT   (1L << 16)
 
#define HA_CREATE_USED_PASSWORD   (1L << 17)
 
#define HA_CREATE_USED_CONNECTION   (1L << 18)
 
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
 
#define HA_CREATE_USED_TRANSACTIONAL   (1L << 20)
 Unused. More...
 
#define HA_CREATE_USED_PAGE_CHECKSUM   (1L << 21)
 Unused. More...
 
#define HA_CREATE_USED_STATS_PERSISTENT   (1L << 22)
 This is set whenever STATS_PERSISTENT=0|1|default has been specified in CREATE/ALTER TABLE. More...
 
#define HA_CREATE_USED_STATS_AUTO_RECALC   (1L << 23)
 This is set whenever STATS_AUTO_RECALC=0|1|default has been specified in CREATE/ALTER TABLE. More...
 
#define HA_CREATE_USED_STATS_SAMPLE_PAGES   (1L << 24)
 This is set whenever STATS_SAMPLE_PAGES=N|default has been specified in CREATE/ALTER TABLE. More...
 
#define HA_CREATE_USED_TABLESPACE   (1L << 25)
 This is set whenever a 'TABLESPACE=...' phrase is used on CREATE TABLE. More...
 
#define HA_CREATE_USED_COMPRESS   (1L << 26)
 COMPRESSION="zlib|lz4|none" used during table create. More...
 
#define HA_CREATE_USED_ENCRYPT   (1L << 27)
 ENCRYPTION="Y" used during table create. More...
 
#define HA_CREATE_USED_DEFAULT_COLLATE   (1L << 28)
 CREATE|ALTER SCHEMA|DATABASE|TABLE has an explicit COLLATE clause. More...
 
#define HA_CREATE_USED_SECONDARY_ENGINE   (1L << 29)
 SECONDARY_ENGINE used during table create. More...
 
#define MAXGTRIDSIZE   64
 
#define MAXBQUALSIZE   64
 
#define COMPATIBLE_DATA_YES   0
 
#define COMPATIBLE_DATA_NO   1
 
#define UNDEF_NODEGROUP   65535
 
#define HTON_NO_FLAGS   0
 
#define HTON_CLOSE_CURSORS_AT_COMMIT   (1 << 0)
 
#define HTON_ALTER_NOT_SUPPORTED   (1 << 1)
 
#define HTON_CAN_RECREATE   (1 << 2)
 
#define HTON_HIDDEN   (1 << 3)
 
#define HTON_NOT_USER_SELECTABLE   (1 << 5)
 
#define HTON_TEMPORARY_NOT_SUPPORTED   (1 << 6)
 
#define HTON_SUPPORT_LOG_TABLES   (1 << 7)
 
#define HTON_NO_PARTITION   (1 << 8)
 
#define HTON_NO_BINLOG_ROW_OPT   (1 << 9)
 
#define HTON_SUPPORTS_EXTENDED_KEYS   (1 << 10)
 Engine supports extended keys. More...
 
#define HTON_SUPPORTS_FOREIGN_KEYS   (1 << 11)
 
#define HTON_SUPPORTS_ATOMIC_DDL   (1 << 12)
 Engine supports atomic DDL. More...
 
#define HTON_SUPPORTS_PACKED_KEYS   (1 << 13)
 
#define HTON_IS_SECONDARY_ENGINE   (1 << 14)
 Engine is a secondary storage engine. More...
 
#define HTON_SUPPORTS_SECONDARY_ENGINE   (1 << 15)
 Engine supports secondary storage engines. More...
 
#define HA_MRR_SINGLE_POINT   1
 
#define HA_MRR_FIXED_KEY   2
 
#define HA_MRR_NO_ASSOCIATION   4
 
#define HA_MRR_SORTED   8
 
#define HA_MRR_INDEX_ONLY   16
 
#define HA_MRR_LIMITS   32
 
#define HA_MRR_USE_DEFAULT_IMPL   64
 
#define HA_MRR_NO_NULL_ENDPOINTS   128
 
#define HA_MRR_SUPPORT_SORTED   256
 
#define make_keypart_map(N)   (((key_part_map)2 << (N)) - 1)
 
#define make_prev_keypart_map(N)   (((key_part_map)1 << (N)) - 1)
 

Typedefs

typedef struct xid_t XID
 
typedef struct st_xarecover_txn XA_recover_txn
 
typedef sdi_key dd::sdi_key_t
 
typedef sdi_vector dd::sdi_vector_t
 
typedef bool(* qc_engine_callback) (THD *thd, const char *table_key, uint key_length, ulonglong *engine_data)
 
typedef bool() stat_print_fn(THD *thd, const char *type, size_t type_len, const char *file, size_t file_len, const char *status, size_t status_len)
 
using Ha_clone_flagset = std::bitset< HA_CLONE_TYPE_MAX >
 
typedef int(* close_connection_t) (handlerton *hton, THD *thd)
 close_connection is only called if thd->ha_data[xxx_hton.slot] is non-zero, so even if you don't need this storage area - set it to something, so that MySQL would know this storage engine was accessed in this connection More...
 
typedef void(* kill_connection_t) (handlerton *hton, THD *thd)
 Terminate connection/statement notification. More...
 
typedef void(* pre_dd_shutdown_t) (handlerton *hton)
 Shut down all storage engine background tasks that might access the data dictionary, before the main shutdown. More...
 
typedef int(* savepoint_rollback_t) (handlerton *hton, THD *thd, void *sv)
 sv points to a storage area, that was earlier passed to the savepoint_set call More...
 
typedef int(* savepoint_set_t) (handlerton *hton, THD *thd, void *sv)
 sv points to an uninitialized storage area of requested size (see savepoint_offset description) More...
 
typedef bool(* savepoint_rollback_can_release_mdl_t) (handlerton *hton, THD *thd)
 Check if storage engine allows to release metadata locks which were acquired after the savepoint if rollback to savepoint is done. More...
 
typedef int(* savepoint_release_t) (handlerton *hton, THD *thd, void *sv)
 
typedef int(* commit_t) (handlerton *hton, THD *thd, bool all)
 'all' is true if it's a real commit, that makes persistent changes 'all' is false if it's not in fact a commit but an end of the statement that is part of the transaction. More...
 
typedef int(* rollback_t) (handlerton *hton, THD *thd, bool all)
 
typedef int(* prepare_t) (handlerton *hton, THD *thd, bool all)
 
typedef int(* recover_t) (handlerton *hton, XA_recover_txn *xid_list, uint len, MEM_ROOT *mem_root)
 
typedef xa_status_code(* commit_by_xid_t) (handlerton *hton, XID *xid)
 
typedef xa_status_code(* rollback_by_xid_t) (handlerton *hton, XID *xid)
 
typedef handler *(* create_t) (handlerton *hton, TABLE_SHARE *table, bool partitioned, MEM_ROOT *mem_root)
 Create handler object for the table in the storage engine. More...
 
typedef void(* drop_database_t) (handlerton *hton, char *path)
 
typedef int(* panic_t) (handlerton *hton, enum ha_panic_function flag)
 
typedef int(* start_consistent_snapshot_t) (handlerton *hton, THD *thd)
 
typedef bool(* flush_logs_t) (handlerton *hton, bool binlog_group_flush)
 Flush the log(s) of storage engine(s). More...
 
typedef bool(* show_status_t) (handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat)
 
typedef uint(* partition_flags_t) ()
 The flag values are defined in sql_partition.h. More...
 
typedef bool(* is_valid_tablespace_name_t) (ts_command_type ts_cmd, const char *tablespace_name)
 SE specific validation of the tablespace name. More...
 
typedef int(* get_tablespace_t) (THD *thd, LEX_CSTRING db_name, LEX_CSTRING table_name, LEX_CSTRING *tablespace_name)
 Get the tablespace name from the SE for the given schema and table. More...
 
typedef int(* alter_tablespace_t) (handlerton *hton, THD *thd, st_alter_tablespace *ts_info, const dd::Tablespace *old_ts_def, dd::Tablespace *new_ts_def)
 Create/drop or alter tablespace in the storage engine. More...
 
typedef const char *(* get_tablespace_filename_ext_t) ()
 SE interface for getting tablespace extension. More...
 
typedef int(* upgrade_tablespace_t) (THD *thd)
 Get the tablespace data from SE and insert it into Data dictionary. More...
 
typedef bool(* upgrade_space_version_t) (dd::Tablespace *tablespace)
 Get the tablespace data from SE and insert it into Data dictionary. More...
 
typedef int(* finish_upgrade_t) (THD *thd, bool failed_upgrade)
 Finish upgrade process inside storage engines. More...
 
typedef int(* upgrade_logs_t) (THD *thd)
 Upgrade logs after the checkpoint from where upgrade process can only roll forward. More...
 
typedef bool(* get_tablespace_type_t) (const dd::Tablespace &space, Tablespace_type *space_type)
 Get the tablespace type from the SE. More...
 
typedef int(* fill_is_table_t) (handlerton *hton, THD *thd, TABLE_LIST *tables, class Item *cond, enum enum_schema_tables)
 
typedef int(* binlog_func_t) (handlerton *hton, THD *thd, enum_binlog_func fn, void *arg)
 
typedef void(* binlog_log_query_t) (handlerton *hton, THD *thd, enum_binlog_command binlog_command, const char *query, uint query_length, const char *db, const char *table_name)
 
typedef int(* discover_t) (handlerton *hton, THD *thd, const char *db, const char *name, uchar **frmblob, size_t *frmlen)
 
typedef int(* find_files_t) (handlerton *hton, THD *thd, const char *db, const char *path, const char *wild, bool dir, List< LEX_STRING > *files)
 
typedef int(* table_exists_in_engine_t) (handlerton *hton, THD *thd, const char *db, const char *name)
 
typedef int(* make_pushed_join_t) (handlerton *hton, THD *thd, const AQP::Join_plan *plan)
 
typedef bool(* is_supported_system_table_t) (const char *db, const char *table_name, bool is_sql_layer_system_table)
 Check if the given db.tablename is a system table for this SE. More...
 
typedef bool(* sdi_create_t) (dd::Tablespace *tablespace)
 Create SDI in a tablespace. More...
 
typedef bool(* sdi_drop_t) (dd::Tablespace *tablespace)
 Drop SDI in a tablespace. More...
 
typedef bool(* sdi_get_keys_t) (const dd::Tablespace &tablespace, dd::sdi_vector_t &vector)
 Get the SDI keys in a tablespace into vector. More...
 
typedef bool(* sdi_get_t) (const dd::Tablespace &tablespace, const dd::sdi_key_t *sdi_key, void *sdi, uint64 *sdi_len)
 Retrieve SDI for a given SDI key. More...
 
typedef bool(* sdi_set_t) (handlerton *hton, const dd::Tablespace &tablespace, const dd::Table *table, const dd::sdi_key_t *sdi_key, const void *sdi, uint64 sdi_len)
 Insert/Update SDI for a given SDI key. More...
 
typedef bool(* sdi_delete_t) (const dd::Tablespace &tablespace, const dd::Table *table, const dd::sdi_key_t *sdi_key)
 Delete SDI for a given SDI key. More...
 
typedef bool(* is_dict_readonly_t) ()
 Check if the DDSE is started in a way that leaves thd DD being read only. More...
 
typedef bool(* rm_tmp_tables_t) (handlerton *hton, THD *thd, List< LEX_STRING > *files)
 Drop all temporary tables which have been left from previous server run belonging to this SE. More...
 
typedef SE_cost_constants *(* get_cost_constants_t) (uint storage_category)
 Retrieve cost constants to be used for this storage engine. More...
 
typedef void(* replace_native_transaction_in_thd_t) (THD *thd, void *new_trx_arg, void **ptr_trx_arg)
 
typedef bool(* dict_init_t) (dict_init_mode_t dict_init_mode, uint version, List< const Plugin_table > *DDSE_tables, List< const Plugin_tablespace > *DDSE_tablespaces)
 Initialize the SE for being used to store the DD tables. More...
 
typedef bool(* ddse_dict_init_t) (dict_init_mode_t dict_init_mode, uint version, List< const dd::Object_table > *DDSE_tables, List< const Plugin_tablespace > *DDSE_tablespaces)
 
typedef void(* dict_register_dd_table_id_t) (dd::Object_id hard_coded_tables)
 Initialize the set of hard coded DD table ids. More...
 
typedef void(* dict_cache_reset_t) (const char *schema_name, const char *table_name)
 Invalidate an entry in the local dictionary cache. More...
 
typedef void(* dict_cache_reset_tables_and_tablespaces_t) ()
 Invalidate all table and tablespace entries in the local dictionary cache. More...
 
typedef bool(* dict_recover_t) (dict_recovery_mode_t dict_recovery_mode, uint version)
 Do recovery in the DDSE as part of initializing the data dictionary. More...
 
typedef bool(* dict_get_server_version_t) (uint *version)
 Get the server version id stored in the header of the dictionary tablespace. More...
 
typedef bool(* dict_set_server_version_t) ()
 Store the current server version number into the header of the dictionary tablespace. More...
 
typedef bool(* notify_exclusive_mdl_t) (THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, bool *victimized)
 Notify/get permission from storage engine before acquisition or after release of exclusive metadata lock on object represented by key. More...
 
typedef bool(* notify_alter_table_t) (THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type)
 Notify/get permission from storage engine before or after execution of ALTER TABLE operation on the table identified by the MDL key. More...
 
typedef bool(* rotate_encryption_master_key_t) (void)
 Initiate master key rotation. More...
 
typedef bool(* get_table_statistics_t) (const char *db_name, const char *table_name, dd::Object_id se_private_id, const dd::Properties &ts_se_private_data, const dd::Properties &tbl_se_private_data, uint flags, ha_statistics *stats)
 Retrieve ha_statistics from SE. More...
 
typedef bool(* get_index_column_cardinality_t) (const char *db_name, const char *table_name, const char *index_name, uint index_ordinal_position, uint column_ordinal_position, dd::Object_id se_private_id, ulonglong *cardinality)
 Retrieve index column cardinality from SE. More...
 
typedef bool(* get_tablespace_statistics_t) (const char *tablespace_name, const char *file_name, const dd::Properties &ts_se_private_data, ha_tablespace_statistics *stats)
 Retrieve ha_tablespace_statistics from SE. More...
 
using Clone_capability_t = void(*)(Ha_clone_flagset &flags)
 Get capability flags for clone operation. More...
 
using Clone_begin_t = int(*)(handlerton *hton, THD *thd, const uchar *&loc, uint &loc_len, uint &task_id, Ha_clone_type type, Ha_clone_mode mode)
 Begin copy from source database. More...
 
using Clone_copy_t = int(*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, Ha_clone_cbk *cbk)
 Copy data from source database in chunks via callback. More...
 
using Clone_ack_t = int(*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err, Ha_clone_cbk *cbk)
 Acknowledge data transfer to source database. More...
 
using Clone_end_t = int(*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err)
 End copy from source database. More...
 
using Clone_apply_begin_t = int(*)(handlerton *hton, THD *thd, const uchar *&loc, uint &loc_len, uint &task_id, Ha_clone_mode mode, const char *data_dir)
 Begin apply to destination database. More...
 
using Clone_apply_t = int(*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err, Ha_clone_cbk *cbk)
 Apply data to destination database in chunks via callback. More...
 
using Clone_apply_end_t = int(*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err)
 End apply to destination database. More...
 
typedef void(* post_ddl_t) (THD *thd)
 Perform post-commit/rollback cleanup after DDL statement (e.g. More...
 
typedef void(* post_recover_t) (void)
 Perform SE-specific cleanup after recovery of transactions. More...
 
typedef bool(* lock_hton_log_t) (handlerton *hton)
 Lock a handlerton (resource) log to collect log information. More...
 
typedef bool(* unlock_hton_log_t) (handlerton *hton)
 Unlock a handlerton (resource) log after collecting log information. More...
 
typedef bool(* collect_hton_log_info_t) (handlerton *hton, Json_dom *json)
 Collect a handlerton (resource) log information. More...
 
typedef bool(* check_fk_column_compat_t) (const Ha_fk_column_type *child_column_type, const Ha_fk_column_type *parent_column_type, bool check_charsets)
 Check SE considers types of child and parent columns in foreign key to be compatible. More...
 
typedef bool(* is_reserved_db_name_t) (handlerton *hton, const char *name)
 
typedef void * range_seq_t
 
typedef bool Log_func(THD *, TABLE *, bool, const uchar *, const uchar *)
 
typedef ulonglong my_xid
 recover() step of xa. More...
 

Enumerations

enum  enum_alter_inplace_result {
  HA_ALTER_ERROR, HA_ALTER_INPLACE_NOT_SUPPORTED, HA_ALTER_INPLACE_EXCLUSIVE_LOCK, HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE,
  HA_ALTER_INPLACE_SHARED_LOCK, HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE, HA_ALTER_INPLACE_NO_LOCK, HA_ALTER_INPLACE_INSTANT
}
 Return values for check_if_supported_inplace_alter(). More...
 
enum  legacy_db_type {
  DB_TYPE_UNKNOWN = 0, DB_TYPE_DIAB_ISAM = 1, DB_TYPE_HASH, DB_TYPE_MISAM,
  DB_TYPE_PISAM, DB_TYPE_RMS_ISAM, DB_TYPE_HEAP, DB_TYPE_ISAM,
  DB_TYPE_MRG_ISAM, DB_TYPE_MYISAM, DB_TYPE_MRG_MYISAM, DB_TYPE_BERKELEY_DB,
  DB_TYPE_INNODB, DB_TYPE_GEMINI, DB_TYPE_NDBCLUSTER, DB_TYPE_EXAMPLE_DB,
  DB_TYPE_ARCHIVE_DB, DB_TYPE_CSV_DB, DB_TYPE_FEDERATED_DB, DB_TYPE_BLACKHOLE_DB,
  DB_TYPE_PARTITION_DB, DB_TYPE_BINLOG, DB_TYPE_SOLID, DB_TYPE_PBXT,
  DB_TYPE_TABLE_FUNCTION, DB_TYPE_MEMCACHE, DB_TYPE_FALCON, DB_TYPE_MARIA,
  DB_TYPE_PERFORMANCE_SCHEMA, DB_TYPE_TEMPTABLE, DB_TYPE_FIRST_DYNAMIC = 42, DB_TYPE_DEFAULT = 127
}
 
enum  row_type : int {
  ROW_TYPE_NOT_USED = -1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED, ROW_TYPE_DYNAMIC,
  ROW_TYPE_COMPRESSED, ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGED
}
 
enum  enum_binlog_func {
  BFN_RESET_LOGS = 1, BFN_RESET_SLAVE = 2, BFN_BINLOG_WAIT = 3, BFN_BINLOG_END = 4,
  BFN_BINLOG_PURGE_FILE = 5
}
 
enum  enum_binlog_command {
  LOGCOM_CREATE_TABLE, LOGCOM_ALTER_TABLE, LOGCOM_RENAME_TABLE, LOGCOM_DROP_TABLE,
  LOGCOM_CREATE_DB, LOGCOM_ALTER_DB, LOGCOM_DROP_DB, LOGCOM_ACL_NOTIFY
}
 
enum  enum_sampling_method { enum_sampling_method::SYSTEM }
 
enum  ts_command_type {
  TS_CMD_NOT_DEFINED = -1, CREATE_TABLESPACE = 0, ALTER_TABLESPACE = 1, CREATE_LOGFILE_GROUP = 2,
  ALTER_LOGFILE_GROUP = 3, DROP_TABLESPACE = 4, DROP_LOGFILE_GROUP = 5, CHANGE_FILE_TABLESPACE = 6,
  ALTER_ACCESS_MODE_TABLESPACE = 7, CREATE_UNDO_TABLESPACE = 8, ALTER_UNDO_TABLESPACE = 9, DROP_UNDO_TABLESPACE = 10
}
 
enum  ts_alter_tablespace_type {
  TS_ALTER_TABLESPACE_TYPE_NOT_DEFINED = -1, ALTER_TABLESPACE_ADD_FILE = 1, ALTER_TABLESPACE_DROP_FILE = 2, ALTER_TABLESPACE_RENAME = 3,
  ALTER_TABLESPACE_OPTIONS = 4, ALTER_UNDO_TABLESPACE_SET_ACTIVE = 5, ALTER_UNDO_TABLESPACE_SET_INACTIVE = 6
}
 
enum  enum_schema_tables {
  SCH_FIRST = 0, SCH_COLUMN_PRIVILEGES = SCH_FIRST, SCH_ENGINES, SCH_OPEN_TABLES,
  SCH_OPTIMIZER_TRACE, SCH_PLUGINS, SCH_PROCESSLIST, SCH_PROFILES,
  SCH_SCHEMA_PRIVILEGES, SCH_TABLESPACES, SCH_TABLE_PRIVILEGES, SCH_USER_PRIVILEGES,
  SCH_TMP_TABLE_COLUMNS, SCH_TMP_TABLE_KEYS, SCH_LAST = SCH_TMP_TABLE_KEYS
}
 
enum  ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX }
 
enum  ha_notification_type : int { HA_NOTIFY_PRE_EVENT, HA_NOTIFY_POST_EVENT }
 
enum  Ha_clone_mode {
  HA_CLONE_MODE_START, HA_CLONE_MODE_RESTART, HA_CLONE_MODE_ADD_TASK, HA_CLONE_MODE_VERSION,
  HA_CLONE_MODE_MAX
}
 Clone start operation mode. More...
 
enum  Ha_clone_type : size_t {
  HA_CLONE_BLOCKING, HA_CLONE_REDO, HA_CLONE_PAGE, HA_CLONE_HYBRID,
  HA_CLONE_MULTI_TASK, HA_CLONE_RESTART, HA_CLONE_TYPE_MAX
}
 Clone operation types. More...
 
enum  xa_status_code {
  XA_OK = 0, XAER_ASYNC = -2, XAER_RMERR = -3, XAER_NOTA = -4,
  XAER_INVAL = -5, XAER_PROTO = -6, XAER_RMFAIL = -7, XAER_DUPID = -8,
  XAER_OUTSIDE = -9
}
 X/Open XA distributed transaction status codes. More...
 
enum  Tablespace_type {
  Tablespace_type::SPACE_TYPE_DICTIONARY, Tablespace_type::SPACE_TYPE_SYSTEM, Tablespace_type::SPACE_TYPE_UNDO, Tablespace_type::SPACE_TYPE_TEMPORARY,
  Tablespace_type::SPACE_TYPE_SHARED, Tablespace_type::SPACE_TYPE_IMPLICIT
}
 
enum  dict_init_mode_t { DICT_INIT_CREATE_FILES, DICT_INIT_CHECK_FILES, DICT_INIT_UPGRADE_57_FILES, DICT_INIT_IGNORE_FILES }
 Mode for initializing the data dictionary. More...
 
enum  dict_recovery_mode_t { DICT_RECOVERY_INITIALIZE_SERVER, DICT_RECOVERY_INITIALIZE_TABLESPACES, DICT_RECOVERY_RESTART_SERVER }
 Mode for data dictionary recovery. More...
 
enum  enum_tx_isolation : int { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED, ISO_REPEATABLE_READ, ISO_SERIALIZABLE }
 
enum  enum_stats_auto_recalc : int { HA_STATS_AUTO_RECALC_DEFAULT = 0, HA_STATS_AUTO_RECALC_ON, HA_STATS_AUTO_RECALC_OFF }
 

Functions

st_plugin_inthton2plugin (uint slot)
 Maps from slot to plugin. May return NULL if plugin has been unloaded. More...
 
size_t num_hton2plugins ()
 Returns the size of the array holding pointers to plugins. More...
 
st_plugin_intinsert_hton2plugin (uint slot, st_plugin_int *plugin)
 For unit testing. More...
 
st_plugin_intremove_hton2plugin (uint slot)
 
bool ddl_is_atomic (const handlerton *hton)
 
void get_sweep_read_cost (TABLE *table, ha_rows nrows, bool interrupted, Cost_estimate *cost)
 Get cost of reading nrows table records in a "disk sweep". More...
 
uint calculate_key_len (TABLE *table, uint key, key_part_map keypart_map)
 Calculates length of key. More...
 
int check_table_for_old_types (const TABLE *table)
 Function identifies any old data type present in table. More...
 
handlertonha_default_handlerton (THD *thd)
 Return the default storage engine handlerton used for non-temp tables for thread. More...
 
handlertonha_default_temp_handlerton (THD *thd)
 Return the default storage engine handlerton used for explicitly created temp tables for a thread. More...
 
plugin_ref ha_resolve_by_name_raw (THD *thd, const LEX_CSTRING &name)
 Resolve handlerton plugin by name, without checking for "DEFAULT" or HTON_NOT_USER_SELECTABLE. More...
 
plugin_ref ha_resolve_by_name (THD *thd, const LEX_STRING *name, bool is_temp_table)
 Return the storage engine handlerton for the supplied name. More...
 
plugin_ref ha_lock_engine (THD *thd, const handlerton *hton)
 
handlertonha_resolve_by_legacy_type (THD *thd, enum legacy_db_type db_type)
 
handlerget_new_handler (TABLE_SHARE *share, bool partitioned, MEM_ROOT *alloc, handlerton *db_type)
 Create handler object for the table in the storage engine. More...
 
handlertonha_checktype (THD *thd, enum legacy_db_type database_type, bool no_substitute, bool report_error)
 Use other database handler if databasehandler is not compiled in. More...
 
static enum legacy_db_type ha_legacy_type (const handlerton *db_type)
 
const char * ha_resolve_storage_engine_name (const handlerton *db_type)
 
static bool ha_check_storage_engine_flag (const handlerton *db_type, uint32 flag)
 
static bool ha_storage_engine_is_enabled (const handlerton *db_type)
 
int ha_init_errors (void)
 Register handler error messages for use with my_error(). More...
 
int ha_init (void)
 
void ha_end ()
 
int ha_initialize_handlerton (st_plugin_int *plugin)
 
int ha_finalize_handlerton (st_plugin_int *plugin)
 
TYPELIBha_known_exts ()
 
int ha_panic (enum ha_panic_function flag)
 
void ha_close_connection (THD *thd)
 function to close a connection and thd, defined in sql/handler.cc More...
 
void ha_kill_connection (THD *thd)
 
void ha_pre_dd_shutdown (void)
 Invoke handlerton::pre_dd_shutdown() on every storage engine plugin. More...
 
bool ha_flush_logs (bool binlog_group_flush=false)
 Flush the log(s) of storage engine(s). More...
 
void ha_drop_database (char *path)
 
int ha_create_table (THD *thd, const char *path, const char *db, const char *table_name, HA_CREATE_INFO *create_info, bool update_create_info, bool is_temp_table, dd::Table *table_def)
 Initiates table-file and calls appropriate database-creator. More...
 
int ha_delete_table (THD *thd, handlerton *db_type, const char *path, const char *db, const char *alias, const dd::Table *table_def, bool generate_warning)
 Delete table from the storage engine. More...
 
bool ha_check_reserved_db_name (const char *name)
 Check if the database name is reserved word used by SE. More...
 
bool ha_show_status (THD *thd, handlerton *db_type, enum ha_stat_type stat)
 
int binlog_log_row (TABLE *table, const uchar *before_record, const uchar *after_record, Log_func *log_func)
 binlog a row operation More...
 
int ha_create_table_from_engine (THD *thd, const char *db, const char *name)
 Try to discover table from engine. More...
 
bool ha_check_if_table_exists (THD *thd, const char *db, const char *name, bool *exists)
 Try to find a table in a storage engine. More...
 
int ha_find_files (THD *thd, const char *db, const char *path, const char *wild, bool dir, List< LEX_STRING > *files)
 
int ha_table_exists_in_engine (THD *thd, const char *db, const char *name)
 
bool ha_check_if_supported_system_table (handlerton *hton, const char *db, const char *table_name)
 Check if a given table is a system table. More...
 
bool ha_rm_tmp_tables (THD *thd, List< LEX_STRING > *files)
 Ask all SEs to drop all temporary tables which have been left from previous server run. More...
 
bool default_rm_tmp_tables (handlerton *hton, THD *thd, List< LEX_STRING > *files)
 Default implementation for handlerton::rm_tmp_tables() method which simply removes all files from "files" list which have one of SE's extensions. More...
 
int ha_init_key_cache (const char *name, KEY_CACHE *key_cache)
 Init a key cache if it has not been initied before. More...
 
int ha_resize_key_cache (KEY_CACHE *key_cache)
 Resize key cache. More...
 
int ha_change_key_cache (KEY_CACHE *old_key_cache, KEY_CACHE *new_key_cache)
 Move all tables from one key cache to another one. More...
 
int ha_start_consistent_snapshot (THD *thd)
 
int ha_commit_trans (THD *thd, bool all, bool ignore_global_read_lock=false)
 
int ha_commit_attachable (THD *thd)
 Commit the attachable transaction in storage engines. More...
 
int ha_rollback_trans (THD *thd, bool all)
 
int ha_prepare (THD *thd)
 
int ha_recover (const memroot_unordered_set< my_xid > *commit_list)
 
void ha_post_recover ()
 Perform SE-specific cleanup after recovery of transactions. More...
 
int ha_commit_low (THD *thd, bool all, bool run_after_commit=true)
 Commit the sessions outstanding transaction. More...
 
int ha_prepare_low (THD *thd, bool all)
 
int ha_rollback_low (THD *thd, bool all)
 
int ha_enable_transaction (THD *thd, bool on)
 Tell the storage engine that it is allowed to "disable transaction" in the handler. More...
 
int ha_rollback_to_savepoint (THD *thd, SAVEPOINT *sv)
 
bool ha_rollback_to_savepoint_can_release_mdl (THD *thd)
 Check if all storage engines used in transaction agree that after rollback to savepoint it is safe to release MDL locks acquired after savepoint creation. More...
 
int ha_savepoint (THD *thd, SAVEPOINT *sv)
 
int ha_release_savepoint (THD *thd, SAVEPOINT *sv)
 
int ha_make_pushed_joins (THD *thd, const AQP::Join_plan *plan)
 
void trans_register_ha (THD *thd, bool all, handlerton *ht, const ulonglong *trxid)
 

Transaction handling in the server

More...
 
int ha_reset_logs (THD *thd)
 
int ha_binlog_index_purge_file (THD *thd, const char *file)
 
void ha_reset_slave (THD *thd)
 
void ha_binlog_log_query (THD *thd, handlerton *db_type, enum_binlog_command binlog_command, const char *query, size_t query_length, const char *db, const char *table_name)
 
void ha_binlog_wait (THD *thd)
 
int ha_binlog_end (THD *thd)
 
const char * get_canonical_filename (handler *file, const char *path, char *tmp_path)
 make canonical filename More...
 
const char * table_case_name (const HA_CREATE_INFO *info, const char *name)
 
void print_keydup_error (TABLE *table, KEY *key, const char *msg, myf errflag)
 Construct and emit duplicate key error message using information from table's record buffer. More...
 
void print_keydup_error (TABLE *table, KEY *key, myf errflag)
 Construct and emit duplicate key error message using information from table's record buffer. More...
 
void ha_set_normalized_disabled_se_str (const std::string &disabled_se_str)
 
bool ha_is_storage_engine_disabled (handlerton *se_engine)
 
bool ha_notify_exclusive_mdl (THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, bool *victimized)
 Notify/get permission from all interested storage engines before acquisition or after release of exclusive metadata lock on object represented by key. More...
 
bool ha_notify_alter_table (THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type)
 Notify/get permission from all interested storage engines before or after executed ALTER TABLE on the table identified by key. More...
 
int commit_owned_gtids (THD *thd, bool all, bool *need_clear_ptr)
 The function computes condition to call gtid persistor wrapper, and executes it. More...
 
int commit_owned_gtid_by_partial_command (THD *thd)
 The function is a wrapper of commit_owned_gtids(...). More...
 
bool set_tx_isolation (THD *thd, enum_tx_isolation tx_isolation, bool one_shot)
 Set the transaction isolation level for the next transaction and update session tracker information about the transaction isolation level. More...
 
const char * ha_rkey_function_to_str (enum ha_rkey_function r)
 Generate a string representation of an ha_rkey_function enum value. More...
 
std::string table_definition (const char *table_name, const TABLE *mysql_table)
 Generate a human readable string that describes a table structure. More...
 
std::string row_to_string (const uchar *mysql_row, TABLE *mysql_table)
 Generate a human readable string that describes the contents of a row. More...
 
std::string indexed_cells_to_string (const uchar *indexed_cells, uint indexed_cells_len, const KEY &mysql_index)
 Generate a human readable string that describes indexed cells that are given to handler::index_read() as input. More...
 

Variables

ulong savepoint_alloc_size
 
const char * ha_row_type []
 
const char * tx_isolation_names []
 
const char * binlog_format_names []
 
TYPELIB tx_isolation_typelib
 
ulong total_ha_2pc
 
static const uint MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT = 1
 Options for the START TRANSACTION statement. More...
 
static const uint MYSQL_START_TRANS_OPT_READ_ONLY = 2
 
static const uint MYSQL_START_TRANS_OPT_READ_WRITE = 4
 
static const uint MYSQL_START_TRANS_OPT_HIGH_PRIORITY = 8
 
static const uint32 HTON_FKS_WITH_PREFIX_PARENT_KEYS = (1 << 0)
 Engine supports both unique and non-unique parent keys for foreign keys which contain full foreign key as its prefix. More...
 
static const uint32 HTON_FKS_WITH_SUPPORTING_HASH_KEYS = (1 << 1)
 Storage engine supports hash keys as supporting keys for foreign keys. More...
 
static const uint32 HTON_FKS_WITH_ANY_PREFIX_SUPPORTING_KEYS = (1 << 2)
 Storage engine supports non-hash keys which have common prefix with the foreign key as supporting keys for it. More...
 
static const uint32 HTON_FKS_NEED_DIFFERENT_PARENT_AND_SUPPORTING_KEYS
 Storage engine does not support using the same key for both parent and supporting key, but requires the two to be different. More...
 

Macro Definition Documentation

◆ COMPATIBLE_DATA_NO

#define COMPATIBLE_DATA_NO   1

◆ COMPATIBLE_DATA_YES

#define COMPATIBLE_DATA_YES   0

◆ HA_ABORT_IF_LOCKED

#define HA_ABORT_IF_LOCKED   128 /* skip if locked on open.*/

◆ HA_ADMIN_ALREADY_DONE

#define HA_ADMIN_ALREADY_DONE   1

◆ HA_ADMIN_CORRUPT

#define HA_ADMIN_CORRUPT   -3

◆ HA_ADMIN_FAILED

#define HA_ADMIN_FAILED   -2

◆ HA_ADMIN_INTERNAL_ERROR

#define HA_ADMIN_INTERNAL_ERROR   -4

◆ HA_ADMIN_INVALID

#define HA_ADMIN_INVALID   -5

◆ HA_ADMIN_NEEDS_ALTER

#define HA_ADMIN_NEEDS_ALTER   -11

◆ HA_ADMIN_NEEDS_CHECK

#define HA_ADMIN_NEEDS_CHECK   -12

◆ HA_ADMIN_NEEDS_DUMP_UPGRADE

#define HA_ADMIN_NEEDS_DUMP_UPGRADE   -14

User needs to dump and re-create table to fix pre 5.0 decimal types.

◆ HA_ADMIN_NEEDS_UPGRADE

#define HA_ADMIN_NEEDS_UPGRADE   -10

◆ HA_ADMIN_NOT_BASE_TABLE

#define HA_ADMIN_NOT_BASE_TABLE   -9

◆ HA_ADMIN_NOT_IMPLEMENTED

#define HA_ADMIN_NOT_IMPLEMENTED   -1

◆ HA_ADMIN_OK

#define HA_ADMIN_OK   0

◆ HA_ADMIN_REJECT

#define HA_ADMIN_REJECT   -6

◆ HA_ADMIN_STATS_UPD_ERR

#define HA_ADMIN_STATS_UPD_ERR   -13

◆ HA_ADMIN_TRY_ALTER

#define HA_ADMIN_TRY_ALTER   -7

◆ HA_ADMIN_WRONG_CHECKSUM

#define HA_ADMIN_WRONG_CHECKSUM   -8

◆ HA_ANY_INDEX_MAY_BE_UNIQUE

#define HA_ANY_INDEX_MAY_BE_UNIQUE   (1 << 30)

◆ HA_ATTACHABLE_TRX_COMPATIBLE

#define HA_ATTACHABLE_TRX_COMPATIBLE   (1LL << 45)

A storage engine is compatible with the attachable transaction requirements means that.

  • either SE detects the fact that THD::ha_data was reset and starts a new attachable transaction, closes attachable transaction on close_connection and resumes regular (outer) transaction when THD::ha_data is restored;
  • or SE completely ignores THD::ha_data and close_connection like MyISAM does.

◆ HA_AUTO_PART_KEY

#define HA_AUTO_PART_KEY   (1 << 11)

◆ HA_BINLOG_FLAGS

#define HA_BINLOG_FLAGS   (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)

◆ HA_BINLOG_ROW_CAPABLE

#define HA_BINLOG_ROW_CAPABLE   (1LL << 34)

◆ HA_BINLOG_STMT_CAPABLE

#define HA_BINLOG_STMT_CAPABLE   (1LL << 35)

◆ HA_BLOB_PARTIAL_UPDATE

#define HA_BLOB_PARTIAL_UPDATE   (1LL << 49)

Supports partial update of BLOB columns.

◆ HA_BLOCK_CONST_TABLE

#define HA_BLOCK_CONST_TABLE   (1LL << 42)

◆ HA_BLOCK_LOCK

#define HA_BLOCK_LOCK   256 /* unlock when reading some records */

◆ HA_CAN_BIT_FIELD

#define HA_CAN_BIT_FIELD   (1 << 28)

◆ HA_CAN_EXPORT

#define HA_CAN_EXPORT   (1LL << 41)

◆ HA_CAN_FULLTEXT

#define HA_CAN_FULLTEXT   (1 << 21)

◆ HA_CAN_FULLTEXT_EXT

#define HA_CAN_FULLTEXT_EXT   (1LL << 39)

◆ HA_CAN_FULLTEXT_HINTS

#define HA_CAN_FULLTEXT_HINTS   (1LL << 43)

◆ HA_CAN_GEOMETRY

#define HA_CAN_GEOMETRY   (1 << 4)

◆ HA_CAN_INDEX_BLOBS

#define HA_CAN_INDEX_BLOBS   (1 << 10)

◆ HA_CAN_INDEX_VIRTUAL_GENERATED_COLUMN

#define HA_CAN_INDEX_VIRTUAL_GENERATED_COLUMN   (1LL << 47)

Supports index on virtual generated column.

◆ HA_CAN_REPAIR

#define HA_CAN_REPAIR   (1LL << 37)

◆ HA_CAN_RTREEKEYS

#define HA_CAN_RTREEKEYS   (1 << 17)

◆ HA_CAN_SQL_HANDLER

#define HA_CAN_SQL_HANDLER   (1 << 22)

◆ HA_COUNT_ROWS_INSTANT

#define HA_COUNT_ROWS_INSTANT   (1LL << 32) /* records() gives exact count*/

◆ HA_CREATE_USED_AUTO

#define HA_CREATE_USED_AUTO   (1L << 0)

◆ HA_CREATE_USED_AVG_ROW_LENGTH

#define HA_CREATE_USED_AVG_ROW_LENGTH   (1L << 6)

◆ HA_CREATE_USED_CHARSET

#define HA_CREATE_USED_CHARSET   (1L << 8)

◆ HA_CREATE_USED_CHECKSUM

#define HA_CREATE_USED_CHECKSUM   (1L << 13)

◆ HA_CREATE_USED_COMMENT

#define HA_CREATE_USED_COMMENT   (1L << 16)

◆ HA_CREATE_USED_COMPRESS

#define HA_CREATE_USED_COMPRESS   (1L << 26)

COMPRESSION="zlib|lz4|none" used during table create.

◆ HA_CREATE_USED_CONNECTION

#define HA_CREATE_USED_CONNECTION   (1L << 18)

◆ HA_CREATE_USED_DATADIR

#define HA_CREATE_USED_DATADIR   (1L << 10)

◆ HA_CREATE_USED_DEFAULT_CHARSET

#define HA_CREATE_USED_DEFAULT_CHARSET   (1L << 9)

◆ HA_CREATE_USED_DEFAULT_COLLATE

#define HA_CREATE_USED_DEFAULT_COLLATE   (1L << 28)

CREATE|ALTER SCHEMA|DATABASE|TABLE has an explicit COLLATE clause.

Implies HA_CREATE_USED_DEFAULT_CHARSET.

◆ HA_CREATE_USED_DELAY_KEY_WRITE

#define HA_CREATE_USED_DELAY_KEY_WRITE   (1L << 14)

◆ HA_CREATE_USED_ENCRYPT

#define HA_CREATE_USED_ENCRYPT   (1L << 27)

ENCRYPTION="Y" used during table create.

◆ HA_CREATE_USED_ENGINE

#define HA_CREATE_USED_ENGINE   (1L << 12)

◆ HA_CREATE_USED_INDEXDIR

#define HA_CREATE_USED_INDEXDIR   (1L << 11)

◆ HA_CREATE_USED_INSERT_METHOD

#define HA_CREATE_USED_INSERT_METHOD   (1L << 3)

◆ HA_CREATE_USED_KEY_BLOCK_SIZE

#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)

◆ HA_CREATE_USED_MAX_ROWS

#define HA_CREATE_USED_MAX_ROWS   (1L << 5)

◆ HA_CREATE_USED_MIN_ROWS

#define HA_CREATE_USED_MIN_ROWS   (1L << 4)

◆ HA_CREATE_USED_PACK_KEYS

#define HA_CREATE_USED_PACK_KEYS   (1L << 7)

◆ HA_CREATE_USED_PAGE_CHECKSUM

#define HA_CREATE_USED_PAGE_CHECKSUM   (1L << 21)

Unused.

Reserved for future versions.

◆ HA_CREATE_USED_PASSWORD

#define HA_CREATE_USED_PASSWORD   (1L << 17)

◆ HA_CREATE_USED_RAID

#define HA_CREATE_USED_RAID   (1L << 1)

◆ HA_CREATE_USED_ROW_FORMAT

#define HA_CREATE_USED_ROW_FORMAT   (1L << 15)

◆ HA_CREATE_USED_SECONDARY_ENGINE

#define HA_CREATE_USED_SECONDARY_ENGINE   (1L << 29)

SECONDARY_ENGINE used during table create.

◆ HA_CREATE_USED_STATS_AUTO_RECALC

#define HA_CREATE_USED_STATS_AUTO_RECALC   (1L << 23)

This is set whenever STATS_AUTO_RECALC=0|1|default has been specified in CREATE/ALTER TABLE.

See enum_stats_auto_recalc. It is possible to distinguish whether STATS_AUTO_RECALC=default has been specified or no STATS_AUTO_RECALC= is given at all.

◆ HA_CREATE_USED_STATS_PERSISTENT

#define HA_CREATE_USED_STATS_PERSISTENT   (1L << 22)

This is set whenever STATS_PERSISTENT=0|1|default has been specified in CREATE/ALTER TABLE.

See also HA_OPTION_STATS_PERSISTENT in include/my_base.h. It is possible to distinguish whether STATS_PERSISTENT=default has been specified or no STATS_PERSISTENT= is given at all.

◆ HA_CREATE_USED_STATS_SAMPLE_PAGES

#define HA_CREATE_USED_STATS_SAMPLE_PAGES   (1L << 24)

This is set whenever STATS_SAMPLE_PAGES=N|default has been specified in CREATE/ALTER TABLE.

It is possible to distinguish whether STATS_SAMPLE_PAGES=default has been specified or no STATS_SAMPLE_PAGES= is given at all.

◆ HA_CREATE_USED_TABLESPACE

#define HA_CREATE_USED_TABLESPACE   (1L << 25)

This is set whenever a 'TABLESPACE=...' phrase is used on CREATE TABLE.

◆ HA_CREATE_USED_TRANSACTIONAL

#define HA_CREATE_USED_TRANSACTIONAL   (1L << 20)

Unused.

Reserved for future versions.

◆ HA_CREATE_USED_UNION

#define HA_CREATE_USED_UNION   (1L << 2)

◆ HA_DELETE_NOT_SUPPORTED

#define HA_DELETE_NOT_SUPPORTED   (1LL << 53)

Handlers with this flag set do not support DELETE operations.

◆ HA_DESCENDING_INDEX

#define HA_DESCENDING_INDEX   (1LL << 48)

Supports descending indexes.

◆ HA_DO_INDEX_COND_PUSHDOWN

#define HA_DO_INDEX_COND_PUSHDOWN   256 /* Supports Index Condition Pushdown */

◆ HA_DUPLICATE_KEY_NOT_IN_ORDER

#define HA_DUPLICATE_KEY_NOT_IN_ORDER   (1LL << 36)

◆ HA_DUPLICATE_POS

#define HA_DUPLICATE_POS   (1 << 8)

◆ HA_FAST_KEY_READ

#define HA_FAST_KEY_READ   (1 << 5)

◆ HA_FILE_BASED

#define HA_FILE_BASED   (1 << 26)

◆ HA_GENERATED_COLUMNS

#define HA_GENERATED_COLUMNS   (1LL << 46)

Handler supports Generated Columns.

◆ HA_GET_INDEX

#define HA_GET_INDEX   4

◆ HA_GET_INFO

#define HA_GET_INFO   8 /* do a handler::info() after open */

◆ HA_HAS_CHECKSUM

#define HA_HAS_CHECKSUM   (1 << 24)

◆ HA_HAS_OWN_BINLOGGING

#define HA_HAS_OWN_BINLOGGING   (1LL << 33)

◆ HA_KEY_BLOB_LENGTH

#define HA_KEY_BLOB_LENGTH   2

◆ HA_KEY_NULL_LENGTH

#define HA_KEY_NULL_LENGTH   1

◆ HA_KEY_SCAN_NOT_ROR

#define HA_KEY_SCAN_NOT_ROR   128

◆ HA_KEY_SWITCH_ALL

#define HA_KEY_SWITCH_ALL   1

◆ HA_KEY_SWITCH_ALL_SAVE

#define HA_KEY_SWITCH_ALL_SAVE   3

◆ HA_KEY_SWITCH_NONUNIQ

#define HA_KEY_SWITCH_NONUNIQ   0

◆ HA_KEY_SWITCH_NONUNIQ_SAVE

#define HA_KEY_SWITCH_NONUNIQ_SAVE   2

◆ HA_KEYREAD_ONLY

#define HA_KEYREAD_ONLY   64

◆ HA_LEX_CREATE_IF_NOT_EXISTS

#define HA_LEX_CREATE_IF_NOT_EXISTS   2

◆ HA_LEX_CREATE_INTERNAL_TMP_TABLE

#define HA_LEX_CREATE_INTERNAL_TMP_TABLE   8

◆ HA_LEX_CREATE_TABLE_LIKE

#define HA_LEX_CREATE_TABLE_LIKE   4

◆ HA_LEX_CREATE_TMP_TABLE

#define HA_LEX_CREATE_TMP_TABLE   1

◆ HA_MAX_REC_LENGTH

#define HA_MAX_REC_LENGTH   65535U

◆ HA_MRR_FIXED_KEY

#define HA_MRR_FIXED_KEY   2

◆ HA_MRR_INDEX_ONLY

#define HA_MRR_INDEX_ONLY   16

◆ HA_MRR_LIMITS

#define HA_MRR_LIMITS   32

◆ HA_MRR_NO_ASSOCIATION

#define HA_MRR_NO_ASSOCIATION   4

◆ HA_MRR_NO_NULL_ENDPOINTS

#define HA_MRR_NO_NULL_ENDPOINTS   128

◆ HA_MRR_SINGLE_POINT

#define HA_MRR_SINGLE_POINT   1

◆ HA_MRR_SORTED

#define HA_MRR_SORTED   8

◆ HA_MRR_SUPPORT_SORTED

#define HA_MRR_SUPPORT_SORTED   256

◆ HA_MRR_USE_DEFAULT_IMPL

#define HA_MRR_USE_DEFAULT_IMPL   64

◆ HA_NO_AUTO_INCREMENT

#define HA_NO_AUTO_INCREMENT   (1 << 23)

◆ HA_NO_BLOBS

#define HA_NO_BLOBS   (1 << 9) /* Doesn't support blobs */

◆ HA_NO_COPY_ON_ALTER

#define HA_NO_COPY_ON_ALTER   (1LL << 31)

◆ HA_NO_PREFIX_CHAR_KEYS

#define HA_NO_PREFIX_CHAR_KEYS   (1 << 20)

◆ HA_NO_READ_LOCAL_LOCK

#define HA_NO_READ_LOCAL_LOCK   (1LL << 44)

Storage engine doesn't support LOCK TABLE ...

READ LOCAL locks but doesn't want to use handler::store_lock() API for upgrading them to LOCK TABLE ... READ locks, for example, because it doesn't use THR_LOCK locks at all.

◆ HA_NO_TRANSACTIONS

#define HA_NO_TRANSACTIONS   (1 << 0) /* Doesn't support transactions */

◆ HA_NO_VARCHAR

#define HA_NO_VARCHAR   (1 << 27)

◆ HA_NOT_DELETE_WITH_CACHE

#define HA_NOT_DELETE_WITH_CACHE   (1 << 18)

◆ HA_NULL_IN_KEY

#define HA_NULL_IN_KEY   (1 << 7)

◆ HA_ONLY_WHOLE_INDEX

#define HA_ONLY_WHOLE_INDEX   16

◆ HA_OPEN_KEYFILE

#define HA_OPEN_KEYFILE   1

◆ HA_OPEN_RNDFILE

#define HA_OPEN_RNDFILE   2

◆ HA_OPEN_TEMPORARY

#define HA_OPEN_TEMPORARY   512

◆ HA_PARTIAL_COLUMN_READ

#define HA_PARTIAL_COLUMN_READ   (1 << 1) /* read may not return all columns */

◆ HA_PRIMARY_KEY_IN_READ_INDEX

#define HA_PRIMARY_KEY_IN_READ_INDEX   (1 << 15)

◆ HA_PRIMARY_KEY_REQUIRED_FOR_DELETE

#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE   (1 << 19)

◆ HA_PRIMARY_KEY_REQUIRED_FOR_POSITION

#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION   (1 << 16)

◆ HA_READ_BEFORE_WRITE_REMOVAL

#define HA_READ_BEFORE_WRITE_REMOVAL   (1LL << 38)

The handler supports read before write removal optimization.

Read before write removal may be used for storage engines which support write without previous read of the row to be updated. Handler returning this flag must implement start_read_removal() and end_read_removal(). The handler may return "fake" rows constructed from the key of the row asked for. This is used to optimize UPDATE and DELETE by reducing the number of round-trips between handler and storage engine.

Example: UPDATE a=1 WHERE pk IN (<keys>)

mysql_update()
{
  if (<conditions for starting read removal>)
    start_read_removal()
    -> handler returns true if read removal supported for this table/query

  while(read_record("pk=<key>"))
    -> handler returns fake row with column "pk" set to <key>

    ha_update_row()
    -> handler sends write "a=1" for row with "pk=<key>"

  end_read_removal()
  -> handler returns the number of rows actually written
}
Note
This optimization in combination with batching may be used to remove even more round-trips.

◆ HA_READ_NEXT

#define HA_READ_NEXT   1 /* TODO really use this flag */

◆ HA_READ_ONLY

#define HA_READ_ONLY   16 /* File opened as readonly */

◆ HA_READ_ORDER

#define HA_READ_ORDER   4

◆ HA_READ_OUT_OF_SYNC

#define HA_READ_OUT_OF_SYNC   (1LL << 40)

◆ HA_READ_PREV

#define HA_READ_PREV   2

◆ HA_READ_RANGE

#define HA_READ_RANGE   8

◆ HA_REQUIRE_PRIMARY_KEY

#define HA_REQUIRE_PRIMARY_KEY   (1 << 12)

◆ HA_REQUIRES_KEY_COLUMNS_FOR_DELETE

#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE   (1 << 6)

◆ HA_SLOT_UNDEF

#define HA_SLOT_UNDEF   ((uint)-1)

◆ HA_STATS_RECORDS_IS_EXACT

#define HA_STATS_RECORDS_IS_EXACT   (1 << 13)

◆ HA_SUPPORTS_DEFAULT_EXPRESSION

#define HA_SUPPORTS_DEFAULT_EXPRESSION   (1LL << 51)

Handler supports expressions as DEFAULT for a column.

◆ HA_SUPPORTS_GEOGRAPHIC_GEOMETRY_COLUMN

#define HA_SUPPORTS_GEOGRAPHIC_GEOMETRY_COLUMN   (1LL << 50)

If this isn't defined, only columns/indexes with Cartesian coordinate systems (projected SRS or SRID 0) is supported.

Columns/indexes without SRID restriction is also supported if this isn't defined.

◆ HA_TABLE_SCAN_ON_INDEX

#define HA_TABLE_SCAN_ON_INDEX   (1 << 2)

◆ HA_TRY_READ_ONLY

#define HA_TRY_READ_ONLY   32

◆ HA_UNUSED14

#define HA_UNUSED14   (1 << 14)

Not in use.

◆ HA_UNUSED3

#define HA_UNUSED3   (1 << 3)

Not in use.

◆ HA_UPDATE_NOT_SUPPORTED

#define HA_UPDATE_NOT_SUPPORTED   (1LL << 52)

Handlers with this flag set do not support UPDATE operations.

◆ HA_WAIT_IF_LOCKED

#define HA_WAIT_IF_LOCKED   64 /* Wait if locked on open */

◆ HTON_ALTER_NOT_SUPPORTED

#define HTON_ALTER_NOT_SUPPORTED   (1 << 1)

◆ HTON_CAN_RECREATE

#define HTON_CAN_RECREATE   (1 << 2)

◆ HTON_CLOSE_CURSORS_AT_COMMIT

#define HTON_CLOSE_CURSORS_AT_COMMIT   (1 << 0)

◆ HTON_HIDDEN

#define HTON_HIDDEN   (1 << 3)

◆ HTON_IS_SECONDARY_ENGINE

#define HTON_IS_SECONDARY_ENGINE   (1 << 14)

Engine is a secondary storage engine.

◆ HTON_NO_BINLOG_ROW_OPT

#define HTON_NO_BINLOG_ROW_OPT   (1 << 9)

◆ HTON_NO_FLAGS

#define HTON_NO_FLAGS   0

◆ HTON_NO_PARTITION

#define HTON_NO_PARTITION   (1 << 8)

◆ HTON_NOT_USER_SELECTABLE

#define HTON_NOT_USER_SELECTABLE   (1 << 5)

◆ HTON_SUPPORT_LOG_TABLES

#define HTON_SUPPORT_LOG_TABLES   (1 << 7)

◆ HTON_SUPPORTS_ATOMIC_DDL

#define HTON_SUPPORTS_ATOMIC_DDL   (1 << 12)

Engine supports atomic DDL.

That is rollback of transaction for DDL statement will also rollback all changes in SE, commit of transaction of DDL statement will make it durable.

◆ HTON_SUPPORTS_EXTENDED_KEYS

#define HTON_SUPPORTS_EXTENDED_KEYS   (1 << 10)

Engine supports extended keys.

The flag allows to use 'extended key' feature if the engine is able to do it (has primary key values in the secondary key). Note that handler flag HA_PRIMARY_KEY_IN_READ_INDEX is actually partial case of HTON_SUPPORTS_EXTENDED_KEYS.

◆ HTON_SUPPORTS_FOREIGN_KEYS

#define HTON_SUPPORTS_FOREIGN_KEYS   (1 << 11)

◆ HTON_SUPPORTS_PACKED_KEYS

#define HTON_SUPPORTS_PACKED_KEYS   (1 << 13)

◆ HTON_SUPPORTS_SECONDARY_ENGINE

#define HTON_SUPPORTS_SECONDARY_ENGINE   (1 << 15)

Engine supports secondary storage engines.

◆ HTON_TEMPORARY_NOT_SUPPORTED

#define HTON_TEMPORARY_NOT_SUPPORTED   (1 << 6)

◆ make_keypart_map

#define make_keypart_map (   N)    (((key_part_map)2 << (N)) - 1)

◆ make_prev_keypart_map

#define make_prev_keypart_map (   N)    (((key_part_map)1 << (N)) - 1)

◆ MAXBQUALSIZE

#define MAXBQUALSIZE   64

◆ MAXGTRIDSIZE

#define MAXGTRIDSIZE   64

◆ UNDEF_NODEGROUP

#define UNDEF_NODEGROUP   65535

Typedef Documentation

◆ alter_tablespace_t

typedef int(* alter_tablespace_t) (handlerton *hton, THD *thd, st_alter_tablespace *ts_info, const dd::Tablespace *old_ts_def, dd::Tablespace *new_ts_def)

Create/drop or alter tablespace in the storage engine.

Parameters
htonHadlerton of the SE.
thdThread context.
ts_infoDescription of tablespace and specific operation on it.
old_ts_defdd::Tablespace object describing old version of tablespace.
[in,out]new_ts_defdd::Tablespace object describing new version of tablespace. Engines which support atomic DDL can adjust this object. The updated information will be saved to the data-dictionary.
Returns
Operation status.
Return values
==0 Success.
!=0 Error (handler error code returned).

◆ binlog_func_t

typedef int(* binlog_func_t) (handlerton *hton, THD *thd, enum_binlog_func fn, void *arg)

◆ binlog_log_query_t

typedef void(* binlog_log_query_t) (handlerton *hton, THD *thd, enum_binlog_command binlog_command, const char *query, uint query_length, const char *db, const char *table_name)

◆ check_fk_column_compat_t

typedef bool(* check_fk_column_compat_t) (const Ha_fk_column_type *child_column_type, const Ha_fk_column_type *parent_column_type, bool check_charsets)

Check SE considers types of child and parent columns in foreign key to be compatible.

Parameters
child_column_typeChild column type description.
parent_column_typeParent column type description.
check_charsetsIndicates whether we need to check that charsets of string columns match. Which is true in most cases.
Returns
True if types are compatible, False if not.

◆ Clone_ack_t

using Clone_ack_t = int (*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err, Ha_clone_cbk *cbk)

Acknowledge data transfer to source database.

Parameters
[in]htonhandlerton for SE
[in]thdserver thread handle
[in]loclocator
[in]loc_lenlocator length in bytes
[in]task_idtask identifier
[in]in_errinform any error occurred
[in]cbkcallback interface
Returns
error code

◆ Clone_apply_begin_t

using Clone_apply_begin_t = int (*)(handlerton *hton, THD *thd, const uchar *&loc, uint &loc_len, uint &task_id, Ha_clone_mode mode, const char *data_dir)

Begin apply to destination database.

Parameters
[in]htonhandlerton for SE
[in]thdserver thread handle
[in,out]loclocator
[in,out]loc_lenlocator length
[in]task_idtask identifier
[in]modemode for starting clone
[in]data_dirtarget data directory
Returns
error code

◆ Clone_apply_end_t

using Clone_apply_end_t = int (*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err)

End apply to destination database.

Parameters
[in]htonhandlerton for SE
[in]thdserver thread handle
[in]loclocator
[in]loc_lenlocator length in bytes
[in]task_idtask identifier
[in]in_errerror code when ending after error
Returns
error code

◆ Clone_apply_t

using Clone_apply_t = int (*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err, Ha_clone_cbk *cbk)

Apply data to destination database in chunks via callback.

Parameters
[in]htonhandlerton for SE
[in]thdserver thread handle
[in]loclocator
[in]loc_lenlocator length in bytes
[in]task_idtask identifier
[in]in_errinform any error occurred
[in]cbkcallback interface for receiving data
Returns
error code

◆ Clone_begin_t

using Clone_begin_t = int (*)(handlerton *hton, THD *thd, const uchar *&loc, uint &loc_len, uint &task_id, Ha_clone_type type, Ha_clone_mode mode)

Begin copy from source database.

Parameters
[in]htonhandlerton for SE
[in]thdserver thread handle
[in,out]loclocator
[in,out]loc_lenlocator length
[out]task_idtask identifier
[in]typeclone type
[in]modemode for starting clone
Returns
error code

◆ Clone_capability_t

Get capability flags for clone operation.

Parameters
[out]flagscapability flag

◆ Clone_copy_t

using Clone_copy_t = int (*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, Ha_clone_cbk *cbk)

Copy data from source database in chunks via callback.

Parameters
[in]htonhandlerton for SE
[in]thdserver thread handle
[in]loclocator
[in]loc_lenlocator length in bytes
[in]task_idtask identifier
[in]cbkcallback interface for sending data
Returns
error code

◆ Clone_end_t

using Clone_end_t = int (*)(handlerton *hton, THD *thd, const uchar *loc, uint loc_len, uint task_id, int in_err)

End copy from source database.

Parameters
[in]htonhandlerton for SE
[in]thdserver thread handle
[in]loclocator
[in]loc_lenlocator length in bytes
[in]task_idtask identifier
[in]in_errerror code when ending after error
Returns
error code

◆ close_connection_t

typedef int(* close_connection_t) (handlerton *hton, THD *thd)

close_connection is only called if thd->ha_data[xxx_hton.slot] is non-zero, so even if you don't need this storage area - set it to something, so that MySQL would know this storage engine was accessed in this connection

◆ collect_hton_log_info_t

typedef bool(* collect_hton_log_info_t) (handlerton *hton, Json_dom *json)

Collect a handlerton (resource) log information.

◆ commit_by_xid_t

typedef xa_status_code(* commit_by_xid_t) (handlerton *hton, XID *xid)

◆ commit_t

typedef int(* commit_t) (handlerton *hton, THD *thd, bool all)

'all' is true if it's a real commit, that makes persistent changes 'all' is false if it's not in fact a commit but an end of the statement that is part of the transaction.

NOTE 'all' is also false in auto-commit mode where 'end of statement' and 'real commit' mean the same event.

◆ create_t

typedef handler*(* create_t) (handlerton *hton, TABLE_SHARE *table, bool partitioned, MEM_ROOT *mem_root)

Create handler object for the table in the storage engine.

Parameters
htonHandlerton object for the storage engine.
tableTABLE_SHARE for the table, can be NULL if caller didn't perform full-blown open of table definition.
partitionedIndicates whether table is partitioned.
mem_rootMemory root to be used for allocating handler object.

◆ ddse_dict_init_t

typedef bool(* ddse_dict_init_t) (dict_init_mode_t dict_init_mode, uint version, List< const dd::Object_table > *DDSE_tables, List< const Plugin_tablespace > *DDSE_tablespaces)

◆ dict_cache_reset_t

typedef void(* dict_cache_reset_t) (const char *schema_name, const char *table_name)

Invalidate an entry in the local dictionary cache.

Needed during bootstrap to make sure the contents in the DDSE dictionary cache is in sync with the global DD.

Parameters
schema_nameSchema name.
table_nameTable name.

◆ dict_cache_reset_tables_and_tablespaces_t

typedef void(* dict_cache_reset_tables_and_tablespaces_t) ()

Invalidate all table and tablespace entries in the local dictionary cache.

Needed for recovery during server restart.

◆ dict_get_server_version_t

typedef bool(* dict_get_server_version_t) (uint *version)

Get the server version id stored in the header of the dictionary tablespace.

Parameters
[out]versionVersion number from the DD tablespace header.
Return values
Operationoutcome, false if no error, otherwise true.

◆ dict_init_t

typedef bool(* dict_init_t) (dict_init_mode_t dict_init_mode, uint version, List< const Plugin_table > *DDSE_tables, List< const Plugin_tablespace > *DDSE_tablespaces)

Initialize the SE for being used to store the DD tables.

Create the required files according to the dict_init_mode. Create strings representing the required DDSE tables, i.e., tables that the DDSE expects to exist in the DD, and add them to the appropriate out parameter.

Note
There are two variants of this function type, one is to be used by the DDSE, and has a different type of output parameters because the SQL layer needs more information about the DDSE tables in order to support upgrade.
Parameters
dict_init_modeHow to initialize files
versionTarget DD version if a new server is being installed. 0 if restarting an existing server.
[out]DDSE_tablesList of SQL DDL statements for creating DD tables that are needed by the DDSE.
[out]DDSE_tablespacesList of meta data for predefined tablespaces created by the DDSE.
Return values
trueAn error occurred.
falseSuccess - no errors.

◆ dict_recover_t

typedef bool(* dict_recover_t) (dict_recovery_mode_t dict_recovery_mode, uint version)

Do recovery in the DDSE as part of initializing the data dictionary.

The dict_recovery_mode indicates what kind of recovery should be done.

Parameters
dict_recovery_modeHow to do recovery
versionTarget DD version if a new server is being installed. Actual DD version if restarting an existing server.
Return values
trueAn error occurred.
falseSuccess - no errors.

◆ dict_register_dd_table_id_t

typedef void(* dict_register_dd_table_id_t) (dd::Object_id hard_coded_tables)

Initialize the set of hard coded DD table ids.

◆ dict_set_server_version_t

typedef bool(* dict_set_server_version_t) ()

Store the current server version number into the header of the dictionary tablespace.

Return values
Operationoutcome, false if no error, otherwise true.

◆ discover_t

typedef int(* discover_t) (handlerton *hton, THD *thd, const char *db, const char *name, uchar **frmblob, size_t *frmlen)

◆ drop_database_t

typedef void(* drop_database_t) (handlerton *hton, char *path)

◆ fill_is_table_t

typedef int(* fill_is_table_t) (handlerton *hton, THD *thd, TABLE_LIST *tables, class Item *cond, enum enum_schema_tables)

◆ find_files_t

typedef int(* find_files_t) (handlerton *hton, THD *thd, const char *db, const char *path, const char *wild, bool dir, List< LEX_STRING > *files)

◆ finish_upgrade_t

typedef int(* finish_upgrade_t) (THD *thd, bool failed_upgrade)

Finish upgrade process inside storage engines.

This includes resetting flags to indicate upgrade process and cleanup after upgrade.

Parameters
thdThread context
Returns
Operation status.
Return values
==0 Success.
!=0 Error (handler error code returned)

◆ flush_logs_t

typedef bool(* flush_logs_t) (handlerton *hton, bool binlog_group_flush)

Flush the log(s) of storage engine(s).

Parameters
htonHandlerton of storage engine.
binlog_group_flushtrue if we got invoked by binlog group commit during flush stage, false in other cases.
Return values
falseSucceed
trueError

◆ get_cost_constants_t

typedef SE_cost_constants*(* get_cost_constants_t) (uint storage_category)

Retrieve cost constants to be used for this storage engine.

A storage engine that wants to provide its own cost constants to be used in the optimizer cost model, should implement this function. The server will call this function to get a cost constant object that will be used for tables stored in this storage engine instead of using the default cost constants.

Life cycle for the cost constant object: The storage engine must allocate the cost constant object on the heap. After the function returns, the server takes over the ownership of this object. The server will eventually delete the object by calling delete.

Note
In the initial version the storage_category parameter will not be used. The only valid value this will have is DEFAULT_STORAGE_CLASS (see declaration in opt_costconstants.h).
Parameters
storage_categorythe storage type that the cost constants will be used for
Returns
a pointer to the cost constant object, if NULL is returned the default cost constants will be used

◆ get_index_column_cardinality_t

typedef bool(* get_index_column_cardinality_t) (const char *db_name, const char *table_name, const char *index_name, uint index_ordinal_position, uint column_ordinal_position, dd::Object_id se_private_id, ulonglong *cardinality)

Retrieve index column cardinality from SE.

Parameters
db_nameName of schema
table_nameName of table
index_nameName of index
index_ordinal_positionPosition of index.
column_ordinal_positionPosition of column in index.
se_private_idSE private id of the table.
[out]cardinalitycardinality being returned by SE.
Note
Handlers that implement this callback/API should adhere to servers expectation that, the implementation would invoke my_error() before returning 'true'/failure from this function.
Returns
false on success, true on failure

◆ get_table_statistics_t

typedef bool(* get_table_statistics_t) (const char *db_name, const char *table_name, dd::Object_id se_private_id, const dd::Properties &ts_se_private_data, const dd::Properties &tbl_se_private_data, uint flags, ha_statistics *stats)

Retrieve ha_statistics from SE.

Parameters
db_nameName of schema
table_nameName of table
se_private_idSE private id of the table.
ts_se_private_dataTablespace SE private data.
tbl_se_private_dataTable SE private data.
flagsType of statistics to retrieve.
[out]statsContains statistics read from SE.
Note
Handlers that implement this callback/API should adhere to servers expectation that, the implementation would invoke my_error() before returning 'true'/failure from this function.
Returns
false on success, true on failure

◆ get_tablespace_filename_ext_t

typedef const char*(* get_tablespace_filename_ext_t) ()

SE interface for getting tablespace extension.

Returns
Extension of tablespace datafile name.

◆ get_tablespace_statistics_t

typedef bool(* get_tablespace_statistics_t) (const char *tablespace_name, const char *file_name, const dd::Properties &ts_se_private_data, ha_tablespace_statistics *stats)

Retrieve ha_tablespace_statistics from SE.

Parameters
tablespace_nameTablespace_name
ts_se_private_dataTablespace SE private data.
tbl_se_private_dataTable SE private data.
[out]statsContains tablespace statistics read from SE.
Note
Handlers that implement this callback/API should adhere to servers expectation that, the implementation would invoke my_error() before returning 'true'/failure from this function.
Returns
false on success, true on failure

◆ get_tablespace_t

typedef int(* get_tablespace_t) (THD *thd, LEX_CSTRING db_name, LEX_CSTRING table_name, LEX_CSTRING *tablespace_name)

Get the tablespace name from the SE for the given schema and table.

Parameters
thdThread context.
db_nameName of the relevant schema.
table_nameName of the relevant table.
[out]tablespace_nameName of the tablespace containing the table.
Returns
Operation status.
Return values
==0 Success.
!=0 Error (handler error code returned).

◆ get_tablespace_type_t

typedef bool(* get_tablespace_type_t) (const dd::Tablespace &space, Tablespace_type *space_type)

Get the tablespace type from the SE.

Parameters
[in]spacetablespace object
[out]space_typetype of space
Returns
Operation status.
Return values
==0 Success.
!=0 Error (unknown space type, no error code returned)

◆ Ha_clone_flagset

using Ha_clone_flagset = std::bitset<HA_CLONE_TYPE_MAX>

◆ is_dict_readonly_t

typedef bool(* is_dict_readonly_t) ()

Check if the DDSE is started in a way that leaves thd DD being read only.

Return values
trueThe data dictionary can only be read.
falseThe data dictionary can be read and written.

◆ is_reserved_db_name_t

typedef bool(* is_reserved_db_name_t) (handlerton *hton, const char *name)

◆ is_supported_system_table_t

typedef bool(* is_supported_system_table_t) (const char *db, const char *table_name, bool is_sql_layer_system_table)

Check if the given db.tablename is a system table for this SE.

Parameters
dbDatabase name to check.
table_nametable name to check.
is_sql_layer_system_tableif the supplied db.table_name is a SQL layer system table.
See also
example_is_supported_system_table in ha_example.cc

is_sql_layer_system_table is supplied to make more efficient checks possible for SEs that support all SQL layer tables.

This interface is optional, so every SE need not implement it.

◆ is_valid_tablespace_name_t

typedef bool(* is_valid_tablespace_name_t) (ts_command_type ts_cmd, const char *tablespace_name)

SE specific validation of the tablespace name.

This function will ask the relevant SE whether the submitted tablespace name is valid.

Parameters
ts_cmdPurpose of usage - is this tablespace DDL?
tablespace_nameName of the tablespace.
Returns
Tablespace name validity.
Return values
==false: The tablespace name is invalid.
==true: The tablespace name is valid.

◆ kill_connection_t

typedef void(* kill_connection_t) (handlerton *hton, THD *thd)

Terminate connection/statement notification.

◆ lock_hton_log_t

typedef bool(* lock_hton_log_t) (handlerton *hton)

Lock a handlerton (resource) log to collect log information.

◆ Log_func

typedef bool Log_func(THD *, TABLE *, bool, const uchar *, const uchar *)

◆ make_pushed_join_t

typedef int(* make_pushed_join_t) (handlerton *hton, THD *thd, const AQP::Join_plan *plan)

◆ my_xid

typedef ulonglong my_xid

recover() step of xa.

Note
there are three modes of operation:
  • automatic recover after a crash in this case commit_list != 0, tc_heuristic_recover==TC_HEURISTIC_NOT_USED all xids from commit_list are committed, others are rolled back
  • manual (heuristic) recover in this case commit_list==0, tc_heuristic_recover != TC_HEURISTIC_NOT_USED DBA has explicitly specified that all prepared transactions should be committed (or rolled back).
  • no recovery (MySQL did not detect a crash) in this case commit_list==0, tc_heuristic_recover == TC_HEURISTIC_NOT_USED there should be no prepared transactions in this case.

◆ notify_alter_table_t

typedef bool(* notify_alter_table_t) (THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type)

Notify/get permission from storage engine before or after execution of ALTER TABLE operation on the table identified by the MDL key.

Parameters
thdThread context.
mdl_keyMDL key identifying table which is going to be or was ALTERed.
notification_typeIndicates whether this is pre-ALTER TABLE or post-ALTER TABLE notification.
Note
This hook is necessary because for ALTER TABLE upgrade to X metadata lock happens fairly late during the execution process, so it can be expensive to abort ALTER TABLE operation at this stage by returning failure from notify_exclusive_mdl() hook.
This hook follows the same error reporting convention as
See also
notify_exclusive_mdl().
Note
Similarly to notify_exclusive_mdl() in some cases post-ALTER notification might happen even if there were no prior pre-ALTER notification.
Post-ALTER notification can happen before post-release notification for exclusive metadata lock acquired by this ALTER TABLE.
Returns
False - if notification was successful/ALTER TABLE can proceed. True - if it has failed/ALTER TABLE should be aborted.

◆ notify_exclusive_mdl_t

typedef bool(* notify_exclusive_mdl_t) (THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, bool *victimized)

Notify/get permission from storage engine before acquisition or after release of exclusive metadata lock on object represented by key.

Parameters
thdThread context.
mdl_keyMDL key identifying object on which exclusive lock is to be acquired/was released.
notification_typeIndicates whether this is pre-acquire or post-release notification.
victimized'true' if locking failed as we were selected as a victim in order to avoid possible deadlocks.
Note
Notification is done only for objects from TABLESPACE, SCHEMA, TABLE, FUNCTION, PROCEDURE, TRIGGER and EVENT namespaces.
Problems during notification are to be reported as warnings, MDL subsystem will report generic error if pre-acquire notification fails/SE refuses lock acquisition.
Return value is ignored/error is not reported in case of post-release notification.
In some cases post-release notification might happen even if there were no prior pre-acquire notification. For example, when SE was loaded after exclusive lock acquisition, or when we need notify SEs which permitted lock acquisition that it didn't happen because one of SEs didn't allow it (in such case we will do post-release notification for all SEs for simplicity).
Returns
False - if notification was successful/lock can be acquired, True - if it has failed/lock should not be acquired.

◆ panic_t

typedef int(* panic_t) (handlerton *hton, enum ha_panic_function flag)

◆ partition_flags_t

typedef uint(* partition_flags_t) ()

The flag values are defined in sql_partition.h.

If this function is set, then it implies that the handler supports partitioned tables. If this function exists, then handler::get_partition_handler must also be implemented.

◆ post_ddl_t

typedef void(* post_ddl_t) (THD *thd)

Perform post-commit/rollback cleanup after DDL statement (e.g.

in case of DROP TABLES really remove table files from disk).

Note
This hook will be invoked after DDL commit or rollback only for storage engines supporting atomic DDL.
Problems during execution of this method should be reported to error log and as warnings/notes to user. Since this method is called after successful commit of the statement we can't fail statement with error.

◆ post_recover_t

typedef void(* post_recover_t) (void)

Perform SE-specific cleanup after recovery of transactions.

Note
Particularly SEs supporting atomic DDL can use this call to perform post-DDL actions for DDL statements which were committed or rolled back during recovery stage.

◆ pre_dd_shutdown_t

typedef void(* pre_dd_shutdown_t) (handlerton *hton)

Shut down all storage engine background tasks that might access the data dictionary, before the main shutdown.

◆ prepare_t

typedef int(* prepare_t) (handlerton *hton, THD *thd, bool all)

◆ qc_engine_callback

typedef bool(* qc_engine_callback) (THD *thd, const char *table_key, uint key_length, ulonglong *engine_data)

◆ range_seq_t

typedef void* range_seq_t

◆ recover_t

typedef int(* recover_t) (handlerton *hton, XA_recover_txn *xid_list, uint len, MEM_ROOT *mem_root)

◆ replace_native_transaction_in_thd_t

typedef void(* replace_native_transaction_in_thd_t) (THD *thd, void *new_trx_arg, void **ptr_trx_arg)
Parameters
[in,out]thdpointer to THD
[in]new_trx_argpointer to replacement transaction
[out]ptr_trx_argdouble pointer to being replaced transaction

Associated with THD engine's native transaction is replaced with new_trx_arg. The old value is returned through a buffer if non-null pointer is provided with ptr_trx_arg. The method is adapted by XA start and XA prepare handlers to handle XA transaction that is logged as two parts by slave applier.

This interface concerns engines that are aware of XA transaction.

◆ rm_tmp_tables_t

typedef bool(* rm_tmp_tables_t) (handlerton *hton, THD *thd, List< LEX_STRING > *files)

Drop all temporary tables which have been left from previous server run belonging to this SE.

Used on server start-up.

Parameters
[in]htonHandlerton for storage engine.
[in]thdThread context.
[in,out]filesList of files in directories for temporary files which match tmp_file_prefix and thus can belong to temporary tables (but not necessarily in this SE). It is recommended to remove file from the list if SE recognizes it as belonging to temporary table in this SE and deletes it.

◆ rollback_by_xid_t

typedef xa_status_code(* rollback_by_xid_t) (handlerton *hton, XID *xid)

◆ rollback_t

typedef int(* rollback_t) (handlerton *hton, THD *thd, bool all)

◆ rotate_encryption_master_key_t

typedef bool(* rotate_encryption_master_key_t) (void)

Initiate master key rotation.

Returns
false on success, true on failure

◆ savepoint_release_t

typedef int(* savepoint_release_t) (handlerton *hton, THD *thd, void *sv)

◆ savepoint_rollback_can_release_mdl_t

typedef bool(* savepoint_rollback_can_release_mdl_t) (handlerton *hton, THD *thd)

Check if storage engine allows to release metadata locks which were acquired after the savepoint if rollback to savepoint is done.

Returns
true - If it is safe to release MDL locks. false - If it is not.

◆ savepoint_rollback_t

typedef int(* savepoint_rollback_t) (handlerton *hton, THD *thd, void *sv)

sv points to a storage area, that was earlier passed to the savepoint_set call

◆ savepoint_set_t

typedef int(* savepoint_set_t) (handlerton *hton, THD *thd, void *sv)

sv points to an uninitialized storage area of requested size (see savepoint_offset description)

◆ sdi_create_t

typedef bool(* sdi_create_t) (dd::Tablespace *tablespace)

Create SDI in a tablespace.

This API should be used when upgrading a tablespace with no SDI or after invoking sdi_drop().

Parameters
[in]tablespacetablespace object
Return values
falsesuccess
truefailure

◆ sdi_delete_t

typedef bool(* sdi_delete_t) (const dd::Tablespace &tablespace, const dd::Table *table, const dd::sdi_key_t *sdi_key)

Delete SDI for a given SDI key.

Parameters
[in]tablespacetablespace object
[in]sdi_keySDI key to uniquely identify SDI obj
Return values
falsesuccess
truefailure, my_error() should be called by SE

◆ sdi_drop_t

typedef bool(* sdi_drop_t) (dd::Tablespace *tablespace)

Drop SDI in a tablespace.

This API should be used only when SDI is corrupted.

Parameters
[in]tablespacetablespace object
Return values
falsesuccess
truefailure

◆ sdi_get_keys_t

typedef bool(* sdi_get_keys_t) (const dd::Tablespace &tablespace, dd::sdi_vector_t &vector)

Get the SDI keys in a tablespace into vector.

Parameters
[in]tablespacetablespace object
[in,out]vectorvector of SDI Keys
Return values
falsesuccess
truefailure

◆ sdi_get_t

typedef bool(* sdi_get_t) (const dd::Tablespace &tablespace, const dd::sdi_key_t *sdi_key, void *sdi, uint64 *sdi_len)

Retrieve SDI for a given SDI key.

Since the caller of this api will not know the SDI length, SDI retrieval should be done in the following way.

i. Allocate initial memory of some size (Lets say 64KB) ii. Pass the allocated memory to the below api. iii. If passed buffer is sufficient, sdi_get_by_id() copies the sdi to the buffer passed and returns success, else sdi_len is modified with the actual length of the SDI (and returns false on failure). For genuine errors, sdi_len is returned as UINT64_MAX iv. If sdi_len != UINT64_MAX, retry the call after allocating the memory of sdi_len v. Free the memory after using SDI (responsibility of caller)

Parameters
[in]tablespacetablespace object
[in]sdi_keySDI key to uniquely identify SDI obj
[in,out]sdiSDI retrieved from tablespace A non-null pointer must be passed in
[in,out]sdi_lenin: length of the memory allocated out: actual length of SDI
Return values
falsesuccess
truefailure

◆ sdi_set_t

typedef bool(* sdi_set_t) (handlerton *hton, const dd::Tablespace &tablespace, const dd::Table *table, const dd::sdi_key_t *sdi_key, const void *sdi, uint64 sdi_len)

Insert/Update SDI for a given SDI key.

Parameters
[in]htonhandlerton object
[in]tablespacetablespace object
[in]sdi_keySDI key to uniquely identify SDI obj
[in]sdiSDI to write into the tablespace
[in]sdi_lenlength of SDI BLOB returned
Return values
falsesuccess
truefailure, my_error() should be called by SE

◆ show_status_t

typedef bool(* show_status_t) (handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat)

◆ start_consistent_snapshot_t

typedef int(* start_consistent_snapshot_t) (handlerton *hton, THD *thd)

◆ stat_print_fn

typedef bool() stat_print_fn(THD *thd, const char *type, size_t type_len, const char *file, size_t file_len, const char *status, size_t status_len)

◆ table_exists_in_engine_t

typedef int(* table_exists_in_engine_t) (handlerton *hton, THD *thd, const char *db, const char *name)

◆ unlock_hton_log_t

typedef bool(* unlock_hton_log_t) (handlerton *hton)

Unlock a handlerton (resource) log after collecting log information.

◆ upgrade_logs_t

typedef int(* upgrade_logs_t) (THD *thd)

Upgrade logs after the checkpoint from where upgrade process can only roll forward.

Parameters
thdThread context
Returns
Operation status.
Return values
==0 Success.
!=0 Error (handler error code returned)

◆ upgrade_space_version_t

typedef bool(* upgrade_space_version_t) (dd::Tablespace *tablespace)

Get the tablespace data from SE and insert it into Data dictionary.

Parameters
[in]tablespacetablespace object
Returns
Operation status.
Return values
==0 Success.
!=0 Error (handler error code returned)

◆ upgrade_tablespace_t

typedef int(* upgrade_tablespace_t) (THD *thd)

Get the tablespace data from SE and insert it into Data dictionary.

Parameters
thdThread context
Returns
Operation status.
Return values
==0 Success.
!=0 Error (handler error code returned)

◆ XA_recover_txn

◆ XID

typedef struct xid_t XID

Enumeration Type Documentation

◆ dict_init_mode_t

Mode for initializing the data dictionary.

Enumerator
DICT_INIT_CREATE_FILES 

Create all required SE files.

DICT_INIT_CHECK_FILES 

Verify existence of expected files.

DICT_INIT_UPGRADE_57_FILES 

Used for upgrade from mysql-5.7.

DICT_INIT_IGNORE_FILES 

Don't care about files at all.

◆ dict_recovery_mode_t

Mode for data dictionary recovery.

Enumerator
DICT_RECOVERY_INITIALIZE_SERVER 

First start of a new server.

DICT_RECOVERY_INITIALIZE_TABLESPACES 

First start, create tablespaces.

DICT_RECOVERY_RESTART_SERVER 

Restart of an existing server.

◆ enum_alter_inplace_result

Return values for check_if_supported_inplace_alter().

See also
check_if_supported_inplace_alter() for description of the individual values.
Enumerator
HA_ALTER_ERROR 
HA_ALTER_INPLACE_NOT_SUPPORTED 
HA_ALTER_INPLACE_EXCLUSIVE_LOCK 
HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARE 
HA_ALTER_INPLACE_SHARED_LOCK 
HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE 
HA_ALTER_INPLACE_NO_LOCK 
HA_ALTER_INPLACE_INSTANT 

◆ enum_binlog_command

Enumerator
LOGCOM_CREATE_TABLE 
LOGCOM_ALTER_TABLE 
LOGCOM_RENAME_TABLE 
LOGCOM_DROP_TABLE 
LOGCOM_CREATE_DB 
LOGCOM_ALTER_DB 
LOGCOM_DROP_DB 
LOGCOM_ACL_NOTIFY 

◆ enum_binlog_func

Enumerator
BFN_RESET_LOGS 
BFN_RESET_SLAVE 
BFN_BINLOG_WAIT 
BFN_BINLOG_END 
BFN_BINLOG_PURGE_FILE 

◆ enum_sampling_method

enum enum_sampling_method
strong
Enumerator
SYSTEM 

◆ enum_schema_tables

Enumerator
SCH_FIRST 
SCH_COLUMN_PRIVILEGES 
SCH_ENGINES 
SCH_OPEN_TABLES 
SCH_OPTIMIZER_TRACE 
SCH_PLUGINS 
SCH_PROCESSLIST 
SCH_PROFILES 
SCH_SCHEMA_PRIVILEGES 
SCH_TABLESPACES 
SCH_TABLE_PRIVILEGES 
SCH_USER_PRIVILEGES 
SCH_TMP_TABLE_COLUMNS 
SCH_TMP_TABLE_KEYS 
SCH_LAST 

◆ enum_stats_auto_recalc

Enumerator
HA_STATS_AUTO_RECALC_DEFAULT 
HA_STATS_AUTO_RECALC_ON 
HA_STATS_AUTO_RECALC_OFF 

◆ enum_tx_isolation

enum enum_tx_isolation : int
Enumerator
ISO_READ_UNCOMMITTED 
ISO_READ_COMMITTED 
ISO_REPEATABLE_READ 
ISO_SERIALIZABLE 

◆ Ha_clone_mode

Clone start operation mode.

Enumerator
HA_CLONE_MODE_START 

Start a new clone operation.

HA_CLONE_MODE_RESTART 

Re-start a clone operation after failure.

HA_CLONE_MODE_ADD_TASK 

Add a new task to a running clone operation.

HA_CLONE_MODE_VERSION 

Get version for transfer data format.

HA_CLONE_MODE_MAX 

Max value for clone mode.

◆ Ha_clone_type

enum Ha_clone_type : size_t

Clone operation types.

Enumerator
HA_CLONE_BLOCKING 

Caller must block all write operation to the SE.

HA_CLONE_REDO 

For transactional SE, archive redo to support concurrent dml.

HA_CLONE_PAGE 

For transactional SE, track page changes to support concurrent dml.

HA_CLONE_HYBRID 

For transactional SE, use both page tracking and redo to optimize clone with concurrent dml.

Currently supported by Innodb.

HA_CLONE_MULTI_TASK 

SE supports multiple threads for clone.

HA_CLONE_RESTART 

SE supports restarting clone after network failure.

HA_CLONE_TYPE_MAX 

Maximum value of clone type.

◆ ha_notification_type

Enumerator
HA_NOTIFY_PRE_EVENT 
HA_NOTIFY_POST_EVENT 

◆ ha_stat_type

Enumerator
HA_ENGINE_STATUS 
HA_ENGINE_LOGS 
HA_ENGINE_MUTEX 

◆ legacy_db_type

Enumerator
DB_TYPE_UNKNOWN 
DB_TYPE_DIAB_ISAM 
DB_TYPE_HASH 
DB_TYPE_MISAM 
DB_TYPE_PISAM 
DB_TYPE_RMS_ISAM 
DB_TYPE_HEAP 
DB_TYPE_ISAM 
DB_TYPE_MRG_ISAM 
DB_TYPE_MYISAM 
DB_TYPE_MRG_MYISAM 
DB_TYPE_BERKELEY_DB 
DB_TYPE_INNODB 
DB_TYPE_GEMINI 
DB_TYPE_NDBCLUSTER 
DB_TYPE_EXAMPLE_DB 
DB_TYPE_ARCHIVE_DB 
DB_TYPE_CSV_DB 
DB_TYPE_FEDERATED_DB 
DB_TYPE_BLACKHOLE_DB 
DB_TYPE_PARTITION_DB 
DB_TYPE_BINLOG 
DB_TYPE_SOLID 
DB_TYPE_PBXT 
DB_TYPE_TABLE_FUNCTION 
DB_TYPE_MEMCACHE 
DB_TYPE_FALCON 
DB_TYPE_MARIA 
DB_TYPE_PERFORMANCE_SCHEMA 

Performance schema engine.

DB_TYPE_TEMPTABLE 
DB_TYPE_FIRST_DYNAMIC 
DB_TYPE_DEFAULT 

◆ row_type

enum row_type : int
Enumerator
ROW_TYPE_NOT_USED 
ROW_TYPE_DEFAULT 
ROW_TYPE_FIXED 
ROW_TYPE_DYNAMIC 
ROW_TYPE_COMPRESSED 
ROW_TYPE_REDUNDANT 
ROW_TYPE_COMPACT 
ROW_TYPE_PAGED 

Unused.

Reserved for future versions.

◆ Tablespace_type

enum Tablespace_type
strong
Enumerator
SPACE_TYPE_DICTIONARY 
SPACE_TYPE_SYSTEM 
SPACE_TYPE_UNDO 
SPACE_TYPE_TEMPORARY 
SPACE_TYPE_SHARED 
SPACE_TYPE_IMPLICIT 

◆ ts_alter_tablespace_type

Enumerator
TS_ALTER_TABLESPACE_TYPE_NOT_DEFINED 
ALTER_TABLESPACE_ADD_FILE 
ALTER_TABLESPACE_DROP_FILE 
ALTER_TABLESPACE_RENAME 
ALTER_TABLESPACE_OPTIONS 
ALTER_UNDO_TABLESPACE_SET_ACTIVE 
ALTER_UNDO_TABLESPACE_SET_INACTIVE 

◆ ts_command_type

Enumerator
TS_CMD_NOT_DEFINED 
CREATE_TABLESPACE 
ALTER_TABLESPACE 
CREATE_LOGFILE_GROUP 
ALTER_LOGFILE_GROUP 
DROP_TABLESPACE 
DROP_LOGFILE_GROUP 
CHANGE_FILE_TABLESPACE 
ALTER_ACCESS_MODE_TABLESPACE 
CREATE_UNDO_TABLESPACE 
ALTER_UNDO_TABLESPACE 
DROP_UNDO_TABLESPACE 

◆ xa_status_code

X/Open XA distributed transaction status codes.

Enumerator
XA_OK 

normal execution

XAER_ASYNC 

asynchronous operation already outstanding

XAER_RMERR 

a resource manager error occurred in the transaction branch

XAER_NOTA 

the XID is not valid

XAER_INVAL 

invalid arguments were given

XAER_PROTO 

routine invoked in an improper context

XAER_RMFAIL 

resource manager unavailable

XAER_DUPID 

the XID already exists

XAER_OUTSIDE 

resource manager doing work outside transaction

Function Documentation

◆ binlog_log_row()

int binlog_log_row ( TABLE table,
const uchar before_record,
const uchar after_record,
Log_func log_func 
)

binlog a row operation

◆ calculate_key_len()

uint calculate_key_len ( TABLE table,
uint  key,
key_part_map  keypart_map 
)

Calculates length of key.

Given a key index and a map of key parts return length of buffer used by key parts.

Parameters
tableTable containing the key
keyKey index
keypart_mapwhich key parts that is used
Returns
Length of used key parts.

◆ check_table_for_old_types()

int check_table_for_old_types ( const TABLE table)

Function identifies any old data type present in table.

This function was handler::check_old_types(). Function is not part of SE API. It is now converted to auxiliary standalone function.

Parameters
[in]tableTABLE object
Return values
0ON SUCCESS
errorcode ON FAILURE

◆ commit_owned_gtid_by_partial_command()

int commit_owned_gtid_by_partial_command ( THD thd)

The function is a wrapper of commit_owned_gtids(...).

It is invoked at committing a partially failed statement or transaction.

Parameters
thdThread context.
Return values
-1if error when persisting owned gtid.
0if succeed to commit owned gtid.
1if do not meet conditions to commit owned gtid.

◆ commit_owned_gtids()

int commit_owned_gtids ( THD thd,
bool  all,
bool need_clear_owned_gtid_ptr 
)

The function computes condition to call gtid persistor wrapper, and executes it.

It is invoked at committing a statement or transaction, including XA, and also at XA prepare handling.

Parameters
thdThread context.
allThe execution scope, true for the transaction one, false for the statement one.
[out]need_clear_owned_gtid_ptrA pointer to bool variable to return the computed decision value.
Returns
zero as no error indication, non-zero otherwise

◆ ddl_is_atomic()

bool ddl_is_atomic ( const handlerton hton)
inline

◆ default_rm_tmp_tables()

bool default_rm_tmp_tables ( handlerton hton,
THD ,
List< LEX_STRING > *  files 
)

Default implementation for handlerton::rm_tmp_tables() method which simply removes all files from "files" list which have one of SE's extensions.

This implementation corresponds to default implementation of handler::delete_table() method.

◆ get_canonical_filename()

const char* get_canonical_filename ( handler file,
const char *  path,
char *  tmp_path 
)

make canonical filename

Parameters
[in]filetable handler
[in]pathoriginal path
[out]tmp_pathbuffer for canonized path

Lower case db name and table name path parts for non file based tables when lower_case_table_names is 2 (store as is, compare in lower case). Filesystem path prefix (mysql_data_home or tmpdir) is left intact.

Note
tmp_path may be left intact if no conversion was performed.
Return values
canonizedpath

◆ get_new_handler()

handler* get_new_handler ( TABLE_SHARE share,
bool  partitioned,
MEM_ROOT alloc,
handlerton db_type 
)

Create handler object for the table in the storage engine.

Parameters
shareTABLE_SHARE for the table, can be NULL if caller didn't perform full-blown open of table definition.
partitionedIndicates whether table is partitioned.
allocMemory root to be used for allocating handler object.
db_typeTable's storage engine.
Note
This function will try to use default storage engine if one which was specified through db_type parameter is not available.

◆ get_sweep_read_cost()

void get_sweep_read_cost ( TABLE table,
ha_rows  nrows,
bool  interrupted,
Cost_estimate cost 
)

Get cost of reading nrows table records in a "disk sweep".

A disk sweep read is a sequence of handler->rnd_pos(rowid) calls that made for an ordered sequence of rowids.

We take into account that some of the records might be in a memory buffer while others need to be read from a secondary storage device. The model for this assumes hard disk IO. A disk read is performed as follows:

  1. The disk head is moved to the needed cylinder
  2. The controller waits for the plate to rotate
  3. The data is transferred

Time to do #3 is insignificant compared to #2+#1.

Time to move the disk head is proportional to head travel distance.

Time to wait for the plate to rotate depends on whether the disk head was moved or not.

If disk head wasn't moved, the wait time is proportional to distance between the previous block and the block we're reading.

If the head was moved, we don't know how much we'll need to wait for the plate to rotate. We assume the wait time to be a variate with a mean of 0.5 of full rotation time.

Our cost units are "random disk seeks". The cost of random disk seek is actually not a constant, it depends one range of cylinders we're going to access. We make it constant by introducing a fuzzy concept of "typical datafile length" (it's fuzzy as it's hard to tell whether it should include index file, temp.tables etc). Then random seek cost is:

1 = half_rotation_cost + move_cost * 1/3 * typical_data_file_length

We define half_rotation_cost as disk_seek_base_cost() (see Cost_model_server::disk_seek_base_cost()).

Parameters
tableTable to be accessed
nrowsNumber of rows to retrieve
interruptedtrue <=> Assume that the disk sweep will be interrupted by other disk IO. false - otherwise.
[out]costthe cost

◆ ha_binlog_end()

int ha_binlog_end ( THD thd)

◆ ha_binlog_index_purge_file()

int ha_binlog_index_purge_file ( THD thd,
const char *  file 
)

◆ ha_binlog_log_query()

void ha_binlog_log_query ( THD thd,
handlerton db_type,
enum_binlog_command  binlog_command,
const char *  query,
size_t  query_length,
const char *  db,
const char *  table_name 
)

◆ ha_binlog_wait()

void ha_binlog_wait ( THD thd)

◆ ha_change_key_cache()

int ha_change_key_cache ( KEY_CACHE old_key_cache,
KEY_CACHE new_key_cache 
)

Move all tables from one key cache to another one.

◆ ha_check_if_supported_system_table()

bool ha_check_if_supported_system_table ( handlerton hton,
const char *  db,
const char *  table_name 
)

Check if a given table is a system table.

The primary purpose of introducing this function is to stop system tables to be created or being moved to undesired storage engines.

Parameters
htonHandlerton of new engine.
dbDatabase name.
table_nameTable name to be checked.
Returns
Operation status
Return values
trueIf the table name is a valid system table or if its a valid user table.
falseIf the table name is a system table name and does not belong to engine specified in the command.

◆ ha_check_if_table_exists()

bool ha_check_if_table_exists ( THD thd,
const char *  db,
const char *  name,
bool exists 
)

Try to find a table in a storage engine.

Parameters
thdThread handle
dbNormalized table schema name
nameNormalized table name.
[out]existsOnly valid if the function succeeded.
Return values
trueAn error is found
falseSuccess, check *exists

◆ ha_check_reserved_db_name()

bool ha_check_reserved_db_name ( const char *  name)

Check if the database name is reserved word used by SE.

Parameters
nameDatabase name.
Return values
trueIf the name is a reserved word.
falseIf the name is not a reserved word.

◆ ha_check_storage_engine_flag()

static bool ha_check_storage_engine_flag ( const handlerton db_type,
uint32  flag 
)
inlinestatic

◆ ha_checktype()

handlerton* ha_checktype ( THD thd,
enum legacy_db_type  database_type,
bool  no_substitute,
bool  report_error 
)

Use other database handler if databasehandler is not compiled in.

◆ ha_close_connection()

void ha_close_connection ( THD thd)

function to close a connection and thd, defined in sql/handler.cc

Note
don't bother to rollback here, it's done already

◆ ha_commit_attachable()

int ha_commit_attachable ( THD thd)

Commit the attachable transaction in storage engines.

Note
This is slimmed down version of ha_commit_trans()/ha_commit_low() which commits attachable transaction but skips code which is unnecessary and unsafe for them (like dealing with GTIDs). Since attachable transactions are read-only their commit only needs to release resources and cleanup state in SE.
Parameters
thdCurrent thread
Return values
0- Success
non-0- Failure

◆ ha_commit_low()

int ha_commit_low ( THD thd,
bool  all,
bool  run_after_commit 
)

Commit the sessions outstanding transaction.

Precondition
thd->transaction.flags.commit_low == true
Postcondition
thd->transaction.flags.commit_low == false
Note
This function does not care about global read lock; the caller should.
Parameters
[in]thdThread handle.
[in]allIs set in case of explicit commit (COMMIT statement), or implicit commit issued by DDL. Is not set when called at the end of statement, even if autocommit=1.
[in]run_after_commitTrue by default, otherwise, does not execute the after_commit hook in the function.

◆ ha_commit_trans()

int ha_commit_trans ( THD thd,
bool  all,
bool  ignore_global_read_lock 
)
Parameters
[in]thdThread handle.
[in]allSession transaction if true, statement otherwise.
[in]ignore_global_read_lockAllow commit to complete even if a global read lock is active. This can be used to allow changes to internal tables (e.g. slave status tables).
Return values
0ok
1transaction was rolled back
2error during commit, data may be inconsistent

◆ ha_create_table()

int ha_create_table ( THD thd,
const char *  path,
const char *  db,
const char *  table_name,
HA_CREATE_INFO create_info,
bool  update_create_info,
bool  is_temp_table,
dd::Table table_def 
)

Initiates table-file and calls appropriate database-creator.

Parameters
thdThread context.
pathPath to table file (without extension).
dbDatabase name.
table_nameTable name.
create_infoHA_CREATE_INFO describing table.
update_create_infoIndicates that create_info needs to be updated from table share.
is_temp_tableIndicates that this is temporary table (for cases when this info is not available from HA_CREATE_INFO).
table_defData-dictionary object describing table to be used for table creation. Can be adjusted by storage engine if it supports atomic DDL. For non-temporary tables these changes will be saved to the data-dictionary by this call.
Return values
0ok
1error

◆ ha_create_table_from_engine()

int ha_create_table_from_engine ( THD thd,
const char *  db,
const char *  name 
)

Try to discover table from engine.

Note
If found, import the serialized dictionary information.
Return values
-1Table did not exists
0Table created ok
<blockquote>0 Error, table existed but could not be created

◆ ha_default_handlerton()

handlerton* ha_default_handlerton ( THD thd)

Return the default storage engine handlerton used for non-temp tables for thread.

SYNOPSIS ha_default_handlerton(thd) thd current thread

RETURN pointer to handlerton

◆ ha_default_temp_handlerton()

handlerton* ha_default_temp_handlerton ( THD thd)

Return the default storage engine handlerton used for explicitly created temp tables for a thread.

SYNOPSIS ha_default_temp_handlerton(thd) thd current thread

RETURN pointer to handlerton

◆ ha_delete_table()

int ha_delete_table ( THD thd,
handlerton table_type,
const char *  path,
const char *  db,
const char *  alias,
const dd::Table table_def,
bool  generate_warning 
)

Delete table from the storage engine.

Parameters
thdThread context.
table_typeHandlerton for table's SE.
pathPath to table (without extension).
dbTable database.
aliasTable name.
table_defdd::Table object describing the table.
generate_warningIndicates whether errors during deletion should be reported as warnings.
Returns
0 - in case of success, non-0 in case of failure, ENOENT if the file doesn't exists.

◆ ha_drop_database()

void ha_drop_database ( char *  path)

◆ ha_enable_transaction()

int ha_enable_transaction ( THD thd,
bool  on 
)

Tell the storage engine that it is allowed to "disable transaction" in the handler.

It is a hint that ACID is not required - it is used in NDB for ALTER TABLE, for example, when data are copied to temporary table. A storage engine may treat this hint any way it likes. NDB for example starts to commit every now and then automatically. This hint can be safely ignored.

◆ ha_end()

void ha_end ( )

◆ ha_finalize_handlerton()

int ha_finalize_handlerton ( st_plugin_int plugin)

◆ ha_find_files()

int ha_find_files ( THD thd,
const char *  db,
const char *  path,
const char *  wild,
bool  dir,
List< LEX_STRING > *  files 
)

◆ ha_flush_logs()

bool ha_flush_logs ( bool  binlog_group_flush = false)

Flush the log(s) of storage engine(s).

Parameters
binlog_group_flushtrue if we got invoked by binlog group commit during flush stage, false in other cases.
Return values
falseSucceed
trueError

◆ ha_init()

int ha_init ( void  )

◆ ha_init_errors()

int ha_init_errors ( void  )

Register handler error messages for use with my_error().

Return values
0OK
!=0Error

◆ ha_init_key_cache()

int ha_init_key_cache ( const char *  name,
KEY_CACHE key_cache 
)

Init a key cache if it has not been initied before.

◆ ha_initialize_handlerton()

int ha_initialize_handlerton ( st_plugin_int plugin)

◆ ha_is_storage_engine_disabled()

bool ha_is_storage_engine_disabled ( handlerton se_engine)

◆ ha_kill_connection()

void ha_kill_connection ( THD thd)

◆ ha_known_exts()

TYPELIB* ha_known_exts ( )

◆ ha_legacy_type()

static enum legacy_db_type ha_legacy_type ( const handlerton db_type)
inlinestatic

◆ ha_lock_engine()

plugin_ref ha_lock_engine ( THD thd,
const handlerton hton 
)

◆ ha_make_pushed_joins()

int ha_make_pushed_joins ( THD thd,
const AQP::Join_plan plan 
)

◆ ha_notify_alter_table()

bool ha_notify_alter_table ( THD thd,
const MDL_key mdl_key,
ha_notification_type  notification_type 
)

Notify/get permission from all interested storage engines before or after executed ALTER TABLE on the table identified by key.

Parameters
thdThread context.
mdl_keyMDL key identifying table.
notification_typeIndicates whether this is pre-ALTER or post-ALTER notification.

See

See also
handlerton::notify_alter_table for rationale, details about calling convention and error reporting.
Returns
False - if notification was successful/ALTER TABLE can proceed. True - if it has failed/ALTER TABLE should fail.

◆ ha_notify_exclusive_mdl()

bool ha_notify_exclusive_mdl ( THD thd,
const MDL_key mdl_key,
ha_notification_type  notification_type,
bool victimized 
)

Notify/get permission from all interested storage engines before acquisition or after release of exclusive metadata lock on object represented by key.

Parameters
thdThread context.
mdl_keyMDL key identifying object on which exclusive lock is to be acquired/was released.
notification_typeIndicates whether this is pre-acquire or post-release notification.
victimized'true' if locking failed as we were selected as a victim in order to avoid possible deadlocks.

See

See also
handlerton::notify_exclusive_mdl for details about calling convention and error reporting.
Returns
False - if notification was successful/lock can be acquired, True - if it has failed/lock should not be acquired.

◆ ha_panic()

int ha_panic ( enum ha_panic_function  flag)

◆ ha_post_recover()

void ha_post_recover ( )

Perform SE-specific cleanup after recovery of transactions.

Note
SE supporting atomic DDL can use this method to perform post-DDL actions for DDL statements which were committed or rolled back during recovery stage.

◆ ha_pre_dd_shutdown()

void ha_pre_dd_shutdown ( void  )

Invoke handlerton::pre_dd_shutdown() on every storage engine plugin.

◆ ha_prepare()

int ha_prepare ( THD thd)
Return values
0ok
1error, transaction was rolled back

◆ ha_prepare_low()

int ha_prepare_low ( THD thd,
bool  all 
)

◆ ha_recover()

int ha_recover ( const memroot_unordered_set< my_xid > *  commit_list)

◆ ha_release_savepoint()

int ha_release_savepoint ( THD thd,
SAVEPOINT sv 
)

◆ ha_reset_logs()

int ha_reset_logs ( THD thd)

◆ ha_reset_slave()

void ha_reset_slave ( THD thd)

◆ ha_resize_key_cache()

int ha_resize_key_cache ( KEY_CACHE key_cache)

Resize key cache.

◆ ha_resolve_by_legacy_type()

handlerton* ha_resolve_by_legacy_type ( THD thd,
enum legacy_db_type  db_type 
)

◆ ha_resolve_by_name()

plugin_ref ha_resolve_by_name ( THD thd,
const LEX_STRING name,
bool  is_temp_table 
)

Return the storage engine handlerton for the supplied name.

SYNOPSIS ha_resolve_by_name(thd, name) thd current thread name name of storage engine

RETURN pointer to storage engine plugin handle

◆ ha_resolve_by_name_raw()

plugin_ref ha_resolve_by_name_raw ( THD thd,
const LEX_CSTRING name 
)

Resolve handlerton plugin by name, without checking for "DEFAULT" or HTON_NOT_USER_SELECTABLE.

Parameters
thdThread context.
namePlugin name.
Returns
plugin or NULL if not found.

◆ ha_resolve_storage_engine_name()

const char* ha_resolve_storage_engine_name ( const handlerton db_type)

◆ ha_rkey_function_to_str()

const char* ha_rkey_function_to_str ( enum ha_rkey_function  r)

Generate a string representation of an ha_rkey_function enum value.

Parameters
[in]rvalue to turn into string
Returns
a string, e.g. "HA_READ_KEY_EXACT" if r == HA_READ_KEY_EXACT

◆ ha_rm_tmp_tables()

bool ha_rm_tmp_tables ( THD thd,
List< LEX_STRING > *  files 
)

Ask all SEs to drop all temporary tables which have been left from previous server run.

Used on server start-up.

Parameters
[in]thdThread context.
[in,out]filesList of files in directories for temporary files which match tmp_file_prefix and thus can belong to temporary tables. If any SE recognizes some file as belonging to temporary table in this SE and deletes the file it is also supposed to remove file from this list.

◆ ha_rollback_low()

int ha_rollback_low ( THD thd,
bool  all 
)

◆ ha_rollback_to_savepoint()

int ha_rollback_to_savepoint ( THD thd,
SAVEPOINT sv 
)

◆ ha_rollback_to_savepoint_can_release_mdl()

bool ha_rollback_to_savepoint_can_release_mdl ( THD thd)

Check if all storage engines used in transaction agree that after rollback to savepoint it is safe to release MDL locks acquired after savepoint creation.

Parameters
thdThe client thread that executes the transaction.
Returns
true - It is safe to release MDL locks. false - If it is not.

Checking whether it is safe to release metadata locks after rollback to savepoint in all the storage engines that are part of the transaction.

◆ ha_rollback_trans()

int ha_rollback_trans ( THD thd,
bool  all 
)

◆ ha_savepoint()

int ha_savepoint ( THD thd,
SAVEPOINT sv 
)
Note
according to the sql standard (ISO/IEC 9075-2:2003) section "4.33.4 SQL-statements and transaction states", SAVEPOINT is not transaction-initiating SQL-statement

◆ ha_set_normalized_disabled_se_str()

void ha_set_normalized_disabled_se_str ( const std::string &  disabled_se_str)

◆ ha_show_status()

bool ha_show_status ( THD thd,
handlerton db_type,
enum ha_stat_type  stat 
)

◆ ha_start_consistent_snapshot()

int ha_start_consistent_snapshot ( THD thd)

◆ ha_storage_engine_is_enabled()

static bool ha_storage_engine_is_enabled ( const handlerton db_type)
inlinestatic

◆ ha_table_exists_in_engine()

int ha_table_exists_in_engine ( THD thd,
const char *  db,
const char *  name 
)

◆ hton2plugin()

st_plugin_int* hton2plugin ( uint  slot)

Maps from slot to plugin. May return NULL if plugin has been unloaded.

◆ indexed_cells_to_string()

std::string indexed_cells_to_string ( const uchar indexed_cells,
uint  indexed_cells_len,
const KEY mysql_index 
)

Generate a human readable string that describes indexed cells that are given to handler::index_read() as input.

The generated string is similar to the one generated by row_to_string(), but only contains the cells covered by the given index.

Parameters
[in]indexed_cellsraw buffer in handler::index_read() input format
[in]indexed_cells_lenlength of indexed_cells in bytes
[in]mysql_indexthe index that covers the cells, for querying metadata
Returns
textual dump of the cells

◆ insert_hton2plugin()

st_plugin_int* insert_hton2plugin ( uint  slot,
st_plugin_int plugin 
)

For unit testing.

Insert plugin into arbitrary slot in array. Remove plugin from arbitrary slot in array.

◆ num_hton2plugins()

size_t num_hton2plugins ( )

Returns the size of the array holding pointers to plugins.

◆ print_keydup_error() [1/2]

void print_keydup_error ( TABLE table,
KEY key,
const char *  msg,
myf  errflag 
)

Construct and emit duplicate key error message using information from table's record buffer.

Parameters
tableTABLE object which record buffer should be used as source for column values.
keyKey description.
msgError message template to which key value should be added.
errflagFlags for my_error() call.

◆ print_keydup_error() [2/2]

void print_keydup_error ( TABLE table,
KEY key,
myf  errflag 
)

Construct and emit duplicate key error message using information from table's record buffer.

See also
print_keydup_error(table, key, msg, errflag).

◆ remove_hton2plugin()

st_plugin_int* remove_hton2plugin ( uint  slot)

◆ row_to_string()

std::string row_to_string ( const uchar mysql_row,
TABLE mysql_table 
)

Generate a human readable string that describes the contents of a row.

The row must be in the same format as provided to handler::write_row(). For example, given this table structure: t1 (pk int(11) not null, col_int_key int(11), col_varchar_key varchar(1), hash unique index0(pk, col_int_key, col_varchar_key))

something like this will be generated (without the new lines):

len=16, raw=..........c....., hex=f9 1d 00 00 00 08 00 00 00 01 63 a5 a5 a5 a5 a5, human=(pk=29, col_int_key=8, col_varchar_key=c)

Parameters
[in]mysql_rowrow to dump
[in]mysql_tabletable to which the row belongs, for querying metadata
Returns
textual dump of the row

◆ set_tx_isolation()

bool set_tx_isolation ( THD thd,
enum_tx_isolation  tx_isolation,
bool  one_shot 
)

Set the transaction isolation level for the next transaction and update session tracker information about the transaction isolation level.

Parameters
thdTHD session setting the tx_isolation.
tx_isolationThe isolation level to be set.
one_shotTrue if the isolation level should be restored to session default after finishing the transaction.

◆ table_case_name()

const char* table_case_name ( const HA_CREATE_INFO info,
const char *  name 
)

◆ table_definition()

std::string table_definition ( const char *  table_name,
const TABLE mysql_table 
)

Generate a human readable string that describes a table structure.

For example: t1 (c1 char(60) not null, c2 char(60), hash unique index0(c1, c2))

Parameters
[in]table_namename of the table to be described
[in]mysql_tabletable structure
Returns
a string similar to a CREATE TABLE statement

◆ trans_register_ha()

void trans_register_ha ( THD thd,
bool  all,
handlerton ht_arg,
const ulonglong trxid 
)

Transaction handling in the server

In each client connection, MySQL maintains two transactional states:

  • a statement transaction,
  • a standard, also called normal transaction.

Historical note

"Statement transaction" is a non-standard term that comes from the times when MySQL supported BerkeleyDB storage engine.

First of all, it should be said that in BerkeleyDB auto-commit mode auto-commits operations that are atomic to the storage engine itself, such as a write of a record, and are too high-granular to be atomic from the application perspective (MySQL). One SQL statement could involve many BerkeleyDB auto-committed operations and thus BerkeleyDB auto-commit was of little use to MySQL.

Secondly, instead of SQL standard savepoints, BerkeleyDB provided the concept of "nested transactions". In a nutshell, transactions could be arbitrarily nested, but when the parent transaction was committed or aborted, all its child (nested) transactions were handled committed or aborted as well. Commit of a nested transaction, in turn, made its changes visible, but not durable: it destroyed the nested transaction, all its changes would become available to the parent and currently active nested transactions of this parent.

So the mechanism of nested transactions was employed to provide "all or nothing" guarantee of SQL statements required by the standard. A nested transaction would be created at start of each SQL statement, and destroyed (committed or aborted) at statement end. Such nested transaction was internally referred to as a "statement transaction" and gave birth to the term.

(Historical note ends)

Since then a statement transaction is started for each statement that accesses transactional tables or uses the binary log. If the statement succeeds, the statement transaction is committed. If the statement fails, the transaction is rolled back. Commits of statement transactions are not durable – each such transaction is nested in the normal transaction, and if the normal transaction is rolled back, the effects of all enclosed statement transactions are undone as well. Technically, a statement transaction can be viewed as a savepoint which is maintained automatically in order to make effects of one statement atomic.

The normal transaction is started by the user and is ended usually upon a user request as well. The normal transaction encloses transactions of all statements issued between its beginning and its end. In autocommit mode, the normal transaction is equivalent to the statement transaction.

Since MySQL supports PSEA (pluggable storage engine architecture), more than one transactional engine can be active at a time. Hence transactions, from the server point of view, are always distributed. In particular, transactional state is maintained independently for each engine. In order to commit a transaction the two phase commit protocol is employed.

Not all statements are executed in context of a transaction. Administrative and status information statements do not modify engine data, and thus do not start a statement transaction and also have no effect on the normal transaction. Examples of such statements are SHOW STATUS and RESET SLAVE.

Similarly DDL statements are not transactional, and therefore a transaction is [almost] never started for a DDL statement. The difference between a DDL statement and a purely administrative statement though is that a DDL statement always commits the current transaction before proceeding, if there is any.

At last, SQL statements that work with non-transactional engines also have no effect on the transaction state of the connection. Even though they are written to the binary log, and the binary log is, overall, transactional, the writes are done in "write-through" mode, directly to the binlog file, followed with a OS cache sync, in other words, bypassing the binlog undo log (translog). They do not commit the current normal transaction. A failure of a statement that uses non-transactional tables would cause a rollback of the statement transaction, but in case there no non-transactional tables are used, no statement transaction is started.

Data layout

The server stores its transaction-related data in thd->transaction. This structure has two members of type THD_TRANS. These members correspond to the statement and normal transactions respectively:

  • thd->transaction.stmt contains a list of engines that are participating in the given statement
  • thd->transaction.all contains a list of engines that have participated in any of the statement transactions started within the context of the normal transaction. Each element of the list contains a pointer to the storage engine, engine-specific transactional data, and engine-specific transaction flags.

In autocommit mode thd->transaction.all is empty. Instead, data of thd->transaction.stmt is used to commit/rollback the normal transaction.

The list of registered engines has a few important properties:

  • no engine is registered in the list twice
  • engines are present in the list a reverse temporal order – new participants are always added to the beginning of the list.

Transaction life cycle

When a new connection is established, thd->transaction members are initialized to an empty state. If a statement uses any tables, all affected engines are registered in the statement engine list. In non-autocommit mode, the same engines are registered in the normal transaction list. At the end of the statement, the server issues a commit or a roll back for all engines in the statement list. At this point transaction flags of an engine, if any, are propagated from the statement list to the list of the normal transaction. When commit/rollback is finished, the statement list is cleared. It will be filled in again by the next statement, and emptied again at the next statement's end.

The normal transaction is committed in a similar way (by going over all engines in thd->transaction.all list) but at different times:

  • upon COMMIT SQL statement is issued by the user
  • implicitly, by the server, at the beginning of a DDL statement or SET AUTOCOMMIT={0|1} statement.

The normal transaction can be rolled back as well:

  • if the user has requested so, by issuing ROLLBACK SQL statement
  • if one of the storage engines requested a rollback by setting thd->transaction_rollback_request. This may happen in case, e.g., when the transaction in the engine was chosen a victim of the internal deadlock resolution algorithm and rolled back internally. When such a situation happens, there is little the server can do and the only option is to rollback transactions in all other participating engines. In this case the rollback is accompanied by an error sent to the user.

As follows from the use cases above, the normal transaction is never committed when there is an outstanding statement transaction. In most cases there is no conflict, since commits of the normal transaction are issued by a stand-alone administrative or DDL statement, thus no outstanding statement transaction of the previous statement exists. Besides, all statements that manipulate with the normal transaction are prohibited in stored functions and triggers, therefore no conflicting situation can occur in a sub-statement either. The remaining rare cases when the server explicitly has to commit the statement transaction prior to committing the normal one cover error-handling scenarios (see for example SQLCOM_LOCK_TABLES).

When committing a statement or a normal transaction, the server either uses the two-phase commit protocol, or issues a commit in each engine independently. The two-phase commit protocol is used only if:

  • all participating engines support two-phase commit (provide handlerton::prepare PSEA API call) and
  • transactions in at least two engines modify data (i.e. are not read-only).

Note that the two phase commit is used for statement transactions, even though they are not durable anyway. This is done to ensure logical consistency of data in a multiple- engine transaction. For example, imagine that some day MySQL supports unique constraint checks deferred till the end of statement. In such case a commit in one of the engines may yield ER_DUP_KEY, and MySQL should be able to gracefully abort statement transactions of other participants.

After the normal transaction has been committed, thd->transaction.all list is cleared.

When a connection is closed, the current normal transaction, if any, is rolled back.

Roles and responsibilities

The server has no way to know that an engine participates in the statement and a transaction has been started in it unless the engine says so. Thus, in order to be a part of a transaction, the engine must "register" itself. This is done by invoking trans_register_ha() server call. Normally the engine registers itself whenever handler::external_lock() is called. trans_register_ha() can be invoked many times: if an engine is already registered, the call does nothing. In case autocommit is not set, the engine must register itself twice – both in the statement list and in the normal transaction list. In which list to register is a parameter of trans_register_ha().

Note, that although the registration interface in itself is fairly clear, the current usage practice often leads to undesired effects. E.g. since a call to trans_register_ha() in most engines is embedded into implementation of handler::external_lock(), some DDL statements start a transaction (at least from the server point of view) even though they are not expected to. E.g. CREATE TABLE does not start a transaction, since handler::external_lock() is never called during CREATE TABLE. But CREATE TABLE ... SELECT does, since handler::external_lock() is called for the table that is being selected from. This has no practical effects currently, but must be kept in mind nevertheless.

Once an engine is registered, the server will do the rest of the work.

During statement execution, whenever any of data-modifying PSEA API methods is used, e.g. handler::write_row() or handler::update_row(), the read-write flag is raised in the statement transaction for the involved engine. Currently All PSEA calls are "traced", and the data can not be changed in a way other than issuing a PSEA call. Important: unless this invariant is preserved the server will not know that a transaction in a given engine is read-write and will not involve the two-phase commit protocol!

At the end of a statement, server call trans_commit_stmt is invoked. This call in turn invokes handlerton::prepare() for every involved engine. Prepare is followed by a call to handlerton::commit_one_phase() If a one-phase commit will suffice, handlerton::prepare() is not invoked and the server only calls handlerton::commit_one_phase(). At statement commit, the statement-related read-write engine flag is propagated to the corresponding flag in the normal transaction. When the commit is complete, the list of registered engines is cleared.

Rollback is handled in a similar fashion.

Additional notes on DDL and the normal transaction.

DDLs and operations with non-transactional engines do not "register" in thd->transaction lists, and thus do not modify the transaction state. Besides, each DDL in MySQL is prefixed with an implicit normal transaction commit (a call to trans_commit_implicit()), and thus leaves nothing to modify. However, as it has been pointed out with CREATE TABLE .. SELECT, some DDL statements can start a new transaction.

Behaviour of the server in this case is currently badly defined. DDL statements use a form of "semantic" logging to maintain atomicity: if CREATE TABLE .. SELECT failed, the newly created table is deleted. In addition, some DDL statements issue interim transaction commits: e.g. ALTER TABLE issues a commit after data is copied from the original table to the internal temporary table. Other statements, e.g. CREATE TABLE ... SELECT do not always commit after itself. And finally there is a group of DDL statements such as RENAME/DROP TABLE that doesn't start a new transaction and doesn't commit.

This diversity makes it hard to say what will happen if by chance a stored function is invoked during a DDL – whether any modifications it makes will be committed or not is not clear. Fortunately, SQL grammar of few DDLs allows invocation of a stored function.

A consistent behaviour is perhaps to always commit the normal transaction after all DDLs, just like the statement transaction is always committed at the end of all statements. Register a storage engine for a transaction.

Every storage engine MUST call this function when it starts a transaction or a statement (that is it must be called both for the "beginning of transaction" and "beginning of statement"). Only storage engines registered for the transaction/statement will know when to commit/rollback it.

Note
trans_register_ha is idempotent - storage engine may register many times per transaction.

Variable Documentation

◆ binlog_format_names

const char* binlog_format_names[]

◆ ha_row_type

const char* ha_row_type[]

◆ HTON_FKS_NEED_DIFFERENT_PARENT_AND_SUPPORTING_KEYS

const uint32 HTON_FKS_NEED_DIFFERENT_PARENT_AND_SUPPORTING_KEYS
static
Initial value:
=
(1 << 3)

Storage engine does not support using the same key for both parent and supporting key, but requires the two to be different.

◆ HTON_FKS_WITH_ANY_PREFIX_SUPPORTING_KEYS

const uint32 HTON_FKS_WITH_ANY_PREFIX_SUPPORTING_KEYS = (1 << 2)
static

Storage engine supports non-hash keys which have common prefix with the foreign key as supporting keys for it.

If there are several such keys, one which shares biggest prefix with FK is chosen.

Storage engines which support foreign keys but do not have this flag set are assumed to require that supporting key contains full foreign key as its prefix.

◆ HTON_FKS_WITH_PREFIX_PARENT_KEYS

const uint32 HTON_FKS_WITH_PREFIX_PARENT_KEYS = (1 << 0)
static

Engine supports both unique and non-unique parent keys for foreign keys which contain full foreign key as its prefix.

Storage engines which support foreign keys but do not have this flag set are assumed to support only parent keys which are primary/unique and contain exactly the same columns as the foreign key, possibly, in different order.

◆ HTON_FKS_WITH_SUPPORTING_HASH_KEYS

const uint32 HTON_FKS_WITH_SUPPORTING_HASH_KEYS = (1 << 1)
static

Storage engine supports hash keys as supporting keys for foreign keys.

Hash key should contain all foreign key columns and only them (altough in any order).

Storage engines which support foreign keys but do not have this flag set are assumed to not allow hash keys as supporting keys.

◆ MYSQL_START_TRANS_OPT_HIGH_PRIORITY

const uint MYSQL_START_TRANS_OPT_HIGH_PRIORITY = 8
static

◆ MYSQL_START_TRANS_OPT_READ_ONLY

const uint MYSQL_START_TRANS_OPT_READ_ONLY = 2
static

◆ MYSQL_START_TRANS_OPT_READ_WRITE

const uint MYSQL_START_TRANS_OPT_READ_WRITE = 4
static

◆ MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT

const uint MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT = 1
static

Options for the START TRANSACTION statement.

Note that READ ONLY and READ WRITE are logically mutually exclusive. This is enforced by the parser and depended upon by trans_begin().

We need two flags instead of one in order to differentiate between situation when no READ WRITE/ONLY clause were given and thus transaction is implicitly READ WRITE and the case when READ WRITE clause was used explicitly.

◆ savepoint_alloc_size

ulong savepoint_alloc_size

◆ total_ha_2pc

ulong total_ha_2pc

◆ tx_isolation_names

const char* tx_isolation_names[]

◆ tx_isolation_typelib

TYPELIB tx_isolation_typelib