MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
handler Class Reference

#include <handler.h>

Inheritance diagram for handler:
Collaboration diagram for handler:

Public Types

enum  enum_range_scan_direction { RANGE_SCAN_ASC, RANGE_SCAN_DESC }
enum  { NONE = 0, INDEX, RND }
typedef ulonglong Table_flags

Public Member Functions

virtual void unbind_psi ()
virtual void rebind_psi ()
 handler (handlerton *ht_arg, TABLE_SHARE *share_arg)
virtual handlerclone (const char *name, MEM_ROOT *mem_root)
void init ()
int ha_open (TABLE *table, const char *name, int mode, int test_if_locked)
 Open database-handler.
int ha_close (void)
int ha_index_init (uint idx, bool sorted)
int ha_index_end ()
int ha_rnd_init (bool scan)
int ha_rnd_end ()
int ha_rnd_next (uchar *buf)
int ha_rnd_pos (uchar *buf, uchar *pos)
int ha_index_read_map (uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
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)
int ha_index_next (uchar *buf)
int ha_index_prev (uchar *buf)
int ha_index_first (uchar *buf)
int ha_index_last (uchar *buf)
int ha_index_next_same (uchar *buf, const uchar *key, uint keylen)
int ha_index_read (uchar *buf, const uchar *key, uint key_len, enum ha_rkey_function find_flag)
int ha_index_read_last (uchar *buf, const uchar *key, uint key_len)
int ha_reset ()
 Check handler usage and reset state of file to after 'open'.
int ha_index_or_rnd_end ()
Table_flags ha_table_flags () const
int ha_external_lock (THD *thd, int lock_type)
int ha_write_row (uchar *buf)
int ha_update_row (const uchar *old_data, uchar *new_data)
int ha_delete_row (const uchar *buf)
void ha_release_auto_increment ()
int check_collation_compatibility ()
int ha_check_for_upgrade (HA_CHECK_OPT *check_opt)
int ha_check (THD *thd, HA_CHECK_OPT *check_opt)
int ha_repair (THD *thd, HA_CHECK_OPT *check_opt)
void ha_start_bulk_insert (ha_rows rows)
int ha_end_bulk_insert ()
int ha_bulk_update_row (const uchar *old_data, uchar *new_data, uint *dup_key_found)
int ha_delete_all_rows ()
int ha_truncate ()
int ha_reset_auto_increment (ulonglong value)
int ha_optimize (THD *thd, HA_CHECK_OPT *check_opt)
int ha_analyze (THD *thd, HA_CHECK_OPT *check_opt)
bool ha_check_and_repair (THD *thd)
int ha_disable_indexes (uint mode)
int ha_enable_indexes (uint mode)
int ha_discard_or_import_tablespace (my_bool discard)
int ha_rename_table (const char *from, const char *to)
int ha_delete_table (const char *name)
void ha_drop_table (const char *name)
int ha_create (const char *name, TABLE *form, HA_CREATE_INFO *info)
int ha_create_handler_files (const char *name, const char *old_name, int action_flag, HA_CREATE_INFO *info)
int ha_change_partitions (HA_CREATE_INFO *create_info, const char *path, ulonglong *const copied, ulonglong *const deleted, const uchar *pack_frm_data, size_t pack_frm_len)
int ha_drop_partitions (const char *path)
int ha_rename_partitions (const char *path)
void adjust_next_insert_id_after_explicit_value (ulonglong nr)
int update_auto_increment ()
virtual void print_error (int error, myf errflag)
virtual bool get_error_message (int error, String *buf)
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)
virtual void change_table_ptr (TABLE *table_arg, TABLE_SHARE *share)
virtual double scan_time ()
virtual double read_time (uint index, uint ranges, ha_rows rows)
virtual double index_only_read_time (uint keynr, double records)
virtual longlong get_memory_buffer_size () const
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, Cost_estimate *cost)
virtual ha_rows multi_range_read_info (uint keyno, uint n_ranges, uint keys, uint *bufsz, uint *flags, Cost_estimate *cost)
virtual int multi_range_read_init (RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, uint mode, HANDLER_BUFFER *buf)
virtual int multi_range_read_next (char **range_info)
virtual const key_mapkeys_to_use_for_scanning ()
bool has_transactions ()
virtual uint extra_rec_buf_length () const
virtual bool is_fatal_error (int error, uint flags)
virtual ha_rows records ()
virtual ha_rows estimate_rows_upper_bound ()
virtual enum row_type get_row_type () const
virtual const char * index_type (uint key_number)
virtual void column_bitmaps_signal ()
 MySQL signal that it changed the column bitmap.
uint get_index (void) const
virtual bool start_bulk_update ()
virtual bool start_bulk_delete ()
virtual int exec_bulk_update (uint *dup_key_found)
virtual void end_bulk_update ()
virtual int end_bulk_delete ()
virtual int read_range_first (const key_range *start_key, const key_range *end_key, bool eq_range, bool sorted)
 Read first row between two ranges. Store ranges for future calls to read_range_next.
virtual int read_range_next ()
 Read next row between two endpoints.
void set_end_range (const key_range *range, enum_range_scan_direction direction)
int compare_key (key_range *range)
int compare_key_icp (const key_range *range) const
virtual int ft_init ()
void ft_end ()
virtual FT_INFOft_init_ext (uint flags, uint inx, String *key)
virtual int ft_read (uchar *buf)
virtual int rnd_pos_by_record (uchar *record)
virtual int read_first_row (uchar *buf, uint primary_key)
virtual int restart_rnd_next (uchar *buf, uchar *pos)
virtual int rnd_same (uchar *buf, uint inx)
virtual ha_rows records_in_range (uint inx, key_range *min_key, key_range *max_key)
virtual void position (const uchar *record)=0
virtual int info (uint)=0
virtual void get_dynamic_partition_info (PARTITION_STATS *stat_info, uint part_id)
virtual uint32 calculate_key_hash_value (Field **field_array)
virtual int extra (enum ha_extra_function operation)
virtual int extra_opt (enum ha_extra_function operation, ulong cache_size)
virtual bool start_read_removal (void)
virtual ha_rows end_read_removal (void)
virtual bool was_semi_consistent_read ()
virtual void try_semi_consistent_read (bool)
virtual void unlock_row ()
virtual int start_stmt (THD *thd, thr_lock_type lock_type)
virtual void get_auto_increment (ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong *first_value, ulonglong *nb_reserved_values)
void set_next_insert_id (ulonglong id)
void restore_auto_increment (ulonglong prev_insert_id)
virtual void update_create_info (HA_CREATE_INFO *create_info)
int check_old_types ()
virtual int assign_to_keycache (THD *thd, HA_CHECK_OPT *check_opt)
virtual int preload_keys (THD *thd, HA_CHECK_OPT *check_opt)
virtual int indexes_are_disabled (void)
virtual char * update_table_comment (const char *comment)
virtual void append_create_info (String *packet)
virtual bool is_fk_defined_on_table_or_index (uint index)
virtual char * get_foreign_key_create_info ()
virtual bool can_switch_engines ()
virtual int get_foreign_key_list (THD *thd, List< FOREIGN_KEY_INFO > *f_key_list)
virtual int get_parent_foreign_key_list (THD *thd, List< FOREIGN_KEY_INFO > *f_key_list)
virtual uint referenced_by_foreign_key ()
virtual void init_table_handle_for_HANDLER ()
virtual void free_foreign_key_create_info (char *str)
virtual const char * table_type () const =0
virtual const char ** bas_ext () const =0
virtual int get_default_no_partitions (HA_CREATE_INFO *info)
virtual void set_auto_partitions (partition_info *part_info)
virtual bool get_no_parts (const char *name, uint *no_parts)
virtual void set_part_info (partition_info *part_info, bool early)
virtual ulong index_flags (uint idx, uint part, bool all_parts) const =0
uint max_record_length () const
uint max_keys () const
uint max_key_parts () const
uint max_key_length () const
uint max_key_part_length () const
virtual uint max_supported_record_length () const
virtual uint max_supported_keys () const
virtual uint max_supported_key_parts () const
virtual uint max_supported_key_length () const
virtual uint max_supported_key_part_length () const
virtual uint min_record_length (uint options) const
virtual bool low_byte_first () const
virtual uint checksum () const
virtual bool is_crashed () const
virtual bool auto_repair () const
virtual uint lock_count (void) const
virtual THR_LOCK_DATA ** store_lock (THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type)=0
virtual uint8 table_cache_type ()
virtual my_bool register_query_cache_table (THD *thd, char *table_key, uint key_length, qc_engine_callback *engine_callback, ulonglong *engine_data)
 Register a named table with a call back function to the query cache.
