My Project
Public Member Functions
ha_partition Class Reference
Inheritance diagram for ha_partition:
handler Sql_alloc

List of all members.

Public Member Functions

Partition_shareget_part_share ()
handlerclone (const char *name, MEM_ROOT *mem_root)
virtual void set_part_info (partition_info *part_info, bool early)
 ha_partition (handlerton *hton, TABLE_SHARE *table)
 ha_partition (handlerton *hton, partition_info *part_info)
 ha_partition (handlerton *hton, TABLE_SHARE *share, partition_info *part_info_arg, ha_partition *clone_arg, MEM_ROOT *clone_mem_root_arg)
bool initialize_partition (MEM_ROOT *mem_root)
virtual int delete_table (const char *from)
virtual int rename_table (const char *from, const char *to)
virtual int create (const char *name, TABLE *form, HA_CREATE_INFO *create_info)
virtual int create_handler_files (const char *name, const char *old_name, int action_flag, HA_CREATE_INFO *create_info)
virtual void update_create_info (HA_CREATE_INFO *create_info)
virtual char * update_table_comment (const char *comment)
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)
bool get_no_parts (const char *name, uint *num_parts)
virtual void change_table_ptr (TABLE *table_arg, TABLE_SHARE *share)
virtual bool check_if_incompatible_data (HA_CREATE_INFO *create_info, uint table_changes)
virtual int open (const char *name, int mode, uint test_if_locked)
virtual int close (void)
virtual THR_LOCK_DATA ** store_lock (THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type)
virtual int external_lock (THD *thd, int lock_type)
virtual int start_stmt (THD *thd, thr_lock_type lock_type)
virtual uint lock_count (void) const
virtual void unlock_row ()
virtual bool was_semi_consistent_read ()
virtual void try_semi_consistent_read (bool)
virtual int write_row (uchar *buf)
virtual int update_row (const uchar *old_data, uchar *new_data)
virtual int delete_row (const uchar *buf)
virtual int delete_all_rows (void)
virtual int truncate ()
virtual void start_bulk_insert (ha_rows rows)
virtual int end_bulk_insert ()
int truncate_partition (Alter_info *, bool *binlog_stmt)
virtual bool is_fatal_error (int error, uint flags)
virtual int rnd_init (bool scan)
virtual int rnd_end ()
virtual int rnd_next (uchar *buf)
virtual int rnd_pos (uchar *buf, uchar *pos)
virtual int rnd_pos_by_record (uchar *record)
virtual void position (const uchar *record)
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_init (uint idx, bool sorted)
virtual int index_end ()
virtual int index_read_idx_map (uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
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 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.
virtual int info (uint)
void get_dynamic_partition_info (PARTITION_STATS *stat_info, uint part_id)
virtual int extra (enum ha_extra_function operation)
virtual int extra_opt (enum ha_extra_function operation, ulong cachesize)
virtual int reset (void)
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 const key_mapkeys_to_use_for_scanning ()
virtual double scan_time ()
virtual double read_time (uint index, uint ranges, ha_rows rows)
virtual ha_rows records_in_range (uint inx, key_range *min_key, key_range *max_key)
virtual ha_rows estimate_rows_upper_bound ()
virtual uint8 table_cache_type ()
virtual ha_rows records ()
uint32 calculate_key_hash_value (Field **field_array)
virtual const char * index_type (uint inx)
virtual const char * table_type () const
virtual enum row_type get_row_type () const
virtual void print_error (int error, myf errflag)
virtual bool get_error_message (int error, String *buf)
virtual Table_flags table_flags () const
virtual ulong index_flags (uint inx, uint part, bool all_parts) const
virtual uint alter_table_flags (uint flags)
virtual const char ** bas_ext () const
uint min_of_the_max_uint (uint(handler::*operator_func)(void) const) 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 bool low_byte_first () const
virtual uint extra_rec_buf_length () const
virtual uint min_record_length (uint options) const
virtual bool primary_key_is_clustered ()
virtual int cmp_ref (const uchar *ref1, const uchar *ref2)
virtual void get_auto_increment (ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong *first_value, ulonglong *nb_reserved_values)
virtual void release_auto_increment ()
virtual void init_table_handle_for_HANDLER ()
virtual bool can_switch_engines ()
virtual enum_alter_inplace_result check_if_supported_inplace_alter (TABLE *altered_table, Alter_inplace_info *ha_alter_info)
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 ()
virtual int optimize (THD *thd, HA_CHECK_OPT *check_opt)
virtual int analyze (THD *thd, HA_CHECK_OPT *check_opt)
virtual int check (THD *thd, HA_CHECK_OPT *check_opt)
virtual int repair (THD *thd, HA_CHECK_OPT *check_opt)
virtual bool check_and_repair (THD *thd)
virtual bool auto_repair () const
virtual bool is_crashed () const
virtual int check_for_upgrade (HA_CHECK_OPT *check_opt)
virtual uint checksum () const
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 disable_indexes (uint mode)
virtual int enable_indexes (uint mode)
virtual int indexes_are_disabled (void)

Member Function Documentation

virtual uint ha_partition::alter_table_flags ( uint  flags) [virtual]

wrapper function for handlerton alter_table_flags, since the ha_partition_hton cannot know all its capabilities

Reimplemented from handler.

virtual const char** ha_partition::bas_ext ( ) const [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.

Implements handler.

virtual bool ha_partition::can_switch_engines ( ) [virtual]

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 from handler.

virtual int ha_partition::check_for_upgrade ( HA_CHECK_OPT check_opt) [virtual]

admin commands - called from mysql_admin_table

Reimplemented from handler.

virtual bool ha_partition::check_if_incompatible_data ( HA_CREATE_INFO create_info,
uint  table_changes 
) [virtual]

Part of old, deprecated in-place ALTER API.

Reimplemented from handler.

virtual enum_alter_inplace_result ha_partition::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 from handler.

virtual bool ha_partition::commit_inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info,
bool  commit 
) [virtual]

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 from handler.

virtual int ha_partition::delete_all_rows ( void  ) [virtual]

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 from handler.

virtual int ha_partition::delete_table ( const char *  name) [virtual]

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 from handler.

virtual ha_rows ha_partition::estimate_rows_upper_bound ( ) [virtual]

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 from handler.

virtual void ha_partition::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 from handler.

virtual bool ha_partition::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 from handler.

bool ha_partition::get_no_parts ( const char *  name,
uint *  no_parts 
) [inline, virtual]

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 from handler.

virtual enum row_type ha_partition::get_row_type ( ) const [virtual]

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 from handler.

virtual int ha_partition::index_first ( uchar *  buf) [virtual]
Returns:
See also:
index_read_map().

Reimplemented from handler.

virtual int ha_partition::index_last ( uchar *  buf) [virtual]
Returns:
See also:
index_read_map().

Reimplemented from handler.

virtual int ha_partition::index_next ( uchar *  buf) [virtual]
Returns:
See also:
index_read_map().

Reimplemented from handler.

virtual int ha_partition::index_next_same ( uchar *  buf,
const uchar *  key,
uint  keylen 
) [virtual]
Returns:
See also:
index_read_map().

Reimplemented from handler.

virtual int ha_partition::index_prev ( uchar *  buf) [virtual]
Returns:
See also:
index_read_map().

Reimplemented from handler.

virtual int ha_partition::index_read_idx_map ( uchar *  buf,
uint  index,
const uchar *  key,
key_part_map  keypart_map,
enum ha_rkey_function  find_flag 
) [virtual]

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

Reimplemented from handler.

virtual int ha_partition::index_read_last_map ( uchar *  buf,
const uchar *  key,
key_part_map  keypart_map 
) [virtual]

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 from handler.

virtual int ha_partition::index_read_map ( uchar *  buf,
const uchar *  key,
key_part_map  keypart_map,
enum ha_rkey_function  find_flag 
) [virtual]

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 from handler.

virtual bool ha_partition::inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info 
) [virtual]

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 from handler.

