MySQL 8.4.3
Source Code Documentation
temptable::Handler Class Reference

Temptable engine handler. More...

#include <handler.h>

Inheritance diagram for temptable::Handler:
[legend]

Public Types

enum class  NextCondition { NO , ONLY_IF_SAME }
 A condition used by index_next_conditional() to control whether to fetch the next row or not. More...
 
- 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 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...
 

Public Member Functions

 Handler (handlerton *hton, TABLE_SHARE *table_share)
 Constructor. More...
 
 ~Handler () override=default
 Destructor. More...
 
int create (const char *table_name, TABLE *mysql_table, HA_CREATE_INFO *, dd::Table *) override
 Create an in-memory table. More...
 
int delete_table (const char *table_name, const dd::Table *) override
 Delete a table. More...
 
int open (const char *table_name, int, uint, const dd::Table *) override
 Open an existing table. More...
 
int close () override
 Close the opened table. More...
 
int rnd_init (bool) override
 Begin a table scan. More...
 
int rnd_next (uchar *mysql_row) override
 Advance the cursor to the next row in insertion order and retrieve it. More...
 
int rnd_pos (uchar *mysql_row, uchar *position) override
 Fetch the record pointed by position. More...
 
int rnd_end () override
 End a table scan. More...
 
int index_init (uint index_no, bool) override
 Set the index to be used by subsequent index_*() calls. More...
 
int index_read (uchar *mysql_row, const uchar *mysql_search_cells, uint mysql_search_cells_len_bytes, ha_rkey_function find_flag) override
 Read a row from the currently opened table using the index set with index_init(). More...
 
int index_next (uchar *mysql_row) override
 Advance the index cursor and read the row at that position. More...
 
int index_next_same (uchar *mysql_row, const uchar *, uint) override
 Advance the index cursor and read the row at that position if its indexed cells are the same as in the current row. More...
 
Result index_next_conditional (uchar *mysql_row, NextCondition condition)
 Advance the index cursor and read the row at that position, conditionally. More...
 
int index_read_last (uchar *mysql_row, const uchar *mysql_search_cells, uint mysql_search_cells_len_bytes) override
 Read the last row that matches mysql_search_cells (in index order). More...
 
int index_prev (uchar *mysql_row) override
 Step to the previous row in index order. More...
 
int index_end () override
 End an index scan. More...
 
void position (const uchar *) override
 Store position to current row inside the handler. More...
 
int write_row (uchar *mysql_row) override
 Insert a new row to the currently opened table. More...
 
int update_row (const uchar *mysql_row_old, uchar *mysql_row_new) override
 Update a row. More...
 
int delete_row (const uchar *mysql_row) override
 Delete the row where the handler is currently positioned. More...
 
int truncate (dd::Table *) override
 Delete all rows in the table. More...
 
int delete_all_rows () override
 Delete all rows in the table. More...
 
int info (uint flag) override
 Refresh table stats. More...
 
longlong get_memory_buffer_size () const override
 Get the limit on the memory usage. More...
 
const char * table_type () const override
 Get the name of the storage engine. More...
 
Table_flags table_flags () const override
 Get the table flags. More...
 
ulong index_flags (uint index_no, uint, bool) const override
 Get the flags for a given index. More...
 
ha_key_alg get_default_index_algorithm () const override
 Get the default index algorithm. More...
 
bool is_index_algorithm_supported (ha_key_alg algorithm) const override
 Check whether an index algorithm is supported. More...
 
uint max_supported_key_length () const override
 Get the maximum supported index length in bytes. More...
 
uint max_supported_key_part_length (HA_CREATE_INFO *create_info) const override
 Get the maximum supported indexed columns length. More...
 
THR_LOCK_DATA ** store_lock (THD *, THR_LOCK_DATA **, thr_lock_type) override
 Not implemented. More...
 
double scan_time () override
 Scan time. More...
 
double read_time (uint, uint, ha_rows rows) override
 Read time. More...
 
int disable_indexes (uint mode) override
 Disable indexes. More...
 
int enable_indexes (uint mode) override
 Enable indexes. More...
 
int external_lock (THD *, int) override
 Not implemented. More...
 
void unlock_row () override
 Not implemented. More...
 