virtual bool primary_key_is_clustered ()
virtual int cmp_ref (const uchar *ref1, const uchar *ref2)
virtual const Itemcond_push (const Item *cond)
virtual void cond_pop ()
virtual Itemidx_cond_push (uint keyno, Item *idx_cond)
virtual void cancel_pushed_idx_cond ()
virtual uint number_of_pushed_joins () const
virtual const TABLEroot_of_pushed_join () const
virtual const TABLEparent_of_pushed_join () const
virtual int index_read_pushed (uchar *buf, const uchar *key, key_part_map keypart_map)
virtual int index_next_pushed (uchar *buf)
virtual bool check_if_incompatible_data (HA_CREATE_INFO *create_info, uint table_changes)
virtual enum_alter_inplace_result check_if_supported_inplace_alter (TABLE *altered_table, Alter_inplace_info *ha_alter_info)
bool ha_prepare_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info)
bool ha_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info)
bool ha_commit_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit)
void ha_notify_table_changed ()
virtual void use_hidden_primary_key ()
virtual uint alter_table_flags (uint flags)
virtual int bulk_update_row (const uchar *old_data, uchar *new_data, uint *dup_key_found)
virtual int delete_all_rows ()
virtual int truncate ()
virtual int reset_auto_increment (ulonglong value)
virtual int optimize (THD *thd, HA_CHECK_OPT *check_opt)
virtual int analyze (THD *thd, HA_CHECK_OPT *check_opt)
virtual bool check_and_repair (THD *thd)
virtual int disable_indexes (uint mode)
virtual int enable_indexes (uint mode)
virtual int discard_or_import_tablespace (my_bool discard)
virtual void drop_table (const char *name)
virtual int create (const char *name, TABLE *form, HA_CREATE_INFO *info)=0
virtual int create_handler_files (const char *name, const char *old_name, int action_flag, HA_CREATE_INFO *info)
virtual int change_partitions (HA_CREATE_INFO *create_info, const char *path, ulonglong *const copied, ulonglong *const deleted, const uchar *pack_frm_data, size_t pack_frm_len)
virtual int drop_partitions (const char *path)
virtual int rename_partitions (const char *path)
virtual bool set_ha_share_ref (Handler_share **arg_ha_share)
int get_lock_type () const

Public Attributes

handlertonht
uchar * ref
uchar * dup_ref
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
uint errkey
uint key_used_on_scan
uint active_index
uint ref_length
FT_INFOft_handler
enum handler:: { ... }  inited
bool implicit_emptied
const Itempushed_cond
Itempushed_idx_cond
uint pushed_idx_cond_keyno
ulonglong next_insert_id
ulonglong insert_id_for_cur_row
Discrete_interval auto_inc_interval_for_cur_row
uint auto_inc_intervals_count
PSI_table * m_psi

Protected Member Functions

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'). Fetches the row if available. If the key value is null, begin at the first key of the index.
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. Fetches the row if available. If the key value is null, begin at the first key of the index.
virtual int index_next (uchar *buf)
virtual int index_prev (uchar *buf)
virtual int index_first (uchar *buf)
virtual int index_last (uchar *buf)
virtual int index_next_same (uchar *buf, const uchar *key, uint keylen)
virtual int index_read_last_map (uchar *buf, const uchar *key, key_part_map keypart_map)
 The following functions works like index_read, but it find the last row with the current key value or prefix.
virtual int rnd_next (uchar *buf)=0
virtual int rnd_pos (uchar *buf, uchar *pos)=0
virtual bool prepare_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info)
virtual bool inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info)
virtual bool commit_inplace_alter_table (TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit)
virtual void notify_table_changed ()
void ha_statistic_increment (ulonglong SSV::*offset) const
void ** ha_data (THD *) const
THD * ha_thd (void) const
PSI_table_share * ha_table_share_psi (const TABLE_SHARE *share) const
virtual int rename_table (const char *from, const char *to)
virtual int delete_table (const char *name)
virtual int index_read (uchar *buf, const uchar *key, uint key_len, enum ha_rkey_function find_flag)
virtual int index_read_last (uchar *buf, const uchar *key, uint key_len)
Handler_shareget_ha_share_ptr ()
void set_ha_share_ptr (Handler_share *arg_ha_share)
void lock_shared_ha_data ()
void unlock_shared_ha_data ()

Protected Attributes

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

Friends

class DsMrr_impl

Additional Inherited Members

- Static Public Member Functions inherited from Sql_alloc
static void * operator new (size_t size) throw ()
static void * operator new[] (size_t size) throw ()
static void * operator new[] (size_t size, MEM_ROOT *mem_root) throw ()
static void * operator new (size_t size, MEM_ROOT *mem_root) throw ()
static void operator delete (void *ptr, size_t size)
static void operator delete (void *ptr, MEM_ROOT *mem_root)
static void operator delete[] (void *ptr, MEM_ROOT *mem_root)
static void operator delete[] (void *ptr, size_t size)

Detailed Description

The handler class is the interface for dynamically loadable storage engines. Do not add ifdefs and take care when adding or changing virtual functions to avoid vtable confusion

Functions in this class accept and return table columns data. Two data representation formats are used:

  1. TableRecordFormat - Used to pass [partial] table records to/from storage engine
  1. KeyTupleFormat - used to pass index search tuples (aka "keys") to storage engine. See opt_range.cc for description of this format.

TableRecordFormat

[Warning: this description is work in progress and may be incomplete] The table record is stored in a fixed-size buffer:

record: null_bytes, column1_data, column2_data, ...

The offsets of the parts of the buffer are also fixed: every column has an offset to its column{i}_data, and if it is nullable it also has its own bit in null_bytes.

The record buffer only includes data about columns that are marked in the relevant column set (table->read_set and/or table->write_set, depending on the situation). <not-sure>It could be that it is required that null bits of non-present columns are set to 1</not-sure>

VARIOUS EXCEPTIONS AND SPECIAL CASES

f the table has no nullable columns, then null_bytes is still present, its length is one byte <not-sure> which must be set to 0xFF at all times. </not-sure>

If the table has columns of type BIT, then certain bits from those columns may be stored in null_bytes as well. Grep around for Field_bit for details.

For blob columns (see Field_blob), the record buffer stores length of the data, following by memory pointer to the blob data. The pointer is owned by the storage engine and is valid until the next operation.

If a blob column has NULL value, then its length and blob data pointer must be set to 0.

Definition at line 1787 of file handler.h.

Member Function Documentation

virtual const char** handler::bas_ext ( ) const
pure virtual

If frm_error() is called then we will use this to find out what file extentions exist for the storage engine. This is also used by the default rename_table and delete_table method in handler.cc.

For engines that have two file name extentions (separate meta/index file and data file), the order of elements is relevant. First element of engine file name extentions array should be meta/index file extention. Second element - data file extention. This order is assumed by prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.

Implemented in ha_partition, ha_ndbcluster, ha_federated, ha_innobase, ha_tina, ha_archive, ha_example, ha_myisammrg, ha_myisam, ha_blackhole, ha_perfschema, ha_heap, and ha_ndbinfo.

Here is the caller graph for this function:

virtual int handler::bulk_update_row ( const uchar *  old_data,
uchar *  new_data,
uint *  dup_key_found 
)
inlinevirtual

This method is similar to update_row, however the handler doesn't need to execute the updates at this point in time. The handler can be certain that another call to bulk_update_row will occur OR a call to exec_bulk_update before the set of updates in this query is concluded.

Note: If HA_ERR_FOUND_DUPP_KEY is returned, the handler must read all columns of the row so MySQL can create an error message. If the columns required for the error message are not read, the error message will contain garbage.

