MySQL 8.4.3
Source Code Documentation
|
#include <fcntl.h>
#include <float.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <random>
#include <set>
#include <string>
#include <string_view>
#include <mysql/components/services/bulk_data_service.h>
#include <mysql/components/services/page_track_service.h>
#include "ft_global.h"
#include "lex_string.h"
#include "map_helpers.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_bitmap.h"
#include "my_checksum.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_table_map.h"
#include "my_thread_local.h"
#include "mysql/components/services/bits/psi_table_bits.h"
#include "mysql/strings/m_ctype.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 "string_with_len.h"
#include "thr_lock.h"
#include "typelib.h"
Go to the source code of this file.
Classes | |
struct | sdi_key_t |
Key to identify a dictionary object. More... | |
struct | sdi_vector_t |
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... | |
class | Xa_state_list |
Class to maintain list of externally coordinated transactions and their current state at recovery. More... | |
struct | Clone_interface_t |
struct | SecondaryEngineGraphSimplificationRequestParameters |
struct | Page_track_t |
Page track interface. More... | |
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 to hold information about the table that should be created. More... | |
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 | Temp_table_handle |
class | DsMrr_impl |
class | ha_tablespace_statistics |
Namespaces | |
namespace | dd |
The version of the current data dictionary table definitions. | |
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_UNUSED18 |
Not in use. More... | |
#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 ... 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. 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_NO_INDEX_ACCESS (1LL << 54) |
The storage engine does not support using indexes for access. More... | |
#define | HA_MULTI_VALUED_KEY_SUPPORT (1LL << 55) |
Supports multi-valued index. 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_TABLE_SCAN_ON_NULL 32 |
#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 | HA_CREATE_USED_DEFAULT_ENCRYPTION (1L << 30) |
CREATE|ALTER SCHEMA|DATABASE has an explicit ENCRYPTION clause. 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 | HTON_SUPPORTS_TABLE_ENCRYPTION (1 << 16) |
Engine supports table or tablespace encryption . More... | |
#define | HTON_SECONDARY_ENGINE_SUPPORTS_DDL (1 << 19) |
Whether the secondary engine supports DDLs. More... | |
#define | HTON_NO_TRIGGER_SUPPORT (1 << 20) |
Whether the engine does not support triggers. More... | |
#define | HTON_SUPPORTS_EXTERNAL_SOURCE (1 << 21) |
Whether the primary engine supports external data sources. 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 |
using | sdi_container = std::vector< sdi_key_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 ulonglong | my_xid |
using | Xid_commit_list = std::unordered_set< my_xid, std::hash< my_xid >, std::equal_to< my_xid >, Mem_root_allocator< my_xid > > |
Single occurrence set of XIDs of internally coordinated transactions found as been committed in the transaction coordinator state. More... | |
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 void(* | reset_plugin_vars_t) (THD *thd) |
Some plugin session variables may require some special handling upon clean up. 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) |
using | recover_prepared_in_tc_t = int(*)(handlerton *hton, Xa_state_list &xa_list) |
Retrieves information about externally coordinated transactions for which the two-phase prepare was finished and transactions were prepared in the server TC. More... | |
using | set_prepared_in_tc_t = int(*)(handlerton *hton, THD *thd) |
Instructs the storage engine to mark the externally coordinated transactions held by the THD parameters as prepared in the server TC. More... | |
typedef xa_status_code(* | commit_by_xid_t) (handlerton *hton, XID *xid) |
typedef xa_status_code(* | rollback_by_xid_t) (handlerton *hton, XID *xid) |
using | set_prepared_in_tc_by_xid_t = xa_status_code(*)(handlerton *hton, XID *xid) |
Instructs the storage engine to mark the externally coordinated transactions identified by the XID parameters as prepared in the server TC. More... | |
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 bool(* | get_tablespace_type_by_name_t) (const char *tablespace_name, Tablespace_type *space_type) |
Get the tablespace type given the name, from the SE. More... | |
typedef int(* | fill_is_table_t) (handlerton *hton, THD *thd, Table_ref *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 void(* | acl_notify_t) (THD *thd, const class Acl_change_notification *notice) |
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) |
using | push_to_engine_t = int(*)(THD *thd, AccessPath *query, JOIN *join) |
Let storage engine inspect the query Accesspath and pick whatever it like for being pushed down to the engine. More... | |
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, sdi_vector_t &vector) |
Get the SDI keys in a tablespace into vector. More... | |
typedef bool(* | sdi_get_t) (const dd::Tablespace &tablespace, const 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 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 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(* | notify_rename_table_t) (THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, const char *old_db_name, const char *old_table_name, const char *new_db_name, const char *new_table_name) |
Notify/get permission from storage engine before or after execution of RENAME TABLE operation on the table identified by the MDL key. More... | |
typedef bool(* | notify_truncate_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 TRUNCATE 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(* | redo_log_set_state_t) (THD *thd, bool enable) |
Enable or Disable SE write ahead logging. 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) |
using | prepare_secondary_engine_t = bool(*)(THD *thd, LEX *lex) |
Prepare the secondary engine for executing a statement. More... | |
using | optimize_secondary_engine_t = bool(*)(THD *thd, LEX *lex) |
Optimize a statement for execution on a secondary storage engine. More... | |
using | compare_secondary_engine_cost_t = bool(*)(THD *thd, const JOIN &join, double optimizer_cost, bool *use_best_so_far, bool *cheaper, double *secondary_engine_cost) |
Compares the cost of two join plans in the secondary storage engine. More... | |
using | secondary_engine_modify_access_path_cost_t = bool(*)(THD *thd, const JoinHypergraph &hypergraph, AccessPath *access_path) |
Evaluates the cost of executing the given access path in this secondary storage engine, and potentially modifies the cost estimates that are in the access path. More... | |
using | external_engine_explain_check_t = bool(*)(THD *thd) |
Checks whether the tables used in an explain query are loaded in the secondary engine. More... | |
using | get_secondary_engine_offload_or_exec_fail_reason_t = std::string_view(*)(const THD *thd) |
Looks up and returns a specific secondary engine query offload or exec failure reason as a string given a thread context (representing the query) when the offloaded query fails in the secondary storage engine. More... | |
using | find_secondary_engine_offload_fail_reason_t = std::string_view(*)(THD *thd) |
Finds and returns a specific secondary engine query offload failure reason as a string given a thread context (representing the query) whenever get_secondary_engine_offload_or_exec_fail_reason_t returns an empty reason. More... | |
using | set_secondary_engine_offload_fail_reason_t = bool(*)(const THD *thd, std::string_view reason) |
Sets a specific secondary engine offload failure reason for a query represented by the thread context when the offloaded query fails in the secondary storage engine. More... | |
using | secondary_engine_check_optimizer_request_t = SecondaryEngineGraphSimplificationRequestParameters(*)(THD *thd, const JoinHypergraph &hypergraph, const AccessPath *access_path, int current_subgraph_pairs, int current_subgraph_pairs_limit, bool is_root_access_path, std::string *trace) |
Hook for secondary engine to evaluate the current hypergraph optimization state, and returns the state that hypergraph should transition to. More... | |
using | SecondaryEngineFlags = uint64_t |
using | se_before_commit_t = void(*)(void *arg) |
using | se_after_commit_t = void(*)(void *arg) |
using | se_before_rollback_t = void(*)(void *arg) |
using | notify_after_select_t = void(*)(THD *thd, SelectExecutedIn executed_in) |
Notify plugins when a SELECT query was executed. More... | |
using | notify_create_table_t = void(*)(struct HA_CREATE_INFO *create_info, const char *db, const char *table_name) |
Notify plugins when a table is created. More... | |
using | secondary_engine_pre_prepare_hook_t = bool(*)(THD *thd) |
Secondary engine hook called after PRIMARY_TENTATIVELY optimization is complete, and decides if secondary engine optimization will be performed, and comparison of primary engine cost and secondary engine cost will determine which engine to use for execution. More... | |
using | notify_drop_table_t = void(*)(Table_ref *tab) |
Notify plugins when a table is dropped. More... | |
using | page_track_start_t = int(*)(uint64_t *start_id) |
Start page tracking. More... | |
using | page_track_stop_t = int(*)(uint64_t *stop_id) |
Stop page tracking. More... | |
using | page_track_purge_t = int(*)(uint64_t *purge_id) |
Purge page tracking data. More... | |
using | page_track_get_page_ids_t = int(*)(Page_Track_Callback cbk_func, void *cbk_ctx, uint64_t *start_id, uint64_t *stop_id, unsigned char *buffer, size_t buffer_len) |
Fetch tracked pages. More... | |
using | page_track_get_num_page_ids_t = int(*)(uint64_t *start_id, uint64_t *stop_id, uint64_t *num_pages) |
Fetch approximate number of tracked pages in the given range. More... | |
using | page_track_get_status_t = void(*)(std::vector< std::pair< uint64_t, bool > > &status) |
Fetch the status of the page tracking system. More... | |
typedef void * | range_seq_t |
typedef bool | Log_func(THD *, TABLE *, bool, const uchar *, const uchar *) |
Functions | |
st_plugin_int * | hton2plugin (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_int * | insert_hton2plugin (uint slot, st_plugin_int *plugin) |
For unit testing. More... | |
st_plugin_int * | remove_hton2plugin (uint slot) |
void | set_externally_disabled_storage_engine_names (const char *) |
Read a comma-separated list of storage engine names. More... | |
bool | ha_is_externally_disabled (const handlerton &) |
Returns true if the storage engine of the handlerton argument has been listed in the disabled_storage_engines system variable. More... | |
constexpr SecondaryEngineFlags | MakeSecondaryEngineFlags () |
Creates an empty bitmap of access path types. More... | |
template<typename... Args> | |
constexpr SecondaryEngineFlags | MakeSecondaryEngineFlags (SecondaryEngineFlag flag1, Args... rest) |
Creates a bitmap representing a set of access path types. More... | |
const handlerton * | SecondaryEngineHandlerton (const THD *thd) |
Returns the handlerton of the secondary engine that is used in the session, or nullptr if a secondary engine is not used. More... | |
bool | secondary_engine_supports_ddl (const handlerton *hton) |
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... | |
handlerton * | ha_default_handlerton (THD *thd) |
Return the default storage engine handlerton used for non-temp tables for thread. More... | |
handlerton * | ha_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_CSTRING *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) |
handlerton * | ha_resolve_by_legacy_type (THD *thd, enum legacy_db_type db_type) |
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. More... | |
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. More... | |
bool | ha_secondary_engine_supports_ddl (THD *thd, const LEX_CSTRING &secondary_engine) noexcept |
handlerton * | get_default_handlerton (THD *thd, handlerton *hton) |
Get default handlerton, if handler supplied is null. 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) |
bool | ha_storage_engine_is_enabled (const handlerton *db_type) |
Predicate to determine if a storage engine, represented by a handlerton*, is enabled. More... | |
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) |
TYPELIB * | ha_known_exts () |
int | ha_panic (enum ha_panic_function flag) |
void | ha_reset_plugin_vars (THD *thd) |
void | ha_close_connection (THD *thd) |
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) |
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 (std::string_view 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_recover (Xid_commit_list *commit_list=nullptr, Xa_state_list *xa_state_list=nullptr) |
Stage of the recovery process where information is collected from the storage engines (SE), merged with information from the transaction coordinator (TC) and transactions states are determined and enforced. More... | |
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) |
Prepares the underlying transaction of the THD session object parameter in the storage engines that participate in the transaction. More... | |
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) |
void | trans_register_ha (THD *thd, bool all, handlerton *ht, const ulonglong *trxid) |
Register a storage engine for a transaction. More... | |
int | ha_reset_logs (THD *thd) |
int | ha_binlog_index_purge_file (THD *thd, const char *file) |
Inform storage engine(s) that a binary log file will be purged and any references to it should be removed. More... | |
void | ha_binlog_index_purge_wait (THD *thd) |
Request the storage engine to complete any operations that were initiated by ha_binlog_index_purge_file and which need to complete before PURGE BINARY LOGS completes. More... | |
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_acl_notify (THD *thd, class Acl_change_notification *) |
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, const char *org_table_name) |
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, const char *org_table_name) |
Construct and emit duplicate key error message using information from table's record buffer. More... | |
void | print_keydup_error (TABLE *table, KEY *key, const char *msg, myf errflag) |
void | print_keydup_error (TABLE *table, KEY *key, myf errflag) |
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_table_ddl (THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, ha_ddl_type ddl_type, const char *old_db_name, const char *old_table_name, const char *new_db_name, const char *new_table_name) |
Notify/get permission from all interested storage engines before or after executed DDL (ALTER TABLE, RENAME TABLE, TRUNCATE TABLE) on the table identified by key. More... | |
std::pair< int, bool > | commit_owned_gtids (THD *thd, bool all) |
The function computes condition to call gtid persistor wrapper, and executes it. 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... | |
bool | is_index_access_error (int error) |
Check whether an error is index access error or not after an index read. More... | |
Variables | |
constexpr const ha_rows | EXTRA_RECORDS {10} |
constexpr const uint32 | SDI_TYPE_TABLE = 1 |
Id for identifying Table SDIs. More... | |
constexpr const uint32 | SDI_TYPE_TABLESPACE = 2 |
Id for identifying Tablespace SDIs. More... | |
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 |
constexpr const uint64_t | HA_CREATE_USED_START_TRANSACTION {1ULL << 31} |
This option is used to convey that the create table should not commit the operation and keep the transaction started. More... | |
constexpr const uint64_t | HA_CREATE_USED_ENGINE_ATTRIBUTE {1ULL << 32} |
constexpr const uint64_t | HA_CREATE_USED_SECONDARY_ENGINE_ATTRIBUTE {1ULL << 33} |
constexpr const uint64_t | HA_CREATE_USED_READ_ONLY {1ULL << 34} |
ALTER SCHEMA|DATABASE has an explicit READ_ONLY clause. More... | |
constexpr const uint64_t | HA_CREATE_USED_AUTOEXTEND_SIZE {1ULL << 35} |
These flags convey that the options AUTOEXTEND_SIZE has been specified in the CREATE TABLE statement. More... | |
constexpr const decltype(handlerton::flags) | HTON_SUPPORTS_ENGINE_ATTRIBUTE |
constexpr const decltype(handlerton::flags) | HTON_SUPPORTS_GENERATED_INVISIBLE_PK {1 << 18} |
Engine supports Generated invisible primary key. More... | |
constexpr const decltype(handlerton::flags) | HTON_SUPPORTS_BULK_LOAD {1 << 22} |
constexpr const decltype(handlerton::flags) | HTON_SUPPORTS_DISTANCE_SCAN |
Engine supports index distance scan. More... | |
constexpr const decltype(handlerton::flags) | HTON_NO_DEFAULT_ENGINE_SUPPORT {1 << 24} |
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... | |
static const uint32 | HTON_FKS_WITH_EXTENDED_PARENT_KEYS = (1 << 4) |
Engine takes into account hidden part of key (coming from primary key) when determines if it can serve as parent key for a foreign key. More... | |
static const size_t | MAX_FK_NAME_SUFFIX_LENGTH = 16 |
Maximum possible length of SE-specific suffixes for auto-generated foreign key names. More... | |
static const LEX_CSTRING | FK_NAME_DEFAULT_SUFFIX = {STRING_WITH_LEN("_fk_")} |
Suffix for auto-generated foreign key names for tables in SE's which don't specify own suffix. More... | |
#define COMPATIBLE_DATA_NO 1 |
#define COMPATIBLE_DATA_YES 0 |
#define HA_ABORT_IF_LOCKED 128 /* skip if locked on open.*/ |
#define HA_ADMIN_ALREADY_DONE 1 |
#define HA_ADMIN_CORRUPT -3 |
#define HA_ADMIN_FAILED -2 |
#define HA_ADMIN_INTERNAL_ERROR -4 |
#define HA_ADMIN_INVALID -5 |
#define HA_ADMIN_NEEDS_ALTER -11 |
#define HA_ADMIN_NEEDS_CHECK -12 |
#define HA_ADMIN_NEEDS_DUMP_UPGRADE -14 |
User needs to dump and re-create table to fix pre 5.0 decimal types.
#define HA_ADMIN_NEEDS_UPGRADE -10 |
#define HA_ADMIN_NOT_BASE_TABLE -9 |
#define HA_ADMIN_NOT_IMPLEMENTED -1 |
#define HA_ADMIN_OK 0 |
#define HA_ADMIN_REJECT -6 |
#define HA_ADMIN_STATS_UPD_ERR -13 |
#define HA_ADMIN_TRY_ALTER -7 |
#define HA_ADMIN_WRONG_CHECKSUM -8 |
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30) |
#define HA_ATTACHABLE_TRX_COMPATIBLE (1LL << 45) |
A storage engine is compatible with the attachable transaction requirements means that.
#define HA_AUTO_PART_KEY (1 << 11) |
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE) |
#define HA_BINLOG_ROW_CAPABLE (1LL << 34) |
#define HA_BINLOG_STMT_CAPABLE (1LL << 35) |
#define HA_BLOB_PARTIAL_UPDATE (1LL << 49) |
Supports partial update of BLOB columns.
#define HA_BLOCK_CONST_TABLE (1LL << 42) |
#define HA_BLOCK_LOCK 256 /* unlock when reading some records */ |
#define HA_CAN_BIT_FIELD (1 << 28) |
#define HA_CAN_EXPORT (1LL << 41) |
#define HA_CAN_FULLTEXT (1 << 21) |
#define HA_CAN_FULLTEXT_EXT (1LL << 39) |
#define HA_CAN_FULLTEXT_HINTS (1LL << 43) |
#define HA_CAN_GEOMETRY (1 << 4) |
#define HA_CAN_INDEX_BLOBS (1 << 10) |
#define HA_CAN_INDEX_VIRTUAL_GENERATED_COLUMN (1LL << 47) |
Supports index on virtual generated column.
#define HA_CAN_REPAIR (1LL << 37) |
#define HA_CAN_RTREEKEYS (1 << 17) |
#define HA_CAN_SQL_HANDLER (1 << 22) |
#define HA_COUNT_ROWS_INSTANT (1LL << 32) /* records() gives exact count*/ |
#define HA_CREATE_USED_AUTO (1L << 0) |
#define HA_CREATE_USED_AVG_ROW_LENGTH (1L << 6) |
#define HA_CREATE_USED_CHARSET (1L << 8) |
#define HA_CREATE_USED_CHECKSUM (1L << 13) |
#define HA_CREATE_USED_COMMENT (1L << 16) |
#define HA_CREATE_USED_COMPRESS (1L << 26) |
COMPRESSION="zlib|lz4|none" used during table create.
#define HA_CREATE_USED_CONNECTION (1L << 18) |
#define HA_CREATE_USED_DATADIR (1L << 10) |
#define HA_CREATE_USED_DEFAULT_CHARSET (1L << 9) |
#define HA_CREATE_USED_DEFAULT_COLLATE (1L << 28) |
CREATE|ALTER SCHEMA|DATABASE|TABLE has an explicit COLLATE clause.
Implies HA_CREATE_USED_DEFAULT_CHARSET.
#define HA_CREATE_USED_DEFAULT_ENCRYPTION (1L << 30) |
CREATE|ALTER SCHEMA|DATABASE has an explicit ENCRYPTION clause.
Implies HA_CREATE_USED_DEFAULT_ENCRYPTION.
#define HA_CREATE_USED_DELAY_KEY_WRITE (1L << 14) |
#define HA_CREATE_USED_ENCRYPT (1L << 27) |
ENCRYPTION="Y" used during table create.
#define HA_CREATE_USED_ENGINE (1L << 12) |
#define HA_CREATE_USED_INDEXDIR (1L << 11) |
#define HA_CREATE_USED_INSERT_METHOD (1L << 3) |
#define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19) |
#define HA_CREATE_USED_MAX_ROWS (1L << 5) |
#define HA_CREATE_USED_MIN_ROWS (1L << 4) |
#define HA_CREATE_USED_PACK_KEYS (1L << 7) |
#define HA_CREATE_USED_PAGE_CHECKSUM (1L << 21) |
Unused.
Reserved for future versions.
#define HA_CREATE_USED_PASSWORD (1L << 17) |
#define HA_CREATE_USED_RAID (1L << 1) |
#define HA_CREATE_USED_ROW_FORMAT (1L << 15) |
#define HA_CREATE_USED_SECONDARY_ENGINE (1L << 29) |
SECONDARY_ENGINE used during table create.
#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.
#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.
#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.
#define HA_CREATE_USED_TABLESPACE (1L << 25) |
This is set whenever a 'TABLESPACE=...' phrase is used on CREATE TABLE.
#define HA_CREATE_USED_TRANSACTIONAL (1L << 20) |
Unused.
Reserved for future versions.
#define HA_CREATE_USED_UNION (1L << 2) |
#define HA_DELETE_NOT_SUPPORTED (1LL << 53) |
Handlers with this flag set do not support DELETE operations.
#define HA_DESCENDING_INDEX (1LL << 48) |
Supports descending indexes.
#define HA_DO_INDEX_COND_PUSHDOWN 256 /* Supports Index Condition Pushdown */ |
#define HA_DUPLICATE_KEY_NOT_IN_ORDER (1LL << 36) |
#define HA_DUPLICATE_POS (1 << 8) |
#define HA_FAST_KEY_READ (1 << 5) |
#define HA_FILE_BASED (1 << 26) |
#define HA_GENERATED_COLUMNS (1LL << 46) |
Handler supports Generated Columns.
#define HA_GET_INDEX 4 |
#define HA_GET_INFO 8 /* do a handler::info() after open */ |
#define HA_HAS_CHECKSUM (1 << 24) |
#define HA_HAS_OWN_BINLOGGING (1LL << 33) |
#define HA_KEY_BLOB_LENGTH 2 |
#define HA_KEY_NULL_LENGTH 1 |
#define HA_KEY_SCAN_NOT_ROR 128 |
#define HA_KEY_SWITCH_ALL 1 |
#define HA_KEY_SWITCH_ALL_SAVE 3 |
#define HA_KEY_SWITCH_NONUNIQ 0 |
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2 |
#define HA_KEYREAD_ONLY 64 |
#define HA_LEX_CREATE_IF_NOT_EXISTS 2 |
#define HA_LEX_CREATE_INTERNAL_TMP_TABLE 8 |
#define HA_LEX_CREATE_TABLE_LIKE 4 |
#define HA_LEX_CREATE_TMP_TABLE 1 |
#define HA_MAX_REC_LENGTH 65535U |
#define HA_MRR_FIXED_KEY 2 |
#define HA_MRR_INDEX_ONLY 16 |
#define HA_MRR_LIMITS 32 |
#define HA_MRR_NO_ASSOCIATION 4 |
#define HA_MRR_NO_NULL_ENDPOINTS 128 |
#define HA_MRR_SINGLE_POINT 1 |
#define HA_MRR_SORTED 8 |
#define HA_MRR_SUPPORT_SORTED 256 |
#define HA_MRR_USE_DEFAULT_IMPL 64 |
#define HA_MULTI_VALUED_KEY_SUPPORT (1LL << 55) |
Supports multi-valued index.
#define HA_NO_AUTO_INCREMENT (1 << 23) |
#define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */ |
#define HA_NO_COPY_ON_ALTER (1LL << 31) |
#define HA_NO_INDEX_ACCESS (1LL << 54) |
The storage engine does not support using indexes for access.
Indexes can only be used for estimating cost.
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20) |
#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.
#define HA_NO_TRANSACTIONS (1 << 0) /* Doesn't support transactions */ |
#define HA_NO_VARCHAR (1 << 27) |
#define HA_NULL_IN_KEY (1 << 7) |
#define HA_ONLY_WHOLE_INDEX 16 |
#define HA_OPEN_KEYFILE 1 |
#define HA_OPEN_RNDFILE 2 |
#define HA_OPEN_TEMPORARY 512 |
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */ |
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15) |
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19) |
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16) |
#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 }
#define HA_READ_NEXT 1 /* TODO really use this flag */ |
#define HA_READ_ORDER 4 |
#define HA_READ_OUT_OF_SYNC (1LL << 40) |
#define HA_READ_PREV 2 |
#define HA_READ_RANGE 8 |
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) |
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6) |
#define HA_SLOT_UNDEF ((uint)-1) |
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) |
#define HA_SUPPORTS_DEFAULT_EXPRESSION (1LL << 51) |
Handler supports expressions as DEFAULT for a 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.
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) |
#define HA_TABLE_SCAN_ON_NULL 32 |
#define HA_TRY_READ_ONLY 32 |
#define HA_UNUSED14 (1 << 14) |
Not in use.
#define HA_UNUSED18 |
Not in use.
#define HA_UNUSED3 (1 << 3) |
Not in use.
#define HA_UPDATE_NOT_SUPPORTED (1LL << 52) |
Handlers with this flag set do not support UPDATE operations.
#define HA_WAIT_IF_LOCKED 64 /* Wait if locked on open */ |
#define HTON_ALTER_NOT_SUPPORTED (1 << 1) |
#define HTON_CAN_RECREATE (1 << 2) |
#define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0) |
#define HTON_HIDDEN (1 << 3) |
#define HTON_IS_SECONDARY_ENGINE (1 << 14) |
Engine is a secondary storage engine.
#define HTON_NO_BINLOG_ROW_OPT (1 << 9) |
#define HTON_NO_FLAGS 0 |
#define HTON_NO_PARTITION (1 << 8) |
#define HTON_NO_TRIGGER_SUPPORT (1 << 20) |
Whether the engine does not support triggers.
#define HTON_NOT_USER_SELECTABLE (1 << 5) |
#define HTON_SECONDARY_ENGINE_SUPPORTS_DDL (1 << 19) |
Whether the secondary engine supports DDLs.
No meaning if the engine is not secondary.
#define HTON_SUPPORT_LOG_TABLES (1 << 7) |
#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.
#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.
#define HTON_SUPPORTS_EXTERNAL_SOURCE (1 << 21) |
Whether the primary engine supports external data sources.
This case refers to having tables with data in object store and the engine does not store any of those data, only metadata. Table contents can be accessed only after loading the table in the secondary storage engine. The flag is used for a primary engine only.
#define HTON_SUPPORTS_FOREIGN_KEYS (1 << 11) |
#define HTON_SUPPORTS_PACKED_KEYS (1 << 13) |
#define HTON_SUPPORTS_SECONDARY_ENGINE (1 << 15) |
Engine supports secondary storage engines.
#define HTON_SUPPORTS_TABLE_ENCRYPTION (1 << 16) |
Engine supports table or tablespace encryption .
#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) |
#define make_keypart_map | ( | N | ) | (((key_part_map)2 << (N)) - 1) |
#define make_prev_keypart_map | ( | N | ) | (((key_part_map)1 << (N)) - 1) |
#define MAXBQUALSIZE 64 |
#define MAXGTRIDSIZE 64 |
#define UNDEF_NODEGROUP 65535 |
typedef void(* acl_notify_t) (THD *thd, const class Acl_change_notification *notice) |
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.
hton | Hadlerton of the SE. | |
thd | Thread context. | |
ts_info | Description of tablespace and specific operation on it. | |
old_ts_def | dd::Tablespace object describing old version of tablespace. | |
[in,out] | new_ts_def | dd::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. |
== | 0 Success. |
!= | 0 Error (handler error code returned). |
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 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.
child_column_type | Child column type description. |
parent_column_type | Parent column type description. |
check_charsets | Indicates whether we need to check that charsets of string columns match. Which is true in most cases. |
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.
[in] | hton | handlerton for SE |
[in] | thd | server thread handle |
[in] | loc | locator |
[in] | loc_len | locator length in bytes |
[in] | task_id | task identifier |
[in] | in_err | inform any error occurred |
[in] | cbk | callback interface |
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.
[in] | hton | handlerton for SE |
[in] | thd | server thread handle |
[in,out] | loc | locator |
[in,out] | loc_len | locator length |
[in] | task_id | task identifier |
[in] | mode | mode for starting clone |
[in] | data_dir | target data directory |
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.
[in] | hton | handlerton for SE |
[in] | thd | server thread handle |
[in] | loc | locator |
[in] | loc_len | locator length in bytes |
[in] | task_id | task identifier |
[in] | in_err | error code when ending after error |
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.
[in] | hton | handlerton for SE |
[in] | thd | server thread handle |
[in] | loc | locator |
[in] | loc_len | locator length in bytes |
[in] | task_id | task identifier |
[in] | in_err | inform any error occurred |
[in] | cbk | callback interface for receiving data |
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.
[in] | hton | handlerton for SE |
[in] | thd | server thread handle |
[in,out] | loc | locator |
[in,out] | loc_len | locator length |
[out] | task_id | task identifier |
[in] | type | clone type |
[in] | mode | mode for starting clone |
using Clone_capability_t = void (*)(Ha_clone_flagset &flags) |
Get capability flags for clone operation.
[out] | flags | capability flag |
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.
[in] | hton | handlerton for SE |
[in] | thd | server thread handle |
[in] | loc | locator |
[in] | loc_len | locator length in bytes |
[in] | task_id | task identifier |
[in] | cbk | callback interface for sending data |
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.
[in] | hton | handlerton for SE |
[in] | thd | server thread handle |
[in] | loc | locator |
[in] | loc_len | locator length in bytes |
[in] | task_id | task identifier |
[in] | in_err | error code when ending after error |
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
typedef bool(* collect_hton_log_info_t) (handlerton *hton, Json_dom *json) |
Collect a handlerton (resource) log information.
typedef xa_status_code(* commit_by_xid_t) (handlerton *hton, XID *xid) |
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.
using compare_secondary_engine_cost_t = bool (*)(THD *thd, const JOIN &join, double optimizer_cost, bool *use_best_so_far, bool *cheaper, double *secondary_engine_cost) |
Compares the cost of two join plans in the secondary storage engine.
The cost of the current candidate is compared with the cost of the best plan seen so far.
thd | thread context | |
join | the candidate plan to evaluate | |
optimizer_cost | the cost estimate calculated by the optimizer | |
[out] | use_best_so_far | true if the optimizer should stop searching for a better plan and use the best plan it has seen so far |
[out] | cheaper | true if the candidate is the best plan seen so far for this JOIN (must be true if it is the first plan seen), false otherwise |
[out] | secondary_engine_cost | the cost estimated by the secondary engine |
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.
hton | Handlerton object for the storage engine. |
table | TABLE_SHARE for the table, can be NULL if caller didn't perform full-blown open of table definition. |
partitioned | Indicates whether table is partitioned. |
mem_root | Memory root to be used for allocating handler object. |
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_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.
schema_name | Schema name. |
table_name | Table name. |
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.
typedef bool(* dict_get_server_version_t) (uint *version) |
Get the server version id stored in the header of the dictionary tablespace.
[out] | version | Version number from the DD tablespace header. |
Operation | outcome, false if no error, otherwise true. |
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.
dict_init_mode | How to initialize files | |
version | Target DD version if a new server is being installed. 0 if restarting an existing server. | |
[out] | DDSE_tables | List of SQL DDL statements for creating DD tables that are needed by the DDSE. |
[out] | DDSE_tablespaces | List of meta data for predefined tablespaces created by the DDSE. |
true | An error occurred. |
false | Success - no errors. |
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.
dict_recovery_mode | How to do recovery |
version | Target DD version if a new server is being installed. Actual DD version if restarting an existing server. |
true | An error occurred. |
false | Success - no errors. |
typedef void(* dict_register_dd_table_id_t) (dd::Object_id hard_coded_tables) |
Initialize the set of hard coded DD table ids.
typedef bool(* dict_set_server_version_t) () |
Store the current server version number into the header of the dictionary tablespace.
Operation | outcome, false if no error, otherwise true. |
typedef int(* discover_t) (handlerton *hton, THD *thd, const char *db, const char *name, uchar **frmblob, size_t *frmlen) |
typedef void(* drop_database_t) (handlerton *hton, char *path) |
using external_engine_explain_check_t = bool (*)(THD *thd) |
Checks whether the tables used in an explain query are loaded in the secondary engine.
thd | thread context. |
true | if there is a table not loaded to the secondary engine, false otherwise |
typedef int(* fill_is_table_t) (handlerton *hton, THD *thd, Table_ref *tables, class Item *cond, enum enum_schema_tables) |
typedef int(* find_files_t) (handlerton *hton, THD *thd, const char *db, const char *path, const char *wild, bool dir, List< LEX_STRING > *files) |
using find_secondary_engine_offload_fail_reason_t = std::string_view (*)(THD *thd) |
Finds and returns a specific secondary engine query offload failure reason as a string given a thread context (representing the query) whenever get_secondary_engine_offload_or_exec_fail_reason_t returns an empty reason.
thd | thread context. |
std::string_view | as the offload failure reason. |
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.
thd | Thread context |
failed_upgrade | True if the upgrade failed. |
== | 0 Success. |
!= | 0 Error (handler error code returned) |
typedef bool(* flush_logs_t) (handlerton *hton, bool binlog_group_flush) |
Flush the log(s) of storage engine(s).
hton | Handlerton of storage engine. |
binlog_group_flush | true if we got invoked by binlog group commit during flush stage, false in other cases. |
false | Succeed |
true | Error |
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.
storage_category | the storage type that the cost constants will be used for |
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.
db_name | Name of schema | |
table_name | Name of table | |
index_name | Name of index | |
index_ordinal_position | Position of index. | |
column_ordinal_position | Position of column in index. | |
se_private_id | SE private id of the table. | |
[out] | cardinality | cardinality being returned by SE. |
using get_secondary_engine_offload_or_exec_fail_reason_t = std::string_view (*)(const THD *thd) |
Looks up and returns a specific secondary engine query offload or exec failure reason as a string given a thread context (representing the query) when the offloaded query fails in the secondary storage engine.
thd | thread context. |
std::string_view | as the offload failure reason. The memory pointed to is managed by the handlerton and may be freed when the statement completes. |
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.
db_name | Name of schema | |
table_name | Name of table | |
se_private_id | SE private id of the table. | |
ts_se_private_data | Tablespace SE private data. | |
tbl_se_private_data | Table SE private data. | |
flags | Type of statistics to retrieve. | |
[out] | stats | Contains statistics read from SE. |
typedef const char *(* get_tablespace_filename_ext_t) () |
SE interface for getting tablespace extension.
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.
tablespace_name | Tablespace_name | |
file_name | Tablespace file name. | |
ts_se_private_data | Tablespace SE private data. | |
[out] | stats | Contains tablespace statistics read from SE. |
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.
thd | Thread context. | |
db_name | Name of the relevant schema. | |
table_name | Name of the relevant table. | |
[out] | tablespace_name | Name of the tablespace containing the table. |
== | 0 Success. |
!= | 0 Error (handler error code returned). |
typedef bool(* get_tablespace_type_by_name_t) (const char *tablespace_name, Tablespace_type *space_type) |
Get the tablespace type given the name, from the SE.
[in] | tablespace_name | tablespace name |
[out] | space_type | type of space |
false | on success and true for failure. |
typedef bool(* get_tablespace_type_t) (const dd::Tablespace &space, Tablespace_type *space_type) |
Get the tablespace type from the SE.
[in] | space | tablespace object |
[out] | space_type | type of space |
false | on success and true for failure. |
using Ha_clone_flagset = std::bitset<HA_CLONE_TYPE_MAX> |
typedef bool(* is_dict_readonly_t) () |
Check if the DDSE is started in a way that leaves thd DD being read only.
true | The data dictionary can only be read. |
false | The data dictionary can be read and written. |
typedef bool(* is_reserved_db_name_t) (handlerton *hton, const char *name) |
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.
db | Database name to check. |
table_name | table name to check. |
is_sql_layer_system_table | if the supplied db.table_name is a SQL layer system table. |
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.
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.
ts_cmd | Purpose of usage - is this tablespace DDL? |
tablespace_name | Name of the tablespace. |
Whether | the tablespace name is valid. |
typedef void(* kill_connection_t) (handlerton *hton, THD *thd) |
Terminate connection/statement notification.
typedef bool(* lock_hton_log_t) (handlerton *hton) |
Lock a handlerton (resource) log to collect log information.
using notify_after_select_t = void (*)(THD *thd, SelectExecutedIn executed_in) |
Notify plugins when a SELECT query was executed.
The plugins will be notified only if the query is not considered secondary engine relevant, i.e.:
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.
thd | Thread context. |
mdl_key | MDL key identifying table which is going to be or was ALTERed. |
notification_type | Indicates whether this is pre-ALTER TABLE or post-ALTER TABLE notification. |
using notify_create_table_t = void (*)(struct HA_CREATE_INFO *create_info, const char *db, const char *table_name) |
Notify plugins when a table is created.
using notify_drop_table_t = void (*)(Table_ref *tab) |
Notify plugins when a table is dropped.
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.
thd | Thread context. |
mdl_key | MDL key identifying object on which exclusive lock is to be acquired/was released. |
notification_type | Indicates 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. |
typedef bool(* notify_rename_table_t) (THD *thd, const MDL_key *mdl_key, ha_notification_type notification_type, const char *old_db_name, const char *old_table_name, const char *new_db_name, const char *new_table_name) |
Notify/get permission from storage engine before or after execution of RENAME TABLE operation on the table identified by the MDL key.
thd | Thread context. |
mdl_key | MDL key identifying table which is going to be or was RENAMEd. |
notification_type | Indicates whether this is pre-RENAME TABLE or post-RENAME TABLE notification. |
old_db_name | old db name |
old_table_name | old table name |
new_db_name | new db name |
new_table_name | new table name |
typedef bool(* notify_truncate_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 TRUNCATE TABLE operation on the table identified by the MDL key.
thd | Thread context. |
mdl_key | MDL key identifying table which is going to be or was TRUNCATEd. |
notification_type | Indicates whether this is pre-TRUNCATE TABLE or post-TRUNCATE TABLE notification. |
using optimize_secondary_engine_t = bool (*)(THD *thd, LEX *lex) |
Optimize a statement for execution on a secondary storage engine.
This function is called when the optimization of a statement has completed, just before the statement is executed. Secondary engines can use this function to apply engine-specific optimizations to the execution plan. They can also reject executing the query by raising an error, in which case the query will be reprepared and executed by the primary storage engine.
thd | thread context |
lex | the statement being optimized |
using page_track_get_num_page_ids_t = int (*)(uint64_t *start_id, uint64_t *stop_id, uint64_t *num_pages) |
Fetch approximate number of tracked pages in the given range.
[in,out] | start_id | SE specific sequence number [LSN for InnoDB] from where the pages tracked would be returned. |
[in,out] | stop_id | SE specific sequence number [LSN for InnoDB] until where the pages tracked would be returned. |
[out] | num_pages | number of pages tracked |
0 | Success |
other | ER_* mysql error. Get error details from THD. |
using page_track_get_page_ids_t = int (*)(Page_Track_Callback cbk_func, void *cbk_ctx, uint64_t *start_id, uint64_t *stop_id, unsigned char *buffer, size_t buffer_len) |
Fetch tracked pages.
[in] | cbk_func | callback function return page IDs |
[in] | cbk_ctx | caller's context for callback |
[in,out] | start_id | SE specific sequence number [LSN for InnoDB] from where the pages tracked would be returned. |
[in,out] | stop_id | SE specific sequence number [LSN for InnoDB] until where the pages tracked would be returned. |
[out] | buffer | allocated buffer to copy page IDs |
[in] | buffer_len | length of buffer in bytes |
0 | Success |
other | ER_* mysql error. Get error details from THD. |
using page_track_get_status_t = void (*)(std::vector<std::pair<uint64_t, bool> > &status) |
Fetch the status of the page tracking system.
[out] | status | vector of a pair of (ID, bool) where ID is the start/stop point and bool is true if the ID is a start point else false |
using page_track_purge_t = int (*)(uint64_t *purge_id) |
Purge page tracking data.
[in,out] | purge_id | SE specific sequence number [LSN for InnoDB] initially indicating till where the data needs to be purged and finally updated to until where it was actually purged |
0 | Success |
other | ER_* mysql error. Get error details from THD. |
using page_track_start_t = int (*)(uint64_t *start_id) |
Start page tracking.
[out] | start_id | SE specific sequence number [LSN for InnoDB] indicating when the tracking was started |
0 | Success |
other | ER_* mysql error. Get error details from THD. |
using page_track_stop_t = int (*)(uint64_t *stop_id) |
Stop page tracking.
[out] | stop_id | SE specific sequence number [LSN for InnoDB] indicating when the tracking was stopped |
0 | Success |
other | ER_* mysql error. Get error details from THD. |
typedef int(* panic_t) (handlerton *hton, enum ha_panic_function flag) |
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.
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).
typedef void(* post_recover_t) (void) |
Perform SE-specific cleanup after recovery of transactions.
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.
using prepare_secondary_engine_t = bool (*)(THD *thd, LEX *lex) |
Prepare the secondary engine for executing a statement.
This function is called right after the secondary engine TABLE objects have been opened by open_secondary_engine_tables(), before the statement is optimized and executed. Secondary engines will typically create a context object in this function, which they can use to store state that is needed during the optimization and execution phases.
thd | thread context |
lex | the statement to execute |
typedef int(* prepare_t) (handlerton *hton, THD *thd, bool all) |
using push_to_engine_t = int (*)(THD *thd, AccessPath *query, JOIN *join) |
Let storage engine inspect the query Accesspath and pick whatever it like for being pushed down to the engine.
(Join, conditions, ..)
The handler implementation should itself keep track of what it 'pushed', such that later calls to the handlers access methods should activate the pushed parts of the execution plan on the storage engines.
thd | Thread context |
query | The AccessPath for the entire query. |
join | The JOIN to be pushed |
typedef bool(* qc_engine_callback) (THD *thd, const char *table_key, uint key_length, ulonglong *engine_data) |
typedef void* range_seq_t |
using recover_prepared_in_tc_t = int (*)(handlerton *hton, Xa_state_list &xa_list) |
Retrieves information about externally coordinated transactions for which the two-phase prepare was finished and transactions were prepared in the server TC.
typedef int(* recover_t) (handlerton *hton, XA_recover_txn *xid_list, uint len, MEM_ROOT *mem_root) |
typedef bool(* redo_log_set_state_t) (THD *thd, bool enable) |
Enable or Disable SE write ahead logging.
[in] | thd | server thread handle |
[in] | enable | enable/disable redo logging |
typedef void(* replace_native_transaction_in_thd_t) (THD *thd, void *new_trx_arg, void **ptr_trx_arg) |
[in,out] | thd | pointer to THD |
[in] | new_trx_arg | pointer to replacement transaction |
[out] | ptr_trx_arg | double 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.
typedef void(* reset_plugin_vars_t) (THD *thd) |
Some plugin session variables may require some special handling upon clean up.
Reset appropriately these variables before ending the THD connection
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.
[in] | hton | Handlerton for storage engine. |
[in] | thd | Thread context. |
[in,out] | files | List 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. |
typedef xa_status_code(* rollback_by_xid_t) (handlerton *hton, XID *xid) |
typedef int(* rollback_t) (handlerton *hton, THD *thd, bool all) |
typedef bool(* rotate_encryption_master_key_t) (void) |
Initiate master key rotation.
typedef int(* savepoint_release_t) (handlerton *hton, THD *thd, void *sv) |
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.
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
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)
using sdi_container = std::vector<sdi_key_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().
[in] | tablespace | tablespace object |
false | success |
true | failure |
typedef bool(* sdi_delete_t) (const dd::Tablespace &tablespace, const dd::Table *table, const sdi_key_t *sdi_key) |
Delete SDI for a given SDI key.
[in] | tablespace | tablespace object |
[in] | table | table object |
[in] | sdi_key | SDI key to uniquely identify SDI obj |
false | success |
true | failure, my_error() should be called by SE |
typedef bool(* sdi_drop_t) (dd::Tablespace *tablespace) |
Drop SDI in a tablespace.
This API should be used only when SDI is corrupted.
[in] | tablespace | tablespace object |
false | success |
true | failure |
typedef bool(* sdi_get_keys_t) (const dd::Tablespace &tablespace, sdi_vector_t &vector) |
Get the SDI keys in a tablespace into vector.
[in] | tablespace | tablespace object |
[in,out] | vector | vector of SDI Keys |
false | success |
true | failure |
typedef bool(* sdi_get_t) (const dd::Tablespace &tablespace, const 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)
[in] | tablespace | tablespace object |
[in] | sdi_key | SDI key to uniquely identify SDI obj |
[in,out] | sdi | SDI retrieved from tablespace A non-null pointer must be passed in |
[in,out] | sdi_len | in: length of the memory allocated out: actual length of SDI |
false | success |
true | failure |
typedef bool(* sdi_set_t) (handlerton *hton, const dd::Tablespace &tablespace, const dd::Table *table, const sdi_key_t *sdi_key, const void *sdi, uint64 sdi_len) |
Insert/Update SDI for a given SDI key.
[in] | hton | handlerton object |
[in] | tablespace | tablespace object |
[in] | table | table object |
[in] | sdi_key | SDI key to uniquely identify SDI obj |
[in] | sdi | SDI to write into the tablespace |
[in] | sdi_len | length of SDI BLOB returned |
false | success |
true | failure, my_error() should be called by SE |
using se_after_commit_t = void (*)(void *arg) |
using se_before_commit_t = void (*)(void *arg) |
using se_before_rollback_t = void (*)(void *arg) |
using secondary_engine_check_optimizer_request_t = SecondaryEngineGraphSimplificationRequestParameters (*)( THD *thd, const JoinHypergraph &hypergraph, const AccessPath *access_path, int current_subgraph_pairs, int current_subgraph_pairs_limit, bool is_root_access_path, std::string *trace) |
Hook for secondary engine to evaluate the current hypergraph optimization state, and returns the state that hypergraph should transition to.
Usually invoked after secondary_engine_modify_access_path_cost_t is invoked via the optimizer. The state is returned as object of type SecondaryEngineGraphSimplificationRequestParameters, and can lead to simplification of hypergraph search space, or resetting the graph and starting search afresh.
thd | The thread context. |
hypergraph | The hypergraph that represents the search space. |
access_path | The AccessPath to evaluate. |
current_subgraph_pairs | Count of subgraph pairs explored so far. |
current_subgraph_pairs_limit | Limit for current hypergraph. |
is_root_access_path | Indicating if access_path is root. |
trace | Optimizer trace string. |
using secondary_engine_modify_access_path_cost_t = bool (*)( THD *thd, const JoinHypergraph &hypergraph, AccessPath *access_path) |
Evaluates the cost of executing the given access path in this secondary storage engine, and potentially modifies the cost estimates that are in the access path.
This function is only called from the hypergraph join optimizer.
The function is called on every access path that the join optimizer might compare to an alternative access path. This includes both paths that represent complete execution plans and paths that represent partial plans. It is not guaranteed to be called on every child path. For example, if GROUP BY is done by sorting first and then aggregating the sorted results, the function will only be called on the aggregation path, and not on the sort path, because only the aggregation path will be compared to other paths.
The secondary engine is allowed to modify the estimates in the access path to better match the costs of the access path in the secondary engine. It can change any of the following AccessPath members:
Any other members should be left unchanged. The AccessPath must be in an internally consistent state when the function returns, and satisfy invariants expected by the hypergraph join optimizer, such as:
The secondary engine can also reject an access path altogether, by returning true, in which case the join optimizer will not use that path in the final plan. Since the secondary engine can reject any partial or complete plan, it is possible that the join optimizer does not find any valid plan that is accepted. In this case, the join optimizer will raise an error.
If the secondary encounters an error when evaluating the cost of the path, it can signal an error by calling my_error() and return true, in which case the join optimizer will not suggest any plan for the query.
thd | The thread context. | |
hypergraph | The hypergraph that represents the search space. | |
[in,out] | access_path | The AccessPath to evaluate. |
false | on success. |
true | if the plan is to be rejected, or if an error was raised. |
using secondary_engine_pre_prepare_hook_t = bool (*)(THD *thd) |
Secondary engine hook called after PRIMARY_TENTATIVELY optimization is complete, and decides if secondary engine optimization will be performed, and comparison of primary engine cost and secondary engine cost will determine which engine to use for execution.
[in] | thd | current thd. |
true | When secondary_engine's prepare hook is to be further called |
false | When secondary_engine's prepare hook is NOT to be further called |
using SecondaryEngineFlags = uint64_t |
using set_prepared_in_tc_by_xid_t = xa_status_code (*)(handlerton *hton, XID *xid) |
Instructs the storage engine to mark the externally coordinated transactions identified by the XID parameters as prepared in the server TC.
using set_prepared_in_tc_t = int (*)(handlerton *hton, THD *thd) |
Instructs the storage engine to mark the externally coordinated transactions held by the THD parameters as prepared in the server TC.
using set_secondary_engine_offload_fail_reason_t = bool (*)(const THD *thd, std::string_view reason) |
Sets a specific secondary engine offload failure reason for a query represented by the thread context when the offloaded query fails in the secondary storage engine.
thd | thread context. |
reason | offload failure reason. |
bool | to indicate if the setting succeeded or failed |
typedef bool(* show_status_t) (handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat) |
typedef int(* start_consistent_snapshot_t) (handlerton *hton, THD *thd) |
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) |
typedef int(* table_exists_in_engine_t) (handlerton *hton, THD *thd, const char *db, const char *name) |
typedef bool(* unlock_hton_log_t) (handlerton *hton) |
Unlock a handlerton (resource) log after collecting log information.
typedef int(* upgrade_logs_t) (THD *thd) |
Upgrade logs after the checkpoint from where upgrade process can only roll forward.
thd | Thread context |
== | 0 Success. |
!= | 0 Error (handler error code returned) |
typedef bool(* upgrade_space_version_t) (dd::Tablespace *tablespace) |
Get the tablespace data from SE and insert it into Data dictionary.
[in] | tablespace | tablespace object |
== | 0 Success. |
!= | 0 Error (handler error code returned) |
typedef int(* upgrade_tablespace_t) (THD *thd) |
Get the tablespace data from SE and insert it into Data dictionary.
thd | Thread context |
== | 0 Success. |
!= | 0 Error (handler error code returned) |
typedef struct st_xarecover_txn XA_recover_txn |
using Xid_commit_list = std::unordered_set<my_xid, std::hash<my_xid>, std::equal_to<my_xid>, Mem_root_allocator<my_xid> > |
Single occurrence set of XIDs of internally coordinated transactions found as been committed in the transaction coordinator state.
enum dict_init_mode_t |
enum dict_recovery_mode_t |
Return values for check_if_supported_inplace_alter().
enum enum_binlog_command |
enum enum_binlog_func |
|
strong |
|
strong |
enum enum_schema_tables : int |
enum enum_stats_auto_recalc : int |
enum enum_tx_isolation : int |
enum Ha_clone_mode |
Clone start operation mode.
enum Ha_clone_type : size_t |
Clone operation types.
enum ha_ddl_type : int |
enum ha_notification_type : int |
enum ha_stat_type |
enum legacy_db_type |
enum row_type : int |
|
strong |
|
strong |
|
strong |
|
strong |
enum ts_command_type |
enum xa_status_code |
X/Open XA distributed transaction status codes.
int binlog_log_row | ( | TABLE * | table, |
const uchar * | before_record, | ||
const uchar * | after_record, | ||
Log_func * | log_func | ||
) |
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.
table | Table containing the key |
key | Key index |
keypart_map | which key parts that is used |
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.
[in] | table | TABLE object |
0 | ON SUCCESS |
error | code ON FAILURE |
std::pair< int, bool > commit_owned_gtids | ( | THD * | thd, |
bool | all | ||
) |
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.
thd | Thread context. |
all | The execution scope, true for the transaction one, false for the statement one. |
0 | Ok |
!0 | Error |
Owned GTID release status
true | remove the GTID owned by thread from owned GTIDs |
false | removal of the GTID owned by thread from owned GTIDs is not required |
|
inline |
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.
This implementation corresponds to default implementation of handler::delete_table() method.
const char * get_canonical_filename | ( | handler * | file, |
const char * | path, | ||
char * | tmp_path | ||
) |
make canonical filename
[in] | file | table handler |
[in] | path | original path |
[out] | tmp_path | buffer 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.
canonized | path |
|
inline |
Get default handlerton, if handler supplied is null.
thd | Thread context. |
hton | The handlerton passed. |
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.
share | TABLE_SHARE for the table, can be NULL if caller didn't perform full-blown open of table definition. |
partitioned | Indicates whether table is partitioned. |
alloc | Memory root to be used for allocating handler object. |
db_type | Table's storage engine. |
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:
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()).
table | Table to be accessed | |
nrows | Number of rows to retrieve | |
interrupted | true <=> Assume that the disk sweep will be interrupted by other disk IO. false - otherwise. | |
[out] | cost | the cost |
void ha_acl_notify | ( | THD * | thd, |
class Acl_change_notification * | data | ||
) |
int ha_binlog_end | ( | THD * | thd | ) |
int ha_binlog_index_purge_file | ( | THD * | thd, |
const char * | file | ||
) |
Inform storage engine(s) that a binary log file will be purged and any references to it should be removed.
The function is called for all purged files, regardless if it is an explicit PURGE BINARY LOGS statement, or an automatic purge performed by the server.
ha_binlog_index_purge_wait
callback to wait for completion.thd | Thread handle of session purging file. The nullptr value indicates that purge is done at server startup. |
file | Name of file being purged. |
void ha_binlog_index_purge_wait | ( | THD * | thd | ) |
Request the storage engine to complete any operations that were initiated by ha_binlog_index_purge_file
and which need to complete before PURGE BINARY LOGS completes.
The function is called only from PURGE BINARY LOGS. Each PURGE BINARY LOGS statement will result in 0, 1 or more calls to ha_binlog_index_purge_file
, followed by exactly 1 call to ha_binlog_index_purge_wait
.
thd | Thread handle of session. |
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 | ) |
Move all tables from one key cache to another one.
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.
hton | Handlerton of new engine. |
db | Database name. |
table_name | Table name to be checked. |
true | If the table name is a valid system table or if its a valid user table. |
false | If the table name is a system table name and does not belong to engine specified in the command. |
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.
thd | Thread handle | |
db | Normalized table schema name | |
name | Normalized table name. | |
[out] | exists | Only valid if the function succeeded. |
true | An error is found |
false | Success, check *exists |
bool ha_check_reserved_db_name | ( | const char * | name | ) |
Check if the database name is reserved word used by SE.
name | Database name. |
true | If the name is a reserved word. |
false | If the name is not a reserved word. |
|
inlinestatic |
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.
void ha_close_connection | ( | THD * | thd | ) |
int ha_commit_attachable | ( | THD * | thd | ) |
Commit the attachable transaction in storage engines.
thd | Current thread |
0 | - Success |
non-0 | - Failure |
int ha_commit_low | ( | THD * | thd, |
bool | all, | ||
bool | run_after_commit | ||
) |
Commit the sessions outstanding transaction.
[in] | thd | Thread handle. |
[in] | all | Is 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_commit | True by default, otherwise, does not execute the after_commit hook in the function. |
int ha_commit_trans | ( | THD * | thd, |
bool | all, | ||
bool | ignore_global_read_lock | ||
) |
[in] | thd | Thread handle. |
[in] | all | Session transaction if true, statement otherwise. |
[in] | ignore_global_read_lock | Allow 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). |
0 | ok |
1 | transaction was rolled back |
2 | error during commit, data may be inconsistent |
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.
thd | Thread context. |
path | Path to table file (without extension). |
db | Database name. |
table_name | Table name. |
create_info | HA_CREATE_INFO describing table. |
update_create_info | Indicates that create_info needs to be updated from table share. |
is_temp_table | Indicates that this is temporary table (for cases when this info is not available from HA_CREATE_INFO). |
table_def | Data-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. |
0 | ok |
1 | error |
int ha_create_table_from_engine | ( | THD * | thd, |
const char * | db, | ||
const char * | name | ||
) |
Try to discover table from engine.
-1 | Table did not exists |
0 | Table created ok |
<blockquote>0 | Error, table existed but could not be created |
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
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
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.
thd | Thread context. |
table_type | Handlerton for table's SE. |
path | Path to table (without extension). |
db | Table database. |
alias | Table name. |
table_def | dd::Table object describing the table. |
generate_warning | Indicates whether errors during deletion should be reported as warnings. |
void ha_drop_database | ( | char * | path | ) |
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.
void ha_end | ( | ) |
int ha_finalize_handlerton | ( | st_plugin_int * | plugin | ) |
int ha_find_files | ( | THD * | thd, |
const char * | db, | ||
const char * | path, | ||
const char * | wild, | ||
bool | dir, | ||
List< LEX_STRING > * | files | ||
) |
bool ha_flush_logs | ( | bool | binlog_group_flush = false | ) |
Flush the log(s) of storage engine(s).
binlog_group_flush | true if we got invoked by binlog group commit during flush stage, false in other cases. |
false | Succeed |
true | Error |
int ha_init | ( | void | ) |
int ha_init_errors | ( | void | ) |
Register handler error messages for use with my_error().
0 | OK |
!=0 | Error |
int ha_init_key_cache | ( | std::string_view | name, |
KEY_CACHE * | key_cache | ||
) |
Init a key cache if it has not been initied before.
int ha_initialize_handlerton | ( | st_plugin_int * | plugin | ) |
bool ha_is_externally_disabled | ( | const handlerton & | htnr | ) |
Returns true if the storage engine of the handlerton argument has been listed in the disabled_storage_engines system variable.
bool ha_is_storage_engine_disabled | ( | handlerton * | se_engine | ) |
void ha_kill_connection | ( | THD * | thd | ) |
TYPELIB * ha_known_exts | ( | ) |
|
inlinestatic |
plugin_ref ha_lock_engine | ( | THD * | thd, |
const handlerton * | hton | ||
) |
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.
thd | Thread context. |
mdl_key | MDL key identifying object on which exclusive lock is to be acquired/was released. |
notification_type | Indicates 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
bool ha_notify_table_ddl | ( | THD * | thd, |
const MDL_key * | mdl_key, | ||
ha_notification_type | notification_type, | ||
ha_ddl_type | ddl_type, | ||
const char * | old_db_name, | ||
const char * | old_table_name, | ||
const char * | new_db_name, | ||
const char * | new_table_name | ||
) |
Notify/get permission from all interested storage engines before or after executed DDL (ALTER TABLE, RENAME TABLE, TRUNCATE TABLE) on the table identified by key.
thd | Thread context. |
mdl_key | MDL key identifying table. |
notification_type | Indicates whether this is pre-DDL or post-DDL notification. |
old_db_name | Old db name, used in RENAME DDL |
old_table_name | Old table name, used in RENAME DDL |
new_db_name | New db name, used in RENAME DDL |
new_table_name | New table name, used in RENAME DDL |
See
int ha_panic | ( | enum ha_panic_function | flag | ) |
void ha_post_recover | ( | ) |
Perform SE-specific cleanup after recovery of transactions.
void ha_pre_dd_shutdown | ( | void | ) |
Invoke handlerton::pre_dd_shutdown() on every storage engine plugin.
int ha_prepare_low | ( | THD * | thd, |
bool | all | ||
) |
Prepares the underlying transaction of the THD session object parameter in the storage engines that participate in the transaction.
In case of failure, an error will be emitted by the function in the case of internally coordinated transactions. In the case of externally coordinated transactions (XA), the error treatment must follow the XA/Open specification and is handled by the Sql_cmd_xa_prepare
class.
thd | The THD session object holding the transaction to be prepared. |
all | Whether or not the prepare regards a full transaction or the statement being executed.. |
int ha_recover | ( | Xid_commit_list * | commit_list = nullptr , |
Xa_state_list * | xa_state_list = nullptr |
||
) |
Stage of the recovery process where information is collected from the storage engines (SE), merged with information from the transaction coordinator (TC) and transactions states are determined and enforced.
Implemented heuristics is as follows:
commit_list
parameter contains the set of internally coordinated transactions that the TC ensures were marked as committed.xa_state_list
parameter contains the list of externally coordinated transactions and their states, as recorded by the TC.For each SE: a. Collect list of transactions found in PREPARED_IN_TC
state in the SE and merge it with the information collected from the TC, in xa_state_list
. b. Retrieve the list of transactions found in prepared state in the SE.
c. For each internally coordinated transactions found in prepared state:
commit_list
, commit it.commit_list
but tc_heuristic_recover = TC_HEURISTIC_RECOVER_COMMIT
, commit it.d. For each externally coordinated transactions found in prepared state:
xa_state_list
, roll it back.xa_state_list
in COMMITTED
state, commit it.xa_state_list
in ROLLEDBACK
state, roll it back.xa_state_list
in PREPARED
state, ensure that the transaction state in the SE is PREPARED_IN_TC
.commit_list | Set of XIDs of internally coordinated transactions found as been committed in the transaction coordinator state. |
xa_state_list | Map between XIDs and states of externally coordinated transactions as found in the internal transaction coordinator state. |
int ha_reset_logs | ( | THD * | thd | ) |
void ha_reset_plugin_vars | ( | THD * | thd | ) |
void ha_reset_slave | ( | THD * | thd | ) |
int ha_resize_key_cache | ( | KEY_CACHE * | key_cache | ) |
Resize key cache.
handlerton * ha_resolve_by_legacy_type | ( | THD * | thd, |
enum legacy_db_type | db_type | ||
) |
plugin_ref ha_resolve_by_name | ( | THD * | thd, |
const LEX_CSTRING * | name, | ||
bool | is_temp_table | ||
) |
Return the storage engine handlerton for the supplied name.
thd | Current thread. May be nullptr, (e.g. during initialize). |
name | Name of storage engine. |
is_temp_table | true if table is a temporary table. |
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.
thd | Thread context. |
name | Plugin name. |
const char * ha_resolve_storage_engine_name | ( | const handlerton * | db_type | ) |
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.
[in] | thd | Thread context. |
[in,out] | files | List 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. |
int ha_rollback_low | ( | THD * | thd, |
bool | all | ||
) |
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.
thd | The client thread that executes the transaction. |
Checking whether it is safe to release metadata locks after rollback to savepoint in all the storage engines that are part of the transaction.
int ha_rollback_trans | ( | THD * | thd, |
bool | all | ||
) |
|
noexcept |
bool ha_show_status | ( | THD * | thd, |
handlerton * | db_type, | ||
enum ha_stat_type | stat | ||
) |
int ha_start_consistent_snapshot | ( | THD * | thd | ) |
|
inline |
Predicate to determine if a storage engine, represented by a handlerton*, is enabled.
int ha_table_exists_in_engine | ( | THD * | thd, |
const char * | db, | ||
const char * | name | ||
) |
st_plugin_int * hton2plugin | ( | uint | slot | ) |
Maps from slot to plugin. May return NULL if plugin has been unloaded.
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.
bool is_index_access_error | ( | int | error | ) |
Check whether an error is index access error or not after an index read.
Error other than HA_ERR_END_OF_FILE or HA_ERR_KEY_NOT_FOUND will stop next index read.
error | Handler error code. |
true | if error is different from HA_ERR_END_OF_FILE or HA_ERR_KEY_NOT_FOUND. |
false | if error is HA_ERR_END_OF_FILE or HA_ERR_KEY_NOT_FOUND. |
|
inlineconstexpr |
Creates an empty bitmap of access path types.
This is the base case for the function template with the same name below.
|
constexpr |
Creates a bitmap representing a set of access path types.
size_t num_hton2plugins | ( | ) |
Returns the size of the array holding pointers to plugins.
void print_keydup_error | ( | TABLE * | table, |
KEY * | key, | ||
const char * | msg, | ||
myf | errflag, | ||
const char * | org_table_name | ||
) |
Construct and emit duplicate key error message using information from table's record buffer.
table | TABLE object which record buffer should be used as source for column values. |
key | Key description. |
msg | Error message template to which key value should be added. |
errflag | Flags for my_error() call. |
org_table_name | The original table name (if any) |
Construct and emit duplicate key error message using information from table's record buffer.
st_plugin_int * remove_hton2plugin | ( | uint | slot | ) |
|
inline |
const handlerton * SecondaryEngineHandlerton | ( | const THD * | thd | ) |
Returns the handlerton of the secondary engine that is used in the session, or nullptr if a secondary engine is not used.
void set_externally_disabled_storage_engine_names | ( | const char * | disabled_list | ) |
Read a comma-separated list of storage engine names.
Look up each in the known list of canonical and legacy names. In case of a match; add both the canonical and the legacy name to disabled_se_names, which is a static vector of disabled storage engine names. If there is no match, the unmodified name is added to the vector.
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.
thd | THD session setting the tx_isolation. |
tx_isolation | The isolation level to be set. |
one_shot | True if the isolation level should be restored to session default after finishing the transaction. |
const char * table_case_name | ( | const HA_CREATE_INFO * | info, |
const char * | name | ||
) |
void trans_register_ha | ( | THD * | thd, |
bool | all, | ||
handlerton * | ht_arg, | ||
const ulonglong * | trxid | ||
) |
Register a storage engine for a transaction.
In each client connection, MySQL maintains two transactional states:
"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 REPLICA.
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.
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:
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:
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:
The normal transaction can be rolled back as well:
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:
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.
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.
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.
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.
|
extern |
|
constexpr |
|
static |
Suffix for auto-generated foreign key names for tables in SE's which don't specify own suffix.
I.e. for foreign keys on tables in such SE's generated names follow (table name)FK_NAME_DEFAULT_SUFFIX(FK number) pattern.
|
constexpr |
These flags convey that the options AUTOEXTEND_SIZE has been specified in the CREATE TABLE statement.
|
constexpr |
|
constexpr |
ALTER SCHEMA|DATABASE has an explicit READ_ONLY clause.
Implies HA_CREATE_USED_READ_ONLY.
|
constexpr |
|
constexpr |
This option is used to convey that the create table should not commit the operation and keep the transaction started.
|
extern |
|
static |
Storage engine does not support using the same key for both parent and supporting key, but requires the two to be different.
|
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.
|
static |
Engine takes into account hidden part of key (coming from primary key) when determines if it can serve as parent key for a foreign key.
Implies HTON_FKS_WITH_PREFIX_PARENT_KEYS and is related to HTON_SUPPORTS_EXTENDED_KEYS.
|
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.
|
static |
Storage engine supports hash keys as supporting keys for foreign keys.
Hash key should contain all foreign key columns and only them (although 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.
|
inlineconstexpr |
|
constexpr |
|
inlineconstexpr |
Engine supports index distance scan.
|
constexpr |
|
constexpr |
Engine supports Generated invisible primary key.
|
static |
Maximum possible length of SE-specific suffixes for auto-generated foreign key names.
|
static |
|
static |
|
static |
|
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.
|
extern |
|
constexpr |
Id for identifying Table SDIs.
|
constexpr |
Id for identifying Tablespace SDIs.
|
extern |
|
extern |
|
extern |