handlerclone (const char *, MEM_ROOT *) override
 Not implemented. More...
 
int index_first (uchar *) override
 Not implemented. More...
 
int index_last (uchar *) override
 Not implemented. More...
 
int analyze (THD *, HA_CHECK_OPT *) override
 Not implemented. More...
 
int optimize (THD *, HA_CHECK_OPT *) override
 Not implemented. More...
 
int check (THD *, HA_CHECK_OPT *) override
 Not implemented. More...
 
int start_stmt (THD *, thr_lock_type) override
 Not implemented. More...
 
int reset () override
 Not implemented. More...
 
int records (ha_rows *) override
 Not implemented. More...
 
void update_create_info (HA_CREATE_INFO *) override
 Not implemented. More...
 
int rename_table (const char *, const char *, const dd::Table *, dd::Table *) override
 Not implemented. More...
 
void init_table_handle_for_HANDLER () override
 Not implemented. More...
 
bool get_error_message (int, String *) override
 Not implemented. More...
 
bool primary_key_is_clustered () const override
 Not implemented. More...
 
int cmp_ref (const uchar *, const uchar *) const override
 Not implemented. More...
 
bool check_if_incompatible_data (HA_CREATE_INFO *, uint) override
 Not implemented. 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...
 
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_bufferha_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 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...
 
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_SHAREget_table_share () const
 
const TABLEget_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...
 
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_INFOft_init_ext (uint flags, uint inx, String *key)
 
virtual FT_INFOft_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 ha_rows records_in_range (uint inx, key_range *min_key, key_range *max_key)
 Find number of records in a range. 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 handlertonhton_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 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 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)
 
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_record_length () const
 
virtual uint max_supported_keys () const
 
virtual uint max_supported_key_parts () 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 const Itemcond_push (const Item *cond)
 Push condition down to the table handler. More...
 
virtual Itemidx_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 TABLEmember_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 TABLEparent_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 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 bool check_and_repair (THD *thd)
 Check and repair the table if necessary. 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_handlerget_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...
 
handlerha_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

void opened_table_validate ()
 
bool is_field_type_fixed_size (const Field &mysql_field) const
 Checks if field has a fixed size. More...
 

Private Attributes

Tablem_opened_table
 Currently opened table, or nullptr if none is opened. More...
 
Blockm_shared_block
 Pointer to the non-owned shared-block of memory to be re-used by all Allocator instances or copies made by Table. More...
 
Storage::Iterator m_rnd_iterator
 Iterator used by rnd_init(), rnd_next() and rnd_end() methods. More...
 
bool m_rnd_iterator_is_positioned
 Flag that denotes whether m_rnd_iterator is positioned. More...
 
Cursor m_index_cursor
 Cursor used by index_*() methods. More...
 
size_t m_index_read_number_of_cells
 Number of cells to compare in index_next() after index_read() has positioned m_index_cursor. More...
 
size_t m_deleted_rows
 Number of deleted rows by this handler object. More...
 

Additional Inherited Members

- 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
handlertonht
 
ucharref
 Pointer to current row. More...
 
uchardup_ref
 Pointer to duplicate row. More...
 
ha_statistics stats
 
range_seq_t mrr_iter
 
RANGE_SEQ_IF mrr_funcs
 
HANDLER_BUFFERmulti_range_buffer
 
uint ranges_in_seq
 
bool mrr_is_output_sorted
 
bool mrr_have_range
 
KEY_MULTI_RANGE mrr_cur_range
 
key_rangeend_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_INFOft_handler
 
enum handler:: { ... }  inited
 
bool implicit_emptied
 
const Itempushed_cond
 
