MySQL  8.0.20
Source Code Documentation
ha_innobase Class Reference

The class defining a handle to an InnoDB table. More...

#include <ha_innodb.h>

Inheritance diagram for ha_innobase:
handler ha_innopart

Public Types

using Reader = Parallel_reader_adapter
 
- 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

 ha_innobase (handlerton *hton, TABLE_SHARE *table_arg)
 Construct ha_innobase handler. More...
 
 ~ha_innobase () override
 Destruct ha_innobase handler. More...
 
row_type get_real_row_type (const HA_CREATE_INFO *create_info) const override
 Get real row type for the table created based on one specified by user, CREATE TABLE options and SE capabilities. More...
 
const char * table_type () const override
 Returns the table type (storage engine name). More...
 
enum ha_key_alg get_default_index_algorithm () const override
 Get default key algorithm for SE. More...
 
bool is_index_algorithm_supported (enum ha_key_alg key_alg) const override
 Check if SE supports specific key algorithm. More...
 
Table_flags table_flags () const override
 Get the table flags to use for the statement. More...
 
ulong index_flags (uint idx, uint part, bool all_parts) const override
 Returns the operations supported for indexes. More...
 
uint max_supported_keys () const override
 Returns the maximum number of keys. More...
 
uint max_supported_key_length () const override
 Returns the maximum key length. More...
 
uint max_supported_key_part_length (HA_CREATE_INFO *create_info) const override
 
int open (const char *name, int, uint open_flags, const dd::Table *table_def) override
 Open an InnoDB table. More...
 
handlerclone (const char *name, MEM_ROOT *mem_root) override
 
int close (void) override
 Closes a handle to an InnoDB table. More...
 
double scan_time () override
 How many seeks it will take to read through the table. More...
 
double read_time (uint index, uint ranges, ha_rows rows) override
 Calculate the time it takes to read a set of ranges through an index This enables us to optimise reads for clustered indexes. More...
 
longlong get_memory_buffer_size () const override
 Return the size of the InnoDB memory buffer. More...
 
int write_row (uchar *buf) override
 Stores a row in an InnoDB database, to the table specified in this handle. More...
 
int update_row (const uchar *old_data, uchar *new_data) override
 Updates a row given as a parameter to a new value. More...
 
int delete_row (const uchar *buf) override
 Deletes a row given as the parameter. More...
 
int delete_all_rows () override
 Delete all rows from the table. More...
 
bool was_semi_consistent_read () override
 Normally, when running UPDATE or DELETE queries, we need to wait for other transactions to release their locks on a given row before we can read it and potentially update it. More...
 
void try_semi_consistent_read (bool yes) override
 Tell the engine whether it should avoid unnecessary lock waits. More...
 
void unlock_row () override
 Removes a new lock set on a row, if it was not read optimistically. More...
 
int index_init (uint index, bool sorted) override
 Initializes a handle to use an index. More...
 
int index_end () override
 Currently does nothing. More...
 
int index_read (uchar *buf, const uchar *key, uint key_len, ha_rkey_function find_flag) override
 Positions an index cursor to the index specified in the handle. More...
 
int index_read_last (uchar *buf, const uchar *key, uint key_len) override
 The following functions works like index_read, but it find the last row with the current key value or prefix. More...
 
int index_next (uchar *buf) override
 Reads the next row from a cursor, which must have previously been positioned using index_read. More...
 
int index_next_same (uchar *buf, const uchar *key, uint keylen) override
 Reads the next row matching to the key value given as the parameter. More...
 
int index_prev (uchar *buf) override
 Reads the previous row from a cursor, which must have previously been positioned using index_read. More...
 
int index_first (uchar *buf) override
 Positions a cursor on the first record in an index and reads the corresponding row to buf. More...
 
int index_last (uchar *buf) override
 Positions a cursor on the last record in an index and reads the corresponding row to buf. More...
 
int read_range_first (const key_range *start_key, const key_range *end_key, bool eq_range_arg, bool sorted) override
 Read first row between two ranges. More...
 
int read_range_next () override
 Read next row between two endpoints. More...
 
int rnd_init (bool scan) override
 Initialize a table scan. More...
 
int rnd_end () override
 Ends a table scan. More...
 
int rnd_next (uchar *buf) override
 Reads the next row in a table scan (also used to read the FIRST row in a table scan). More...
 
int rnd_pos (uchar *buf, uchar *pos) override
 Fetches a row from the table based on a row reference. More...
 
int ft_init () override
 Initialize FT index scan. More...
 
void ft_end ()
 
FT_INFOft_init_ext (uint flags, uint inx, String *key) override
 Initialize FT index scan. More...
 
FT_INFOft_init_ext_with_hints (uint inx, String *key, Ft_hints *hints) override
 Initialize FT index scan. More...
 
int ft_read (uchar *buf) override
 Fetch next result from the FT result set. More...
 
void position (const uchar *record) override
 Store a reference to the current row to 'ref' field of the handle. More...
 
int info (uint) override
 Returns statistics information of the table to the MySQL interpreter, in various fields of the handle object. More...
 
int enable_indexes (uint mode) override
 Enable indexes. More...
 
int disable_indexes (uint mode) override
 Disable indexes. More...
 
int analyze (THD *thd, HA_CHECK_OPT *check_opt) override
 Updates index cardinalities of the table, based on random dives into each index tree. More...
 
int optimize (THD *thd, HA_CHECK_OPT *check_opt) override
 This is mapped to "ALTER TABLE tablename ENGINE=InnoDB", which rebuilds the table in MySQL. More...
 
int discard_or_import_tablespace (bool discard, dd::Table *table_def) override
 Discards or imports an InnoDB tablespace. More...
 
int extra (ha_extra_function operation) override
 Tells something additional to the handler about how to do things. More...
 
int reset () override
 MySQL calls this method at the end of each statement. More...
 
int external_lock (THD *thd, int lock_type) override
 As MySQL will execute an external lock for every new table it uses when it starts to process an SQL statement (an exception is when MySQL calls start_stmt for the handle) we can use this function to store the pointer to the THD in the handle. More...
 
int sample_init (void *&scan_ctx, double sampling_percentage, int sampling_seed, enum_sampling_method sampling_method) override
 Initialize sampling. More...
 
int sample_next (void *scan_ctx, uchar *buf) override
 Get the next record for sampling. More...
 
int sample_end (void *scan_ctx) override
 End sampling. More...
 
int start_stmt (THD *thd, thr_lock_type lock_type) override
 MySQL calls this function at the start of each SQL statement inside LOCK TABLES. More...
 
void position (uchar *record)
 
int records (ha_rows *num_rows) override
 Returns the exact number of records that this client can see using this handler object. More...
 
int records_from_index (ha_rows *num_rows, uint) override
 Number of rows in table counted using the secondary index chosen by optimizer. More...
 
ha_rows records_in_range (uint inx, key_range *min_key, key_range *max_key) override
 Estimates the number of index records in a range. More...
 
ha_rows estimate_rows_upper_bound () override
 Gives an UPPER BOUND to the number of rows in a table. More...
 
void update_create_info (HA_CREATE_INFO *create_info) override
 Update create_info. More...
 
bool get_se_private_data (dd::Table *dd_table, bool reset) override
 Get storage-engine private data for a data dictionary table. More...
 
int get_extra_columns_and_keys (const HA_CREATE_INFO *, const List< Create_field > *, const KEY *, uint, dd::Table *dd_table) override
 Add hidden columns and indexes to an InnoDB table definition. More...
 
bool upgrade_table (THD *thd, const char *db_name, const char *table_name, dd::Table *dd_table) override
 Set Engine specific data to dd::Table object for upgrade. More...
 
int create (const char *name, TABLE *form, HA_CREATE_INFO *create_info, dd::Table *table_def) override
 Create an InnoDB table. More...
 
int delete_table (const char *name, const dd::Table *table_def) override
 Drop a table. More...
 
int rename_table (const char *from, const char *to, const dd::Table *from_table, dd::Table *to_table) override
 Renames an InnoDB table. More...
 