virtual bool ha_partition::is_fatal_error ( int  error,
uint  flags 
) [inline, virtual]

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 from handler.

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

Reimplemented from handler.

virtual void ha_partition::notify_table_changed ( ) [virtual]

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

Note:
No errors are allowed during notify_table_changed().

Reimplemented from handler.

virtual bool ha_partition::prepare_inplace_alter_table ( TABLE altered_table,
Alter_inplace_info ha_alter_info 
) [virtual]

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 from handler.

virtual void ha_partition::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 from handler.

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

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

virtual double ha_partition::read_time ( uint  index,
uint  ranges,
ha_rows  rows 
) [virtual]

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 from handler.

virtual ha_rows ha_partition::records ( ) [virtual]

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

Reimplemented from handler.

virtual my_bool ha_partition::register_query_cache_table ( THD *  thd,
char *  table_key,
uint  key_length,
qc_engine_callback *  engine_callback,
ulonglong *  engine_data 
) [inline, virtual]

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 from handler.

virtual int ha_partition::rename_table ( const char *  from,
const char *  to 
) [virtual]

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 from handler.

virtual int ha_partition::repair ( THD *  thd,
HA_CHECK_OPT check_opt 
) [virtual]

In this method check_opt can be modified to specify CHECK option to use to call check() upon the table.

Reimplemented from handler.

virtual int ha_partition::reset ( void  ) [virtual]

Reset state of file to after 'open'. This function is called after every statement for all tables used by that statement.

Reimplemented from handler.

virtual int ha_partition::rnd_init ( bool  scan) [virtual]

rnd_init() can be called two times without rnd_end() in between (it only makes sense if scan=1). then the second call should prepare for the new table scan (e.g if rnd_init allocates the cursor, second call should position it to the start of the table, no need to deallocate and allocate it again

Implements handler.

virtual int ha_partition::rnd_next ( uchar *  buf) [virtual]
Returns:
See also:
index_read_map().

Implements handler.

virtual int ha_partition::rnd_pos ( uchar *  buf,
uchar *  pos 
) [virtual]
Returns:
See also:
index_read_map().

Implements handler.

virtual int ha_partition::rnd_pos_by_record ( uchar *  record) [virtual]

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 from handler.

virtual THR_LOCK_DATA** ha_partition::store_lock ( THD *  thd,
THR_LOCK_DATA **  to,
enum thr_lock_type  lock_type 
) [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.

Implements handler.

virtual uint8 ha_partition::table_cache_type ( ) [virtual]

Type of table for caching query

Reimplemented from handler.

virtual const char* ha_partition::table_type ( ) const [virtual]

The following can be called without an open handler

Implements handler.

virtual int ha_partition::truncate ( ) [virtual]

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 from handler.

virtual void ha_partition::try_semi_consistent_read ( bool  ) [virtual]

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.

virtual bool ha_partition::was_semi_consistent_read ( ) [virtual]

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 from handler.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines