MySQL 9.1.0
Source Code Documentation
|
Class definition for the storage engine. More...
#include <ha_example.h>
Public Member Functions | |
ha_example (handlerton *hton, TABLE_SHARE *table_arg) | |
~ha_example () override=default | |
const char * | table_type () const override |
The name that will be used for display purposes. More... | |
enum ha_key_alg | get_default_index_algorithm () const override |
Replace key algorithm with one supported by SE, return the default key algorithm for SE if explicit key algorithm was not provided. More... | |
bool | is_index_algorithm_supported (enum ha_key_alg key_alg) const override |
Check if SE supports specific key algorithm. More... | |
ulonglong | table_flags () const override |
This is a list of flags that indicate what functionality the storage engine implements. More... | |
ulong | index_flags (uint inx, uint part, bool all_parts) const override |
This is a bitmap of flags that indicates how the storage engine implements indexes. More... | |
uint | max_supported_record_length () const override |
unireg.cc will call max_supported_record_length(), max_supported_keys(), max_supported_key_parts(), uint max_supported_key_length() to make sure that the storage engine can handle the data it is about to send. More... | |
uint | max_supported_keys () const override |
unireg.cc will call this to make sure that the storage engine can handle the data it is about to send. More... | |
uint | max_supported_key_parts () const override |
unireg.cc will call this to make sure that the storage engine can handle the data it is about to send. More... | |
uint | max_supported_key_length () const override |
unireg.cc will call this to make sure that the storage engine can handle the data it is about to send. More... | |
double | scan_time () override |
Called in test_quick_select to determine if indexes should be used. More... | |
double | read_time (uint, uint, ha_rows rows) override |
This method will never be called if you do not implement indexes. More... | |
int | open (const char *name, int mode, uint test_if_locked, const dd::Table *table_def) override |
We implement this in ha_example.cc; it's a required method. More... | |
int | close (void) override |
We implement this in ha_example.cc; it's a required method. More... | |
int | write_row (uchar *buf) override |
We implement this in ha_example.cc. More... | |
int | update_row (const uchar *old_data, uchar *new_data) override |
We implement this in ha_example.cc. More... | |
int | delete_row (const uchar *buf) override |
We implement this in ha_example.cc. More... | |
int | index_read_map (uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) override |
We implement this in ha_example.cc. More... | |
int | index_next (uchar *buf) override |
We implement this in ha_example.cc. More... | |
int | index_prev (uchar *buf) override |
We implement this in ha_example.cc. More... | |
int | index_first (uchar *buf) override |
We implement this in ha_example.cc. More... | |
int | index_last (uchar *buf) override |
We implement this in ha_example.cc. More... | |
int | rnd_init (bool scan) override |
Unlike index_init(), rnd_init() can be called two consecutive times without rnd_end() in between (it only makes sense if scan=1). More... | |
int | rnd_end () override |
int | rnd_next (uchar *buf) override |
required More... | |
int | rnd_pos (uchar *buf, uchar *pos) override |
required More... | |
void | position (const uchar *record) override |
required More... | |
int | info (uint) override |
required More... | |
int | extra (enum ha_extra_function operation) override |
extra() is called whenever the server wishes to send a hint to the storage engine. More... | |
int | external_lock (THD *thd, int lock_type) override |
required More... | |
int | delete_all_rows (void) override |
Used to delete all rows in a table, including cases of truncate and cases where the optimizer realizes that all rows will be removed as a result of an SQL statement. More... | |
ha_rows | records_in_range (uint inx, key_range *min_key, key_range *max_key) override |
Given a starting key and an ending key, estimate the number of rows that will exist between the two keys. More... | |
int | delete_table (const char *from, const dd::Table *table_def) override |
Used to delete a table. More... | |
int | rename_table (const char *from, const char *to, const dd::Table *from_table_def, dd::Table *to_table_def) override |
Renames a table from one name to another via an alter table call. More... | |
int | create (const char *name, TABLE *form, HA_CREATE_INFO *create_info, dd::Table *table_def) override |
required More... | |
THR_LOCK_DATA ** | store_lock (THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) override |
required More... | |
Public Member Functions inherited from handler | |
void | unbind_psi () |
void | rebind_psi () |
void | start_psi_batch_mode () |
Put the handler in 'batch' mode when collecting table io instrumented events. More... | |
void | end_psi_batch_mode () |
End a batch started with start_psi_batch_mode . More... | |
bool | end_psi_batch_mode_if_started () |
If a PSI batch was started, turn if off. More... | |
handler (handlerton *ht_arg, TABLE_SHARE *share_arg) | |
virtual | ~handler (void) |
virtual std::string | explain_extra () const |
Return extra handler specific text for EXPLAIN. More... | |
virtual handler * | clone (const char *name, MEM_ROOT *mem_root) |
void | init () |
This is called after create to allow us to set up cached variables. More... | |
void | ha_set_record_buffer (Record_buffer *buffer) |
Set a record buffer that the storage engine can use for multi-row reads. More... | |
Record_buffer * | ha_get_record_buffer () const |
Get the record buffer that was set with ha_set_record_buffer(). More... | |
bool | ha_is_record_buffer_wanted (ha_rows *const max_rows) const |
Does this handler want to get a Record_buffer for multi-row reads via the ha_set_record_buffer() function? And if so, what is the maximum number of records to allocate space for in the buffer? More... | |
int | ha_open (TABLE *table, const char *name, int mode, int test_if_locked, const dd::Table *table_def) |
int | ha_close (void) |
Close handler. More... | |
int | ha_index_init (uint idx, bool sorted) |
Initialize use of index. More... | |
int | ha_index_end () |
End use of index. More... | |
int | ha_rnd_init (bool scan) |
Initialize table for random read or scan. More... | |
int | ha_rnd_end () |
End use of random access. More... | |
int | ha_rnd_next (uchar *buf) |
Read next row via random scan. More... | |
int | ha_rnd_pos (uchar *buf, uchar *pos) |
Read row via random scan from position. More... | |
int | ha_index_read_map (uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) |
Read [part of] row via [part of] index. More... | |
int | ha_index_read_last_map (uchar *buf, const uchar *key, key_part_map keypart_map) |
int | ha_index_read_idx_map (uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) |
Initializes an index and read it. More... | |
int | ha_index_next (uchar *buf) |
Reads the next row via index. More... | |
int | ha_index_prev (uchar *buf) |
Reads the previous row via index. More... | |
int | ha_index_first (uchar *buf) |
Reads the first row via index. More... | |
int | ha_index_last (uchar *buf) |
Reads the last row via index. More... | |
int | ha_index_next_same (uchar *buf, const uchar *key, uint keylen) |
Reads the next same row via index. More... | |
int | ha_reset () |
Check handler usage and reset state of file to after 'open'. More... | |
int | ha_index_or_rnd_end () |
Table_flags | ha_table_flags () const |
The cached_table_flags is set at ha_open and ha_external_lock. More... | |
int | ha_external_lock (THD *thd, int lock_type) |
These functions represent the public interface to users of the handler class, hence they are not virtual. More... | |
int | ha_write_row (uchar *buf) |
int | ha_update_row (const uchar *old_data, uchar *new_data) |
Update the current row. More... | |
int | ha_delete_row (const uchar *buf) |
void | ha_release_auto_increment () |
int | ha_check_for_upgrade (HA_CHECK_OPT *check_opt) |
int | ha_check (THD *thd, HA_CHECK_OPT *check_opt) |
to be actually called to get 'check()' functionality More... | |
int | ha_repair (THD *thd, HA_CHECK_OPT *check_opt) |
Repair table: public interface. More... | |
void | ha_start_bulk_insert (ha_rows rows) |
Start bulk insert. More... | |
int | ha_end_bulk_insert () |
End bulk insert. More... | |
int | ha_bulk_update_row (const uchar *old_data, uchar *new_data, uint *dup_key_found) |
Bulk update row: public interface. More... | |
int | ha_delete_all_rows () |
Delete all rows: public interface. More... | |
int | ha_truncate (dd::Table *table_def) |
Truncate table: public interface. More... | |
int | ha_optimize (THD *thd, HA_CHECK_OPT *check_opt) |
Optimize table: public interface. More... | |
int | ha_analyze (THD *thd, HA_CHECK_OPT *check_opt) |
Analyze table: public interface. More... | |
bool | ha_check_and_repair (THD *thd) |
Check and repair table: public interface. More... | |
int | ha_disable_indexes (uint mode) |
Disable indexes: public interface. More... | |
int | ha_enable_indexes (uint mode) |
Enable indexes: public interface. More... | |
int | ha_discard_or_import_tablespace (bool discard, dd::Table *table_def) |
Discard or import tablespace: public interface. More... | |
int | ha_rename_table (const char *from, const char *to, const dd::Table *from_table_def, dd::Table *to_table_def) |
Rename table: public interface. More... | |
int | ha_delete_table (const char *name, const dd::Table *table_def) |
Delete table: public interface. More... | |
void | ha_drop_table (const char *name) |
Drop table in the engine: public interface. More... | |
int | ha_create (const char *name, TABLE *form, HA_CREATE_INFO *info, dd::Table *table_def) |
Create a table in the engine: public interface. More... | |
int | ha_load_table (const TABLE &table, bool *skip_metadata_update) |
Loads a table into its defined secondary storage engine: public interface. More... | |
int | ha_unload_table (const char *db_name, const char *table_name, bool error_if_not_loaded) |
Unloads a table from its defined secondary storage engine: public interface. More... | |
virtual int | parallel_scan_init (void *&scan_ctx, size_t *num_threads, bool use_reserved_threads, size_t max_desired_threads) |
Initializes a parallel scan. More... | |
virtual int | parallel_scan (void *scan_ctx, void **thread_ctxs, Load_init_cbk init_fn, Load_cbk load_fn, Load_end_cbk end_fn) |
Run the parallel read of data. More... | |
virtual void | parallel_scan_end (void *scan_ctx) |
End of the parallel scan. More... | |
virtual bool | bulk_load_check (THD *thd) const |
Check if the table is ready for bulk load. More... | |
virtual size_t | bulk_load_available_memory (THD *thd) const |
Get the total memory available for bulk load in SE. More... | |
virtual void * | bulk_load_begin (THD *thd, size_t data_size, size_t memory, size_t num_threads) |
Begin parallel bulk data load to the table. More... | |
virtual int | bulk_load_execute (THD *thd, void *load_ctx, size_t thread_idx, const Rows_mysql &rows, Bulk_load::Stat_callbacks &wait_cbk) |
Execute bulk load operation. More... | |
virtual int | open_blob (THD *thd, void *load_ctx, size_t thread_idx, Blob_context &blob_ctx, unsigned char *blobref) |
Open a blob for write operation. More... | |
virtual int | write_blob (THD *thd, void *load_ctx, size_t thread_idx, Blob_context blob_ctx, unsigned char *blobref, const unsigned char *data, size_t data_len) |
Write to a blob. More... | |
virtual int | close_blob (THD *thd, void *load_ctx, size_t thread_idx, Blob_context blob_ctx, unsigned char *blobref) |
Close the blob. More... | |
virtual int | bulk_load_end (THD *thd, void *load_ctx, bool is_error) |
End bulk load operation. More... | |
bool | ha_get_se_private_data (dd::Table *dd_table, bool reset) |
Submit a dd::Table object representing a core DD table having hardcoded data to be filled in by the DDSE. More... | |
void | adjust_next_insert_id_after_explicit_value (ulonglong nr) |
int | update_auto_increment () |
virtual void | print_error (int error, myf errflag) |
Print error that we got from handler function. More... | |
virtual bool | get_error_message (int error, String *buf) |
Return an error message specific to this handler. More... | |
uint | get_dup_key (int error) |
virtual bool | get_foreign_dup_key (char *child_table_name, uint child_table_name_len, char *child_key_name, uint child_key_name_len) |
Retrieves the names of the table and the key for which there was a duplicate entry in the case of HA_ERR_FOREIGN_DUPLICATE_KEY. More... | |
virtual void | change_table_ptr (TABLE *table_arg, TABLE_SHARE *share) |
Change the internal TABLE_SHARE pointer. More... | |
const TABLE_SHARE * | get_table_share () const |
const TABLE * | get_table () const |
virtual double | index_only_read_time (uint keynr, double records) |
Calculate cost of 'index only' scan for given index and number of records. More... | |
virtual Cost_estimate | table_scan_cost () |
Cost estimate for doing a complete table scan. More... | |
virtual Cost_estimate | index_scan_cost (uint index, double ranges, double rows) |
Cost estimate for reading a number of ranges from an index. More... | |
virtual Cost_estimate | read_cost (uint index, double ranges, double rows) |
Cost estimate for reading a set of ranges from the table using an index to access it. More... | |
virtual double | page_read_cost (uint index, double reads) |
Cost estimate for doing a number of non-sequentially accesses against the storage engine. More... | |
virtual double | worst_seek_times (double reads) |
Provide an upper cost-limit of doing a specified number of seek-and-read key lookups. More... | |
virtual longlong | get_memory_buffer_size () const |
Return an estimate on the amount of memory the storage engine will use for caching data in memory. More... | |
double | table_in_memory_estimate () const |
Return an estimate of how much of the table that is currently stored in main memory. More... | |
double | index_in_memory_estimate (uint keyno) const |
Return an estimate of how much of the index that is currently stored in main memory. More... | |
int | ha_sample_init (void *&scan_ctx, double sampling_percentage, int sampling_seed, enum_sampling_method sampling_method, const bool tablesample) |
Initialize sampling. More... | |
int | ha_sample_next (void *scan_ctx, uchar *buf) |
Get the next record for sampling. More... | |
int | ha_sample_end (void *scan_ctx) |
End sampling. More... | |
virtual ha_rows | multi_range_read_info_const (uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint *bufsz, uint *flags, bool *force_default_mrr, Cost_estimate *cost) |
Get cost and other information about MRR scan over a known list of ranges. More... | |
virtual ha_rows | multi_range_read_info (uint keyno, uint n_ranges, uint keys, uint *bufsz, uint *flags, Cost_estimate *cost) |
Get cost and other information about MRR scan over some sequence of ranges. More... | |
virtual int | multi_range_read_init (RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint mode, HANDLER_BUFFER *buf) |
Initialize the MRR scan. More... | |
int | ha_multi_range_read_next (char **range_info) |
int | ha_read_range_first (const key_range *start_key, const key_range *end_key, bool eq_range, bool sorted) |
int | ha_read_range_next () |
bool | has_transactions () |
virtual uint | extra_rec_buf_length () const |
virtual bool | is_ignorable_error (int error) |
Determine whether an error can be ignored or not. More... | |
virtual bool | is_fatal_error (int error) |
Determine whether an error is fatal or not. More... | |
int | ha_records (ha_rows *num_rows) |
Wrapper function to call records() in storage engine. More... | |
int | ha_records (ha_rows *num_rows, uint index) |
Wrapper function to call records_from_index() in storage engine. More... | |
virtual ha_rows | estimate_rows_upper_bound () |
Return upper bound of current number of records in the table (max. More... | |
virtual enum row_type | get_real_row_type (const HA_CREATE_INFO *create_info) const |
Get real row type for the table created based on one specified by user, CREATE TABLE options and SE capabilities. More... | |
virtual void | column_bitmaps_signal () |
Signal that the table->read_set and table->write_set table maps changed The handler is allowed to set additional bits in the above map in this call. More... | |
uint | get_index (void) const |
virtual bool | start_bulk_update () |
virtual bool | start_bulk_delete () |
virtual int | exec_bulk_update (uint *dup_key_found) |
After this call all outstanding updates must be performed. More... | |
virtual void | end_bulk_update () |
Perform any needed clean-up, no outstanding updates are there at the moment. More... | |
virtual int | end_bulk_delete () |
Execute all outstanding deletes and close down the bulk delete. More... | |
void | set_end_range (const key_range *range, enum_range_scan_direction direction) |
Set the end position for a range scan. More... | |
int | compare_key (key_range *range) |
Compare if found key (in row) is over max-value. More... | |
int | compare_key_icp (const key_range *range) const |
int | compare_key_in_buffer (const uchar *buf) const |
Check if the key in the given buffer (which is not necessarily TABLE::record[0]) is within range. More... | |
virtual int | ft_init () |
virtual FT_INFO * | ft_init_ext (uint flags, uint inx, String *key) |
virtual FT_INFO * | ft_init_ext_with_hints (uint inx, String *key, Ft_hints *hints) |
int | ha_ft_read (uchar *buf) |
int | ha_read_first_row (uchar *buf, uint primary_key) |
Read first row (only) from a table. More... | |
virtual int | rnd_pos_by_record (uchar *record) |
This function only works for handlers having HA_PRIMARY_KEY_REQUIRED_FOR_POSITION set. More... | |
virtual uint32 | calculate_key_hash_value (Field **field_array) |
int | ha_extra (enum ha_extra_function operation) |
Request storage engine to do an extra operation: enable,disable or run some functionality. More... | |
virtual int | extra_opt (enum ha_extra_function operation, ulong cache_size) |
virtual const handlerton * | hton_supporting_engine_pushdown () |
Get the handlerton of the storage engine if the SE is capable of pushing down some of the AccessPath functionality. More... | |
virtual bool | start_read_removal (void) |
Start read (before write) removal on the current table. More... | |
virtual ha_rows | end_read_removal (void) |
End read (before write) removal and return the number of rows really written. More... | |
virtual bool | was_semi_consistent_read () |
virtual void | try_semi_consistent_read (bool) |
Tell the engine whether it should avoid unnecessary lock waits. More... | |
virtual void | unlock_row () |
Unlock last accessed row. More... | |
virtual int | start_stmt (THD *thd, thr_lock_type lock_type) |
Start a statement when table is locked. More... | |
virtual void | get_auto_increment (ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong *first_value, ulonglong *nb_reserved_values) |
Reserves an interval of auto_increment values from the handler. More... | |
void | set_next_insert_id (ulonglong id) |
void | restore_auto_increment (ulonglong prev_insert_id) |
virtual void | update_create_info (HA_CREATE_INFO *create_info) |
Update create info as part of ALTER TABLE. More... | |
virtual int | assign_to_keycache (THD *, HA_CHECK_OPT *) |
virtual int | preload_keys (THD *, HA_CHECK_OPT *) |
virtual int | indexes_are_disabled (void) |
Check if indexes are disabled. More... | |
virtual void | append_create_info (String *packet) |
virtual void | init_table_handle_for_HANDLER () |
uint | max_record_length () const |
uint | max_keys () const |
uint | max_key_parts () const |
uint | max_key_length () const |
uint | max_key_part_length (HA_CREATE_INFO *create_info) const |
virtual uint | max_supported_key_part_length (HA_CREATE_INFO *create_info) const |
virtual uint | min_record_length (uint options) const |
virtual bool | low_byte_first () const |
virtual ha_checksum | checksum () const |
virtual bool | is_crashed () const |
Check if the table is crashed. More... | |
virtual bool | auto_repair () const |
Check if the table can be automatically repaired. More... | |
virtual uint | lock_count (void) const |
Get number of lock objects returned in store_lock. More... | |
virtual bool | primary_key_is_clustered () const |
Check if the primary key is clustered or not. More... | |
virtual int | cmp_ref (const uchar *ref1, const uchar *ref2) const |
Compare two positions. More... | |
virtual const Item * | cond_push (const Item *cond) |
Push condition down to the table handler. More... | |
virtual Item * | idx_cond_push (uint keyno, Item *idx_cond) |
Push down an index condition to the handler. More... | |
virtual void | cancel_pushed_idx_cond () |
Reset information about pushed index conditions. More... | |
virtual uint | number_of_pushed_joins () const |
Reports number of tables included in pushed join which this handler instance is part of. More... | |
virtual const TABLE * | member_of_pushed_join () const |
If this handler instance is part of a pushed join sequence returned TABLE instance being root of the pushed query? More... | |
virtual const TABLE * | parent_of_pushed_join () const |
If this handler instance is a child in a pushed join sequence returned TABLE instance being my parent? More... | |
virtual table_map | tables_in_pushed_join () const |
int | ha_index_read_pushed (uchar *buf, const uchar *key, key_part_map keypart_map) |
int | ha_index_next_pushed (uchar *buf) |
virtual bool | check_if_incompatible_data (HA_CREATE_INFO *create_info, uint table_changes) |
Part of old, deprecated in-place ALTER API. More... | |
virtual enum_alter_inplace_result | check_if_supported_inplace_alter (TABLE *altered_table, Alter_inplace_info *ha_alter_info) |
Check if a storage engine supports a particular alter table in-place. More... | |
bool | ha_prepare_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_table_def, dd::Table *new_table_def) |
Public functions wrapping the actual handler call. More... | |
bool | ha_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_table_def, dd::Table *new_table_def) |
Public function wrapping the actual handler call. More... | |
bool | ha_commit_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit, const dd::Table *old_table_def, dd::Table *new_table_def) |
Public function wrapping the actual handler call. More... | |
void | ha_notify_table_changed (Alter_inplace_info *ha_alter_info) |
Public function wrapping the actual handler call. More... | |
virtual void | use_hidden_primary_key () |
use_hidden_primary_key() is called in case of an update/delete when (table_flags() and HA_PRIMARY_KEY_REQUIRED_FOR_DELETE) is defined but we don't have a primary key More... | |
virtual int | bulk_update_row (const uchar *old_data, uchar *new_data, uint *dup_key_found) |
This method is similar to update_row, however the handler doesn't need to execute the updates at this point in time. More... | |
virtual int | truncate (dd::Table *table_def) |
Quickly remove all rows from a table. More... | |
virtual int | optimize (THD *, HA_CHECK_OPT *) |
virtual int | analyze (THD *, HA_CHECK_OPT *) |
virtual bool | check_and_repair (THD *thd) |
Check and repair the table if necessary. More... | |
virtual int | disable_indexes (uint mode) |
Disable indexes for a while. More... | |
virtual int | enable_indexes (uint mode) |
Enable indexes again. More... | |
virtual int | discard_or_import_tablespace (bool discard, dd::Table *table_def) |
Discard or import tablespace. More... | |
virtual void | drop_table (const char *name) |
virtual bool | get_se_private_data (dd::Table *dd_table, bool reset) |
virtual int | get_extra_columns_and_keys (const HA_CREATE_INFO *create_info, const List< Create_field > *create_list, const KEY *key_info, uint key_count, dd::Table *table_obj) |
Adjust definition of table to be created by adding implicit columns and indexes necessary for the storage engine. More... | |
virtual bool | set_ha_share_ref (Handler_share **arg_ha_share) |
void | set_ha_table (TABLE *table_arg) |
int | get_lock_type () const |
virtual Partition_handler * | get_partition_handler () |
bool | ha_upgrade_table (THD *thd, const char *dbname, const char *table_name, dd::Table *dd_table, TABLE *table_arg) |
Set se_private_id and se_private_data during upgrade. More... | |
void | ha_set_primary_handler (handler *primary_handler) |
Store a pointer to the handler of the primary table that corresponds to the secondary table in this handler. More... | |
handler * | ha_get_primary_handler () const |
Get a pointer to a handler for the table in the primary storage engine, if this handler is for a table in a secondary storage engine. More... | |
void | ha_mv_key_capacity (uint *num_keys, size_t *keys_length) const |
Return max limits for a single set of multi-valued keys. More... | |
virtual void | set_external_table_offload_error (const char *) |
Propagates the secondary storage engine offload failure reason for a query to the external engine when the offloaded query fails in the secondary storage engine. More... | |
virtual void | external_table_offload_error () const |
Identifies and throws the propagated external engine query offload or exec failure reason given by the external engine handler. More... | |
Private Member Functions | |
Example_share * | get_share () |
Get the share. More... | |
Private Attributes | |
THR_LOCK_DATA | lock |
MySQL lock. More... | |
Example_share * | share |
Shared lock info. More... | |
Additional Inherited Members | |
Public Types inherited from handler | |
enum | enum_range_scan_direction { RANGE_SCAN_ASC , RANGE_SCAN_DESC } |
enum | { NONE = 0 , INDEX , RND , SAMPLING } |
typedef ulonglong | Table_flags |
using | Blob_context = void * |
using | Load_init_cbk = std::function< bool(void *cookie, ulong ncols, ulong row_len, const ulong *col_offsets, const ulong *null_byte_offsets, const ulong *null_bitmasks)> |
This callback is called by each parallel load thread at the beginning of the parallel load for the adapter scan. More... | |
using | Load_cbk = std::function< bool(void *cookie, uint nrows, void *rowdata, uint64_t partition_id)> |
This callback is called by each parallel load thread when processing of rows is required for the adapter scan. More... | |
using | Load_end_cbk = std::function< void(void *cookie)> |
This callback is called by each parallel load thread when processing of rows has ended for the adapter scan. More... | |
typedef void(* | my_gcolumn_template_callback_t) (const TABLE *, void *) |
Callback function that will be called by my_prepare_gcolumn_template once the table has been opened. More... | |
Static Public Member Functions inherited from handler | |
static bool | my_prepare_gcolumn_template (THD *thd, const char *db_name, const char *table_name, my_gcolumn_template_callback_t myc, void *ib_table) |
Callback to allow InnoDB to prepare a template for generated column processing. More... | |
static bool | my_eval_gcolumn_expr_with_open (THD *thd, const char *db_name, const char *table_name, const MY_BITMAP *const fields, uchar *record, const char **mv_data_ptr, ulong *mv_length) |
Callback for generated columns processing. More... | |
static bool | my_eval_gcolumn_expr (THD *thd, TABLE *table, const MY_BITMAP *const fields, uchar *record, const char **mv_data_ptr, ulong *mv_length) |
Callback for computing generated column values. More... | |
Public Attributes inherited from handler | |
handlerton * | ht |
uchar * | ref |
Pointer to current row. More... | |
uchar * | dup_ref |
Pointer to duplicate row. More... | |
ha_statistics | stats |
range_seq_t | mrr_iter |
RANGE_SEQ_IF | mrr_funcs |
HANDLER_BUFFER * | multi_range_buffer |
uint | ranges_in_seq |
bool | mrr_is_output_sorted |
bool | mrr_have_range |
KEY_MULTI_RANGE | mrr_cur_range |
key_range * | end_range |
End value for a range scan. More... | |
bool | m_virt_gcol_in_end_range = false |
Flag which tells if end_range contains a virtual generated column. More... | |
uint | errkey |
uint | key_used_on_scan |
uint | active_index |
uint | ref_length |
Length of ref (1-8 or the clustered key length) More... | |
FT_INFO * | ft_handler |
enum handler:: { ... } | inited |
bool | implicit_emptied |
const Item * | pushed_cond |
Item * | pushed_idx_cond |
uint | pushed_idx_cond_keyno |
ulonglong | next_insert_id |
next_insert_id is the next value which should be inserted into the auto_increment column: in a inserting-multi-row statement (like INSERT SELECT), for the first row where the autoinc value is not specified by the statement, get_auto_increment() called and asked to generate a value, next_insert_id is set to the next value, then for all other rows next_insert_id is used (and increased each time) without calling get_auto_increment(). More... | |
ulonglong | insert_id_for_cur_row |
insert id for the current row (autogenerated; if not autogenerated, it's 0). More... | |
Discrete_interval | auto_inc_interval_for_cur_row |
Interval returned by get_auto_increment() and being consumed by the inserter. More... | |
uint | auto_inc_intervals_count |
Number of reserved auto-increment intervals. More... | |
PSI_table * | m_psi |
Instrumented table associated with this handler. More... | |
std::mt19937 * | m_random_number_engine {nullptr} |
double | m_sampling_percentage |
Protected Member Functions inherited from handler | |
virtual int | multi_range_read_next (char **range_info) |
Get next record in MRR scan. More... | |
virtual int | records (ha_rows *num_rows) |
Number of rows in table. More... | |
virtual int | records_from_index (ha_rows *num_rows, uint index) |
Number of rows in table counted using the secondary index chosen by optimizer. More... | |
virtual int | index_read_idx_map (uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) |
Positions an index cursor to the index specified in argument. More... | |
virtual int | index_next_same (uchar *buf, const uchar *key, uint keylen) |
virtual int | index_read_last_map (uchar *buf, const uchar *key, key_part_map keypart_map) |
The following functions works like index_read, but it find the last row with the current key value or prefix. More... | |
virtual int | read_range_first (const key_range *start_key, const key_range *end_key, bool eq_range_arg, bool sorted) |
Read first row between two ranges. More... | |
virtual int | read_range_next () |
Read next row between two endpoints. More... | |
virtual int | ft_read (uchar *) |
virtual int | index_read_pushed (uchar *, const uchar *, key_part_map) |
virtual int | index_next_pushed (uchar *) |
virtual bool | prepare_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_table_def, dd::Table *new_table_def) |
Allows the storage engine to update internal structures with concurrent writes blocked. More... | |
virtual bool | inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_table_def, dd::Table *new_table_def) |
Alter the table structure in-place with operations specified using HA_ALTER_FLAGS and Alter_inplace_info. More... | |
virtual bool | commit_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit, const dd::Table *old_table_def, dd::Table *new_table_def) |
Commit or rollback the changes made during prepare_inplace_alter_table() and inplace_alter_table() inside the storage engine. More... | |
virtual void | notify_table_changed (Alter_inplace_info *ha_alter_info) |
Notify the storage engine that the table definition has been updated. More... | |
void | ha_statistic_increment (ulonglong System_status_var::*offset) const |
THD * | ha_thd () const |
PSI_table_share * | ha_table_share_psi (const TABLE_SHARE *share) const |
Acquire the instrumented table information from a table share. More... | |
virtual int | index_read (uchar *buf, const uchar *key, uint key_len, enum ha_rkey_function find_flag) |
virtual int | index_read_last (uchar *buf, const uchar *key, uint key_len) |
Handler_share * | get_ha_share_ptr () |
Get an initialized ha_share. More... | |
void | set_ha_share_ptr (Handler_share *arg_ha_share) |
Set ha_share to be used by all instances of the same table/partition. More... | |
void | lock_shared_ha_data () |
Take a lock for protecting shared handler data. More... | |
void | unlock_shared_ha_data () |
Release lock for protecting ha_share. More... | |
Protected Attributes inherited from handler | |
TABLE_SHARE * | table_share |
TABLE * | table |
Table_flags | cached_table_flags {0} |
ha_rows | estimation_rows_to_insert |
KEY_PART_INFO * | range_key_part |
bool | eq_range |
bool | in_range_check_pushed_down |
Class definition for the storage engine.
ha_example::ha_example | ( | handlerton * | hton, |
TABLE_SHARE * | table_arg | ||
) |
|
overridedefault |
|
overridevirtual |
We implement this in ha_example.cc; it's a required method.
Closes a table.
Called from sql_base.cc, sql_select.cc, and table.cc. In sql_select.cc it is only used to close up temporary tables or during the process where a temporary table is converted over to being a myisam table.
For sql_base.cc look at close_data_tables().
Implements handler.
|
overridevirtual |
required
create() is called to create a database.
The variable name will have the name of the table.
When create() is called you do not need to worry about opening the table. Also, the .frm file will have already been created so adjusting create_info is not necessary. You can overwrite the .frm file at this point if you wish to change the table definition, but there are no methods currently provided for doing so.
Called from handle.cc by ha_create_table().
Implements handler.
|
overridevirtual |
Used to delete all rows in a table, including cases of truncate and cases where the optimizer realizes that all rows will be removed as a result of an SQL statement.
Called from item_sum.cc by Item_func_group_concat::clear(), Item_sum_count_distinct::clear(), and Item_func_group_concat::clear(). Called from sql_delete.cc by mysql_delete(). Called from sql_select.cc by JOIN::reinit(). Called from sql_union.cc by st_query_block_query_expression::exec().
Reimplemented from handler.
|
overridevirtual |
We implement this in ha_example.cc.
This will delete a row.
It's not an obligatory method; skip it and and MySQL will treat it as not implemented.
buf will contain a copy of the row to be deleted. The server will call this right after the current row has been called (from either a previous rnd_nexT() or index call).
If you keep a pointer to the last row or can access a primary key it will make doing the deletion quite a bit easier. Keep in mind that the server does not guarantee consecutive deletions. ORDER BY clauses can be used.
Called in sql_acl.cc and sql_udf.cc to manage internal table information. Called in sql_delete.cc, sql_insert.cc, and sql_select.cc. In sql_select it is used for removing duplicates while in insert it is used for REPLACE calls.
Reimplemented from handler.
|
overridevirtual |
Used to delete a table.
By the time delete_table() has been called all opened references to this table will have been closed (and your globally shared references released). The variable name will just be the name of the table. You will need to remove any files you have created at this point.
If you do not implement this, the default delete_table() is called from handler.cc and it will delete all files with the file extensions from handlerton::file_extensions.
Called from handler.cc by delete_table and ha_create_table(). Only used during create if the table_flag HA_DROP_BEFORE_CREATE was specified for the storage engine.
Reimplemented from handler.
|
overridevirtual |
required
This create a lock on the table.
If you are implementing a storage engine that can handle transacations look at ha_berkely.cc to see how you will want to go about doing this. Otherwise you should consider calling flock() here. Hint: Read the section "locking functions for mysql" in lock.cc to understand this.
Called from lock.cc by lock_external() and unlock_external(). Also called from sql_table.cc by copy_data_between_tables().
Reimplemented from handler.
|
overridevirtual |
extra() is called whenever the server wishes to send a hint to the storage engine.
The myisam engine implements the most hints. ha_innodb.cc has the most exhaustive list of these hints.
Reimplemented from handler.
|
inlineoverridevirtual |
Replace key algorithm with one supported by SE, return the default key algorithm for SE if explicit key algorithm was not provided.
Reimplemented from handler.
|
private |
Get the share.
Example of simple lock controls.
The "share" it creates is a structure we will pass to each example handler. Do you have to have one of these? Well, you have pieces that are used for locking, and they are needed to function.
|
overridevirtual |
We implement this in ha_example.cc.
index_first() asks for the first key in the index.
It's not an obligatory method; skip it and and MySQL will treat it as not implemented.
Called from opt_range.cc, opt_sum.cc, sql_handler.cc, and sql_select.cc.
Reimplemented from handler.
|
inlineoverridevirtual |
This is a bitmap of flags that indicates how the storage engine implements indexes.
The current index flags are documented in handler.h. If you do not implement indexes, just return zero here.
part is the key part to check. First key part is 0. If all_parts is set, MySQL wants to know the flags for the combined index, up to and including 'part'.
Implements handler.
|
overridevirtual |
We implement this in ha_example.cc.
index_last() asks for the last key in the index.
It's not an obligatory method; skip it and and MySQL will treat it as not implemented.
Called from opt_range.cc, opt_sum.cc, sql_handler.cc, and sql_select.cc.
Reimplemented from handler.
|
overridevirtual |
We implement this in ha_example.cc.
Used to read forward through the index.
It's not an obligatory method; skip it and and MySQL will treat it as not implemented.
Reimplemented from handler.
|
overridevirtual |
We implement this in ha_example.cc.
Used to read backwards through the index.
It's not an obligatory method; skip it and and MySQL will treat it as not implemented.
Reimplemented from handler.
|
overridevirtual |
We implement this in ha_example.cc.
Positions an index cursor to the index specified in the handle.
It's not an obligatory method; skip it and and MySQL will treat it as not implemented.
Fetches the row if available. If the key value is null, begin at the first key of the index.
Reimplemented from handler.
|
overridevirtual |
required
info() is used to return information to the optimizer.
See my_base.h for the complete description.
Currently this table handler doesn't implement most of the fields really needed. SHOW also makes use of this data.
You will probably want to have the following in your code:
The reason is that the server will optimize for cases of only a single record. If, in a table scan, you don't know the number of records, it will probably be better to set records to two so you can return as many records as you need. Along with records, a few more variables you may wish to set are: records deleted data_file_length index_file_length delete_length check_time Take a look at the public variables in handler.h for more information.
Called in filesort.cc, ha_heap.cc, item_sum.cc, opt_sum.cc, sql_delete.cc, sql_delete.cc, sql_derived.cc, sql_select.cc, sql_select.cc, sql_select.cc, sql_select.cc, sql_select.cc, sql_show.cc, sql_show.cc, sql_show.cc, sql_show.cc, sql_table.cc, sql_union.cc, and sql_update.cc.
Implements handler.
|
inlineoverridevirtual |
Check if SE supports specific key algorithm.
Reimplemented from handler.
|
inlineoverridevirtual |
unireg.cc will call this to make sure that the storage engine can handle the data it is about to send.
Return real limits of your storage engine here; MySQL will do min(your_limits, MySQL_limits) automatically.
There is no need to implement ..._key_... methods if your engine doesn't support indexes.
Reimplemented from handler.
|
inlineoverridevirtual |
unireg.cc will call this to make sure that the storage engine can handle the data it is about to send.
Return real limits of your storage engine here; MySQL will do min(your_limits, MySQL_limits) automatically.
There is no need to implement ..._key_... methods if your engine doesn't support indexes.
Reimplemented from handler.
|
inlineoverridevirtual |
unireg.cc will call this to make sure that the storage engine can handle the data it is about to send.
Return real limits of your storage engine here; MySQL will do min(your_limits, MySQL_limits) automatically.
There is no need to implement ..._key_... methods if your engine doesn't support indexes.
Reimplemented from handler.
|
inlineoverridevirtual |
unireg.cc will call max_supported_record_length(), max_supported_keys(), max_supported_key_parts(), uint max_supported_key_length() to make sure that the storage engine can handle the data it is about to send.
Return real limits of your storage engine here; MySQL will do min(your_limits, MySQL_limits) automatically.
Reimplemented from handler.
|
overridevirtual |
We implement this in ha_example.cc; it's a required method.
Used for opening tables.
The name will be the name of the file.
A table is opened when it needs to be opened; e.g. when a request comes in for a SELECT on the table (tables are not open and closed for each request, they are cached).
Called from handler.cc by handler::ha_open(). The server opens all tables by calling ha_open() which then calls the handler specific open().
Implements handler.
|
overridevirtual |
required
position() is called after each call to rnd_next() if the data needs to be ordered.
You can do something like the following to store the position:
The server uses ref to store data. ref_length in the above case is the size needed to store current_position. ref is just a byte array that the server will maintain. If you are using offsets to mark rows, then current_position should be the offset. If it is a primary key like in BDB, then it needs to be a primary key.
Called from filesort.cc, sql_select.cc, sql_delete.cc, and sql_update.cc.
Implements handler.
|
inlineoverridevirtual |
This method will never be called if you do not implement indexes.
Reimplemented from handler.
|
overridevirtual |
Given a starting key and an ending key, estimate the number of rows that will exist between the two keys.
end_key may be empty, in which case determine if start_key matches any rows.
Called from opt_range.cc by check_quick_keys().
Reimplemented from handler.
|
overridevirtual |
Renames a table from one name to another via an alter table call.
If you do not implement this, the default rename_table() is called from handler.cc and it will delete all files with the file extensions from handlerton::file_extensions.
Called from sql_table.cc by mysql_rename_table().
Reimplemented from handler.
|
overridevirtual |
Reimplemented from handler.
|
overridevirtual |
Unlike index_init(), rnd_init() can be called two consecutive times without rnd_end() in between (it only makes sense if scan=1).
rnd_init() is called when the system wants the storage engine to do a table scan.
In this case, the second call should prepare for the new table scan (e.g if rnd_init() allocates the cursor, the second call should position the cursor to the start of the table; no need to deallocate and allocate it again. This is a required method.
See the example in the introduction at the top of this file to see when rnd_init() is called.
Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc, and sql_update.cc.
Implements handler.
|
overridevirtual |
required
This is called for each row of the table scan.
When you run out of records you should return HA_ERR_END_OF_FILE. Fill buff up with the row information. The Field structure for the table is the key to getting data into buf in a manner that will allow the server to understand it.
Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc, and sql_update.cc.
Implements handler.
required
This is like rnd_next, but you are given a position to use to determine the row.
The position will be of the type that you stored in ref. You can use ha_get_ptr(pos,ref_length) to retrieve whatever key or position you saved when position() was called.
Called from filesort.cc, records.cc, sql_insert.cc, sql_select.cc, and sql_update.cc.
Implements handler.
|
inlineoverridevirtual |
Called in test_quick_select to determine if indexes should be used.
Reimplemented from handler.
|
overridevirtual |
required
The idea with handler::store_lock() is: The statement decides which locks should be needed for the table.
For updates/deletes/inserts we get WRITE locks, for SELECT... we get read locks.
Before adding the lock into the table lock handler (see thr_lock.c), mysqld calls store lock with the requested locks. Store lock can now modify a write lock to a read lock (or some other lock), ignore the lock (if we don't want to use MySQL table locks at all), or add locks for many tables (like we do when we are using a MERGE handler).
Berkeley DB, for example, changes all WRITE locks to TL_WRITE_ALLOW_WRITE (which signals that we are doing WRITES, but are still allowing other readers and writers).
When releasing locks, store_lock() is also called. In this case one usually doesn't have to do anything.
In some exceptional cases MySQL may send a request for a TL_IGNORE; This means that we are requesting the same lock as last time and this should also be ignored. (This may happen when someone does a flush table when we have opened a part of the tables, in which case mysqld closes and reopens the tables and tries to get the same locks at last time). In the future we will probably try to remove this.
Called from lock.cc by get_lock_data().
Implements handler.
|
inlineoverridevirtual |
This is a list of flags that indicate what functionality the storage engine implements.
The current table flags are documented in handler.h
Implements handler.
|
inlineoverridevirtual |
The name that will be used for display purposes.
Implements handler.
We implement this in ha_example.cc.
Yes, update_row() does what you expect, it updates a row.
It's not an obligatory method; skip it and and MySQL will treat it as not implemented.
old_data will have the previous row record in it, while new_data will have the newest data in it. Keep in mind that the server can do updates based on ordering if an ORDER BY clause was used. Consecutive ordering is not guaranteed.
Currently new_data will not have an updated auto_increament record. You can do this for example by doing:
Called from sql_select.cc, sql_acl.cc, sql_update.cc, and sql_insert.cc.
Reimplemented from handler.
|
overridevirtual |
We implement this in ha_example.cc.
write_row() inserts a row.
It's not an obligatory method; skip it and and MySQL will treat it as not implemented.
No extra() hint is given currently if a bulk load is happening. buf() is a byte array of data. You can use the field information to extract the data from the native byte array type.
Example of this would be:
See ha_tina.cc for an example of extracting all of the data as strings. ha_berekly.cc has an example of how to store it intact by "packing" it for ha_berkeley's own native storage type.
See the note for update_row() on auto_increments. This case also applies to write_row().
Called from item_sum.cc, item_sum.cc, sql_acl.cc, sql_insert.cc, sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc, and sql_update.cc.
Reimplemented from handler.
|
private |
MySQL lock.
|
private |
Shared lock info.