int check (THD *thd, HA_CHECK_OPT *check_opt) override
 Tries to check that an InnoDB table is not corrupted. More...
 
uint lock_count (void) const override
 Returns number of THR_LOCK locks used for one instance of InnoDB table. More...
 
THR_LOCK_DATA ** store_lock (THD *thd, THR_LOCK_DATA **to, thr_lock_type lock_type) override
 Supposed to convert a MySQL table lock stored in the 'lock' field of the handle to a proper type before storing pointer to the lock into an array of pointers. More...
 
void init_table_handle_for_HANDLER () override
 Call this when you have opened a new table handle in HANDLER, before you call index_read_map() etc. More...
 
virtual void get_auto_increment (ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong *first_value, ulonglong *nb_reserved_values) override
 Returns the value of the auto-inc counter in *first_value and ~0 on failure. More...
 
virtual bool get_error_message (int error, String *buf) override
 See comment in handler.cc. More...
 
virtual bool get_foreign_dup_key (char *, uint, char *, uint) override
 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...
 
bool primary_key_is_clustered () const override
 Determines if the primary key is clustered index. More...
 
int cmp_ref (const uchar *ref1, const uchar *ref2) const override
 Compares two 'refs'. More...
 
int parallel_scan_init (void *&scan_ctx, size_t &num_threads) override
 Initializes a parallel scan. More...
 
int parallel_scan (void *scan_ctx, void **thread_ctxs, Reader::Init_fn init_fn, Reader::Load_fn load_fn, Reader::End_fn end_fn) override
 Start parallel read of InnoDB records. More...
 
void parallel_scan_end (void *scan_ctx) override
 End of the parallel scan. More...
 
bool check_if_incompatible_data (HA_CREATE_INFO *info, uint table_changes) override
 Part of old, deprecated in-place ALTER API. More...
 
enum_alter_inplace_result check_if_supported_inplace_alter (TABLE *altered_table, Alter_inplace_info *ha_alter_info) override
 On-line ALTER TABLE interface. More...
 
bool prepare_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_dd_tab, dd::Table *new_dd_tab) override
 Allows InnoDB to update internal structures with concurrent writes blocked (provided that check_if_supported_inplace_alter() did not return HA_ALTER_INPLACE_NO_LOCK). More...
 
bool inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, const dd::Table *old_dd_tab, dd::Table *new_dd_tab) override
 Alter the table structure in-place with operations specified using HA_ALTER_FLAGS and Alter_inplace_information. More...
 
bool commit_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit, const dd::Table *old_dd_tab, dd::Table *new_dd_tab) override
 Commit or rollback the changes made during prepare_inplace_alter_table() and inplace_alter_table() inside the storage engine. 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_prepare_load_table (const TABLE &table)
 Prepares the secondary engine for table load. More...
 
int ha_load_table (const TABLE &table)
 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...
 
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 void change_table_ptr (TABLE *table_arg, TABLE_SHARE *share)
 Change the internal TABLE_SHARE pointer. More...
 
const TABLE_SHAREget_table_share () 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...
 
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)
 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...
 
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 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...
 
void ft_end ()
 
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 int engine_push (AQP::Table_access *table)
 Let storage engine inspect the optimized 'plan' and pick whatever it like for being pushed down to the engine. 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...
 
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_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 const Itemcond_push (const Item *cond, bool other_tbls_ok)
 Push condition down to the table 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)
 
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 bool check_and_repair (THD *thd)
 Check and repair the table if necessary. More...
 
virtual void drop_table (const char *name)
 
virtual bool set_ha_share_ref (Handler_share **arg_ha_share)
 
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...
 

Protected Member Functions

int delete_table (const char *name, const dd::Table *table_def, enum enum_sql_command sqlcom)
 Drop a table. More...
 
void srv_concurrency_enter ()
 Enter InnoDB engine after checking max allowed threads. More...
 
void srv_concurrency_exit ()
 Leave Innodb, if no more tickets are left. More...
 
void update_thd (THD *thd)
 Updates the user_thd field in a handle and also allocates a new InnoDB transaction handle if needed, and updates the transaction fields in the m_prebuilt struct. More...
 
int general_fetch (uchar *buf, uint direction, uint match_mode)
 Reads the next or previous row from a cursor, which must have previously been positioned using index_read. More...
 
virtual dict_index_tinnobase_get_index (uint keynr)
 Get the index for a handle. More...
 
void build_template (bool whole_row)
 Builds a 'template' to the prebuilt struct. More...
 
virtual int info_low (uint flag, bool is_analyze)
 Returns statistics information of the table to the MySQL interpreter, in various fields of the handle object. More...
 
int end_stmt ()
 MySQL calls this method at the end of each statement. More...
 
template<typename Table >
bool prepare_inplace_alter_table_impl (TABLE *altered_table, Alter_inplace_info *ha_alter_info, const Table *old_dd_tab, Table *new_dd_tab)
 Implementation of prepare_inplace_alter_table() More...
 
template<typename Table >
bool inplace_alter_table_impl (TABLE *altered_table, Alter_inplace_info *ha_alter_info, const Table *old_dd_tab, Table *new_dd_tab)
 Implementation of inplace_alter_table() More...
 
template<typename Table >
bool commit_inplace_alter_table_impl (TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit, const Table *old_dd_tab, Table *new_dd_tab)
 Implementation of commit_inplace_alter_table() More...
 
void mv_key_capacity (uint *num_keys, size_t *keys_length) const override
 Return max limits for a single set of multi-valued keys. More...
 
- Protected Member Functions inherited from handler
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 index_read_pushed (uchar *, const uchar *, key_part_map)
 
virtual int index_next_pushed (uchar *)
 
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 (void) 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

DsMrr_impl m_ds_mrr
 The multi range read session object. More...
 
row_prebuilt_tm_prebuilt
 Save CPU time with prebuilt/cached data structures. More...
 
THDm_user_thd
 Thread handle of the user currently using the handler; this is set in external_lock function. More...
 
INNOBASE_SHAREm_share
 information for MySQL table locking More...
 
ucharm_upd_buf
 buffer used in updates More...
 
ulint m_upd_buf_size
 the size of upd_buf in bytes More...
 
Table_flags m_int_table_flags
 Flags that specificy the handler instance (table) capability. More...
 
bool m_start_of_scan
 this is set to 1 when we are starting a table scan but have not yet fetched any row, else false More...
 
uint m_last_match_mode {0}
 
ulint m_stored_select_lock_type
 this field is used to remember the original select_lock_type that was decided in ha_innodb.cc,":: store_lock()", "::external_lock()", etc. More...
 
bool m_mysql_has_locked
 If mysql has locked with external_lock() More...
 
- Protected Attributes inherited from handler
TABLE_SHAREtable_share
 
TABLEtable
 
Table_flags cached_table_flags
 
ha_rows estimation_rows_to_insert
 
KEY_PART_INFOrange_key_part
 
bool eq_range
 
bool in_range_check_pushed_down
 

Private Member Functions

void update_thd ()
 Updates the user_thd field in a handle and also allocates a new InnoDB transaction handle if needed, and updates the transaction fields in the m_prebuilt struct. More...
 
int change_active_index (uint keynr)
 Changes the active index of a handle. More...
 
dberr_t innobase_lock_autoinc ()
 This special handling is really to overcome the limitations of MySQL's binlogging. More...
 
dberr_t innobase_set_max_autoinc (ulonglong auto_inc)
 Store the autoinc value in the table. More...
 
dberr_t innobase_get_autoinc (ulonglong *value)
 Read the next autoinc value. More...
 
void innobase_initialize_autoinc ()
 Set the autoinc column max value. More...
 
void reset_template ()
 Resets a query execution 'template'. More...
 
int intrinsic_table_write_row (uchar *record)
 Write Row Interface optimized for Intrinsic table. More...
 
bool is_record_buffer_wanted (ha_rows *const max_rows) const override
 Find out if a Record_buffer is wanted by this handler, and what is the maximum buffer size the handler wants. More...
 
int truncate_impl (const char *name, TABLE *form, dd::Table *table_def)
 TRUNCATE an InnoDB table. More...
 