Parameters
old_dataOld record
new_dataNew record
dup_key_foundNumber of duplicate keys found

Reimplemented in ha_ndbcluster.

Definition at line 3151 of file handler.h.

Here is the caller graph for this function:

virtual bool handler::can_switch_engines ( )
inlinevirtual

Used in ALTER TABLE to check if changing storage engine is allowed.

Note
Called without holding thr_lock.c lock.
Return values
trueChanging storage engine is allowed.
falseChanging storage engine not allowed.

Reimplemented in ha_partition, and ha_innobase.

Definition at line 2433 of file handler.h.

virtual void handler::cancel_pushed_idx_cond ( )
inlinevirtual

Reset information about pushed index conditions

Definition at line 2688 of file handler.h.

Here is the caller graph for this function:

int handler::check_collation_compatibility ( )

Check for incompatible collation changes.

Return values
HA_ADMIN_NEEDS_UPGRADETable may have data requiring upgrade.
0No upgrade required.

Definition at line 3758 of file handler.cc.

virtual bool handler::check_if_incompatible_data ( HA_CREATE_INFO create_info,
uint  table_changes 
)
inlinevirtual

Part of old, deprecated in-place ALTER API.

Reimplemented in ha_partition, ha_innobase, ha_archive, ha_tina, ha_myisam, ha_myisammrg, and ha_heap.

Definition at line 2726 of file handler.h.

Here is the caller graph for this function:

enum_alter_inplace_result handler::check_if_supported_inplace_alter ( TABLE altered_table,
Alter_inplace_info ha_alter_info 
)
virtual

Check if a storage engine 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_ERRORUnexpected error.
HA_ALTER_INPLACE_NOT_SUPPORTEDNot supported, must use copy.
HA_ALTER_INPLACE_EXCLUSIVE_LOCKSupported, but requires X lock.
HA_ALTER_INPLACE_SHARED_LOCK_AFTER_PREPARESupported, but requires SNW lock during main phase. Prepare phase requires X lock.
HA_ALTER_INPLACE_SHARED_LOCKSupported, but requires SNW lock.
HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARESupported, concurrent reads/writes allowed. However, prepare phase requires X lock.
HA_ALTER_INPLACE_NO_LOCKSupported, concurrent reads/writes allowed.
Note
The default implementation uses the old in-place ALTER API to determine if the storage engine supports in-place ALTER or not.
Called without holding thr_lock.c lock.

Reimplemented in ha_partition, and ha_innobase.

Definition at line 4334 of file handler.cc.

Here is the call graph for this function:

void handler::column_bitmaps_signal ( )
virtual

MySQL signal that it changed the column bitmap.

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. Normally the handler should ignore all calls until we have done a ha_rnd_init() or ha_index_init(), write_row(), update_row or delete_row() as there may be several calls to this routine.

USAGE This is for handlers that needs to setup their own column bitmaps. Normally the handler should set up their own column bitmaps in index_init() or rnd_init() and in any column_bitmaps_signal() call after this.

The handler is allowd to do changes to the bitmap after a index_init or rnd_init() call is made as after this, MySQL will not use the bitmap for any program logic checking.

Definition at line 3320 of file handler.cc.

Here is the caller graph for this function:

virtual bool handler::commit_inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info,
bool  commit 
)
inlineprotectedvirtual

Commit or rollback the changes made during prepare_inplace_alter_table() and inplace_alter_table() inside the storage engine. Note that in case of rollback 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(). (For example, concurrent writes were blocked during prepare, but might not be during rollback).

Note
Storage engines are responsible for reporting any errors by calling my_error()/print_error()
If this function with commit= true reports error, it will be called again with commit= false.
In case of partitioning, this function might be called for rollback without prepare_inplace_alter_table() having been called first. Also partitioned tables sets ha_alter_info->group_commit_ctx to a NULL terminated array of the partitions handlers and if all of them are committed as one, then group_commit_ctx should be set to NULL to indicate to the partitioning handler that all partitions handlers are committed.
See Also
prepare_inplace_alter_table().
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.
commitTrue => Commit, False => Rollback.
Return values
trueError
falseSuccess

Reimplemented in ha_partition, and ha_innobase.

Definition at line 2970 of file handler.h.

Here is the caller graph for this function:

int handler::compare_key ( key_range range)

Compare if found key (in row) is over max-value.

Parameters
rangerange to compare to row. May be 0 for no range

key.cc::key_cmp()

Returns
The return value is SIGN(key_in_row - range_key):
  • 0 : Key is equal to range or 'range' == 0 (no range)
  • -1 : Key is less than range
  • 1 : Key is larger than range

Definition at line 6731 of file handler.cc.

Here is the caller graph for this function:

virtual void handler::cond_pop ( )
inlinevirtual

Pop the top condition from the condition stack of the handler instance.

Pops the top if condition stack, if stack is not empty.

Reimplemented in ha_ndbcluster.

Definition at line 2658 of file handler.h.

virtual const Item* handler::cond_push ( const Item cond)
inlinevirtual

Push condition down to the table handler.

Parameters
condCondition to be pushed. The condition tree must not be modified by the by the caller.
Returns
The 'remainder' condition that caller must use to filter out records. NULL means the handler will not return rows that do not match the passed condition.
Note
The pushed conditions form a stack (from which one can remove the last pushed condition using cond_pop). The table handler filters out rows using (pushed_cond1 AND pushed_cond2 AND ... AND pushed_condN) or less restrictive condition, depending on handler's capabilities.

handler->ha_reset() call empties the condition stack. Calls to rnd_init/rnd_end, index_init/index_end etc do not affect the condition stack.

Reimplemented in ha_ndbcluster.

Definition at line 2652 of file handler.h.

virtual int handler::delete_all_rows ( void  )
inlinevirtual

This is called to delete all rows in a table If the handler don't support this, then this function will return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one by one.

Reimplemented in ha_partition, ha_example, ha_federated, ha_perfschema, ha_tina, ha_myisam, and ha_heap.

Definition at line 3163 of file handler.h.

Here is the caller graph for this function:

int handler::delete_table ( const char *  name)
protectedvirtual

Delete a table in the engine. Called for base as well as temporary tables.

Delete all files with extension from bas_ext().

Parameters
nameBase name of table
Note
We assume that the handler may return more extensions than was actually used for the file.
Return values
0If we successfully deleted at least one file from base_ext and didn't get any other errors than ENOENT
!0Error

Reimplemented in ha_ndbcluster, ha_partition, ha_example, ha_innobase, ha_perfschema, ha_myisam, and ha_heap.

Definition at line 3931 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int handler::end_bulk_delete ( )
inlinevirtual

Execute all outstanding deletes and close down the bulk delete.

Return values
0Success
>0Error code

Definition at line 2211 of file handler.h.

virtual void handler::end_bulk_update ( )
inlinevirtual

Perform any needed clean-up, no outstanding updates are there at the moment.

Reimplemented in ha_ndbcluster.

Definition at line 2204 of file handler.h.

virtual ha_rows handler::end_read_removal ( void  )
inlinevirtual

End read (before write) removal and return the number of rows really written

See Also
HA_READ_BEFORE_WRITE_REMOVAL

Reimplemented in ha_ndbcluster.

Definition at line 2349 of file handler.h.

virtual ha_rows handler::estimate_rows_upper_bound ( void  )
inlinevirtual

Return upper bound of current number of records in the table (max. of how many records one will retrieve when doing a full table scan) If upper bound is not known, HA_POS_ERROR should be returned as a max possible upper bound.

Reimplemented in ha_partition, ha_ndbcluster, ha_federated, ha_innobase, ha_tina, and ha_perfschema.

Definition at line 2152 of file handler.h.

Here is the caller graph for this function:

virtual int handler::exec_bulk_update ( uint *  dup_key_found)
inlinevirtual

After this call all outstanding updates must be performed. The number of duplicate key errors are reported in the duplicate key parameter. It is allowed to continue to the batched update after this call, the handler has to wait until end_bulk_update with changing state.

Parameters
dup_key_foundNumber of duplicate keys found
Return values
0Success
>0Error code

Reimplemented in ha_ndbcluster.

Definition at line 2195 of file handler.h.

void handler::get_auto_increment ( ulonglong  offset,
ulonglong  increment,
ulonglong  nb_desired_values,
ulonglong *  first_value,
ulonglong *  nb_reserved_values 
)
virtual

Reserves an interval of auto_increment values from the handler.

Parameters
offsetoffset (modulus increment)
incrementincrement between calls
nb_desired_valueshow many values we want
[out]first_valuethe first value reserved by the handler
[out]nb_reserved_valueshow many values the handler reserved

offset and increment means that we want values to be of the form offset + N * increment, where N>=0 is integer. If the function sets *first_value to ULONGLONG_MAX it means an error. If the function sets *nb_reserved_values to ULONGLONG_MAX it means it has reserved to "positive infinite".

Reimplemented in ha_partition, ha_innobase, ha_myisam, ha_archive, and ha_heap.

Definition at line 3345 of file handler.cc.

Here is the call graph for this function:

uint handler::get_dup_key ( int  error)
Returns
key if error because of duplicated keys

Definition at line 3902 of file handler.cc.

Here is the caller graph for this function:

bool handler::get_error_message ( int  error,
String buf 
)
virtual

Return an error message specific to this handler.

Parameters
errorerror code previously returned by handler
bufpointer to String where to add error message
Returns
Returns true if this is a temporary error

Reimplemented in ha_partition, ha_ndbcluster, ha_federated, ha_innobase, and ha_ndbinfo.

Definition at line 3743 of file handler.cc.

Here is the caller graph for this function:

virtual bool handler::get_foreign_dup_key ( char *  child_table_name,
uint  child_table_name_len,
char *  child_key_name,
uint  child_key_name_len 
)
inlinevirtual

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 table or key name is not available this method will return false and will not change any of child_table_name or child_key_name.

Parameters
child_table_name[out]Table name
child_table_name_len[in]Table name buffer size
child_key_name[out]Key name
child_key_name_len[in]Key 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 in ha_innobase.

Definition at line 2064 of file handler.h.

Here is the caller graph for this function:

virtual int handler::get_foreign_key_list ( THD *  thd,
List< FOREIGN_KEY_INFO > *  f_key_list 
)
inlinevirtual

Get the list of foreign keys in this table.

Remarks
Returns the set of foreign keys where this table is the dependent or child table.
Parameters
thdThe thread handle.
f_key_list[out]The list of foreign keys.
Returns
The handler error code or zero for success.

Reimplemented in ha_innobase.

Definition at line 2446 of file handler.h.

Handler_share * handler::get_ha_share_ptr ( )
protected

Get an initialized ha_share.

Returns
Initialized ha_share
Return values
NULLha_share is not yet initialized.
!=NULL previous initialized ha_share.
Note
If not a temp table, then LOCK_ha_data must be held.

Definition at line 7301 of file handler.cc.

virtual longlong handler::get_memory_buffer_size ( ) const
inlinevirtual

Return an estimate on the amount of memory the storage engine will use for caching data in memory. If this is unknown or the storage engine does not cache data in memory -1 is returned.

Reimplemented in ha_innobase.

Definition at line 2100 of file handler.h.

virtual bool handler::get_no_parts ( const char *  name,
uint *  no_parts 
)
inlinevirtual

Get number of partitions for table in SE

Parameters
namenormalized path(same as open) to the table
[out]no_partsNumber of partitions
Return values
falsefor success
truefor failure, for example table didn't exist in engine

Reimplemented in ha_ndbcluster, and ha_partition.

Definition at line 2494 of file handler.h.

virtual int handler::get_parent_foreign_key_list ( THD *  thd,
List< FOREIGN_KEY_INFO > *  f_key_list 
)
inlinevirtual

Get the list of foreign keys referencing this table.

Remarks
Returns the set of foreign keys where this table is the referenced or parent table.
Parameters
thdThe thread handle.
f_key_list[out]The list of foreign keys.
Returns
The handler error code or zero for success.

Reimplemented in ha_innobase.

Definition at line 2460 of file handler.h.

virtual enum row_type handler::get_row_type ( ) const
inlinevirtual

Get the row type from the storage engine. If this method returns ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used.

Reimplemented in ha_partition, ha_archive, ha_innobase, and ha_heap.

Definition at line 2159 of file handler.h.

int handler::ha_analyze ( THD *  thd,
HA_CHECK_OPT check_opt 
)

Analyze table: public interface.

See Also
handler::analyze()

Definition at line 4219 of file handler.cc.

Here is the caller graph for this function:

int handler::ha_bulk_update_row ( const uchar *  old_data,
uchar *  new_data,
uint *  dup_key_found 
)

Bulk update row: public interface.

See Also
handler::bulk_update_row()

Definition at line 4133 of file handler.cc.

Here is the call graph for this function:

int handler::ha_change_partitions ( HA_CREATE_INFO create_info,
const char *  path,
ulonglong *const  copied,
ulonglong *const  deleted,
const uchar *  pack_frm_data,
size_t  pack_frm_len 
)

Change partitions: public interface.

See Also
handler::change_partitions()

Definition at line 4496 of file handler.cc.

int handler::ha_check ( THD *  thd,
HA_CHECK_OPT check_opt 
)

to be actually called to get 'check()' functionality

Performs checks upon the table.

Parameters
thdthread doing CHECK TABLE operation
check_optoptions from the parser
Return values
HA_ADMIN_OKSuccessful upgrade
HA_ADMIN_NEEDS_UPGRADETable has structures requiring upgrade
HA_ADMIN_NEEDS_ALTERTable has structures requiring ALTER TABLE
HA_ADMIN_NOT_IMPLEMENTED

Definition at line 4009 of file handler.cc.

Here is the caller graph for this function:

bool handler::ha_check_and_repair ( THD *  thd)

Check and repair table: public interface.

See Also
handler::check_and_repair()

Definition at line 4236 of file handler.cc.

int handler::ha_close ( void  )

Close handler.

Definition at line 2510 of file handler.cc.

Here is the caller graph for this function:

bool handler::ha_commit_inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info,
bool  commit 
)

Public function wrapping the actual handler call. Allows us to enforce asserts regardless of handler implementation.

See Also
commit_inplace_alter_table()

Definition at line 4308 of file handler.cc.

Here is the call graph for this function:

int handler::ha_create ( const char *  name,
TABLE form,
HA_CREATE_INFO info 
)

Create a table in the engine: public interface.

See Also
handler::create()

Definition at line 4457 of file handler.cc.

Here is the caller graph for this function:

int handler::ha_create_handler_files ( const char *  name,
const char *  old_name,
int  action_flag,
HA_CREATE_INFO info 
)

Create handler files for CREATE TABLE: public interface.

See Also
handler::create_handler_files()

Definition at line 4473 of file handler.cc.

Here is the caller graph for this function:

int handler::ha_delete_all_rows ( )

Delete all rows: public interface.

See Also
handler::delete_all_rows()

Definition at line 4151 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_delete_table ( const char *  name)

Delete table: public interface.

See Also
handler::delete_table()

Definition at line 4425 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_disable_indexes ( uint  mode)

Disable indexes: public interface.

See Also
handler::disable_indexes()

Definition at line 4253 of file handler.cc.

Here is the caller graph for this function:

int handler::ha_discard_or_import_tablespace ( my_bool  discard)

Discard or import tablespace: public interface.

See Also
handler::discard_or_import_tablespace()

Definition at line 4287 of file handler.cc.

int handler::ha_drop_partitions ( const char *  path)

Drop partitions: public interface.

See Also
handler::drop_partitions()

Definition at line 4523 of file handler.cc.

void handler::ha_drop_table ( const char *  name)

Drop table in the engine: public interface.

See Also
handler::drop_table()

Definition at line 4441 of file handler.cc.

int handler::ha_enable_indexes ( uint  mode)

Enable indexes: public interface.

See Also
handler::enable_indexes()

Definition at line 4270 of file handler.cc.

int handler::ha_end_bulk_insert ( )

End bulk insert.

Returns
Operation status
Return values
0Success
!=0 Failure (error code returned)

Definition at line 4116 of file handler.cc.

int handler::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. For the inheritance interface, see the (private) functions write_row(), update_row(), and delete_row() below.

Definition at line 7082 of file handler.cc.

Here is the caller graph for this function:

int handler::ha_index_end ( )

End use of index.

Returns
Operation status
Return values
0Success
!=0 Error (error code returned)

Definition at line 2559 of file handler.cc.

Here is the caller graph for this function:

int handler::ha_index_first ( uchar *  buf)

Reads the first row via index.

Parameters
[out]bufRow data
Returns
Operation status.
Return values
0Success
HA_ERR_END_OF_FILERow not found
!=0 Error

Definition at line 2805 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_index_init ( uint  idx,
bool  sorted 
)

Initialize use of index.

Parameters
idxIndex to use
sortedUse sorted order
Returns
Operation status
Return values
0Success
!=0 Error (error code returned)

Definition at line 2536 of file handler.cc.

Here is the caller graph for this function:

int handler::ha_index_last ( uchar *  buf)

Reads the last row via index.

Parameters
[out]bufRow data
Returns
Operation status.
Return values
0Success
HA_ERR_END_OF_FILERow not found
!=0 Error

Definition at line 2829 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_index_next ( uchar *  buf)

Reads the next row via index.

Parameters
[out]bufRow data
Returns
Operation status.
Return values
0Success
HA_ERR_END_OF_FILERow not found
!=0 Error

Definition at line 2755 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_index_next_same ( uchar *  buf,
const uchar *  key,
uint  keylen 
)

Reads the next same row via index.

Parameters
[out]bufRow data
keyKey to search for
keylenLength of key
Returns
Operation status.
Return values
0Success
HA_ERR_END_OF_FILERow not found
!=0 Error

Definition at line 2855 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_index_prev ( uchar *  buf)

Reads the previous row via index.

Parameters
[out]bufRow data
Returns
Operation status.
Return values
0Success
HA_ERR_END_OF_FILERow not found
!=0 Error

Definition at line 2780 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_index_read ( uchar *  buf,
const uchar *  key,
uint  key_len,
enum ha_rkey_function  find_flag 
)

Read one row via index.

Parameters
[out]bufRow data
keyKey to search for
keylenLength of key
find_flagDirection/condition on key usage
Returns
Operation status.
Return values
0Success
HA_ERR_END_OF_FILERow not found
!=0 Error

Definition at line 2882 of file handler.cc.

int handler::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.

See Also
handler::ha_index_read_map.

Definition at line 2729 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_index_read_last ( uchar *  buf,
const uchar *  key,
uint  key_len 
)

Reads the last row via index.

Parameters
[out]bufRow data
keyKey to search for
keylenLength of key
Returns
Operation status.
Return values
0Success
HA_ERR_END_OF_FILERow not found
!=0 Error

Definition at line 2909 of file handler.cc.

int handler::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.

Parameters
[out]bufbuffer where store the data
keyKey to search for
keypart_mapWhich part of key to use
find_flagDirection/condition on key usage
Returns
Operation status
Return values
0Success (found a record, and function has set table->status to 0)
HA_ERR_END_OF_FILERow not found (function has set table->status to STATUS_NOT_FOUND)
!=0 Error
Note
Positions an index cursor to the index specified in the handle. Fetches the row if available. If the key value is null, begin at the first key of the index. ha_index_read_map can be restarted without calling index_end on the previous index scan and without calling ha_index_init. In this case the ha_index_read_map is on the same index as the previous ha_index_scan. This is particularly used in conjunction with multi read ranges.

Definition at line 2693 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool handler::ha_inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info 
)
inline

Public function wrapping the actual handler call.

See Also
inplace_alter_table()

Definition at line 2853 of file handler.h.

Here is the call graph for this function:

void handler::ha_notify_table_changed ( )
inline

Public function wrapping the actual handler call.

See Also
notify_table_changed()

Definition at line 2874 of file handler.h.

Here is the call graph for this function:

int handler::ha_open ( TABLE table_arg,
const char *  name,
int  mode,
int  test_if_locked 
)

Open database-handler.

IMPLEMENTATION Try O_RDONLY if cannot open as O_RDWR Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set

Definition at line 2440 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_optimize ( THD *  thd,
HA_CHECK_OPT check_opt 
)

Optimize table: public interface.

See Also
handler::optimize()

Definition at line 4202 of file handler.cc.

Here is the caller graph for this function:

bool handler::ha_prepare_inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info 
)

Public functions wrapping the actual handler call.

See Also
prepare_inplace_alter_table()

Definition at line 4297 of file handler.cc.

Here is the call graph for this function:

int handler::ha_rename_partitions ( const char *  path)

Rename partitions: public interface.

See Also
handler::rename_partitions()

Definition at line 4540 of file handler.cc.

int handler::ha_rename_table ( const char *  from,
const char *  to 
)

Rename table: public interface.

See Also
handler::rename_table()

Definition at line 4409 of file handler.cc.

Here is the call graph for this function:

int handler::ha_repair ( THD *  thd,
HA_CHECK_OPT check_opt 
)

Repair table: public interface.

See Also
handler::repair()

Definition at line 4074 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_reset ( )

Check handler usage and reset state of file to after 'open'.

Note
can be called regardless of it is locked or not.

Definition at line 7166 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_reset_auto_increment ( ulonglong  value)

Reset auto increment: public interface.

See Also
handler::reset_auto_increment()

Definition at line 4185 of file handler.cc.

Here is the call graph for this function:

int handler::ha_rnd_end ( )

End use of random access.

Returns
Operation status
Return values
0Success
!=0 Error (error code returned)

Definition at line 2606 of file handler.cc.

Here is the caller graph for this function:

int handler::ha_rnd_init ( bool  scan)

Initialize table for random read or scan.

Parameters
scanif true: Initialize for random scans through rnd_next() if false: Initialize for random reads through rnd_pos()
Returns
Operation status
Return values
0Success
!=0 Error (error code returned)

Definition at line 2584 of file handler.cc.

Here is the caller graph for this function:

int handler::ha_rnd_next ( uchar *  buf)

Read next row via random scan.

Parameters
bufBuffer to read the row into
Returns
Operation status
Return values
0Success
!=0 Error (error code returned)

Definition at line 2630 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::ha_rnd_pos ( uchar *  buf,
uchar *  pos 
)

Read row via random scan from position.

Parameters
[out]bufBuffer to read the row into
posPosition from position() call
Returns
Operation status
Return values
0Success
!=0 Error (error code returned)

Definition at line 2655 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

void handler::ha_start_bulk_insert ( ha_rows  rows)

Start bulk insert.

Allow the handler to optimize for multiple row insert.

Parameters
rowsEstimated rows to insert

Definition at line 4097 of file handler.cc.

Here is the caller graph for this function:

Table_flags handler::ha_table_flags ( ) const
inline

The cached_table_flags is set at ha_open and ha_external_lock

Definition at line 1992 of file handler.h.

Here is the caller graph for this function:

PSI_table_share * handler::ha_table_share_psi ( const TABLE_SHARE share) const
protected

Acquire the instrumented table information from a table share.

Parameters
sharea table share
Returns
an instrumented table share, or NULL.

Definition at line 2428 of file handler.cc.

Here is the caller graph for this function:

int handler::ha_truncate ( )

Truncate table: public interface.

See Also
handler::truncate()

Definition at line 4168 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual Item* handler::idx_cond_push ( uint  keyno,
Item idx_cond 
)
inlinevirtual

Push down an index condition to the handler.

The server will use this method to push down a condition it wants the handler to evaluate when retrieving records using a specified index. The pushed index condition will only refer to fields from this handler that is contained in the index (but it may also refer to fields in other handlers). Before the handler evaluates the condition it must read the content of the index entry into the record buffer.

The handler is free to decide if and how much of the condition it will take responsibility for evaluating. Based on this evaluation it should return the part of the condition it will not evaluate. If it decides to evaluate the entire condition it should return NULL. If it decides not to evaluate any part of the condition it should return a pointer to the same condition as given as argument.

Parameters
keynothe index number to evaluate the condition on
idx_condthe condition to be evaluated by the handler
Returns
The part of the pushed condition that the handler decides not to evaluate

