drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzled::Cursor Class Referenceabstract

#include <cursor.h>

Inheritance diagram for drizzled::Cursor:
[legend]
Collaboration diagram for drizzled::Cursor:
[legend]

Public Types

enum  { NONE =0 , INDEX , RND }

Public Member Functions

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 scan_time (void)
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)
virtual const key_map * keys_to_use_for_scanning ()
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 ha_rows estimate_rows_upper_bound ()
virtual const char * index_type (uint32_t)
uint32_t get_index (void) const
virtual int close (void)=0
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 (unsigned char *) __attribute__((warn_unused_result))
virtual int index_prev (unsigned char *)
virtual int index_first (unsigned char *)
virtual int index_last (unsigned char *)
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.
virtual int read_range_first (const key_range *start_key, const key_range *end_key, bool eq_range, bool sorted)
virtual int read_range_next ()
int compare_key (key_range *range)
virtual int rnd_next (unsigned char *)=0
virtual int rnd_pos (unsigned char *, unsigned char *)=0
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 void position (const unsigned char *record)=0
virtual int info (uint32_t)=0
virtual uint32_t calculate_key_hash_value (Field **)
virtual int extra (enum ha_extra_function)
virtual int extra_opt (enum ha_extra_function operation, uint32_t)
virtual bool was_semi_consistent_read ()
virtual void try_semi_consistent_read (bool)
virtual void unlock_row (void)
virtual void get_auto_increment (uint64_t offset, uint64_t increment, uint64_t nb_desired_values, uint64_t *first_value, uint64_t *nb_reserved_values)=0
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 char * get_foreign_key_create_info (void)
virtual bool can_switch_engines (void)
virtual int get_foreign_key_list (Session *, List< ForeignKeyInfo > *)
virtual uint32_t referenced_by_foreign_key ()
virtual void free_foreign_key_create_info (char *)
virtual THR_LOCK_DATA ** store_lock (Session *, THR_LOCK_DATA **to, enum thr_lock_type)
virtual bool primary_key_is_clustered ()
virtual int cmp_ref (const unsigned char *ref1, const unsigned char *ref2)
virtual bool isOrdered (void)

Public Attributes

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

void ha_statistic_increment (uint64_t system_status_var::*offset) const
void ** ha_data (Session *) const

Protected Attributes

ha_rows estimation_rows_to_insert

Private Member Functions

uint32_t calculate_key_len (uint32_t key_position, key_part_map keypart_map_arg)
void setTransactionReadWrite ()
virtual int open (const char *, int, uint32_t)
virtual int doOpen (const identifier::Table &identifier, int mode, uint32_t test_if_locked)
virtual int doStartIndexScan (uint32_t idx, bool)
virtual int doEndIndexScan ()
virtual int doStartTableScan (bool scan) __attribute__((warn_unused_result))=0
virtual int doEndTableScan ()
virtual int doInsertRecord (unsigned char *)
virtual int doUpdateRecord (const unsigned char *, unsigned char *)
virtual int doDeleteRecord (const unsigned char *)
virtual int reset ()
virtual int external_lock (Session *, int)
virtual void release_auto_increment (void)
virtual int check (Session *)
virtual void start_bulk_insert (ha_rows)
virtual int end_bulk_insert (void)
virtual int index_read (unsigned char *, const unsigned char *, uint32_t, enum ha_rkey_function)
virtual int index_read_last (unsigned char *, const unsigned char *, uint32_t)
virtual int delete_all_rows (void)
virtual int reset_auto_increment (uint64_t)
virtual int analyze (Session *)
virtual int disable_indexes (uint32_t)
virtual int enable_indexes (uint32_t)
virtual int discard_or_import_tablespace (bool)
virtual void drop_table ()

Private Attributes

Table & table
plugin::StorageEngine & engine

Friends

class SEAPITesterCursor

Detailed Description

The Cursor 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
  2. KeyTupleFormat - used to pass index search tuples (aka "keys") to storage engine. See optimizer/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>

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 111 of file drizzled/cursor.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Definition at line 162 of file drizzled/cursor.h.

Constructor & Destructor Documentation

◆ Cursor()

drizzled::Cursor::Cursor ( plugin::StorageEngine & engine_arg,
Table & share_arg )

Definition at line 60 of file drizzled/cursor.cc.

◆ ~Cursor()

drizzled::Cursor::~Cursor ( void )
virtual

Definition at line 73 of file drizzled/cursor.cc.

Member Function Documentation

◆ adjust_next_insert_id_after_explicit_value()

void drizzled::Cursor::adjust_next_insert_id_after_explicit_value ( uint64_t nr)

Definition at line 315 of file drizzled/cursor.cc.

◆ analyze()

virtual int drizzled::Cursor::analyze ( Session * )
inlineprivatevirtual

Reimplemented in ha_innobase.

Definition at line 587 of file drizzled/cursor.h.

◆ append_create_info()

virtual void drizzled::Cursor::append_create_info ( String * )
inlinevirtual

Definition at line 418 of file drizzled/cursor.h.

◆ calculate_key_hash_value()

virtual uint32_t drizzled::Cursor::calculate_key_hash_value ( Field ** )
inlinevirtual

Definition at line 362 of file drizzled/cursor.h.

◆ calculate_key_len()

uint32_t drizzled::Cursor::calculate_key_len ( uint32_t key_position,
key_part_map keypart_map_arg )
private

Definition at line 103 of file drizzled/cursor.cc.

◆ can_switch_engines()

virtual bool drizzled::Cursor::can_switch_engines ( void )
inlinevirtual

used in ALTER Table; if changing storage engine is allowed. e.g. not be allowed if table has foreign key constraints in engine.

Reimplemented in ha_innobase.

Definition at line 435 of file drizzled/cursor.h.

◆ check()

virtual int drizzled::Cursor::check ( Session * )
inlineprivatevirtual

admin commands - called from mysql_admin_table

Reimplemented in ha_innobase.

Definition at line 559 of file drizzled/cursor.h.

◆ clone()

Cursor * drizzled::Cursor::clone ( memory::Root * mem_root)
virtual

Definition at line 85 of file drizzled/cursor.cc.

◆ close()

virtual int drizzled::Cursor::close ( void )
pure virtual

Implemented in ha_innobase.

◆ closeMarkForDelete()

void drizzled::Cursor::closeMarkForDelete ( )

Drop table in the engine: public interface.

See also
Cursor::drop_table()

Definition at line 737 of file drizzled/cursor.cc.

◆ cmp_ref()

virtual int drizzled::Cursor::cmp_ref ( const unsigned char * ref1,
const unsigned char * ref2 )
inlinevirtual

Reimplemented in ha_innobase.

Definition at line 470 of file drizzled/cursor.h.

◆ compare_key()

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

@seealso 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 1193 of file drizzled/cursor.cc.

◆ delete_all_rows()

virtual int drizzled::Cursor::delete_all_rows ( void )
inlineprivatevirtual

This is called to delete all rows in a table If the Cursor 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_heap, ha_innobase, ha_myisam, and WiredTigerCursor.

Definition at line 576 of file drizzled/cursor.h.

◆ deleteRecord()

int drizzled::Cursor::deleteRecord ( const unsigned char * buf)

Definition at line 1489 of file drizzled/cursor.cc.

◆ disable_indexes()

virtual int drizzled::Cursor::disable_indexes ( uint32_t )
inlineprivatevirtual

Definition at line 590 of file drizzled/cursor.h.

◆ discard_or_import_tablespace()

virtual int drizzled::Cursor::discard_or_import_tablespace ( bool )
inlineprivatevirtual

Reimplemented in ha_innobase.

Definition at line 596 of file drizzled/cursor.h.

◆ doDeleteRecord()

virtual int drizzled::Cursor::doDeleteRecord ( const unsigned char * )
inlineprivatevirtual

Reimplemented in ha_innobase.

Definition at line 520 of file drizzled/cursor.h.

◆ doEndIndexScan()

virtual int drizzled::Cursor::doEndIndexScan ( void )
inlineprivatevirtual

Reimplemented in ha_innobase.

Definition at line 500 of file drizzled/cursor.h.

◆ doEndTableScan()

virtual int drizzled::Cursor::doEndTableScan ( void )
inlineprivatevirtual

Reimplemented in ha_innobase.

Definition at line 509 of file drizzled/cursor.h.

◆ doInsertRecord()

virtual int drizzled::Cursor::doInsertRecord ( unsigned char * )
inlineprivatevirtual

Reimplemented in ha_innobase.

Definition at line 510 of file drizzled/cursor.h.

◆ doOpen()

int drizzled::Cursor::doOpen ( const identifier::Table & identifier,
int mode,
uint32_t test_if_locked )
privatevirtual

Definition at line 207 of file drizzled/cursor.cc.

◆ doStartIndexScan()

virtual int drizzled::Cursor::doStartIndexScan ( uint32_t idx,
bool  )
inlineprivatevirtual

Reimplemented in WiredTigerCursor.

Definition at line 498 of file drizzled/cursor.h.

◆ doStartTableScan()

virtual int drizzled::Cursor::doStartTableScan ( bool scan)
privatepure virtual

doStartTableScan() can be called two times without doEndTableScan() 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

Implemented in drizzled::SEAPITesterCursor, FunctionCursor, ha_heap, ha_innobase, ha_myisam, TableProtoTesterCursor, and WiredTigerCursor.

◆ doUpdateRecord()

virtual int drizzled::Cursor::doUpdateRecord ( const unsigned char * ,
unsigned char *  )
inlineprivatevirtual

Reimplemented in ha_innobase.

Definition at line 515 of file drizzled/cursor.h.

◆ drop_table()

void drizzled::Cursor::drop_table ( )
privatevirtual

Definition at line 586 of file drizzled/cursor.cc.

◆ enable_indexes()

virtual int drizzled::Cursor::enable_indexes ( uint32_t )
inlineprivatevirtual

Definition at line 593 of file drizzled/cursor.h.

◆ end_bulk_insert()

virtual int drizzled::Cursor::end_bulk_insert ( void )
inlineprivatevirtual

Definition at line 564 of file drizzled/cursor.h.

◆ endIndexScan()

int drizzled::Cursor::endIndexScan ( )

Definition at line 131 of file drizzled/cursor.cc.

◆ endTableScan()

int drizzled::Cursor::endTableScan ( )

Definition at line 148 of file drizzled/cursor.cc.

◆ estimate_rows_upper_bound()

virtual ha_rows drizzled::Cursor::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 FunctionCursor, and ha_innobase.

Definition at line 290 of file drizzled/cursor.h.

◆ external_lock()

virtual int drizzled::Cursor::external_lock ( Session * ,
int  )
inlineprivatevirtual

Is not invoked for non-transactional temporary tables.

Tells the storage engine that we intend to read or write data from the table. This call is prefixed with a call to Cursor::store_lock() and is invoked only for those Cursor instances that stored the lock.