Multi Range Read interface @{
int multi_range_read_init (RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint mode, HANDLER_BUFFER *buf) override
 Initialize multi range read. More...
 
int multi_range_read_next (char **range_info) override
 Process next multi range read. More...
 
ha_rows multi_range_read_info_const (uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint *bufsz, uint *flags, Cost_estimate *cost) override
 Initialize multi range read and get information. More...
 
ha_rows multi_range_read_info (uint keyno, uint n_ranges, uint keys, uint *bufsz, uint *flags, Cost_estimate *cost) override
 Initialize multi range read and get information. More...
 
Itemidx_cond_push (uint keyno, Item *idx_cond) override
 Attempt to push down an index condition. 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
 
double m_sampling_percentage
 

Detailed Description

The class defining a handle to an InnoDB table.

Member Typedef Documentation

◆ Reader

Constructor & Destructor Documentation

◆ ha_innobase()

ha_innobase::ha_innobase ( handlerton hton,
TABLE_SHARE table_arg 
)

Construct ha_innobase handler.

◆ ~ha_innobase()

ha_innobase::~ha_innobase ( )
override

Destruct ha_innobase handler.

Member Function Documentation

◆ analyze()

int ha_innobase::analyze ( THD thd,
HA_CHECK_OPT check_opt 
)
overridevirtual

Updates index cardinalities of the table, based on random dives into each index tree.

This does NOT calculate exact statistics on the table.

Returns
HA_ADMIN_* error code or HA_ADMIN_OK
Parameters
thdin: connection thread handle
check_optin: currently ignored

Reimplemented from handler.

◆ build_template()

void ha_innobase::build_template ( bool  whole_row)
protected

Builds a 'template' to the prebuilt struct.

Builds a 'template' to the m_prebuilt struct.

The template is used in fast retrieval of just those column values MySQL needs in its processing.

Parameters
whole_rowtrue if access is needed to a whole row, false if accessing individual fields is enough

The template is used in fast retrieval of just those column values MySQL needs in its processing.

Parameters
[in]whole_rowtrue=ROW_MYSQL_WHOLE_ROW, false=ROW_MYSQL_REC_FIELDS

◆ change_active_index()

int ha_innobase::change_active_index ( uint  keynr)
private

Changes the active index of a handle.

Returns
0 or error code
Parameters
keynrin: use this index; MAX_KEY means always clustered index, even if it was internally generated by InnoDB

◆ check()

int ha_innobase::check ( THD thd,
HA_CHECK_OPT check_opt 
)
overridevirtual

Tries to check that an InnoDB table is not corrupted.

If corruption is noticed, prints to stderr information about it. In case of corruption may also assert a failure and crash the server.

Returns
HA_ADMIN_CORRUPT or HA_ADMIN_OK
Parameters
thdin: user thread handle
check_optin: check options

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ check_if_incompatible_data()

bool ha_innobase::check_if_incompatible_data ( HA_CREATE_INFO create_info,
uint  table_changes 
)
overridevirtual

Part of old, deprecated in-place ALTER API.

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ check_if_supported_inplace_alter()

enum_alter_inplace_result ha_innobase::check_if_supported_inplace_alter ( TABLE altered_table,
Alter_inplace_info ha_alter_info 
)
overridevirtual

On-line ALTER TABLE interface.

Check if InnoDB supports a particular alter table in-place.

See also
handler0alter.cc Check if InnoDB supports a particular alter table in-place
Parameters
altered_tableTABLE object for new version of table.
ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
Return values
HA_ALTER_INPLACE_NOT_SUPPORTEDNot supported
HA_ALTER_INPLACE_NO_LOCKSupported
HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARESupported, but requires lock during main phase and exclusive lock during prepare phase.
HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARESupported, prepare phase requires exclusive lock.
Parameters
altered_tableTABLE object for new version of table.
ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
Return values
HA_ALTER_INPLACE_NOT_SUPPORTEDNot supported
HA_ALTER_INPLACE_NO_LOCKSupported
HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARESupported, but requires lock during main phase and exclusive lock during prepare phase.
HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARESupported, prepare phase requires exclusive lock (any transactions that have accessed the table must commit or roll back first, and no transactions can access the table while prepare_inplace_alter_table() is executing)

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ clone()

handler * ha_innobase::clone ( const char *  name,
MEM_ROOT mem_root 
)
overridevirtual
Parameters
namein: table name
mem_rootin: memory context

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ close()

int ha_innobase::close ( void  )
overridevirtual

Closes a handle to an InnoDB table.

Returns
0

Implements handler.

Reimplemented in ha_innopart.

◆ cmp_ref()

int ha_innobase::cmp_ref ( const uchar ref1,
const uchar ref2 
) const
overridevirtual

Compares two 'refs'.

A 'ref' is the (internal) primary key value of the row. If there is no explicitly declared non-null unique key or a primary key, then InnoDB internally uses the row id as the primary key.

Returns
< 0 if ref1 < ref2, 0 if equal, else > 0
Parameters
ref1in: an (internal) primary key value in the MySQL key value format
ref2in: an (internal) primary key value in the MySQL key value format

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ commit_inplace_alter_table()

bool ha_innobase::commit_inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info,
bool  commit,
const dd::Table old_dd_tab,
dd::Table new_dd_tab 
)
overridevirtual

Commit or rollback the changes made during prepare_inplace_alter_table() and inplace_alter_table() inside the storage engine.

Note that the allowed level of concurrency during this operation will be the same as for inplace_alter_table() and thus might be higher than during prepare_inplace_alter_table(). (E.g concurrent writes were blocked during prepare, but might not be during commit).

Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
committrue => Commit, false => Rollback.
old_dd_tabdd::Table object describing old version of the table.
new_dd_tabdd::Table object for the new version of the table. Can be adjusted by this call. Changes to the table definition will be persisted in the data-dictionary at statement commit time.
Return values
trueFailure
falseSuccess

Note that the allowed level of concurrency during this operation will be the same as for inplace_alter_table() and thus might be higher than during prepare_inplace_alter_table(). (E.g concurrent writes were blocked during prepare, but might not be during commit).

Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
[in]commitTrue to commit or false to rollback.
[in]old_dd_tabdd::Table object representing old version of the table
[in,out]new_dd_tabdd::Table object representing new version of the table
Return values
trueFailure
falseSuccess

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ commit_inplace_alter_table_impl()

template<typename Table >
bool ha_innobase::commit_inplace_alter_table_impl ( TABLE altered_table,
Alter_inplace_info ha_alter_info,
bool  commit,
const Table old_dd_tab,
Table new_dd_tab 
)
protected

Implementation of commit_inplace_alter_table()

Template Parameters
Tabledd::Table or dd::Partition
Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
[in]commitTrue to commit or false to rollback.
[in]old_dd_tabTable object describing old version of the table.
[in,out]new_dd_tabTable object for the new version of the table. Can be adjusted by this call. Changes to the table definition will be persisted in the data-dictionary at statement version of it.
Return values
trueFailure
falseSuccess
Template Parameters
Tabledd::Table or dd::Partition
Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
[in]committrue => Commit, false => Rollback.
[in]old_dd_tabdd::Table object describing old version of the table.
[in,out]new_dd_tabdd::Table object for the new version of the table. Can be adjusted by this call. Changes to the table definition will be persisted in the data-dictionary at statement commit time.
Return values
trueFailure
falseSuccess

◆ create()

int ha_innobase::create ( const char *  name,
TABLE form,
HA_CREATE_INFO create_info,
dd::Table table_def 
)
overridevirtual

Create an InnoDB table.

Parameters
[in]nametable name in filename-safe encoding
[in]formtable structure
[in]create_infomore information
[in,out]table_defdd::Table describing table to be created. Can be adjusted by SE, the changes will be saved into data-dictionary at statement commit time.
Returns
error number
Return values
0on success
Parameters
[in]nametable name
[in]formtable structure
[in]create_infomore information on the table
[in,out]table_defdd::Table describing table to be created. Can be adjusted by SE, the changes will be saved into data-dictionary at statement commit time.
Returns
error number

Implements handler.

Reimplemented in ha_innopart.

◆ delete_all_rows()

int ha_innobase::delete_all_rows ( void  )
overridevirtual

Delete all rows from the table.

Return values
HA_ERR_WRONG_COMMANDif the table is transactional
0on success

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ delete_row()

int ha_innobase::delete_row ( const uchar record)
overridevirtual

Deletes a row given as the parameter.

Returns
error number or 0
Parameters
recordin: a row in MySQL format

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ delete_table() [1/2]

int ha_innobase::delete_table ( const char *  name,
const dd::Table table_def 
)
overridevirtual

Drop a table.

Parameters
[in]nametable name
[in]table_defdd::Table describing table to be dropped
Returns
error number
Return values
0on success
Parameters
[in]nametable name
[in]table_defdd::Table describing table to be dropped
Returns
error number

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ delete_table() [2/2]

int ha_innobase::delete_table ( const char *  name,
const dd::Table table_def,
enum enum_sql_command  sqlcom 
)
protected

Drop a table.

Parameters
[in]nametable name
[in]table_defdd::Table describing table to be dropped
[in]sqlcomtype of operation that the DROP is part of
Returns
error number
Return values
0on success

◆ disable_indexes()

int ha_innobase::disable_indexes ( uint  mode)
overridevirtual

Disable indexes.

Parameters
[in]modedisable index mode.
Returns
HA_ERR_* error code or 0

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ discard_or_import_tablespace()

int ha_innobase::discard_or_import_tablespace ( bool  discard,
dd::Table table_def 
)
overridevirtual

Discards or imports an InnoDB tablespace.

Parameters
[in]discardTRUE if discard, else import
[in,out]table_defdd::Table describing table which tablespace is to be imported or discarded. Can be adjusted by SE, the changes will be saved into the data-dictionary at statement commit time.
Returns
0 == success, -1 == error

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ enable_indexes()

int ha_innobase::enable_indexes ( uint  mode)
overridevirtual

Enable indexes.

Parameters
[in]modeenable index mode.
Returns
HA_ERR_* error code or 0

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ end_stmt()

int ha_innobase::end_stmt ( )
protected

MySQL calls this method at the end of each statement.

This method exists for readability only, called from reset(). The name reset() doesn't give any clue that it is called at the end of a statement.

This method exists for readability only. ha_innobase::reset() doesn't give any clue about the method.

◆ estimate_rows_upper_bound()

ha_rows ha_innobase::estimate_rows_upper_bound ( void  )
overridevirtual

Gives an UPPER BOUND to the number of rows in a table.

This is used in filesort.cc.

Returns
upper bound of rows

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ external_lock()

int ha_innobase::external_lock ( THD thd,
int  lock_type 
)
overridevirtual

As MySQL will execute an external lock for every new table it uses when it starts to process an SQL statement (an exception is when MySQL calls start_stmt for the handle) we can use this function to store the pointer to the THD in the handle.

We will also use this function to communicate to InnoDB that a new SQL statement has started and that we must store a savepoint to our transaction handle, so that we are able to roll back the SQL statement in case of an error.

Returns
0
Parameters
thdin: handle to the user thread
lock_typein: lock type

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ extra()

int ha_innobase::extra ( ha_extra_function  operation)
overridevirtual

Tells something additional to the handler about how to do things.

Returns
0 or error number
Parameters
operationin: HA_EXTRA_FLUSH or some other flag

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ ft_end()

void ha_innobase::ft_end ( )

◆ ft_init()

int ha_innobase::ft_init ( )
overridevirtual

Initialize FT index scan.

Returns
0 or error number

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ ft_init_ext()

FT_INFO * ha_innobase::ft_init_ext ( uint  flags,
uint  keynr,
String key 
)
overridevirtual

Initialize FT index scan.

Returns
FT_INFO structure if successful or NULL

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ ft_init_ext_with_hints()

FT_INFO * ha_innobase::ft_init_ext_with_hints ( uint  keynr,
String key,
Ft_hints hints 
)
overridevirtual

Initialize FT index scan.

Returns
FT_INFO structure if successful or NULL

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ ft_read()

int ha_innobase::ft_read ( uchar buf)
overridevirtual

Fetch next result from the FT result set.

Returns
error code
Parameters
bufin/out: buf contain result row

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ general_fetch()

int ha_innobase::general_fetch ( uchar buf,
uint  direction,
uint  match_mode 
)
protected

Reads the next or previous row from a cursor, which must have previously been positioned using index_read.

Returns
0, HA_ERR_END_OF_FILE, or error number
Parameters
bufin/out: buffer for next row in MySQL format
directionin: ROW_SEL_NEXT or ROW_SEL_PREV
match_modein: 0, ROW_SEL_EXACT, or ROW_SEL_EXACT_PREFIX

◆ get_auto_increment()

void ha_innobase::get_auto_increment ( ulonglong  offset,
ulonglong  increment,
ulonglong  nb_desired_values,
ulonglong first_value,
ulonglong nb_reserved_values 
)
overridevirtual

Returns the value of the auto-inc counter in *first_value and ~0 on failure.

The following logic is needed to avoid duplicate key error for autoincrement column.

(1) InnoDB gives the current autoincrement value with respect to increment and offset value.

(2) Basically it does compute_next_insert_id() logic inside InnoDB to avoid the current auto increment value changed by handler layer.

(3) It is restricted only for insert operations.

Parameters
offsetin: table autoinc offset
incrementin: table autoinc increment
nb_desired_valuesin: number of values reqd
first_valueout: the autoinc value
nb_reserved_valuesout: count of reserved values

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ get_default_index_algorithm()

enum ha_key_alg ha_innobase::get_default_index_algorithm ( ) const
inlineoverridevirtual

Get default key algorithm for SE.

It is used when user has not provided algorithm explicitly or when algorithm specified is not supported by SE.

Reimplemented from handler.

◆ get_error_message()

bool ha_innobase::get_error_message ( int  error,
String buf 
)
overridevirtual

See comment in handler.cc.

Reimplemented from handler.

◆ get_extra_columns_and_keys()

int ha_innobase::get_extra_columns_and_keys ( const HA_CREATE_INFO ,
const List< Create_field > *  ,
const KEY ,
uint  ,
dd::Table dd_table 
)
overridevirtual

Add hidden columns and indexes to an InnoDB table definition.

Parameters
[in,out]dd_tabledata dictionary cache object
Returns
error number
Return values
0on success

Reimplemented from handler.

◆ get_foreign_dup_key()

bool ha_innobase::get_foreign_dup_key ( char *  child_table_name,
uint  child_table_name_len,
char *  child_key_name,
uint  child_key_name_len 
)
overridevirtual

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.

If any of the names is not available, then this method will return false and will not change any of child_table_name or child_key_name.

Parameters
[out]child_table_nameTable name
[in]child_table_name_lenTable name buffer size
[out]child_key_nameKey name
[in]child_key_name_lenKey name buffer size
Return values
truetable and key names were available and were written into the corresponding out parameters.
falsetable and key names were not available, the out parameters were not touched.

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ get_memory_buffer_size()

longlong ha_innobase::get_memory_buffer_size ( ) const
overridevirtual

Return the size of the InnoDB memory buffer.

Reimplemented from handler.

◆ get_real_row_type()

enum row_type ha_innobase::get_real_row_type ( const HA_CREATE_INFO create_info) const
overridevirtual

Get real row type for the table created based on one specified by user, CREATE TABLE options and SE capabilities.

Note
The current code in this method is redundant with/copy of code from create_table_info_t::innobase_table_flags(). This is temporary workaround. In future this method will always return ROW_TYPE_DYNAMIC (which is suitable for intrisinc temporary tables) and rely on adjusting row format in table definition at ha_innobase::create() or ha_innobase::prepare_inplace_alter_table() time.

Reimplemented from handler.

◆ get_se_private_data()

bool ha_innobase::get_se_private_data ( dd::Table dd_table,
bool  reset 
)
overridevirtual

Get storage-engine private data for a data dictionary table.

Parameters
[in,out]dd_tabledata dictionary table definition
resetreset counters
Return values
truean error occurred
falsesuccess

Reimplemented from handler.

◆ idx_cond_push()

class Item * ha_innobase::idx_cond_push ( uint  keyno,
Item idx_cond 
)
overrideprivatevirtual

Attempt to push down an index condition.

Parameters
[in]keynoMySQL key number
[in]idx_condIndex condition to be checked
Returns
idx_cond if pushed; NULL if not pushed
Parameters
[in]keynoMySQL key number
[in]idx_condIndex condition to be checked
Returns
Part of idx_cond which the handler will not evaluate

Reimplemented from handler.

◆ index_end()

int ha_innobase::index_end ( void  )
overridevirtual

Currently does nothing.

Returns
0

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ index_first()

int ha_innobase::index_first ( uchar buf)
overridevirtual

Positions a cursor on the first record in an index and reads the corresponding row to buf.

Returns
0, HA_ERR_END_OF_FILE, or error code
Parameters
bufin/out: buffer for the row

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ index_flags()

ulong ha_innobase::index_flags ( uint  key,
uint  part,
bool  all_parts 
) const
overridevirtual

Returns the operations supported for indexes.

Returns
flags of supported operations

Implements handler.

◆ index_init()

int ha_innobase::index_init ( uint  keynr,
bool  sorted 
)
overridevirtual

Initializes a handle to use an index.

Returns
0 or error number
Parameters
keynrin: key (index) number
sortedin: 1 if result MUST be sorted according to index

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ index_last()

int ha_innobase::index_last ( uchar buf)
overridevirtual

Positions a cursor on the last record in an index and reads the corresponding row to buf.

Returns
0, HA_ERR_END_OF_FILE, or error code
Parameters
bufin/out: buffer for the row

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ index_next()

int ha_innobase::index_next ( uchar buf)
overridevirtual

Reads the next row from a cursor, which must have previously been positioned using index_read.

Returns
0, HA_ERR_END_OF_FILE, or error number
Parameters
bufin/out: buffer for next row in MySQL format

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ index_next_same()

int ha_innobase::index_next_same ( uchar buf,
const uchar key,
uint  keylen 
)
overridevirtual

Reads the next row matching to the key value given as the parameter.

Returns
0, HA_ERR_END_OF_FILE, or error number
Parameters
bufin/out: buffer for the row
keyin: key value
keylenin: key value length

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ index_prev()

int ha_innobase::index_prev ( uchar buf)
overridevirtual

Reads the previous row from a cursor, which must have previously been positioned using index_read.

Returns
0, HA_ERR_END_OF_FILE, or error number
Parameters
bufin/out: buffer for previous row in MySQL format

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ index_read()

int ha_innobase::index_read ( uchar buf,
const uchar key_ptr,
uint  key_len,
ha_rkey_function  find_flag 
)
overridevirtual

Positions an index cursor to the index specified in the handle.

Fetches the row if any.

Returns
0, HA_ERR_KEY_NOT_FOUND, or error number
Parameters
bufin/out: buffer for the returned row
key_ptrin: key value; if this is NULL we position the cursor at the start or end of index; this can also contain an InnoDB row id, in which case key_len is the InnoDB row id length; the key value can also be a prefix of a full key value, and the last column can be a prefix of a full column
key_lenin: key value length
find_flagin: search flags from my_base.h

Reimplemented from handler.

◆ index_read_last()

int ha_innobase::index_read_last ( uchar buf,
const uchar key_ptr,
uint  key_len 
)
overridevirtual

The following functions works like index_read, but it find the last row with the current key value or prefix.

Returns
0, HA_ERR_KEY_NOT_FOUND, or an error code
Parameters
bufout: fetched row
key_ptrin: key value, or a prefix of a full key value
key_lenin: length of the key val or prefix in bytes

Reimplemented from handler.

◆ info()

int ha_innobase::info ( uint  flag)
overridevirtual

Returns statistics information of the table to the MySQL interpreter, in various fields of the handle object.

Returns
HA_ERR_* error code or 0
Parameters
flagin: what information is requested

Implements handler.

◆ info_low()

int ha_innobase::info_low ( uint  flag,
bool  is_analyze 
)
protectedvirtual

Returns statistics information of the table to the MySQL interpreter, in various fields of the handle object.

Parameters
[in]flagwhat information is requested
[in]is_analyzeTrue if called from "::analyze()"
Returns
HA_ERR_* error code or 0
Parameters
[in]flagwhat information is requested
[in]is_analyzeTrue if called from "::analyze()".
Returns
HA_ERR_* error code or 0

Reimplemented in ha_innopart.

◆ init_table_handle_for_HANDLER()

void ha_innobase::init_table_handle_for_HANDLER ( void  )
overridevirtual

Call this when you have opened a new table handle in HANDLER, before you call index_read_map() etc.

Actually, we can let the cursor stay open even over a transaction commit! Then you should call this before every operation, fetch next etc. This function inits the necessary things even after a transaction commit.

Reimplemented from handler.

◆ innobase_get_autoinc()

dberr_t ha_innobase::innobase_get_autoinc ( ulonglong value)
private

Read the next autoinc value.

Acquire the relevant locks before reading the AUTOINC value. If SUCCESS then the table AUTOINC mutex will be locked on return and all relevant locks acquired.

Returns
DB_SUCCESS or error code
Parameters
valueout: autoinc value

◆ innobase_get_index()

dict_index_t * ha_innobase::innobase_get_index ( uint  keynr)
protectedvirtual

Get the index for a handle.

Does not change active index.

Returns
NULL or index instance.
Parameters
keynrin: use this index; MAX_KEY means always clustered index, even if it was internally generated by InnoDB

Reimplemented in ha_innopart.

◆ innobase_initialize_autoinc()

void ha_innobase::innobase_initialize_autoinc ( )
private

Set the autoinc column max value.

This should only be called from ha_innobase::open, therefore there's no need for a covering lock.

◆ innobase_lock_autoinc()

dberr_t ha_innobase::innobase_lock_autoinc ( void  )
private

This special handling is really to overcome the limitations of MySQL's binlogging.

We need to eliminate the non-determinism that will arise in INSERT ... SELECT type of statements, since MySQL binlog only stores the min value of the autoinc interval. Once that is fixed we can get rid of the special lock handling.

Returns
DB_SUCCESS if all OK else error code

◆ innobase_set_max_autoinc()

dberr_t ha_innobase::innobase_set_max_autoinc ( ulonglong  auto_inc)
private

Store the autoinc value in the table.

The autoinc value is only set if it's greater than the existing autoinc value in the table.

Returns
DB_SUCCESS if all went well else error code
Parameters
auto_incin: value to store

◆ inplace_alter_table()

bool ha_innobase::inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info,
const dd::Table old_dd_tab,
dd::Table new_dd_tab 
)
overridevirtual

Alter the table structure in-place with operations specified using HA_ALTER_FLAGS and Alter_inplace_information.

Alter the table structure in-place with operations specified using Alter_inplace_info.

The level of concurrency allowed during this operation depends on the return value from check_if_supported_inplace_alter().

Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
[in]old_dd_tabdd::Table object describing old version of the table.
[in,out]new_dd_tabdd::Table object for the new version of the table. Can be adjusted by this call. Changes to the table definition will be persisted in the data-dictionary at statement commit time.
Return values
trueFailure
falseSuccess

The level of concurrency allowed during this operation depends on the return value from check_if_supported_inplace_alter().

Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
[in]old_dd_tabdd::Table object representing old version of the table
[in,out]new_dd_tabdd::Table object representing new version of the table
Return values
trueFailure
falseSuccess

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ inplace_alter_table_impl()

template<typename Table >
bool ha_innobase::inplace_alter_table_impl ( TABLE altered_table,
Alter_inplace_info ha_alter_info,
const Table old_dd_tab,
Table new_dd_tab 
)
protected

Implementation of inplace_alter_table()

Template Parameters
Tabledd::Table or dd::Partition
Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
[in]old_dd_tabdd::Table object representing old version of the table
[in,out]new_dd_tabdd::Table object representing new version of the table
Return values
trueFailure
falseSuccess
Template Parameters
Tabledd::Table or dd::Partition
Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
[in]old_dd_tabdd::Table object describing old version of the table.
[in,out]new_dd_tabdd::Table object for the new version of the table. Can be adjusted by this call. Changes to the table definition will be persisted in the data-dictionary at statement commit time.
Return values
trueFailure
falseSuccess

◆ intrinsic_table_write_row()

int ha_innobase::intrinsic_table_write_row ( uchar record)
private

Write Row Interface optimized for Intrinsic table.

Write Row interface optimized for intrinisc table.

Parameters
[in]recorda row in MySQL format.
Returns
0 on success or error code

◆ is_index_algorithm_supported()

bool ha_innobase::is_index_algorithm_supported ( enum ha_key_alg  key_alg) const
inlineoverridevirtual

Check if SE supports specific key algorithm.

Reimplemented from handler.

◆ is_record_buffer_wanted()

bool ha_innobase::is_record_buffer_wanted ( ha_rows *const  max_rows) const
overrideprivatevirtual

Find out if a Record_buffer is wanted by this handler, and what is the maximum buffer size the handler wants.

Parameters
[out]max_rowsgets set to the maximum number of records to allocate space for in the buffer
Return values
trueif the handler wants a buffer
falseif the handler does not want a buffer

Reimplemented from handler.

◆ lock_count()

uint ha_innobase::lock_count ( void  ) const
overridevirtual

Returns number of THR_LOCK locks used for one instance of InnoDB table.

InnoDB no longer relies on THR_LOCK locks so 0 value is returned. Instead of THR_LOCK locks InnoDB relies on combination of metadata locks (e.g. for LOCK TABLES and DDL) and its own locking subsystem. Note that even though this method returns 0, SQL-layer still calls "::store_lock()", "::start_stmt()" and "::external_lock()" methods for InnoDB tables.

Reimplemented from handler.

◆ max_supported_key_length()

uint ha_innobase::max_supported_key_length ( void  ) const
overridevirtual

Returns the maximum key length.

Returns
maximum supported key length, in bytes

Reimplemented from handler.

◆ max_supported_key_part_length()

uint ha_innobase::max_supported_key_part_length ( HA_CREATE_INFO create_info) const
overridevirtual

Reimplemented from handler.

◆ max_supported_keys()

uint ha_innobase::max_supported_keys ( void  ) const
overridevirtual

Returns the maximum number of keys.

Returns
MAX_KEY

Reimplemented from handler.

◆ multi_range_read_info()

ha_rows ha_innobase::multi_range_read_info ( uint  keyno,
uint  n_ranges,
uint  keys,
uint bufsz,
uint flags,
Cost_estimate cost 
)
overrideprivatevirtual

Initialize multi range read and get information.

See also
DsMrr_impl::dsmrr_info
Parameters
keyno
n_ranges
keys
bufsz
flags
cost

Reimplemented from handler.

◆ multi_range_read_info_const()

ha_rows ha_innobase::multi_range_read_info_const ( uint  keyno,
RANGE_SEQ_IF seq,
void *  seq_init_param,
uint  n_ranges,
uint bufsz,
uint flags,
Cost_estimate cost 
)
overrideprivatevirtual

Initialize multi range read and get information.

See also
ha_myisam::multi_range_read_info_const
DsMrr_impl::dsmrr_info_const
Parameters
keyno
seq
seq_init_param
n_ranges
bufsz
flags
cost

Reimplemented from handler.

◆ multi_range_read_init()

int ha_innobase::multi_range_read_init ( RANGE_SEQ_IF seq,
void *  seq_init_param,
uint  n_ranges,
uint  mode,
HANDLER_BUFFER buf 
)
overrideprivatevirtual

Initialize multi range read.

Multi Range Read interface, DS-MRR calls.

See also
DsMrr_impl::dsmrr_init
Parameters
seq
seq_init_param
n_ranges
mode
buf

Reimplemented from handler.

◆ multi_range_read_next()

int ha_innobase::multi_range_read_next ( char **  range_info)
overrideprivatevirtual

Process next multi range read.

See also
DsMrr_impl::dsmrr_next
Parameters
range_info

Reimplemented from handler.

◆ mv_key_capacity()

void ha_innobase::mv_key_capacity ( uint num_keys,
size_t *  keys_length 
) const
overrideprotectedvirtual

Return max limits for a single set of multi-valued keys.

Parameters
[out]num_keysnumber of keys to store
[out]keys_lengthtotal length of keys, bytes

Reimplemented from handler.

◆ open()

int ha_innobase::open ( const char *  name,
int  ,
uint  open_flags,
const dd::Table table_def 
)
overridevirtual

Open an InnoDB table.

Parameters
[in]nametable name
[in]open_flagsflags for opening table from SQL-layer.
[in]table_defdd::Table object describing table to be opened
Return values
1if error
0if success

Implements handler.

Reimplemented in ha_innopart.

◆ optimize()

int ha_innobase::optimize ( THD thd,
HA_CHECK_OPT check_opt 
)
overridevirtual

This is mapped to "ALTER TABLE tablename ENGINE=InnoDB", which rebuilds the table in MySQL.

Parameters
thdin: connection thread handle
check_optin: currently ignored

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ parallel_scan()

int ha_innobase::parallel_scan ( void *  scan_ctx,
void **  thread_ctxs,
Reader::Init_fn  init_fn,
Reader::Load_fn  load_fn,
Reader::End_fn  end_fn 
)
overridevirtual

Start parallel read of InnoDB records.

Parameters
[in]scan_ctxA scan context created by parallel_scan_init
[in]thread_ctxsContext for each of the spawned threads
[in]init_fnCallback called by each parallel load thread at the beginning of the parallel load.
[in]load_fnCallback called by each parallel load thread when processing of rows is required.
[in]end_fnCallback called by each parallel load thread when processing of rows has ended.
Returns
error code
Return values
0on success

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ parallel_scan_end()

void ha_innobase::parallel_scan_end ( void *  scan_ctx)
overridevirtual

End of the parallel scan.

Parameters
[in]scan_ctxA scan context created by parallel_scan_init.

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ parallel_scan_init()

int ha_innobase::parallel_scan_init ( void *&  scan_ctx,
size_t &  num_threads 
)
overridevirtual

Initializes a parallel scan.

It creates a scan_ctx that has to be used across all parallel_scan methods. Also, gets the number of threads that would be spawned for parallel scan.

Parameters
[out]scan_ctxA scan context created by this method that has to be used in parallel_scan
[out]num_threadsNumber of threads to be spawned
Returns
error code
Return values
0on success

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ position() [1/2]

void ha_innobase::position ( const uchar record)
overridevirtual

Store a reference to the current row to 'ref' field of the handle.

Note that in the case where we have generated the clustered index for the table, the function parameter is illogical: we MUST ASSUME that 'record' is the current 'position' of the handle, because if row ref is actually the row id internally generated in InnoDB, then 'record' does not contain it. We just guess that the row id must be for the record where the handle was positioned the last time.

Parameters
[in]recordrow in MySQL format

Implements handler.

Reimplemented in ha_innopart.

◆ position() [2/2]

void ha_innobase::position ( uchar record)

◆ prepare_inplace_alter_table()

bool ha_innobase::prepare_inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info,
const dd::Table old_dd_tab,
dd::Table new_dd_tab 
)
overridevirtual

Allows InnoDB to update internal structures with concurrent writes blocked (provided that check_if_supported_inplace_alter() did not return HA_ALTER_INPLACE_NO_LOCK).

This will be invoked before inplace_alter_table().

Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
[in]old_dd_tabdd::Table object describing old version of the table.
[in,out]new_dd_tabdd::Table object for the new version of the table. Can be adjusted by this call. Changes to the table definition will be persisted in the data-dictionary at statement commit time.
Return values
trueFailure
falseSuccess

This will be invoked before inplace_alter_table().

Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
[in]old_dd_tabdd::Table object representing old version of the table
[in,out]new_dd_tabdd::Table object representing new version of the table
Return values
trueFailure
falseSuccess

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ prepare_inplace_alter_table_impl()

template<typename Table >
bool ha_innobase::prepare_inplace_alter_table_impl ( TABLE altered_table,
Alter_inplace_info ha_alter_info,
const Table old_dd_tab,
Table new_dd_tab 
)
protected

Implementation of prepare_inplace_alter_table()

Template Parameters
Tabledd::Table or dd::Partition
Parameters
[in]altered_tableTABLE object for new version of table.
[in,out]ha_alter_infoStructure describing changes to be done by ALTER TABLE and holding data used during in-place alter.
[in]old_dd_tabdd::Table object representing old version of the table
[in,out]new_dd_tabdd::Table object representing new version of the table
Return values
trueFailure
falseSuccess

< Index to be dropped

< Number of indexes to drop

< Indexes to be dropped

< Number of indexes to rename

< Foreign key constraints to drop

< Number of foreign keys to drop

< Foreign key constraints to drop

< Number of foreign keys to drop

< Table where indexes are created

◆ primary_key_is_clustered()

bool ha_innobase::primary_key_is_clustered ( ) const
overridevirtual

Determines if the primary key is clustered index.

Returns
true

Reimplemented from handler.

◆ read_range_first()

int ha_innobase::read_range_first ( const key_range start_key,
const key_range end_key,
bool  eq_range_arg,
bool  sorted 
)
overridevirtual

Read first row between two ranges.

Store ranges for future calls to read_range_next.

Parameters
start_keyStart key. Is 0 if no min range
end_keyEnd key. Is 0 if no max range
eq_range_argSet to 1 if start_key == end_key
sortedSet to 1 if result should be sorted per key
Note
Record is read into table->record[0]
Return values
0Found row
HA_ERR_END_OF_FILENo rows in range

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ read_range_next()

int ha_innobase::read_range_next ( )
overridevirtual

Read next row between two endpoints.

Note
Record is read into table->record[0]
Return values
0Found row
HA_ERR_END_OF_FILENo rows in range

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ read_time()

double ha_innobase::read_time ( uint  index,
uint  ranges,
ha_rows  rows 
)
overridevirtual

Calculate the time it takes to read a set of ranges through an index This enables us to optimise reads for clustered indexes.

Returns
estimated time measured in disk seeks
Parameters
indexin: key number
rangesin: how many ranges
rowsin: estimated number of rows in the ranges

Reimplemented from handler.

◆ records()

int ha_innobase::records ( ha_rows num_rows)
overridevirtual

Returns the exact number of records that this client can see using this handler object.

Returns
Error code in case something goes wrong. These errors will abort the current query: case HA_ERR_LOCK_DEADLOCK: case HA_ERR_LOCK_TABLE_FULL: case HA_ERR_LOCK_WAIT_TIMEOUT: case HA_ERR_QUERY_INTERRUPTED: For other error codes, the server will fall back to counting records.
Parameters
num_rowsout: number of rows

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ records_from_index()

int ha_innobase::records_from_index ( ha_rows num_rows,
uint  index 
)
inlineoverridevirtual

Number of rows in table counted using the secondary index chosen by optimizer.

See comments in optimize_aggregated_query() .

Parameters
num_rows[out] Number of rows in table.
indexIndex chosen by optimizer for counting.
Return values
0for OK, one of the HA_xxx values in case of error.

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ records_in_range()

ha_rows ha_innobase::records_in_range ( uint  keynr,
key_range min_key,
key_range max_key 
)
overridevirtual

Estimates the number of index records in a range.

Returns
estimated number of rows
Parameters
keynrin: index number
min_keyin: start key value of the range, may also be 0
max_keyin: range end key val, may also be 0

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ rename_table()

int ha_innobase::rename_table ( const char *  from,
const char *  to,
const dd::Table from_table_def,
dd::Table to_table_def 
)
overridevirtual

Renames an InnoDB table.

Parameters
[in]fromOld name of the table.
[in]toNew name of the table.
[in]from_table_defdd::Table object describing old version of table.
[in,out]to_table_defdd::Table object describing version of table with new name. Can be updated by SE. Changes are persisted to the dictionary at statement commit time.
Returns
0 or error code

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ reset()

int ha_innobase::reset ( void  )
overridevirtual

MySQL calls this method at the end of each statement.

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ reset_template()

void ha_innobase::reset_template ( void  )
private

Resets a query execution 'template'.

Resets some fields of a m_prebuilt struct.

See also
build_template()

The template is used in fast retrieval of just those column values MySQL needs in its processing.

◆ rnd_end()

int ha_innobase::rnd_end ( void  )
overridevirtual

Ends a table scan.

Returns
0 or error number

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ rnd_init()

int ha_innobase::rnd_init ( bool  scan)
overridevirtual

Initialize a table scan.

Parameters
[in]scanwhether this is a second call to rnd_init() without rnd_end() in between
Returns
0 or error number

Implements handler.

Reimplemented in ha_innopart.

◆ rnd_next()

int ha_innobase::rnd_next ( uchar buf)
overridevirtual

Reads the next row in a table scan (also used to read the FIRST row in a table scan).

Returns
0, HA_ERR_END_OF_FILE, or error number
Parameters
bufin/out: returns the row in this buffer, in MySQL format

Implements handler.

Reimplemented in ha_innopart.

◆ rnd_pos()

int ha_innobase::rnd_pos ( uchar buf,
uchar pos 
)
overridevirtual

Fetches a row from the table based on a row reference.

Returns
0, HA_ERR_KEY_NOT_FOUND, or error code
Parameters
bufin/out: buffer for the row
posin: primary key value of the row in the MySQL format, or the row id if the clustered index was internally generated by InnoDB; the length of data in pos has to be ref_length

Implements handler.

Reimplemented in ha_innopart.

◆ sample_end()

int ha_innobase::sample_end ( void *  scan_ctx)
overridevirtual

End sampling.

Parameters
[in]scan_ctxScan context of the sampling
Returns
0 for success, else one of the HA_xxx values in case of error.

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ sample_init()

int ha_innobase::sample_init ( void *&  scan_ctx,
double  sampling_percentage,
int  sampling_seed,
enum_sampling_method  sampling_method 
)
overridevirtual

Initialize sampling.

Parameters
[out]scan_ctxA scan context created by this method that has to be used in sample_next
[in]sampling_percentagepercentage of records that need to be sampled
[in]sampling_seedrandom seed that the random generator will use
[in]sampling_methodsampling method to be used; currently only SYSTEM sampling is supported
Returns
0 for success, else one of the HA_xxx values in case of error.

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ sample_next()

int ha_innobase::sample_next ( void *  scan_ctx,
uchar buf 
)
overridevirtual

Get the next record for sampling.

Parameters
[in]scan_ctxScan context of the sampling
[in]bufbuffer to place the read record
Returns
0 for success, else one of the HA_xxx values in case of error.

Buffer rows one by one

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ scan_time()

double ha_innobase::scan_time ( void  )
overridevirtual

How many seeks it will take to read through the table.

This is to be comparable to the number returned by records_in_range so that we can decide if we should scan the table or use keys.

Returns
estimated time measured in disk seeks

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ srv_concurrency_enter()

void ha_innobase::srv_concurrency_enter ( )
protected

Enter InnoDB engine after checking max allowed threads.

◆ srv_concurrency_exit()

void ha_innobase::srv_concurrency_exit ( )
protected

Leave Innodb, if no more tickets are left.

◆ start_stmt()

int ha_innobase::start_stmt ( THD thd,
thr_lock_type  lock_type 
)
overridevirtual

MySQL calls this function at the start of each SQL statement inside LOCK TABLES.

Inside LOCK TABLES the "::external_lock" method does not work to mark SQL statement borders. Note also a special case: if a temporary table is created inside LOCK TABLES, MySQL has not called external_lock() at all on that table. MySQL-5.0 also calls this before each statement in an execution of a stored procedure. To make the execution more deterministic for binlogging, MySQL-5.0 locks all tables involved in a stored procedure with full explicit table locks (thd_in_lock_tables(thd) holds in store_lock()) before executing the procedure.

