drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
ha_innobase Class Reference

#include <ha_innodb.h>

Inheritance diagram for ha_innobase:
[legend]
Collaboration diagram for ha_innobase:
[legend]

Public Member Functions

UNIV_INTERN ha_innobase (plugin::StorageEngine &engine, Table &table_arg)
UNIV_INTERN ~ha_innobase ()
UNIV_INTERN plugin::TransactionalStorageEngine * getTransactionalEngine ()
UNIV_INTERN const char * index_type (uint key_number)
UNIV_INTERN const key_map * keys_to_use_for_scanning ()
UNIV_INTERN int doOpen (const drizzled::identifier::Table &identifier, int mode, uint test_if_locked)
UNIV_INTERN int close (void)
UNIV_INTERN double scan_time ()
UNIV_INTERN double read_time (uint index, uint ranges, ha_rows rows)
UNIV_INTERN int doInsertRecord (unsigned char *buf)
UNIV_INTERN int doUpdateRecord (const unsigned char *old_data, unsigned char *new_data)
UNIV_INTERN int doDeleteRecord (const unsigned char *buf)
UNIV_INTERN bool was_semi_consistent_read ()
UNIV_INTERN void try_semi_consistent_read (bool yes)
UNIV_INTERN void unlock_row ()
UNIV_INTERN int doStartIndexScan (uint index, bool sorted)
UNIV_INTERN int doEndIndexScan ()
UNIV_INTERN int index_read (unsigned char *buf, const unsigned char *key, uint key_len, enum ha_rkey_function find_flag)
UNIV_INTERN int index_read_idx (unsigned char *buf, uint index, const unsigned char *key, uint key_len, enum ha_rkey_function find_flag)
UNIV_INTERN int index_read_last (unsigned char *buf, const unsigned char *key, uint key_len)
UNIV_INTERN int index_next (unsigned char *buf)
UNIV_INTERN int index_next_same (unsigned char *buf, const unsigned char *key, uint keylen)
UNIV_INTERN int index_prev (unsigned char *buf)
UNIV_INTERN int index_first (unsigned char *buf)
UNIV_INTERN int index_last (unsigned char *buf)
UNIV_INTERN int doStartTableScan (bool scan)
UNIV_INTERN int doEndTableScan ()
UNIV_INTERN int rnd_next (unsigned char *buf)
UNIV_INTERN int rnd_pos (unsigned char *buf, unsigned char *pos)
UNIV_INTERN void position (const unsigned char *record)
UNIV_INTERN int info (uint)
UNIV_INTERN int analyze (Session *session)
UNIV_INTERN int discard_or_import_tablespace (bool discard)
UNIV_INTERN int extra (enum ha_extra_function operation)
UNIV_INTERN int reset ()
UNIV_INTERN int external_lock (Session *session, int lock_type)
void position (unsigned char *record)
UNIV_INTERN ha_rows records_in_range (uint inx, key_range *min_key, key_range *max_key)
UNIV_INTERN ha_rows estimate_rows_upper_bound ()
UNIV_INTERN int delete_all_rows ()
UNIV_INTERN int check (Session *session)
UNIV_INTERN char * update_table_comment (const char *comment)
UNIV_INTERN char * get_foreign_key_create_info ()
UNIV_INTERN int get_foreign_key_list (Session *session, List< ForeignKeyInfo > *f_key_list)
UNIV_INTERN bool can_switch_engines ()
UNIV_INTERN uint referenced_by_foreign_key ()
UNIV_INTERN void free_foreign_key_create_info (char *str)
UNIV_INTERN THR_LOCK_DATA ** store_lock (Session *session, THR_LOCK_DATA **to, enum thr_lock_type lock_type)
virtual UNIV_INTERN void get_auto_increment (uint64_t offset, uint64_t increment, uint64_t nb_desired_values, uint64_t *first_value, uint64_t *nb_reserved_values)
UNIV_INTERN int reset_auto_increment (uint64_t value)
UNIV_INTERN bool primary_key_is_clustered ()
UNIV_INTERN int cmp_ref (const unsigned char *ref1, const unsigned char *ref2)
int read_range_first (const key_range *start_key, const key_range *end_key, bool eq_range_arg, bool sorted)
int read_range_next ()
Public Member Functions inherited from drizzled::Cursor
plugin::StorageEngine * getEngine () const
TableShare * getShare ()
Table * getTable () const
uint64_t getNextInsertId () const
uint64_t getAutoIncrement () const
 Cursor (plugin::StorageEngine &engine_arg, Table &share_arg)
virtual Cursor * clone (memory::Root *mem_root)
int ha_open (const identifier::Table &identifier, int mode, int test_if_locked)
int startIndexScan (uint32_t idx, bool sorted) __attribute__((warn_unused_result))
int endIndexScan ()
int startTableScan (bool scan) __attribute__((warn_unused_result))
int endTableScan ()
int ha_reset ()
int ha_index_or_rnd_end ()
int ha_external_lock (Session *session, int lock_type)
int insertRecord (unsigned char *buf) __attribute__((warn_unused_result))
int updateRecord (const unsigned char *old_data, unsigned char *new_data) __attribute__((warn_unused_result))
int deleteRecord (const unsigned char *buf) __attribute__((warn_unused_result))
void ha_release_auto_increment ()
int ha_check (Session *)
void ha_start_bulk_insert (ha_rows rows)
int ha_end_bulk_insert ()
int ha_delete_all_rows ()
int ha_reset_auto_increment (uint64_t value)
int ha_analyze (Session *)
int ha_disable_indexes (uint32_t mode)
int ha_enable_indexes (uint32_t mode)
int ha_discard_or_import_tablespace (bool discard)
void closeMarkForDelete ()
void adjust_next_insert_id_after_explicit_value (uint64_t nr)
int update_auto_increment ()
virtual double read_time (uint32_t, uint32_t ranges, ha_rows rows)
virtual double index_only_read_time (uint32_t keynr, double records)
virtual ha_rows multi_range_read_info_const (uint32_t keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint32_t n_ranges, uint32_t *bufsz, uint32_t *flags, optimizer::CostVector *cost)
virtual int multi_range_read_info (uint32_t keyno, uint32_t n_ranges, uint32_t keys, uint32_t *bufsz, uint32_t *flags, optimizer::CostVector *cost)
virtual int multi_range_read_init (RANGE_SEQ_IF *seq, void *seq_init_param, uint32_t n_ranges, uint32_t mode)
virtual int multi_range_read_next (char **range_info)
bool has_transactions ()
virtual bool is_fatal_error (int error, uint32_t flags)
virtual ha_rows records ()
virtual uint64_t tableSize ()
virtual uint64_t rowSize ()
virtual const char * index_type (uint32_t)
uint32_t get_index (void) const
virtual int index_read_map (unsigned char *buf, const unsigned char *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
 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.
virtual int index_read_idx_map (unsigned char *buf, uint32_t index, const unsigned char *key, key_part_map keypart_map, enum ha_rkey_function find_flag)
 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.
virtual int index_next_same (unsigned char *, const unsigned char *, uint32_t)
virtual int index_read_last_map (unsigned char *buf, const unsigned char *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.
int compare_key (key_range *range)
virtual int read_first_row (unsigned char *buf, uint32_t primary_key)
virtual int rnd_same (unsigned char *, uint32_t)
virtual ha_rows records_in_range (uint32_t, key_range *, key_range *)
virtual int info (uint32_t)=0
virtual uint32_t calculate_key_hash_value (Field **)
virtual int extra_opt (enum ha_extra_function operation, uint32_t)
void set_next_insert_id (uint64_t id)
void restore_auto_increment (uint64_t prev_insert_id)
virtual int indexes_are_disabled (void)
virtual void append_create_info (String *)
virtual bool isOrdered (void)

Private Member Functions

UNIV_INTERN uint store_key_val_for_row (uint keynr, char *buff, uint buff_len, const unsigned char *record)
UNIV_INTERN void update_session (Session *session)
UNIV_INTERN int change_active_index (uint32_t keynr)
UNIV_INTERN int general_fetch (unsigned char *buf, uint32_t direction, uint32_t match_mode)
UNIV_INTERN ulint innobase_lock_autoinc ()
UNIV_INTERN uint64_t innobase_peek_autoinc ()
UNIV_INTERN ulint innobase_set_max_autoinc (uint64_t auto_inc)
UNIV_INTERN ulint innobase_reset_autoinc (uint64_t auto_inc)
UNIV_INTERN ulint innobase_get_autoinc (uint64_t *value)
ulint innobase_update_autoinc (uint64_t auto_inc)
UNIV_INTERN void innobase_initialize_autoinc ()
UNIV_INTERN dict_index_t * innobase_get_index (uint keynr)

Private Attributes

row_prebuilt_t * prebuilt
Session * user_session
THR_LOCK_DATA lock
INNOBASE_SHARE * share
std::vector< unsigned char > upd_buff
std::vector< unsigned char > key_val_buff
ulong upd_and_key_val_buff_len
uint primary_key
ulong start_of_scan
uint last_match_mode
uint num_write_row

Additional Inherited Members

Public Types inherited from drizzled::Cursor
enum  { NONE =0 , INDEX , RND }
Public Attributes inherited from drizzled::Cursor
unsigned char * ref
unsigned char * dup_ref
ha_statistics stats
range_seq_t mrr_iter
RANGE_SEQ_IF mrr_funcs
uint32_t ranges_in_seq
bool mrr_is_output_sorted
bool mrr_have_range
bool eq_range
KEY_MULTI_RANGE mrr_cur_range
key_range save_end_range
key_range * end_range
KeyPartInfo * range_key_part
int key_compare_result_on_equal
uint32_t errkey
uint32_t key_used_on_scan
uint32_t active_index
uint32_t ref_length
enum drizzled::Cursor:: { ... }  inited
bool locked
uint64_t next_insert_id
uint64_t insert_id_for_cur_row
Discrete_interval auto_inc_interval_for_cur_row
Protected Member Functions inherited from drizzled::Cursor
void ha_statistic_increment (uint64_t system_status_var::*offset) const
void ** ha_data (Session *) const
Protected Attributes inherited from drizzled::Cursor
ha_rows estimation_rows_to_insert

Detailed Description

The class defining a handle to an Innodb table

Definition at line 80 of file ha_innodb.h.

Constructor & Destructor Documentation

◆ ha_innobase()

UNIV_INTERN ha_innobase::ha_innobase ( plugin::StorageEngine & engine_arg,
Table & table_arg )

Construct ha_innobase Cursor.

Definition at line 1685 of file ha_innodb.cc.

◆ ~ha_innobase()

UNIV_INTERN ha_innobase::~ha_innobase ( )

Destruct ha_innobase Cursor.

Definition at line 1699 of file ha_innodb.cc.

Member Function Documentation

◆ analyze()

UNIV_INTERN int ha_innobase::analyze ( Session * session)
virtual

Updates index cardinalities of the table, based on 8 random dives into each index tree. This does NOT calculate exact statistics on the table.

Returns
returns always 0 (success)
Parameters
sessionin: connection thread handle

Reimplemented from drizzled::Cursor.

Definition at line 7692 of file ha_innodb.cc.

◆ can_switch_engines()

UNIV_INTERN bool ha_innobase::can_switch_engines ( void )
virtual

Checks if ALTER TABLE may change the storage engine of the table. Changing storage engines is not allowed for tables for which there are foreign key constraints (parent or child tables).

Returns
TRUE if can switch engines

Reimplemented from drizzled::Cursor.

Definition at line 8101 of file ha_innodb.cc.

◆ change_active_index()

UNIV_INTERN int ha_innobase::change_active_index ( uint32_t keynr)
private

Changes the active index of a handle.

Returns
0 or error code

Definition at line 5588 of file ha_innodb.cc.

◆ check()

UNIV_INTERN int ha_innobase::check ( Session * session)
virtual

Tries to check that an InnoDB table is not corrupted. If corruption is noticed, prints to stderr information about it. In case of corruption may also assert a failure and crash the server.

Returns
HA_ADMIN_CORRUPT or HA_ADMIN_OK
Parameters
sessionin: user thread handle

Reimplemented from drizzled::Cursor.

Definition at line 7709 of file ha_innodb.cc.

◆ close()

UNIV_INTERN int ha_innobase::close ( void )
virtual

Closes a handle to an InnoDB table.

Returns
0

Implements drizzled::Cursor.

Definition at line 3837 of file ha_innodb.cc.

◆ cmp_ref()

UNIV_INTERN int ha_innobase::cmp_ref ( const unsigned char * ref1,
const unsigned char * ref2 )
virtual

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

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

Reimplemented from drizzled::Cursor.

Definition at line 9043 of file ha_innodb.cc.

◆ delete_all_rows()

UNIV_INTERN int ha_innobase::delete_all_rows ( void )
virtual

Deletes all rows of an InnoDB table.

Returns
error number

Reimplemented from drizzled::Cursor.

Definition at line 6684 of file ha_innodb.cc.

◆ discard_or_import_tablespace()

UNIV_INTERN int ha_innobase::discard_or_import_tablespace ( bool discard)
virtual

Discards or imports an InnoDB tablespace.

Returns
0 == success, -1 == error

Reimplemented from drizzled::Cursor.

Definition at line 6653 of file ha_innodb.cc.

◆ doDeleteRecord()

UNIV_INTERN int ha_innobase::doDeleteRecord ( const unsigned char * record)
virtual

Deletes a row given as the parameter.

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

Reimplemented from drizzled::Cursor.

Definition at line 5146 of file ha_innodb.cc.

◆ doEndIndexScan()

UNIV_INTERN int ha_innobase::doEndIndexScan ( void )
virtual

Currently does nothing.

Returns
0

Reimplemented from drizzled::Cursor.

Definition at line 5266 of file ha_innodb.cc.

◆ doEndTableScan()

UNIV_INTERN int ha_innobase::doEndTableScan ( void )
virtual

Ends a table scan.

Returns
0 or error number

Reimplemented from drizzled::Cursor.

Definition at line 5848 of file ha_innodb.cc.

◆ doInsertRecord()

UNIV_INTERN int ha_innobase::doInsertRecord ( unsigned char * record)
virtual

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

Returns
error code
Parameters
recordin: a row in MySQL format

Reimplemented from drizzled::Cursor.

Definition at line 4616 of file ha_innodb.cc.

◆ doOpen()

UNIV_INTERN int ha_innobase::doOpen ( const drizzled::identifier::Table & identifier,
int mode,
uint test_if_locked )

Creates and opens a handle to a table which already exists in an InnoDB database.

Returns
1 if error, 0 if success
Parameters
modein: not used
test_if_lockedin: not used

Definition at line 3534 of file ha_innodb.cc.

◆ doStartIndexScan()

UNIV_INTERN int ha_innobase::doStartIndexScan ( uint keynr,
bool sorted )

Initializes a handle to use an index.

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

Definition at line 5253 of file ha_innodb.cc.

◆ doStartTableScan()

UNIV_INTERN int ha_innobase::doStartTableScan ( bool scan)
virtual

Initialize a table scan.

Returns
0 or error number
Parameters
scanin: TRUE if table/index scan FALSE otherwise

Implements drizzled::Cursor.

Definition at line 5816 of file ha_innodb.cc.

◆ doUpdateRecord()

UNIV_INTERN int ha_innobase::doUpdateRecord ( const unsigned char * old_row,
unsigned char * new_row )
virtual

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

Returns
error number or 0
Parameters
old_rowin: old row in MySQL format
new_rowin: new row in MySQL format

Reimplemented from drizzled::Cursor.

Definition at line 5008 of file ha_innodb.cc.

◆ estimate_rows_upper_bound()

UNIV_INTERN ha_rows ha_innobase::estimate_rows_upper_bound ( void )
virtual

Gives an UPPER BOUND to the number of rows in a table. This is used in filesort.cc.

Returns
upper bound of rows

Reimplemented from drizzled::Cursor.

Definition at line 7151 of file ha_innodb.cc.

◆ external_lock()

UNIV_INTERN int ha_innobase::external_lock ( Session * session,
int lock_type )
virtual

As MySQL will execute an external lock for every new table it uses when it starts to process an SQL statement. We can use this function to store the pointer to the Session in the handle.

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

Reimplemented from drizzled::Cursor.

Definition at line 8255 of file ha_innodb.cc.

◆ extra()

UNIV_INTERN int ha_innobase::extra ( enum ha_extra_function operation)
virtual

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

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

Reimplemented from drizzled::Cursor.

Definition at line 8157 of file ha_innodb.cc.

◆ free_foreign_key_create_info()

UNIV_INTERN void ha_innobase::free_foreign_key_create_info ( char * str)
virtual

Frees the foreign key create info for a table stored in InnoDB, if it is non-NULL.

Parameters
strin, own: create info string to free

Reimplemented from drizzled::Cursor.

Definition at line 8145 of file ha_innodb.cc.

◆ general_fetch()

UNIV_INTERN int ha_innobase::general_fetch ( unsigned char * buf,
uint32_t direction,
uint32_t match_mode )
private

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

Returns
0, HA_ERR_END_OF_FILE, or error number

Definition at line 5671 of file ha_innodb.cc.

◆ get_auto_increment()

UNIV_INTERN void ha_innobase::get_auto_increment ( uint64_t offset,
uint64_t increment,
uint64_t nb_desired_values,
uint64_t * first_value,
uint64_t * nb_reserved_values )
virtual

This function initializes the auto-inc counter if it has not been initialized yet. This function does not change the value of the auto-inc counter if it already has been initialized. Returns the value of the auto-inc counter in *first_value, and UINT64_T_MAX in *nb_reserved_values (as we have a table-level lock). offset, increment, nb_desired_values are ignored. first_value is set to -1 if error (deadlock or lock wait timeout)

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

Implements drizzled::Cursor.

Definition at line 8888 of file ha_innodb.cc.

◆ get_foreign_key_create_info()

UNIV_INTERN char * ha_innobase::get_foreign_key_create_info ( void )
virtual

Gets the foreign key create info for a table stored in InnoDB.

Returns
own: character string in the form which can be inserted to the CREATE TABLE statement, MUST be freed with ha_innobase::free_foreign_key_create_info

Reimplemented from drizzled::Cursor.

Definition at line 7949 of file ha_innodb.cc.

◆ get_foreign_key_list()

UNIV_INTERN int ha_innobase::get_foreign_key_list ( Session * ,
List< ForeignKeyInfo > *  )
virtual

used in REPLACE; is > 0 if table is referred by a FOREIGN KEY

Foreign id

Foreign Fields

Reimplemented from drizzled::Cursor.

Definition at line 8003 of file ha_innodb.cc.

◆ getTransactionalEngine()

UNIV_INTERN plugin::TransactionalStorageEngine * ha_innobase::getTransactionalEngine ( )
inline

Returns the plugin::TransactionStorageEngine pointer of the cursor's underlying engine.

Todo

Have a TransactionalCursor subclass...

Definition at line 135 of file ha_innodb.h.

◆ index_first()

UNIV_INTERN int ha_innobase::index_first ( unsigned char * buf)
virtual

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

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

Reimplemented from drizzled::Cursor.

Definition at line 5767 of file ha_innodb.cc.

◆ index_last()

UNIV_INTERN int ha_innobase::index_last ( unsigned char * buf)
virtual

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

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

Reimplemented from drizzled::Cursor.

Definition at line 5792 of file ha_innodb.cc.

◆ index_next()

UNIV_INTERN int ha_innobase::index_next ( unsigned char * buf)
virtual

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

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

Reimplemented from drizzled::Cursor.

Definition at line 5720 of file ha_innodb.cc.

◆ index_next_same()

UNIV_INTERN int ha_innobase::index_next_same ( unsigned char * buf,
const unsigned char * key,
uint keylen )

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

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

Definition at line 5735 of file ha_innodb.cc.

◆ index_prev()

UNIV_INTERN int ha_innobase::index_prev ( unsigned char * buf)
virtual

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

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

Reimplemented from drizzled::Cursor.

Definition at line 5752 of file ha_innodb.cc.

◆ index_read()

UNIV_INTERN int ha_innobase::index_read ( unsigned char * buf,
const unsigned char * key_ptr,
uint key_len,
enum ha_rkey_function find_flag )

Positions an index cursor to the index specified in the handle. Fetches the row if any.

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

Definition at line 5394 of file ha_innodb.cc.

◆ index_read_idx()

UNIV_INTERN int ha_innobase::index_read_idx ( unsigned char * buf,
uint keynr,
const unsigned char * key,
uint key_len,
enum ha_rkey_function find_flag )

Positions an index cursor to the index specified in keynr. Fetches the row if any. ??? This is only used to read whole keys ???

Returns
error number or 0
Parameters
bufin/out: buffer for the returned row
keynrin: use this index
keyin: key value; if this is NULL we position the cursor at the start or end of index
key_lenin: key value length
find_flagin: search flags from my_base.h

Definition at line 5646 of file ha_innodb.cc.

◆ index_read_last()

UNIV_INTERN int ha_innobase::index_read_last ( unsigned char * buf,
const unsigned char * key_ptr,
uint key_len )

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

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

Definition at line 5517 of file ha_innodb.cc.

◆ index_type()

UNIV_INTERN const char * ha_innobase::index_type ( uint key_number)

InnoDB database tables Returns the index type.

Parameters
key_numberout: index type

Definition at line 3126 of file ha_innodb.cc.

◆ info()

UNIV_INTERN int ha_innobase::info ( uint flag)

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

Parameters
flagin: what information MySQL requests

Definition at line 7417 of file ha_innodb.cc.

◆ innobase_get_autoinc()

UNIV_INTERN ulint ha_innobase::innobase_get_autoinc ( uint64_t * value)
private

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

Returns
DB_SUCCESS or error code
Parameters
valueout: autoinc value

Definition at line 8828 of file ha_innodb.cc.

◆ innobase_get_index()

UNIV_INTERN dict_index_t * ha_innobase::innobase_get_index ( uint keynr)
private

Get the index for a handle. Does not change active index.

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

Definition at line 5533 of file ha_innodb.cc.

◆ innobase_initialize_autoinc()

UNIV_INTERN void ha_innobase::innobase_initialize_autoinc ( )
private

Set the autoinc column max value. This should only be called once from ha_innobase::open(). Therefore there's no need for a covering lock.

Definition at line 3437 of file ha_innodb.cc.

◆ innobase_lock_autoinc()

UNIV_INTERN ulint ha_innobase::innobase_lock_autoinc ( void )
private

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

Returns
DB_SUCCESS if all OK else error code

Definition at line 4567 of file ha_innodb.cc.

◆ innobase_peek_autoinc()

UNIV_INTERN uint64_t ha_innobase::innobase_peek_autoinc ( void )
private

This function reads the global auto-inc counter. It doesn't use the AUTOINC lock even if the lock mode is set to TRADITIONAL.

Returns
the autoinc value

Definition at line 8854 of file ha_innodb.cc.

◆ innobase_reset_autoinc()

UNIV_INTERN ulint ha_innobase::innobase_reset_autoinc ( uint64_t autoinc)
private

Reset the autoinc value in the table.

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

Definition at line 4582 of file ha_innodb.cc.

◆ innobase_set_max_autoinc()

UNIV_INTERN ulint ha_innobase::innobase_set_max_autoinc ( uint64_t auto_inc)
private

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

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

Definition at line 4599 of file ha_innodb.cc.

◆ keys_to_use_for_scanning()

UNIV_INTERN const key_map * ha_innobase::keys_to_use_for_scanning ( )
virtual

Returns the key map of keys that are usable for scanning.

Returns
key_map_full

Reimplemented from drizzled::Cursor.

Definition at line 3166 of file ha_innodb.cc.

◆ position()

UNIV_INTERN void ha_innobase::position ( const unsigned char * record)
virtual

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

Parameters
recordin: row in MySQL format

Implements drizzled::Cursor.

Definition at line 5942 of file ha_innodb.cc.

◆ primary_key_is_clustered()

UNIV_INTERN bool ha_innobase::primary_key_is_clustered ( )
virtual

Determines if the primary key is clustered index.

Returns
true

Reimplemented from drizzled::Cursor.

Definition at line 3177 of file ha_innodb.cc.

◆ read_range_first()

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

Fast index creation (smart ALTER TABLE)

See also
handler0alter.cc

Reimplemented from drizzled::Cursor.

Definition at line 9659 of file ha_innodb.cc.

◆ read_range_next()

int ha_innobase::read_range_next ( )
virtual

Read next row between two endpoints.

Note
Record is read into table->getInsertRecord()
Return values
0Found row
HA_ERR_END_OF_FILENo rows in range

# Error code

Reimplemented from drizzled::Cursor.

Definition at line 9674 of file ha_innodb.cc.

◆ read_time()

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

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

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

Definition at line 7220 of file ha_innodb.cc.

◆ records_in_range()

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

Estimates the number of index records in a range.

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

Definition at line 7034 of file ha_innodb.cc.

◆ referenced_by_foreign_key()

UNIV_INTERN uint ha_innobase::referenced_by_foreign_key ( void )
virtual

Checks if a table is referenced by a foreign key. The MySQL manual states that a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a delete is then allowed internally to resolve a duplicate key conflict in REPLACE, not an update.

Returns
> 0 if referenced by a FOREIGN KEY

Reimplemented from drizzled::Cursor.

Definition at line 8129 of file ha_innodb.cc.

◆ reset()

UNIV_INTERN int ha_innobase::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 drizzled::Cursor.

Definition at line 8213 of file ha_innodb.cc.

◆ reset_auto_increment()

UNIV_INTERN int ha_innobase::reset_auto_increment ( uint64_t value)
virtual

Reset the auto-increment counter to the given value, i.e. the next row inserted will get the given value. This is called e.g. after TRUNCATE is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is returned by storage engines that don't support this operation.

Returns
0 or error code
Parameters
valuein: new value for table autoinc

Reimplemented from drizzled::Cursor.

Definition at line 8995 of file ha_innodb.cc.

◆ rnd_next()

UNIV_INTERN int ha_innobase::rnd_next ( unsigned char * buf)
virtual

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

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

Implements drizzled::Cursor.

Definition at line 5860 of file ha_innodb.cc.

◆ rnd_pos()

UNIV_INTERN int ha_innobase::rnd_pos ( unsigned char * buf,
unsigned char * pos )
virtual

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

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

Implements drizzled::Cursor.

Definition at line 5889 of file ha_innodb.cc.

◆ scan_time()

UNIV_INTERN double ha_innobase::scan_time ( void )
virtual

How many seeks it will take to read through the table. This is to be comparable to the number returned by records_in_range so that we can decide if we should scan the table or use keys.

Returns
estimated time measured in disk seeks

Reimplemented from drizzled::Cursor.

Definition at line 7203 of file ha_innodb.cc.

◆ store_key_val_for_row()

UNIV_INTERN uint ha_innobase::store_key_val_for_row ( uint keynr,
char * buff,
uint buff_len,
const unsigned char * record )
private

Stores a key value for a row to a buffer.

Returns
key value length as stored in buff
Parameters
keynrin: key number
buffin/out: buffer for the key value (in MySQL format)
buff_lenin: buffer length
recordin: row in MySQL format

Definition at line 4122 of file ha_innodb.cc.

◆ store_lock()

UNIV_INTERN THR_LOCK_DATA ** ha_innobase::store_lock ( Session * session,
THR_LOCK_DATA ** to,
enum thr_lock_type lock_type )
virtual

Converts a MySQL table lock stored in the 'lock' field of the handle to a proper type before storing pointer to the lock into an array of pointers. MySQL also calls this if it wants to reset some table locks to a not-locked state during the processing of an SQL query. An example is that during a SELECT the read lock is released early on the 'const' tables where we only fetch one row. MySQL does not call this when it releases all locks at the end of an SQL statement.

Returns
pointer to the next element in the 'to' array
Parameters
sessionin: user thread handle
toin: pointer to an array of pointers to lock structs; pointer to the 'lock' field of current handle is stored next to this array
lock_typein: lock type to store in 'lock'; this may also be TL_IGNORE

Reimplemented from drizzled::Cursor.

Definition at line 8687 of file ha_innodb.cc.

◆ try_semi_consistent_read()

UNIV_INTERN void ha_innobase::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 drizzled::Cursor.

Definition at line 5229 of file ha_innodb.cc.

◆ unlock_row()

UNIV_INTERN void ha_innobase::unlock_row ( void )
virtual

Removes a new lock set on a row, if it was not read optimistically. This can be called after a row has been read in the processing of an UPDATE or a DELETE query, if the option innodb_locks_unsafe_for_binlog is set.

Reimplemented from drizzled::Cursor.

Definition at line 5188 of file ha_innodb.cc.

◆ update_session()

UNIV_INTERN void ha_innobase::update_session ( Session * session)
inlineprivate

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

Parameters
sessionin: thd to use the handle

Definition at line 1709 of file ha_innodb.cc.

◆ update_table_comment()

UNIV_INTERN char * ha_innobase::update_table_comment ( const char * comment)

Adds information about free space in the InnoDB tablespace to a table comment which is printed out when a user calls SHOW TABLE STATUS. Adds also info on foreign keys.

Returns
table comment + InnoDB free space + info on foreign keys
Parameters
commentin: table comment defined by user

Definition at line 7874 of file ha_innodb.cc.

◆ was_semi_consistent_read()

UNIV_INTERN bool ha_innobase::was_semi_consistent_read ( void )
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 drizzled::Cursor.

Definition at line 5220 of file ha_innodb.cc.

Member Data Documentation

◆ key_val_buff

std::vector<unsigned char> ha_innobase::key_val_buff
private

buffer used in converting search key values from MySQL format to Innodb format

Definition at line 93 of file ha_innodb.h.

◆ last_match_mode

uint ha_innobase::last_match_mode
private

Definition at line 103 of file ha_innodb.h.

◆ lock

THR_LOCK_DATA ha_innobase::lock
private

Definition at line 88 of file ha_innodb.h.

◆ num_write_row

uint ha_innobase::num_write_row
private

number of doInsertRecord() calls

Definition at line 106 of file ha_innodb.h.

◆ prebuilt

row_prebuilt_t* ha_innobase::prebuilt
private

prebuilt struct in InnoDB, used to save CPU time with prebuilt data structures

Definition at line 82 of file ha_innodb.h.

◆ primary_key

uint ha_innobase::primary_key
private

Definition at line 99 of file ha_innodb.h.

◆ share

INNOBASE_SHARE* ha_innobase::share
private

information for MySQL table locking

Definition at line 89 of file ha_innodb.h.

◆ start_of_scan

ulong ha_innobase::start_of_scan
private

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

Definition at line 100 of file ha_innodb.h.

◆ upd_and_key_val_buff_len

ulong ha_innobase::upd_and_key_val_buff_len
private

Definition at line 96 of file ha_innodb.h.

◆ upd_buff

std::vector<unsigned char> ha_innobase::upd_buff
private

buffer used in updates

Definition at line 92 of file ha_innodb.h.

◆ user_session

Session* ha_innobase::user_session
private

the thread handle of the user currently using the handle; this is set in external_lock function

Definition at line 85 of file ha_innodb.h.


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