Reimplemented in ha_innobase, and ha_myisam.

Definition at line 2685 of file handler.h.

Here is the caller graph for this function:

virtual int handler::index_first ( uchar *  buf)
inlineprotectedvirtual
Returns
See Also
index_read_map().

Reimplemented in ha_partition, ha_ndbcluster, ha_example, ha_innobase, ha_myisammrg, ha_myisam, ha_heap, and ha_blackhole.

Definition at line 2250 of file handler.h.

Here is the caller graph for this function:

virtual int handler::index_last ( uchar *  buf)
inlineprotectedvirtual
Returns
See Also
index_read_map().

Reimplemented in ha_partition, ha_ndbcluster, ha_example, ha_innobase, ha_myisammrg, ha_myisam, ha_heap, and ha_blackhole.

Definition at line 2253 of file handler.h.

Here is the caller graph for this function:

virtual int handler::index_next ( uchar *  buf)
inlineprotectedvirtual
Returns
See Also
index_read_map().

Reimplemented in ha_partition, ha_ndbcluster, ha_federated, ha_example, ha_innobase, ha_archive, ha_myisammrg, ha_myisam, ha_heap, and ha_blackhole.

Definition at line 2244 of file handler.h.

Here is the caller graph for this function:

int handler::index_next_same ( uchar *  buf,
const uchar *  key,
uint  keylen 
)
protectedvirtual
Returns
See Also
index_read_map().

Reimplemented in ha_partition, ha_innobase, ha_myisammrg, and ha_myisam.

Definition at line 4577 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

double handler::index_only_read_time ( uint  keynr,
double  records 
)
virtual

Calculate cost of 'index only' scan for given index and number of records

Parameters
keynrIndex number
recordsEstimated number of records to be retrieved
Note
It is assumed that we will read trough the whole key range and that all key blocks are half full (normally things are much better). It is also assumed that each time we read the next key from the index, the handler performs a random seek, thus the cost is proportional to the number of blocks read.
Todo:
Consider joining this function and handler::read_time() into one handler::read_time(keynr, records, ranges, bool index_only) function.
Returns
Estimated cost of 'index only' scan

Definition at line 5463 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int handler::index_prev ( uchar *  buf)
inlineprotectedvirtual
Returns
See Also
index_read_map().

Reimplemented in ha_partition, ha_ndbcluster, ha_example, ha_innobase, ha_myisammrg, ha_myisam, ha_heap, and ha_blackhole.

Definition at line 2247 of file handler.h.

Here is the caller graph for this function:

int handler::index_read_idx_map ( uchar *  buf,
uint  index,
const uchar *  key,
key_part_map  keypart_map,
enum ha_rkey_function  find_flag 
)
protectedvirtual

Positions an index cursor to the index specified in argument. Fetches the row if available. If the key value is null, begin at the first key of the index.

Returns
See Also
index_read_map().

Reimplemented in ha_partition, ha_ndbcluster, ha_myisammrg, ha_myisam, ha_heap, and ha_blackhole.

Definition at line 6776 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int handler::index_read_last_map ( uchar *  buf,
const uchar *  key,
key_part_map  keypart_map 
)
inlineprotectedvirtual

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

Returns
See Also
index_read_map().

Reimplemented in ha_partition, ha_myisammrg, ha_myisam, ha_blackhole, and ha_heap.

Definition at line 2263 of file handler.h.

virtual int handler::index_read_map ( uchar *  buf,
const uchar *  key,
key_part_map  keypart_map,
enum ha_rkey_function  find_flag 
)
inlineprotectedvirtual

Positions an index cursor to the index specified in the handle ('active_index'). Fetches the row if available. If the key value is null, begin at the first key of the index.

Returns
0 if success (found a record, and function has set table->status to 0); non-zero if no record (function has set table->status to STATUS_NOT_FOUND).

Reimplemented in ha_partition, ha_example, ha_myisammrg, ha_myisam, ha_heap, and ha_blackhole.

Definition at line 2226 of file handler.h.

Here is the caller graph for this function:

void handler::init ( )
inline

This is called after create to allow us to set up cached variables

Definition at line 1953 of file handler.h.

virtual bool handler::inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info 
)
inlineprotectedvirtual

Alter the table structure in-place with operations specified using HA_ALTER_FLAGS and Alter_inplace_info. The level of concurrency allowed during this operation depends on the return value from check_if_supported_inplace_alter().

Note
Storage engines are responsible for reporting any errors by calling my_error()/print_error()
If this function reports error, commit_inplace_alter_table() will be called with commit= false.
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
trueError
falseSuccess

Reimplemented in ha_partition, and ha_innobase.

Definition at line 2933 of file handler.h.

Here is the caller graph for this function:

virtual bool handler::is_fatal_error ( int  error,
uint  flags 
)
inlinevirtual

This method is used to analyse the error to see whether the error is ignorable or not, certain handlers can have more error that are ignorable than others. E.g. the partition handler can get inserts into a range where there is no partition and this is an ignorable error. HA_ERR_FOUND_DUP_UNIQUE is a special case in MyISAM that means the same thing as HA_ERR_FOUND_DUP_KEY but can in some cases lead to a slightly different error message.

Reimplemented in ha_partition, and ha_ndbcluster.

Definition at line 2131 of file handler.h.

Here is the caller graph for this function:

virtual bool handler::is_fk_defined_on_table_or_index ( uint  index)
inlinevirtual

If index == MAX_KEY then a check for table is made and if index < MAX_KEY then a check is made if the table has foreign keys and if a foreign key uses this index (and thus the index cannot be dropped).

Parameters
indexIndex to check if foreign key uses it
Return values
TRUEForeign key defined on table or index
FALSENo foreign key defined

Definition at line 2421 of file handler.h.

virtual uint handler::lock_count ( void  ) const
inlinevirtual
Note
lock_count() can return > 1 if the table is MERGE or partitioned.

Reimplemented in ha_partition, and ha_myisammrg.

Definition at line 2552 of file handler.h.

void handler::lock_shared_ha_data ( )
protected

Take a lock for protecting shared handler data.

Definition at line 7342 of file handler.cc.

ha_rows handler::multi_range_read_info ( uint  keyno,
uint  n_ranges,
uint  n_rows,
uint *  bufsz,
uint *  flags,
Cost_estimate cost 
)
virtual

Get cost and other information about MRR scan over some sequence of ranges

Calculate estimated cost and other information about an MRR scan for some sequence of ranges.

The ranges themselves will be known only at execution phase. When this function is called we only know number of ranges and a (rough) E(records) within those ranges.

Currently this function is only called for "n-keypart singlepoint" ranges, i.e. each range is "keypart1=someconst1 AND ... AND keypartN=someconstN"

The flags parameter is a combination of those flags: HA_MRR_SORTED, HA_MRR_INDEX_ONLY, HA_MRR_NO_ASSOCIATION, HA_MRR_LIMITS.

Parameters
keynoIndex number
n_rangesEstimated number of ranges (i.e. intervals) in the range sequence.
n_rowsEstimated total number of records contained within all of the ranges
bufszINOUT IN: Size of the buffer available for use OUT: Size of the buffer that will be actually used, or 0 if buffer is not needed.
flagsINOUT A combination of HA_MRR_* flags
costOUT Estimated cost of MRR access
Return values
0OK, *cost contains cost of the scan, *bufsz and *flags contain scan parameters.
otherError or can't perform the requested scan

Reimplemented in ha_innobase, and ha_myisam.

Definition at line 5675 of file handler.cc.

Here is the call graph for this function:

ha_rows handler::multi_range_read_info_const ( uint  keyno,
RANGE_SEQ_IF seq,
void *  seq_init_param,
uint  n_ranges_arg,
uint *  bufsz,
uint *  flags,
Cost_estimate cost 
)
virtual

Get cost and other information about MRR scan over a known list of ranges

Calculate estimated cost and other information about an MRR scan for given sequence of ranges.

Parameters
keynoIndex number
seqRange sequence to be traversed
seq_init_paramFirst parameter for seq->init()
n_ranges_argNumber of ranges in the sequence, or 0 if the caller can't efficiently determine it
bufszINOUT IN: Size of the buffer available for use OUT: Size of the buffer that is expected to be actually used, or 0 if buffer is not needed.
flagsINOUT A combination of HA_MRR_* flags
costOUT Estimated cost of MRR access
Note
This method (or an overriding one in a derived class) must check for thd->killed and return HA_POS_ERROR if it is not zero. This is required for a user to be able to interrupt the calculation by killing the connection/query.
Return values
HA_POS_ERRORError or the engine is unable to perform the requested scan. Values of OUT parameters are undefined.
otherOK, *cost contains cost of the scan, *bufsz and *flags contain scan parameters.

Reimplemented in ha_innobase, and ha_myisam.

Definition at line 5541 of file handler.cc.

int handler::multi_range_read_init ( RANGE_SEQ_IF seq_funcs,
void *  seq_init_param,
uint  n_ranges,
uint  mode,
HANDLER_BUFFER buf 
)
virtual

Initialize the MRR scan

Initialize the MRR scan. This function may do heavyweight scan initialization like row prefetching/sorting/etc (NOTE: but better not do it here as we may not need it, e.g. if we never satisfy WHERE clause on previous tables. For many implementations it would be natural to do such initializations in the first multi_read_range_next() call)

mode is a combination of the following flags: HA_MRR_SORTED, HA_MRR_INDEX_ONLY, HA_MRR_NO_ASSOCIATION

Parameters
seqRange sequence to be traversed
seq_init_paramFirst parameter for seq->init()
n_rangesNumber of ranges in the sequence
modeFlags, see the description section for the details
bufINOUT: memory buffer to be used
Note
One must have called index_init() before calling this function. Several multi_range_read_init() calls may be made in course of one query.

Until WL#2623 is done (see its text, section 3.2), the following will also hold: The caller will guarantee that if "seq->init == mrr_ranges_array_init" then seq_init_param is an array of n_ranges KEY_MULTI_RANGE structures. This property will only be used by NDB handler until WL#2623 is done.

Buffer memory management is done according to the following scenario: The caller allocates the buffer and provides it to the callee by filling the members of HANDLER_BUFFER structure. The callee consumes all or some fraction of the provided buffer space, and sets the HANDLER_BUFFER members accordingly. The callee may use the buffer memory until the next multi_range_read_init() call is made, all records have been read, or until index_end() call is made, whichever comes first.

Return values
0OK
1Error

Reimplemented in ha_innobase, and ha_myisam.

Definition at line 5739 of file handler.cc.

int handler::multi_range_read_next ( char **  range_info)
virtual

Get next record in MRR scan

Default MRR implementation: read the next record

Parameters
range_infoOUT Undefined if HA_MRR_NO_ASSOCIATION flag is in effect Otherwise, the opaque value associated with the range that contains the returned record.
Return values
0OK
otherError code

Reimplemented in ha_innobase, and ha_myisam.

Definition at line 5764 of file handler.cc.

Here is the call graph for this function:

void handler::notify_table_changed ( )
protectedvirtual

Notify the storage engine that the table structure (.FRM) has been updated.

Note
No errors are allowed during notify_table_changed().

Reimplemented in ha_partition.

Definition at line 4384 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual uint handler::number_of_pushed_joins ( ) const
inlinevirtual

Reports #tables included in pushed join which this handler instance is part of. ==0 -> Not pushed

Reimplemented in ha_ndbcluster.

Definition at line 2699 of file handler.h.

Here is the caller graph for this function:

virtual const TABLE* handler::parent_of_pushed_join ( ) const
inlinevirtual

If this handler instance is a child in a pushed join sequence returned TABLE instance being my parent?

Reimplemented in ha_ndbcluster.

Definition at line 2713 of file handler.h.

virtual bool handler::prepare_inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info 
)
inlineprotectedvirtual

Allows the storage engine to update internal structures with concurrent writes blocked. If check_if_supported_inplace_alter() returns HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE or HA_ALTER_INPLACE_SHARED_AFTER_PREPARE, this function is called with exclusive lock otherwise the same level of locking as for inplace_alter_table() will be used.

Note
Storage engines are responsible for reporting any errors by calling my_error()/print_error()
If this function reports error, commit_inplace_alter_table() will be called with commit= false.
For partitioning, failing to prepare one partition, means that commit_inplace_alter_table() will be called to roll back changes for all partitions. This means that commit_inplace_alter_table() might be called without prepare_inplace_alter_table() having been called first for a given partition.
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
trueError
falseSuccess

Reimplemented in ha_partition, and ha_innobase.

Definition at line 2909 of file handler.h.

Here is the caller graph for this function:

void handler::print_error ( int  error,
myf  errflag 
)
virtual

Print error that we got from handler function.

Note
In case of delete table it's only safe to use the following parts of the 'table' structure:
  • table->s->path
  • table->alias

Reimplemented in ha_partition, ha_ndbcluster, and ha_perfschema.

Definition at line 3500 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::read_first_row ( uchar *  buf,
uint  primary_key 
)
virtual

Read first row (only) from a table.

This is never called for InnoDB tables, as these table types has the HA_STATS_RECORDS_IS_EXACT set.

Reimplemented in ha_ndbcluster.

Definition at line 2928 of file handler.cc.

Here is the call graph for this function:

int handler::read_range_first ( const key_range start_key,
const key_range end_key,
bool  eq_range_arg,
bool  sorted 
)
virtual

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
\::Error code

Reimplemented in ha_partition, ha_ndbcluster, and ha_federated.

Definition at line 6612 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

int handler::read_range_next ( )
virtual

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
\::Error code

Reimplemented in ha_partition, ha_ndbcluster, and ha_federated.

Definition at line 6666 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual double handler::read_time ( uint  index,
uint  ranges,
ha_rows  rows 
)
inlinevirtual

The cost of reading a set of ranges from the table using an index to access it.

Parameters
indexThe index number.
rangesThe number of ranges to be read.
rowsTotal number of rows to be read.

This method can be used to calculate the total cost of scanning a table using an index by calling it using read_time(index, 1, table_size).

Reimplemented in ha_partition, ha_federated, ha_example, ha_innobase, and ha_heap.

Definition at line 2090 of file handler.h.

Here is the caller graph for this function:

virtual ha_rows handler::records ( )
inlinevirtual