Itempushed_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_tablem_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_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_map (uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
 Positions an index cursor to the index specified in the handle ('active_index'). 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_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
 
THDha_thd () const
 
PSI_table_shareha_table_share_psi (const TABLE_SHARE *share) const
 Acquire the instrumented table information from a table share. More...
 
Handler_shareget_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_SHAREtable_share
 
TABLEtable
 
Table_flags cached_table_flags {0}
 
ha_rows estimation_rows_to_insert
 
KEY_PART_INFOrange_key_part
 
bool eq_range
 
bool in_range_check_pushed_down
 

Detailed Description

Temptable engine handler.

Member Enumeration Documentation

◆ NextCondition

A condition used by index_next_conditional() to control whether to fetch the next row or not.

Enumerator
NO 

No condition - fetch the next row unconditionally.

ONLY_IF_SAME 

Fetch the next row only if it is the same as the current one.

Constructor & Destructor Documentation

◆ Handler()

temptable::Handler::Handler ( handlerton hton,
TABLE_SHARE table_share 
)

Constructor.

Parameters
[in]htonHandlerton, saved in `ht` in this class for later usage.
[in]table_shareTable data that is shared between handlers, saved in `table_share` in this class for later usage.

◆ ~Handler()

temptable::Handler::~Handler ( )
overridedefault

Destructor.

Member Function Documentation

◆ analyze()

int temptable::Handler::analyze ( THD ,
HA_CHECK_OPT  
)
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ check()

int temptable::Handler::check ( THD ,
HA_CHECK_OPT  
)
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ check_if_incompatible_data()

bool temptable::Handler::check_if_incompatible_data ( HA_CREATE_INFO ,
uint   
)
overridevirtual

Not implemented.

Returns
false

Reimplemented from handler.

◆ clone()

handler * temptable::Handler::clone ( const char *  ,
MEM_ROOT  
)
overridevirtual

Not implemented.

Returns
nullptr

Reimplemented from handler.

◆ close()

int temptable::Handler::close ( void  )
overridevirtual

Close the opened table.

Returns
0 on success or HA_ERR_* error code

Implements handler.

◆ cmp_ref()

int temptable::Handler::cmp_ref ( const uchar ,
const uchar  
) const
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ create()

int temptable::Handler::create ( const char *  table_name,
TABLE mysql_table,
HA_CREATE_INFO ,
dd::Table  
)
overridevirtual

Create an in-memory table.

Returns
0 on success or HA_ERR_* error code
Parameters
[in]table_nameName of the new table. The engine does not try to parse it, so it can be anything as long as it is unique wrt other created tables and as long as the same name is given to the `open()` method.
[in]mysql_tableNew table structure (columns and indexes). Some of the members in `mysql_table->s` are remembered for later usage.

Implements handler.

◆ delete_all_rows()

int temptable::Handler::delete_all_rows ( void  )
overridevirtual

Delete all rows in the table.

Returns
0 on success or HA_ERR_* error code

Reimplemented from handler.

◆ delete_row()

int temptable::Handler::delete_row ( const uchar mysql_row)
overridevirtual

Delete the row where the handler is currently positioned.

This row must be equal to mysql_row and the handler must be positioned.

Returns
0 on success or HA_ERR_* error code
Parameters
[in]mysql_rowCopy of the row to be deleted.

Reimplemented from handler.

◆ delete_table()

int temptable::Handler::delete_table ( const char *  table_name,
const dd::Table  
)
overridevirtual

Delete a table.

Returns
0 on success or HA_ERR_* error code
Parameters
[in]table_nameName of the table to delete.

Reimplemented from handler.

◆ disable_indexes()

int temptable::Handler::disable_indexes ( uint  mode)
overridevirtual

Disable indexes.

Returns
0 on success or HA_ERR_* error code
Parameters
[in]modeMode. Only HA_KEY_SWITCH_ALL (disable all) is supported.

Reimplemented from handler.

◆ enable_indexes()

int temptable::Handler::enable_indexes ( uint  mode)
overridevirtual

Enable indexes.

This is only supported if the currently opened table is empty.

Returns
0 on success or HA_ERR_* error code
Parameters
[in]modeMode. Only HA_KEY_SWITCH_ALL (enable all) is supported.

Reimplemented from handler.

◆ external_lock()

int temptable::Handler::external_lock ( THD ,
int   
)
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ get_default_index_algorithm()

ha_key_alg temptable::Handler::get_default_index_algorithm ( ) const
overridevirtual

Get the default index algorithm.

Returns
index type

Reimplemented from handler.

◆ get_error_message()

bool temptable::Handler::get_error_message ( int  ,
String  
)
overridevirtual

Not implemented.

Returns
false

Reimplemented from handler.

◆ get_memory_buffer_size()

longlong temptable::Handler::get_memory_buffer_size ( ) const
overridevirtual

Get the limit on the memory usage.

Reimplemented from handler.

◆ index_end()

int temptable::Handler::index_end ( void  )
overridevirtual

End an index scan.

Returns
0 on success or HA_ERR_* error code

Reimplemented from handler.

◆ index_first()

int temptable::Handler::index_first ( uchar )
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ index_flags()

ulong temptable::Handler::index_flags ( uint  index_no,
uint  ,
bool   
) const
overridevirtual

Get the flags for a given index.

Returns
index flags
Parameters
[in]index_noIndex number (0-based).

Implements handler.

◆ index_init()

int temptable::Handler::index_init ( uint  index_no,
bool   
)
overridevirtual

Set the index to be used by subsequent index_*() calls.

Returns
0 on success or HA_ERR_* error code
Parameters
[in]index_noindex number (0-based).

Reimplemented from handler.

◆ index_last()

int temptable::Handler::index_last ( uchar )
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ index_next()

int temptable::Handler::index_next ( uchar mysql_row)
overridevirtual

Advance the index cursor and read the row at that position.

Iteration is started by index_first() or index_read().

Returns
0 on success or HA_ERR_* error code
Parameters
[out]mysql_rowOutput where the retrieved row is written to.

Reimplemented from handler.

◆ index_next_conditional()

Result temptable::Handler::index_next_conditional ( uchar mysql_row,
NextCondition  condition 
)

Advance the index cursor and read the row at that position, conditionally.

  • depending on the specified condition.
    Returns
    0 on success or HA_ERR_* error code
Parameters
[out]mysql_rowOutput where the retrieved row is written to.
[in]conditionCondition which dictates whether to fetch the next row or not.

◆ index_next_same()

int temptable::Handler::index_next_same ( uchar mysql_row,
const uchar ,
uint   
)
overridevirtual

Advance the index cursor and read the row at that position if its indexed cells are the same as in the current row.

Returns
0 on success or HA_ERR_* error code
Parameters
[out]mysql_rowOutput where the retrieved row is written to.

Reimplemented from handler.

◆ index_prev()

int temptable::Handler::index_prev ( uchar mysql_row)
overridevirtual

Step to the previous row in index order.

Returns
0 on success or HA_ERR_* error code
Parameters
[out]mysql_rowOutput where the retrieved row is written to.

Reimplemented from handler.

◆ index_read()

int temptable::Handler::index_read ( uchar mysql_row,
const uchar mysql_search_cells,
uint  mysql_search_cells_len_bytes,
ha_rkey_function  find_flag 
)
overridevirtual

Read a row from the currently opened table using the index set with index_init().

Returns
0 on success or HA_ERR_* error code
Parameters
[out]mysql_rowOutput where the retrieved row is written to.
[in]mysql_search_cellsConcatenated cells that are to be searched for. For example if the table has columns `c1=INT, c2=INT, c3=VARCHAR(16)` and an index on `(c1, c3)` and we are searching for `WHERE c1=5 AND c3='foo'`, then this will contain 5 and 'foo' concatenated. It may also contain a prefix of the indexed columns.
[in]mysql_search_cells_len_bytesThe length of `mysql_search_cells` in bytes.
[in]find_flagFlag denoting how to search for the row.

Reimplemented from handler.

◆ index_read_last()

int temptable::Handler::index_read_last ( uchar mysql_row,
const uchar mysql_search_cells,
uint  mysql_search_cells_len_bytes 
)
overridevirtual

Read the last row that matches mysql_search_cells (in index order).

Returns
0 on success or HA_ERR_* error code
Parameters
[out]mysql_rowOutput where the retrieved row is written to.
[in]mysql_search_cellsConcatenated cells that are to be searched for.
See also
`index_read()`.
Parameters
[in]mysql_search_cells_len_bytesThe length of `mysql_search_cells` in bytes.

Reimplemented from handler.

◆ info()

int temptable::Handler::info ( uint  flag)
overridevirtual

Refresh table stats.

Returns
0 on success or HA_ERR_* error code.
Parameters
[in]flagWhich stats to refresh.

Implements handler.

◆ init_table_handle_for_HANDLER()

void temptable::Handler::init_table_handle_for_HANDLER ( void  )
overridevirtual

Not implemented.

Reimplemented from handler.

◆ is_field_type_fixed_size()

bool temptable::Handler::is_field_type_fixed_size ( const Field mysql_field) const
inlineprivate

Checks if field has a fixed size.

Returns
true if field has fixed size, false otherwise
Parameters
[in]mysql_fieldField descriptor.

◆ is_index_algorithm_supported()

bool temptable::Handler::is_index_algorithm_supported ( ha_key_alg  algorithm) const
overridevirtual

Check whether an index algorithm is supported.

Returns
true if supported
Parameters
[in]algorithmAlgorithm to check if supported.

Reimplemented from handler.

◆ max_supported_key_length()

uint temptable::Handler::max_supported_key_length ( ) const
overridevirtual

Get the maximum supported index length in bytes.

Returns
max length

Reimplemented from handler.

◆ max_supported_key_part_length()

uint temptable::Handler::max_supported_key_part_length ( HA_CREATE_INFO create_info) const
overridevirtual

Get the maximum supported indexed columns length.

Returns
max length

Reimplemented from handler.

◆ open()

int temptable::Handler::open ( const char *  table_name,
int  ,
uint  ,
const dd::Table  
)
overridevirtual

Open an existing table.

A reference to the opened table is kept internally. Only one table can be opened at a time and the read&write methods operate on it.

Returns
0 on success or HA_ERR_* error code
Parameters
[in]table_nameName of the table to open.

Implements handler.

◆ opened_table_validate()

void temptable::Handler::opened_table_validate ( )
inlineprivate

◆ optimize()

int temptable::Handler::optimize ( THD ,
HA_CHECK_OPT  
)
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ position()

void temptable::Handler::position ( const uchar )
overridevirtual

Store position to current row inside the handler.

Implements handler.

◆ primary_key_is_clustered()

bool temptable::Handler::primary_key_is_clustered ( ) const
overridevirtual

Not implemented.

Returns
false

Reimplemented from handler.

◆ read_time()

double temptable::Handler::read_time ( uint  ,
uint  ,
ha_rows  rows 
)
overridevirtual

Read time.

The unit of the return value is "disk access". E.g. if the operation would require the disk to be accessed 5 times, then 5.0 would be returned.

Deprecated:
This function is deprecated and will be removed in a future version. Use handler::read_cost() instead.
Returns
estimate based on the number of rows
Parameters
[in]rowsTotal number of rows to be read.

Reimplemented from handler.

◆ records()

int temptable::Handler::records ( ha_rows )
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ rename_table()

int temptable::Handler::rename_table ( const char *  ,
const char *  ,
const dd::Table ,
dd::Table  
)
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ reset()

int temptable::Handler::reset ( void  )
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ rnd_end()

int temptable::Handler::rnd_end ( void  )
overridevirtual

End a table scan.

The table scan cursor is invalidated.

Returns
0 on success or HA_ERR_* error code

Reimplemented from handler.

◆ rnd_init()

int temptable::Handler::rnd_init ( bool  )
overridevirtual

Begin a table scan.

The cursor is positioned before the first row in insertion order and subsequent iterations with rnd_next() will return the rows in insertion order. position() must not be called immediately after rnd_init() without a call to rnd_next() after rnd_init().

Returns
0 on success or HA_ERR_* error code

Implements handler.

◆ rnd_next()

int temptable::Handler::rnd_next ( uchar mysql_row)
overridevirtual

Advance the cursor to the next row in insertion order and retrieve it.

If no more rows remain in the table, then HA_ERR_END_OF_FILE is returned. This method can then be called multiple times and it will keep returning HA_ERR_END_OF_FILE. If a new row is inserted after this method has returned HA_ERR_END_OF_FILE and this method is called again then it will fetch the newly inserted row.

Returns
0 on success or HA_ERR_* error code
Parameters
[out]mysql_rowOutput where the retrieved row is written to.

Implements handler.

◆ rnd_pos()

int temptable::Handler::rnd_pos ( uchar mysql_row,
uchar position 
)
overridevirtual

Fetch the record pointed by position.

Returns
0 on success or HA_ERR_* error code
Parameters
[out]mysql_rowOutput where the retrieved row is written to.
[in]positionPosition pointing to a row. Must be retrieved from `handlerref` after a call to `position()`.

Implements handler.

◆ scan_time()

double temptable::Handler::scan_time ( )
overridevirtual

Scan time.

The unit of the return value is "disk access". E.g. if the operation would require the disk to be accessed 5 times, then 5.0 would be returned.

Deprecated:
This function is deprecated and will be removed in a future version. Use handler::table_scan_cost() instead.
Returns
estimate based on the number of rows

Reimplemented from handler.

◆ start_stmt()

int temptable::Handler::start_stmt ( THD ,
thr_lock_type   
)
overridevirtual

Not implemented.

Returns
0

Reimplemented from handler.

◆ store_lock()

THR_LOCK_DATA ** temptable::Handler::store_lock ( THD ,
THR_LOCK_DATA **  ,
thr_lock_type   
)
overridevirtual

Not implemented.

Implements handler.

◆ table_flags()

handler::Table_flags temptable::Handler::table_flags ( void  ) const
overridevirtual

Get the table flags.

Returns
table flags

Implements handler.

◆ table_type()

const char * temptable::Handler::table_type ( ) const
overridevirtual

Get the name of the storage engine.

Returns
name

Implements handler.

◆ truncate()

int temptable::Handler::truncate ( dd::Table )
overridevirtual

Delete all rows in the table.

Returns
0 on success or HA_ERR_* error code

Reimplemented from handler.

◆ unlock_row()

void temptable::Handler::unlock_row ( void  )
overridevirtual

Not implemented.

Reimplemented from handler.

◆ update_create_info()

void temptable::Handler::update_create_info ( HA_CREATE_INFO )
overridevirtual

Not implemented.

Reimplemented from handler.

◆ update_row()

int temptable::Handler::update_row ( const uchar mysql_row_old,
uchar mysql_row_new 
)
overridevirtual

Update a row.

Returns
0 on success or HA_ERR_* error code
Parameters
[in]mysql_row_oldOriginal row to find and update.
[in]mysql_row_newNew row to put into the place of the old one.

Reimplemented from handler.

◆ write_row()

int temptable::Handler::write_row ( uchar mysql_row)
overridevirtual

Insert a new row to the currently opened table.

Returns
0 on success or HA_ERR_* error code
Parameters
[in]mysql_rowRow to insert.

Reimplemented from handler.

Member Data Documentation

◆ m_deleted_rows

size_t temptable::Handler::m_deleted_rows
private

Number of deleted rows by this handler object.

◆ m_index_cursor

Cursor temptable::Handler::m_index_cursor
private

Cursor used by index_*() methods.

It points to the current record that will be retrieved by the next read call (e.g. index_next()).

◆ m_index_read_number_of_cells

size_t temptable::Handler::m_index_read_number_of_cells
private

Number of cells to compare in index_next() after index_read() has positioned m_index_cursor.

If we have an index on two columns, e.g. (c1, c2) and rows: (5, 6), (5, 7) and index_read() is requested to fetch the row where c1=5 then we will fetch the first row and position the index cursor on (5, 6). A subsequent call to index_next() must go to the next row if it is the same as the current, but only comparing the first cell. So in order to be able to treat (5, 6) equal to (5, 7) during index_next() (because the index_read() call only specified the first cell) we remember the number of cells to compare in this variable.

◆ m_opened_table

Table* temptable::Handler::m_opened_table
private

Currently opened table, or nullptr if none is opened.

◆ m_rnd_iterator

Storage::Iterator temptable::Handler::m_rnd_iterator
private

Iterator used by rnd_init(), rnd_next() and rnd_end() methods.

It points to the row that was retrieved by the last read call (e.g. rnd_next()).

◆ m_rnd_iterator_is_positioned

bool temptable::Handler::m_rnd_iterator_is_positioned
private

Flag that denotes whether m_rnd_iterator is positioned.

rnd_init() "unpositions" the iterator, so that rnd_next() knows to start from the first row when the iterator is not positioned.

◆ m_shared_block

Block* temptable::Handler::m_shared_block
private

Pointer to the non-owned shared-block of memory to be re-used by all Allocator instances or copies made by Table.


The documentation for this class was generated from the following files: