MySQL 8.0.39
Source Code Documentation
InnoDB Partitioning Private Handler

Functions specific for native InnoDB partitioning. More...

Functions

int ha_innopart::open (const char *name, int mode, uint test_if_locked, const dd::Table *table_def) override
 Open an InnoDB table. More...
 
int ha_innopart::close () override
 Closes a handle to an InnoDB table. More...
 
double ha_innopart::scan_time () override
 Time estimate for full table scan. More...
 
bool ha_innopart::was_semi_consistent_read () override
 Was the last returned row semi consistent read. More...
 
void ha_innopart::try_semi_consistent_read (bool yes) override
 Try semi consistent read. More...
 
void ha_innopart::unlock_row () override
 Removes a lock on a row. More...
 
int ha_innopart::index_init (uint index, bool sorted) override
 Initializes a handle to use an index. More...
 
int ha_innopart::index_end () override
 End index cursor. More...
 
int ha_innopart::rnd_init (bool scan) override
 Initialize a table scan. More...
 
int ha_innopart::rnd_end () override
 Ends a table scan. More...
 
int ha_innopart::external_lock (THD *thd, int lock_type) override
 Lock/prepare to lock table. More...
 
THR_LOCK_DATA ** ha_innopart::store_lock (THD *thd, THR_LOCK_DATA **to, thr_lock_type lock_type) override
 Function to store lock for all partitions in native partitioned table. More...
 
int ha_innopart::write_row (uchar *record) override
 Stores a row in an InnoDB database, to the table specified in this handle. More...
 
int ha_innopart::update_row (const uchar *old_record, uchar *new_record) override
 Updates a row given as a parameter to a new value. More...
 
int ha_innopart::delete_row (const uchar *record) override
 Deletes a row given as the parameter. More...
 

Detailed Description

Functions specific for native InnoDB partitioning.

See also
handler.h

Function Documentation

◆ close()

int ha_innopart::close ( void  )
overrideprivatevirtual

Closes a handle to an InnoDB table.

Returns
0

Reimplemented from ha_innobase.

◆ delete_row()

int ha_innopart::delete_row ( const uchar record)
inlineoverrideprivatevirtual

Deletes a row given as the parameter.

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

Reimplemented from ha_innobase.

◆ external_lock()

int ha_innopart::external_lock ( THD thd,
int  lock_type 
)
overrideprivatevirtual

Lock/prepare to lock table.

As MySQL will execute an external lock for every new table it uses when it starts to process an SQL statement (an exception is when MySQL calls start_stmt for the handle) we can use this function to store the pointer to the THD in the handle. We will also use this function to communicate to InnoDB that a new SQL statement has started and that we must store a savepoint to our transaction handle, so that we are able to roll back the SQL statement in case of an error.

Parameters
[in]thdHandle to the user thread.
[in]lock_typeLock type.
Returns
0 or error number.

Reimplemented from ha_innobase.

◆ index_end()

int ha_innopart::index_end ( void  )
overrideprivatevirtual

End index cursor.

Returns
0 or error code.

Reimplemented from ha_innobase.

◆ index_init()

int ha_innopart::index_init ( uint  keynr,
bool  sorted 
)
overrideprivatevirtual

Initializes a handle to use an index.

Parameters
[in]keynrKey (index) number.
[in]sortedTrue if result MUST be sorted according to index.
Returns
0 or error number.

Reimplemented from ha_innobase.

◆ open()

int ha_innopart::open ( const char *  name,
int  mode,
uint  test_if_locked,
const dd::Table table_def 
)
overrideprivatevirtual

Open an InnoDB table.

Parameters
[in]nametable name
[in]modeaccess mode
[in]test_if_lockedtest if the file to be opened is locked
[in]table_defdd::Table describing table to be opened
Return values
1if error
0if success

Reimplemented from ha_innobase.

◆ rnd_end()

int ha_innopart::rnd_end ( void  )
inlineoverrideprivatevirtual

Ends a table scan.

Returns
0 or error number

Reimplemented from ha_innobase.

◆ rnd_init()

int ha_innopart::rnd_init ( bool  scan)
inlineoverrideprivatevirtual

Initialize a table scan.

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

Reimplemented from ha_innobase.

◆ scan_time()

double ha_innopart::scan_time ( )
overrideprivatevirtual

Time estimate for full table scan.

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 ha_innobase.

◆ store_lock()

THR_LOCK_DATA ** ha_innopart::store_lock ( THD thd,
THR_LOCK_DATA **  to,
thr_lock_type  lock_type 
)
overrideprivatevirtual

Function to store lock for all partitions in native partitioned table.

Also look at ha_innobase::store_lock for more details.

Parameters
[in]thduser thread handle
[in]topointer to the current element in an array of pointers to lock structs
[in]lock_typelock type to store in 'lock'; this may also be TL_IGNORE
Return values
topointer to the current element in the 'to' array

Reimplemented from ha_innobase.

◆ try_semi_consistent_read()

void ha_innopart::try_semi_consistent_read ( bool  yes)
overrideprivatevirtual

Try semi consistent read.

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.

See also
handler.h and row0mysql.h
Parameters
[in]yesShould semi-consistent read be used.

Reimplemented from ha_innobase.

◆ unlock_row()

void ha_innopart::unlock_row ( void  )
overrideprivatevirtual

Removes a lock on a row.

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.

See also
ha_innobase::unlock_row().

Reimplemented from ha_innobase.

◆ update_row()

int ha_innopart::update_row ( const uchar old_row,
uchar new_row 
)
inlineoverrideprivatevirtual

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

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

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

Reimplemented from ha_innobase.

◆ was_semi_consistent_read()

bool ha_innopart::was_semi_consistent_read ( void  )
overrideprivatevirtual

Was the last returned row semi consistent read.

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. This can be used to avoid unnecessary lock waits.

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

See also
handler.h and row0mysql.h
Returns
true if last read was semi consistent else false.

Reimplemented from ha_innobase.

◆ write_row()

int ha_innopart::write_row ( uchar record)
inlineoverrideprivatevirtual

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 ha_innobase.