Number of rows in table. It will only be called if (table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0

Reimplemented in ha_partition, ha_ndbcluster, ha_myisammrg, and ha_archive.

Definition at line 2145 of file handler.h.

virtual my_bool handler::register_query_cache_table ( THD *  thd,
char *  table_key,
uint  key_length,
qc_engine_callback *  engine_callback,
ulonglong *  engine_data 
)
inlinevirtual

Register a named table with a call back function to the query cache.

Parameters
thdThe thread handle
table_keyA pointer to the table name in the table cache
key_lengthThe length of the table name
[out]engine_callbackThe pointer to the storage engine call back function
[out]engine_dataStorage engine specific data which could be anything

This method offers the storage engine, the possibility to store a reference to a table name which is going to be used with query cache. The method is called each time a statement is written to the cache and can be used to verify if a specific statement is cachable. It also offers the possibility to register a generic (but static) call back function which is called each time a statement is matched against the query cache.

Note
If engine_data supplied with this function is different from engine_data supplied with the callback function, and the callback returns FALSE, a table invalidation on the current table will occur.
Returns
Upon success the engine_callback will point to the storage engine call back function, if any, and engine_data will point to any storage engine data used in the specific implementation.
Return values
TRUESuccess
FALSEThe specified table or current statement should not be cached

Reimplemented in ha_partition, ha_ndbcluster, ha_innobase, and ha_perfschema.

Definition at line 2604 of file handler.h.

int handler::rename_table ( const char *  from,
const char *  to 
)
protectedvirtual

Default rename_table() and delete_table() rename/delete files with a given name and extensions from bas_ext().

These methods can be overridden, but their default implementation provide useful functionality.

Reimplemented in ha_ndbcluster, ha_partition, ha_example, ha_innobase, ha_perfschema, ha_myisam, and ha_heap.

Definition at line 3963 of file handler.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int handler::reset_auto_increment ( ulonglong  value)
inlinevirtual

Reset the auto-increment counter to the given value, i.e. the next row inserted will get the given value. HA_ERR_WRONG_COMMAND is returned by storage engines that don't support this operation.

Reimplemented in ha_innobase, ha_myisam, and ha_heap.

Definition at line 3190 of file handler.h.

Here is the caller graph for this function:

virtual int handler::restart_rnd_next ( uchar *  buf,
uchar *  pos 
)
inlinevirtual

The following function is only needed for tables that may be temporary tables during joins.

Reimplemented in ha_myisam.

Definition at line 2314 of file handler.h.

virtual int handler::rnd_next ( uchar *  buf)
protectedpure virtual
Returns
See Also
index_read_map().

Implemented in ha_partition, ha_ndbcluster, ha_example, ha_federated, ha_perfschema, ha_innobase, ha_tina, ha_archive, ha_myisammrg, ha_myisam, ha_heap, ha_blackhole, and ha_ndbinfo.

Here is the caller graph for this function:

virtual int handler::rnd_pos ( uchar *  buf,
uchar *  pos 
)
protectedpure virtual
Returns
See Also
index_read_map().

Implemented in ha_partition, ha_ndbcluster, ha_example, ha_federated, ha_perfschema, ha_innobase, ha_tina, ha_archive, ha_myisammrg, ha_myisam, ha_heap, ha_blackhole, and ha_ndbinfo.

Here is the caller graph for this function:

virtual int handler::rnd_pos_by_record ( uchar *  record)
inlinevirtual

This function only works for handlers having HA_PRIMARY_KEY_REQUIRED_FOR_POSITION set. It will return the row with the PK given in the record argument.

Reimplemented in ha_partition.

Definition at line 2303 of file handler.h.

Here is the call graph for this function:

virtual const TABLE* handler::root_of_pushed_join ( ) const
inlinevirtual

If this handler instance is part of a pushed join sequence returned TABLE instance being root of the pushed query?

Reimplemented in ha_ndbcluster.

Definition at line 2706 of file handler.h.

Here is the caller graph for this function:

void handler::set_end_range ( const key_range range,
enum_range_scan_direction  direction 
)

Set the end position for a range scan. This is used for checking for when to end the range scan and by the ICP code to determine that the next record is within the current range.

Parameters
rangeThe end value for the range scan
directionDirection of the range scan

Definition at line 6698 of file handler.cc.

Here is the caller graph for this function:

void handler::set_ha_share_ptr ( Handler_share arg_ha_share)
protected

Set ha_share to be used by all instances of the same table/partition.

Parameters
ha_shareHandler_share to be shared.
Note
If not a temp table, then LOCK_ha_data must be held.

Definition at line 7324 of file handler.cc.

virtual bool handler::start_bulk_delete ( )
inlinevirtual
Return values
0Bulk delete used by handler
1Bulk delete not used, normal operation used

Definition at line 2183 of file handler.h.

virtual bool handler::start_bulk_update ( )
inlinevirtual
Return values
0Bulk update used by handler
1Bulk update not used, normal operation used

Reimplemented in ha_ndbcluster.

Definition at line 2178 of file handler.h.

virtual bool handler::start_read_removal ( void  )
inlinevirtual

Start read (before write) removal on the current table.

See Also
HA_READ_BEFORE_WRITE_REMOVAL

Reimplemented in ha_ndbcluster.

Definition at line 2341 of file handler.h.

virtual THR_LOCK_DATA** handler::store_lock ( THD *  thd,
THR_LOCK_DATA **  to,
enum thr_lock_type  lock_type 
)
pure virtual

Is not invoked for non-transactional temporary tables.

Note
store_lock() can return more than one lock if the table is MERGE or partitioned.
that one can NOT rely on table->in_use in store_lock(). It may refer to a different thread if called from mysql_lock_abort_for_thread().
If the table is MERGE, store_lock() can return less locks than lock_count() claimed. This can happen when the MERGE children are not attached when this is called from another thread.

Implemented in ha_partition, ha_ndbcluster, ha_example, ha_federated, ha_innobase, ha_perfschema, ha_tina, ha_archive, ha_myisammrg, ha_myisam, ha_heap, ha_blackhole, and ha_ndbinfo.

virtual uint8 handler::table_cache_type ( void  )
inlinevirtual

Type of table for caching query

Reimplemented in ha_partition, ha_ndbcluster, ha_federated, ha_innobase, ha_perfschema, and ha_ndbinfo.

Definition at line 2571 of file handler.h.

virtual const char* handler::table_type ( ) const
pure virtual

The following can be called without an open handler

Implemented in ha_partition, ha_ndbcluster, ha_federated, ha_innobase, ha_tina, ha_archive, ha_myisammrg, ha_example, ha_myisam, ha_perfschema, ha_blackhole, ha_heap, and ha_ndbinfo.

Here is the caller graph for this function:

virtual int handler::truncate ( )
inlinevirtual

Quickly remove all rows from a table.

Remarks
This method is responsible for implementing MySQL's TRUNCATE TABLE statement, which is a DDL operation. As such, a engine can bypass certain integrity checks and in some cases avoid fine-grained locking (e.g. row locks) which would normally be required for a DELETE statement.
Typically, truncate is not used if it can result in integrity violation. For example, truncate is not used when a foreign key references the table, but it might be used if foreign key checks are disabled.
Engine is responsible for resetting the auto-increment counter.
The table is locked in exclusive mode.

Reimplemented in ha_partition, ha_example, ha_federated, ha_innobase, ha_perfschema, ha_archive, ha_myisammrg, ha_myisam, ha_heap, and ha_blackhole.

Definition at line 3183 of file handler.h.

Here is the caller graph for this function:

virtual void handler::try_semi_consistent_read ( bool  )
inlinevirtual

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 in ha_partition, and ha_innobase.

Definition at line 2371 of file handler.h.

void handler::unlock_shared_ha_data ( )
protected

Release lock for protecting ha_share.

Definition at line 7354 of file handler.cc.

void handler::use_hidden_primary_key ( void  )
virtual

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

Reimplemented in ha_perfschema.

Definition at line 7283 of file handler.cc.

virtual bool handler::was_semi_consistent_read ( void  )
inlinevirtual

In an UPDATE or DELETE, if the row under the cursor was locked by another transaction, and the engine used an optimistic read of the last committed row value under the cursor, then the engine returns 1 from this function. MySQL must NOT try to update this optimistic value. If the optimistic value does not match the WHERE condition, MySQL can decide to skip over this row. Currently only works for InnoDB. This can be used to avoid unnecessary lock waits.

If this method returns nonzero, it will also signal the storage engine that the next read will be a locking re-read of the row.

Reimplemented in ha_partition, and ha_innobase.

Definition at line 2364 of file handler.h.

Here is the caller graph for this function:

Member Data Documentation

Discrete_interval handler::auto_inc_interval_for_cur_row

Interval returned by get_auto_increment() and being consumed by the inserter.

Definition at line 1886 of file handler.h.

uint handler::auto_inc_intervals_count

Number of reserved auto-increment intervals. Serves as a heuristic when we have no estimation of how many records the statement will insert: the more intervals we have reserved, the bigger the next one. Reset in handler::ha_release_auto_increment().

Definition at line 1893 of file handler.h.

ulonglong handler::insert_id_for_cur_row

insert id for the current row (autogenerated; if not autogenerated, it's 0). At first successful insertion, this variable is stored into THD::first_successful_insert_id_in_cur_stmt.

Definition at line 1881 of file handler.h.

PSI_table* handler::m_psi

Instrumented table associated with this handler. This member should be set to NULL when no instrumentation is in place, so that linking an instrumented/non instrumented server/plugin works. For example:

  • the server is compiled with the instrumentation. The server expects either NULL or valid pointers in m_psi.
  • an engine plugin is compiled without instrumentation. The plugin can not leave this pointer uninitialized, or can not leave a trash value on purpose in this pointer, as this would crash the server.

Definition at line 1907 of file handler.h.

ulonglong handler::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().

Definition at line 1874 of file handler.h.

uint handler::ref_length

Length of ref (1-8 or the clustered key length)

Definition at line 1856 of file handler.h.


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