Parameters
[in]thdhandle to the user thread
[in]lock_typelock type
Returns
0 or error code

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ store_lock()

THR_LOCK_DATA ** ha_innobase::store_lock ( THD thd,
THR_LOCK_DATA **  to,
thr_lock_type  lock_type 
)
overridevirtual

Supposed to convert a MySQL table lock stored in the 'lock' field of the handle to a proper type before storing pointer to the lock into an array of pointers.

In practice, since InnoDB no longer relies on THR_LOCK locks and its lock_count() method returns 0 it just informs storage engine about type of THR_LOCK which SQL-layer would have acquired for this specific statement on this specific table. MySQL also calls this if it wants to reset some table locks to a not-locked state during the processing of an SQL query. An example is that during a SELECT the read lock is released early on the 'const' tables where we only fetch one row. MySQL does not call this when it releases all locks at the end of an SQL statement.

Returns
pointer to the current element in the 'to' array.
Parameters
thdin: user thread handle
toin: pointer to the current element in an array of pointers to lock structs; only used as return value
lock_typein: lock type to store in 'lock'; this may also be TL_IGNORE

Implements handler.

Reimplemented in ha_innopart.

◆ table_flags()

handler::Table_flags ha_innobase::table_flags ( void  ) const
overridevirtual

Get the table flags to use for the statement.

Returns
table flags

Implements handler.

Reimplemented in ha_innopart.

◆ table_type()

const char * ha_innobase::table_type ( void  ) const
overridevirtual

Returns the table type (storage engine name).

Returns
table type

Implements handler.

◆ truncate_impl()

int ha_innobase::truncate_impl ( const char *  name,
TABLE form,
dd::Table table_def 
)
private

TRUNCATE an InnoDB table.

Parameters
[in]nametable name
[in]formtable definition
[in,out]table_defdd::Table describing table to be truncated. Can be adjusted by SE, the changes will be saved into the data-dictionary at statement commit time.
Returns
error number
Return values
0on success

◆ try_semi_consistent_read()

void ha_innobase::try_semi_consistent_read ( bool  )
overridevirtual

Tell the engine whether it should avoid unnecessary lock waits.

If yes, in an UPDATE or DELETE, if the row under the cursor was locked by another transaction, the engine may try an optimistic read of the last committed row value under the cursor.

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ unlock_row()

void ha_innobase::unlock_row ( void  )
overridevirtual

Removes a new lock set on a row, if it was not read optimistically.

This can be called after a row has been read in the processing of an UPDATE or a DELETE query, when trx_t::allow_semi_consistent() is true.

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ update_create_info()

void ha_innobase::update_create_info ( HA_CREATE_INFO create_info)
overridevirtual

Update create_info.

Used in SHOW CREATE TABLE et al.

Parameters
create_infoin/out: create info

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ update_row()

int ha_innobase::update_row ( const uchar old_row,
uchar new_row 
)
overridevirtual

Updates a row given as a parameter to a new value.

Note that we are given whole rows, not just the fields which are updated: this incurs some overhead for CPU when we check which fields are actually updated. TODO: currently InnoDB does not prevent the 'Halloween problem': in a searched update a single row can get updated several times if its index columns are updated!

Parameters
[in]old_rowOld row contents in MySQL format
[out]new_rowUpdated row contents in MySQL format
Returns
error number or 0

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ update_thd() [1/2]

void ha_innobase::update_thd ( )
private

Updates the user_thd field in a handle and also allocates a new InnoDB transaction handle if needed, and updates the transaction fields in the m_prebuilt struct.

◆ update_thd() [2/2]

void ha_innobase::update_thd ( THD thd)
protected

Updates the user_thd field in a handle and also allocates a new InnoDB transaction handle if needed, and updates the transaction fields in the m_prebuilt struct.

Parameters
thdin: thd to use the handle

◆ upgrade_table()

bool ha_innobase::upgrade_table ( THD thd,
const char *  db_name,
const char *  table_name,
dd::Table dd_table 
)
overridevirtual

Set Engine specific data to dd::Table object for upgrade.

Parameters
[in,out]thdthread handle
[in]db_namedatabase name
[in]table_nametable name
[in,out]dd_tabledata dictionary cache object
Returns
0 on success, non-zero on failure

Reimplemented from handler.

◆ was_semi_consistent_read()

bool ha_innobase::was_semi_consistent_read ( void  )
overridevirtual

Normally, when running UPDATE or DELETE queries, we need to wait for other transactions to release their locks on a given row before we can read it and potentially update it.

However, in READ UNCOMMITTED and READ COMMITTED, we can ignore these locks if we don't intend to modify the row (e.g., because it failed a WHERE). This is signaled through enabling “semi-consistent read”, by calling try_semi_consistent_read(true) (and then setting it back to false after finishing the query).

If semi-consistent read is enabled, and we are in READ UNCOMMITTED or READ COMMITTED, the storage engine is permitted to return rows that are locked and thus un-updatable. If the optimizer doesn't want the row, e.g., because it got filtered out, it can call unlock_row() as usual. However, if it intends to update the row, it needs to call was_semi_consistent_read() before doing so. If was_semi_consistent_read() returns false, the row was never locked to begin with and can be updated as usual. However, if it returns 1, it was read optimistically, must be discarded (ie., do not try to update the row) and must be re-read with locking enabled. The next read call after was_semi_consistent_read() will automatically re-read the same row, this time with locking enabled.

Thus, typical use in an UPDATE scenario would look like this:

file->try_semi_consistent_read(true);
file->ha_rnd_init(true);
while (file->ha_rnd_next(table->record[0]) == 0) {
  if (row is filtered...) {
    file->unlock_row();
    continue;
  }
  if (file->was_semi_consistent_read()) {

Discard the row; next ha_rnd_next() will read it again with locking. continue; } Process row here. } file->ha_rnd_end(); file->try_semi_consistent_read(false);

If the transaction isolation level is REPEATABLE READ or SERIALIZABLE, enabling this flag has no effect.

Reimplemented from handler.

Reimplemented in ha_innopart.

◆ write_row()

int ha_innobase::write_row ( uchar record)
overridevirtual

Stores a row in an InnoDB database, to the table specified in this handle.

Returns
error code
Parameters
recordin: a row in MySQL format

Reimplemented from handler.

Reimplemented in ha_innopart.

Member Data Documentation

◆ m_ds_mrr

DsMrr_impl ha_innobase::m_ds_mrr
protected

The multi range read session object.

◆ m_int_table_flags

Table_flags ha_innobase::m_int_table_flags
protected

Flags that specificy the handler instance (table) capability.

◆ m_last_match_mode

uint ha_innobase::m_last_match_mode {0}
protected

◆ m_mysql_has_locked

bool ha_innobase::m_mysql_has_locked
protected

If mysql has locked with external_lock()

◆ m_prebuilt

row_prebuilt_t* ha_innobase::m_prebuilt
protected

Save CPU time with prebuilt/cached data structures.

◆ m_share

INNOBASE_SHARE* ha_innobase::m_share
protected

information for MySQL table locking

◆ m_start_of_scan

bool ha_innobase::m_start_of_scan
protected

this is set to 1 when we are starting a table scan but have not yet fetched any row, else false

match mode of the latest search: ROW_SEL_EXACT, ROW_SEL_EXACT_PREFIX, or undefined

◆ m_stored_select_lock_type

ulint ha_innobase::m_stored_select_lock_type
protected

this field is used to remember the original select_lock_type that was decided in ha_innodb.cc,":: store_lock()", "::external_lock()", etc.

◆ m_upd_buf

uchar* ha_innobase::m_upd_buf
protected

buffer used in updates

◆ m_upd_buf_size

ulint ha_innobase::m_upd_buf_size
protected

the size of upd_buf in bytes

◆ m_user_thd

THD* ha_innobase::m_user_thd
protected

Thread handle of the user currently using the handler; this is set in external_lock function.


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