Calls to rnd_init/index_init are prefixed with this call. When table IO is complete, we call external_lock(F_UNLCK). A storage engine writer should expect that each call to ::external_lock(F_[RD|WR]LOCK is followed by a call to ::external_lock(F_UNLCK). If it is not, it is a bug in MySQL.

The name and signature originate from the first implementation in MyISAM, which would call fcntl to set/clear an advisory lock on the data file in this method.

Parameters
lock_typeF_RDLCK, F_WRLCK, F_UNLCK
Returns
non-0 in case of failure, 0 in case of success. When lock_type is F_UNLCK, the return value is ignored.

Reimplemented in drizzled::SEAPITesterCursor, ha_innobase, and ha_myisam.

Definition at line 553 of file drizzled/cursor.h.

◆ extra()

virtual int drizzled::Cursor::extra ( enum ha_extra_function )
inlinevirtual

Reimplemented in ha_innobase.

Definition at line 364 of file drizzled/cursor.h.

◆ extra_opt()

virtual int drizzled::Cursor::extra_opt ( enum ha_extra_function operation,
uint32_t  )
inlinevirtual

Definition at line 366 of file drizzled/cursor.h.

◆ free_foreign_key_create_info()

virtual void drizzled::Cursor::free_foreign_key_create_info ( char * )
inlinevirtual

Reimplemented in ha_innobase.

Definition at line 440 of file drizzled/cursor.h.

◆ get_auto_increment()

virtual void drizzled::Cursor::get_auto_increment ( uint64_t offset,
uint64_t increment,
uint64_t nb_desired_values,
uint64_t * first_value,
uint64_t * nb_reserved_values )
pure virtual

Implemented in ha_innobase.

◆ get_foreign_key_create_info()

virtual char * drizzled::Cursor::get_foreign_key_create_info ( void )
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

Reimplemented in ha_innobase.

Definition at line 430 of file drizzled/cursor.h.

◆ get_foreign_key_list()

virtual int drizzled::Cursor::get_foreign_key_list ( Session * ,
List< ForeignKeyInfo > *  )
inlinevirtual

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

Reimplemented in ha_innobase.

Definition at line 437 of file drizzled/cursor.h.

◆ get_index()

uint32_t drizzled::Cursor::get_index ( void ) const
inline

Definition at line 297 of file drizzled/cursor.h.

◆ getAutoIncrement()

uint64_t drizzled::Cursor::getAutoIncrement ( ) const
inline

Used by SHOW TABLE STATUS to get the current auto_inc from the engine

Definition at line 183 of file drizzled/cursor.h.

◆ getEngine()

plugin::StorageEngine * drizzled::Cursor::getEngine ( ) const
inline

Definition at line 121 of file drizzled/cursor.h.

◆ getNextInsertId()

uint64_t drizzled::Cursor::getNextInsertId ( ) const
inline

Definition at line 175 of file drizzled/cursor.h.

◆ getShare()

TableShare * drizzled::Cursor::getShare ( )

Definition at line 1484 of file drizzled/cursor.cc.

◆ getTable()

Table * drizzled::Cursor::getTable ( ) const
inline

Definition at line 130 of file drizzled/cursor.h.

◆ ha_analyze()

int drizzled::Cursor::ha_analyze ( Session * session)

Analyze table: public interface.

See also
Cursor::analyze()

Definition at line 682 of file drizzled/cursor.cc.

◆ ha_check()

int drizzled::Cursor::ha_check ( Session * )

Definition at line 591 of file drizzled/cursor.cc.

◆ ha_data()

void ** drizzled::Cursor::ha_data ( Session * session) const
protected

Definition at line 187 of file drizzled/cursor.cc.

◆ ha_delete_all_rows()

int drizzled::Cursor::ha_delete_all_rows ( )

Delete all rows: public interface.

See also
Cursor::delete_all_rows()
Note

This is now equalivalent to TRUNCATE TABLE.

Trigger post-truncate notification to plugins...

Todo
Make TransactionServices generic to AfterTriggerServices or similar...

Definition at line 638 of file drizzled/cursor.cc.

◆ ha_disable_indexes()

int drizzled::Cursor::ha_disable_indexes ( uint32_t mode)

Disable indexes: public interface.

See also
Cursor::disable_indexes()

Definition at line 696 of file drizzled/cursor.cc.

◆ ha_discard_or_import_tablespace()

int drizzled::Cursor::ha_discard_or_import_tablespace ( bool discard)

Discard or import tablespace: public interface.

See also
Cursor::discard_or_import_tablespace()

Definition at line 725 of file drizzled/cursor.cc.

◆ ha_enable_indexes()

int drizzled::Cursor::ha_enable_indexes ( uint32_t mode)

Enable indexes: public interface.

See also
Cursor::enable_indexes()

Definition at line 711 of file drizzled/cursor.cc.

◆ ha_end_bulk_insert()

int drizzled::Cursor::ha_end_bulk_insert ( )

Definition at line 166 of file drizzled/cursor.cc.

◆ ha_external_lock()

int drizzled::Cursor::ha_external_lock ( Session * session,
int lock_type )

These functions represent the public interface to users of the Cursor class, hence they are not virtual. For the inheritance interface, see the (private) functions doInsertRecord(), doUpdateRecord(), and doDeleteRecord() below.

Definition at line 1316 of file drizzled/cursor.cc.

◆ ha_index_or_rnd_end()

int drizzled::Cursor::ha_index_or_rnd_end ( )

Definition at line 155 of file drizzled/cursor.cc.

◆ ha_open()

int drizzled::Cursor::ha_open ( const identifier::Table & identifier,
int mode,
int test_if_locked )

Open database-Cursor.

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 218 of file drizzled/cursor.cc.

◆ ha_release_auto_increment()

void drizzled::Cursor::ha_release_auto_increment ( )

Reserves an interval of auto_increment values from the Cursor.

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 ~(uint64_t)0 it means an error. If the function sets *nb_reserved_values to UINT64_MAX it means it has reserved to "positive infinite".

Parameters
offset
increment
nb_desired_valueshow many values we want
first_value(OUT) the first value reserved by the Cursor
nb_reserved_values(OUT) how many values the Cursor reserved

Definition at line 578 of file drizzled/cursor.cc.

◆ ha_reset()

int drizzled::Cursor::ha_reset ( )

Check Cursor usage and reset state of file to after 'open'

Definition at line 1378 of file drizzled/cursor.cc.

◆ ha_reset_auto_increment()

int drizzled::Cursor::ha_reset_auto_increment ( uint64_t value)

Reset auto increment: public interface.

See also
Cursor::reset_auto_increment()

Definition at line 667 of file drizzled/cursor.cc.

◆ ha_start_bulk_insert()

void drizzled::Cursor::ha_start_bulk_insert ( ha_rows rows)

Definition at line 160 of file drizzled/cursor.cc.

◆ ha_statistic_increment()

void drizzled::Cursor::ha_statistic_increment ( uint64_t system_status_var::* offset) const
protected

Definition at line 182 of file drizzled/cursor.cc.

◆ has_transactions()

bool drizzled::Cursor::has_transactions ( )

Definition at line 177 of file drizzled/cursor.cc.

◆ index_first()

virtual int drizzled::Cursor::index_first ( unsigned char * )
inlinevirtual

Reimplemented in ha_innobase.

Definition at line 327 of file drizzled/cursor.h.

◆ index_last()

virtual int drizzled::Cursor::index_last ( unsigned char * )
inlinevirtual

Reimplemented in ha_innobase.

Definition at line 329 of file drizzled/cursor.h.

◆ index_next()

virtual int drizzled::Cursor::index_next ( unsigned char * )
inlinevirtual

Reimplemented in ha_innobase.

Definition at line 323 of file drizzled/cursor.h.

◆ index_next_same()

int drizzled::Cursor::index_next_same ( unsigned char * buf,
const unsigned char * key,
uint32_t keylen )
virtual

Definition at line 743 of file drizzled/cursor.cc.

◆ index_only_read_time()

double drizzled::Cursor::index_only_read_time ( uint32_t keynr,
double key_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 Cursor performs a random seek, thus the cost is proportional to the number of blocks read.
Todo
Consider joining this function and Cursor::read_time() into one Cursor::read_time(keynr, records, ranges, bool index_only) function.
Returns
Estimated cost of 'index only' scan

Definition at line 819 of file drizzled/cursor.cc.

◆ index_prev()

virtual int drizzled::Cursor::index_prev ( unsigned char * )
inlinevirtual

Reimplemented in ha_innobase.

Definition at line 325 of file drizzled/cursor.h.

◆ index_read()

virtual int drizzled::Cursor::index_read ( unsigned char * ,
const unsigned char * ,
uint32_t ,
enum ha_rkey_function )
inlineprivatevirtual

Definition at line 565 of file drizzled/cursor.h.

◆ index_read_idx_map()

int drizzled::Cursor::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 )
virtual

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.

Reimplemented in drizzled::SEAPITesterCursor, ha_heap, ha_myisam, and TableProtoTesterCursor.

Definition at line 1204 of file drizzled/cursor.cc.

◆ index_read_last()

virtual int drizzled::Cursor::index_read_last ( unsigned char * ,
const unsigned char * ,
uint32_t  )
inlineprivatevirtual

Definition at line 568 of file drizzled/cursor.h.

◆ index_read_last_map()

virtual int drizzled::Cursor::index_read_last_map ( unsigned char * buf,
const unsigned char * key,
key_part_map keypart_map )
inlinevirtual

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

Reimplemented in ha_heap, ha_myisam, and TableProtoTesterCursor.

Definition at line 342 of file drizzled/cursor.h.

◆ index_read_map()

virtual int drizzled::Cursor::index_read_map ( unsigned char * buf,
const unsigned char * key,
key_part_map keypart_map,
enum ha_rkey_function find_flag )
inlinevirtual

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.

Reimplemented in ha_heap, ha_myisam, and TableProtoTesterCursor.

Definition at line 306 of file drizzled/cursor.h.

◆ index_type()

virtual const char * drizzled::Cursor::index_type ( uint32_t )
inlinevirtual

Definition at line 293 of file drizzled/cursor.h.

◆ indexes_are_disabled()

virtual int drizzled::Cursor::indexes_are_disabled ( void )
inlinevirtual

Definition at line 417 of file drizzled/cursor.h.

◆ insertRecord()

int drizzled::Cursor::insertRecord ( unsigned char * buf)

Definition at line 1393 of file drizzled/cursor.cc.

◆ is_fatal_error()

bool drizzled::Cursor::is_fatal_error ( int error,
uint32_t flags )
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 Cursor 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.

Definition at line 192 of file drizzled/cursor.cc.

◆ isOrdered()

virtual bool drizzled::Cursor::isOrdered ( void )
inlinevirtual

Definition at line 475 of file drizzled/cursor.h.

◆ keys_to_use_for_scanning()

const key_map * drizzled::Cursor::keys_to_use_for_scanning ( )
virtual

Reimplemented in ha_innobase.

Definition at line 172 of file drizzled/cursor.cc.

◆ multi_range_read_info()

int drizzled::Cursor::multi_range_read_info ( uint32_t keyno,
uint32_t n_ranges,
uint32_t n_rows,
uint32_t * bufsz,
uint32_t * flags,
optimizer::CostVector * 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

Definition at line 951 of file drizzled/cursor.cc.

◆ multi_range_read_info_const()

ha_rows drizzled::Cursor::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

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 session->getKilled() 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.

Definition at line 864 of file drizzled/cursor.cc.

◆ multi_range_read_init()

int drizzled::Cursor::multi_range_read_init ( RANGE_SEQ_IF * seq_funcs,
void * seq_init_param,
uint32_t n_ranges,
uint32_t mode )
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 doStartIndexScan() 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 Cursor 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 doEndIndexScan() call is made, whichever comes first.

Return values
0OK
1Error

Definition at line 1012 of file drizzled/cursor.cc.

◆ multi_range_read_next()

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

Definition at line 1037 of file drizzled/cursor.cc.

◆ open()

virtual int drizzled::Cursor::open ( const char * ,
int ,
uint32_t  )
inlineprivatevirtual

Definition at line 496 of file drizzled/cursor.h.

◆ position()

virtual void drizzled::Cursor::position ( const unsigned char * record)
pure virtual

Implemented in ha_innobase.

◆ primary_key_is_clustered()

virtual bool drizzled::Cursor::primary_key_is_clustered ( )
inlinevirtual

Reimplemented in ha_innobase.

Definition at line 469 of file drizzled/cursor.h.

◆ read_first_row()

int drizzled::Cursor::read_first_row ( unsigned char * buf,
uint32_t 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.

Definition at line 257 of file drizzled/cursor.cc.

◆ read_range_first()

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

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->getInsertRecord()
Return values
0Found row
HA_ERR_END_OF_FILENo rows in range

# Error code

Reimplemented in ha_innobase, and ha_myisam.

Definition at line 1113 of file drizzled/cursor.cc.

◆ read_range_next()

int drizzled::Cursor::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 in ha_innobase, and ha_myisam.

Definition at line 1160 of file drizzled/cursor.cc.

◆ read_time()

virtual double drizzled::Cursor::read_time ( uint32_t ,
uint32_t ranges,
ha_rows rows )
inlinevirtual

Reimplemented in WiredTigerCursor.

Definition at line 246 of file drizzled/cursor.h.

◆ records()

ha_rows drizzled::Cursor::records ( )
virtual

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

Definition at line 203 of file drizzled/cursor.cc.

◆ records_in_range()

virtual ha_rows drizzled::Cursor::records_in_range ( uint32_t ,
key_range * ,
key_range *  )
inlinevirtual

Reimplemented in WiredTigerCursor.

Definition at line 358 of file drizzled/cursor.h.

◆ referenced_by_foreign_key()

virtual uint32_t drizzled::Cursor::referenced_by_foreign_key ( void )
inlinevirtual

Reimplemented in ha_innobase.

Definition at line 439 of file drizzled/cursor.h.

◆ release_auto_increment()

virtual void drizzled::Cursor::release_auto_increment ( void )
inlineprivatevirtual

Definition at line 557 of file drizzled/cursor.h.

◆ reset()

virtual int drizzled::Cursor::reset ( void )
inlineprivatevirtual

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

Reimplemented in drizzled::SEAPITesterCursor, FunctionCursor, ha_heap, ha_innobase, ha_myisam, and WiredTigerCursor.

Definition at line 529 of file drizzled/cursor.h.

◆ reset_auto_increment()

virtual int drizzled::Cursor::reset_auto_increment ( uint64_t )
inlineprivatevirtual

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.

Reimplemented in ha_heap, ha_innobase, ha_myisam, and WiredTigerCursor.

Definition at line 584 of file drizzled/cursor.h.

◆ restore_auto_increment()

void drizzled::Cursor::restore_auto_increment ( uint64_t prev_insert_id)
inline

Definition at line 399 of file drizzled/cursor.h.

◆ rnd_next()

virtual int drizzled::Cursor::rnd_next ( unsigned char * )
pure virtual

Implemented in ha_innobase.

◆ rnd_pos()

virtual int drizzled::Cursor::rnd_pos ( unsigned char * ,
unsigned char *  )
pure virtual

Implemented in ha_innobase.

◆ rnd_same()

virtual int drizzled::Cursor::rnd_same ( unsigned char * ,
uint32_t  )
inlinevirtual

Definition at line 356 of file drizzled/cursor.h.

◆ rowSize()

uint64_t drizzled::Cursor::rowSize ( )
virtual

Definition at line 205 of file drizzled/cursor.cc.

◆ scan_time()

virtual double drizzled::Cursor::scan_time ( void )
inlinevirtual

Reimplemented in ha_innobase, and WiredTigerCursor.

Definition at line 244 of file drizzled/cursor.h.

◆ set_next_insert_id()

void drizzled::Cursor::set_next_insert_id ( uint64_t id)
inline

Definition at line 395 of file drizzled/cursor.h.

◆ setTransactionReadWrite()

void drizzled::Cursor::setTransactionReadWrite ( )
inlineprivate

A helper function to mark a transaction read-write, if it is started.

Definition at line 603 of file drizzled/cursor.cc.

◆ start_bulk_insert()

virtual void drizzled::Cursor::start_bulk_insert ( ha_rows )
inlineprivatevirtual

Definition at line 562 of file drizzled/cursor.h.

◆ startIndexScan()

int drizzled::Cursor::startIndexScan ( uint32_t idx,
bool sorted )

Definition at line 121 of file drizzled/cursor.cc.

◆ startTableScan()

int drizzled::Cursor::startTableScan ( bool scan)

Definition at line 139 of file drizzled/cursor.cc.

◆ store_lock()

virtual THR_LOCK_DATA ** drizzled::Cursor::store_lock ( Session * ,
THR_LOCK_DATA ** to,
enum thr_lock_type  )
inlinevirtual

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 abortLockForThread().
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.

Reimplemented in drizzled::SEAPITesterCursor, ha_innobase, and WiredTigerCursor.

Definition at line 455 of file drizzled/cursor.h.

◆ tableSize()

uint64_t drizzled::Cursor::tableSize ( )
virtual

Definition at line 204 of file drizzled/cursor.cc.

◆ try_semi_consistent_read()

virtual void drizzled::Cursor::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_innobase.

Definition at line 388 of file drizzled/cursor.h.

◆ unlock_row()

virtual void drizzled::Cursor::unlock_row ( void )
inlinevirtual

Reimplemented in ha_innobase.

Definition at line 389 of file drizzled/cursor.h.

◆ update_auto_increment()

int drizzled::Cursor::update_auto_increment ( )

Definition at line 428 of file drizzled/cursor.cc.

◆ updateRecord()

int drizzled::Cursor::updateRecord ( const unsigned char * old_data,
unsigned char * new_data )

Definition at line 1440 of file drizzled/cursor.cc.

◆ was_semi_consistent_read()

virtual bool drizzled::Cursor::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_innobase.

Definition at line 381 of file drizzled/cursor.h.

◆ SEAPITesterCursor

friend class SEAPITesterCursor
friend

Definition at line 113 of file drizzled/cursor.h.

Member Data Documentation

◆ active_index

uint32_t drizzled::Cursor::active_index

Definition at line 159 of file drizzled/cursor.h.

◆ auto_inc_interval_for_cur_row

Discrete_interval drizzled::Cursor::auto_inc_interval_for_cur_row

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

Definition at line 199 of file drizzled/cursor.h.

◆ dup_ref

unsigned char* drizzled::Cursor::dup_ref

Definition at line 126 of file drizzled/cursor.h.

◆ end_range

key_range * drizzled::Cursor::end_range

Definition at line 153 of file drizzled/cursor.h.

◆ engine

plugin::StorageEngine& drizzled::Cursor::engine
private

Definition at line 115 of file drizzled/cursor.h.

◆ eq_range

bool drizzled::Cursor::eq_range

Definition at line 147 of file drizzled/cursor.h.

◆ errkey

uint32_t drizzled::Cursor::errkey

Definition at line 157 of file drizzled/cursor.h.

◆ estimation_rows_to_insert

ha_rows drizzled::Cursor::estimation_rows_to_insert
protected

Definition at line 118 of file drizzled/cursor.h.

◆ insert_id_for_cur_row

uint64_t drizzled::Cursor::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 Session::first_successful_insert_id_in_cur_stmt.

Definition at line 194 of file drizzled/cursor.h.

◆ key_compare_result_on_equal

int drizzled::Cursor::key_compare_result_on_equal

Definition at line 155 of file drizzled/cursor.h.

◆ key_used_on_scan

uint32_t drizzled::Cursor::key_used_on_scan

Definition at line 158 of file drizzled/cursor.h.

◆ locked

bool drizzled::Cursor::locked

Definition at line 163 of file drizzled/cursor.h.

◆ mrr_cur_range

KEY_MULTI_RANGE drizzled::Cursor::mrr_cur_range

Current range (the one we're now returning rows from)

Definition at line 150 of file drizzled/cursor.h.

◆ mrr_funcs

RANGE_SEQ_IF drizzled::Cursor::mrr_funcs

Definition at line 138 of file drizzled/cursor.h.

◆ mrr_have_range

bool drizzled::Cursor::mrr_have_range

true <=> we're currently traversing a range in mrr_cur_range.

Definition at line 145 of file drizzled/cursor.h.

◆ mrr_is_output_sorted

bool drizzled::Cursor::mrr_is_output_sorted

Definition at line 142 of file drizzled/cursor.h.

◆ mrr_iter

range_seq_t drizzled::Cursor::mrr_iter

MultiRangeRead-related members:

Definition at line 137 of file drizzled/cursor.h.

◆ next_insert_id

uint64_t drizzled::Cursor::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 174 of file drizzled/cursor.h.

◆ range_key_part

KeyPartInfo* drizzled::Cursor::range_key_part

Definition at line 154 of file drizzled/cursor.h.

◆ ranges_in_seq

uint32_t drizzled::Cursor::ranges_in_seq

Definition at line 140 of file drizzled/cursor.h.

◆ ref

unsigned char* drizzled::Cursor::ref

Definition at line 125 of file drizzled/cursor.h.

◆ ref_length

uint32_t drizzled::Cursor::ref_length

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

Definition at line 161 of file drizzled/cursor.h.

◆ save_end_range

key_range drizzled::Cursor::save_end_range

The following are for read_range()

Definition at line 153 of file drizzled/cursor.h.

◆ stats

ha_statistics drizzled::Cursor::stats

Definition at line 135 of file drizzled/cursor.h.

◆ table

Table& drizzled::Cursor::table
private

Definition at line 114 of file drizzled/cursor.h.


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