My Project
Public Member Functions
Rpl_info_table_access Class Reference

List of all members.

Public Member Functions

bool open_table (THD *thd, const LEX_STRING dbstr, const LEX_STRING tbstr, uint max_num_field, enum thr_lock_type lock_type, TABLE **table, Open_tables_backup *backup)
bool close_table (THD *thd, TABLE *table, Open_tables_backup *backup, bool error)
enum enum_return_id find_info (Rpl_info_values *field_values, TABLE *table)
enum enum_return_id scan_info (TABLE *table, uint instance)
bool count_info (TABLE *table, uint *counter)
bool load_info_values (uint max_num_field, Field **fields, Rpl_info_values *field_values)
bool store_info_values (uint max_num_field, Field **fields, Rpl_info_values *field_values)
THD * create_thd ()
bool drop_thd (THD *thd)

Member Function Documentation

bool Rpl_info_table_access::close_table ( THD *  thd,
TABLE table,
Open_tables_backup *  backup,
bool  error 
)

Commits the changes, unlocks the table and closes it. This method needs to be called even if the open_table fails, in order to ensure the lock info is properly restored.

Parameters:
[in]thdThread requesting to close the table
[in]tableTable to be closed
[in]backupRestore the lock info from here
[in]errorIf there was an error while updating the table

If there is an error, rolls back the current statement. Otherwise, commits it. However, if a new thread was created and there is an error, the transaction must be rolled back. Otherwise, it must be committed. In this case, the changes were not done on behalf of any user transaction and if not finished, there would be pending changes.

Returns:
Return values:
FALSENo error
TRUEFailure
bool Rpl_info_table_access::count_info ( TABLE table,
uint *  counter 
)

Returns the number of entries in table.

The code built on top of this function needs to ensure there is no concurrent threads trying to update the table. So if an error different from HA_ERR_END_OF_FILE is returned, we abort with an error because this implies that someone has manualy and concurrently changed something.

Parameters:
[in]tableTable
[out]counterRegisters the number of entries.
Returns:
Return values:
falseNo error
trueFailure

Creates a new thread if necessary. In the bootstrap process or in the mysqld startup, a thread is created in order to be able to access a table. Otherwise, the current thread is used.

Returns:
Return values:
THD*Pointer to thread structure
bool Rpl_info_table_access::drop_thd ( THD *  thd)

Destroys the created thread if necessary and restores the system_thread information.

Parameters:
[in]thdThread requesting to be destroyed
Returns:
Return values:
FALSENo error
TRUEFailure
enum enum_return_id Rpl_info_table_access::find_info ( Rpl_info_values field_values,
TABLE table 
)

Positions the internal pointer of `table` according to the primary key.

If the search succeeds, the table cursor points to the found row.

Parameters:
[in,out]field_valuesThe sequence of values
[in,out]tableTable
Returns:
Return values:
FOUNDThe row was found.
NOT_FOUNDThe row was not found.
ERRORThere was a failure.
bool Rpl_info_table_access::load_info_values ( uint  max_num_field,
Field **  fields,
Rpl_info_values field_values 
)

Reads information from a sequence of fields into a set of LEX_STRING structures, where the sequence of values is specified through the object Rpl_info_values.

Parameters:
[in]max_num_fieldMaximum number of fields
[in]fieldsThe sequence of fields
[in]field_valuesThe sequence of values
Returns:
Return values:
FALSENo error
TRUEFailure
bool Rpl_info_table_access::open_table ( THD *  thd,
const LEX_STRING  dbstr,
const LEX_STRING  tbstr,
uint  max_num_field,
enum thr_lock_type  lock_type,
TABLE **  table,
Open_tables_backup *  backup 
)

Opens and locks a table.

It's assumed that the caller knows what they are doing:

  • whether it was necessary to reset-and-backup the open tables state
  • whether the requested lock does not lead to a deadlock
  • whether this open mode would work under LOCK TABLES, or inside a stored function or trigger.

Note that if the table can't be locked successfully this operation will close it. Therefore it provides guarantee that it either opens and locks table or fails without leaving any tables open.

Parameters:
[in]thdThread requesting to open the table
[in]dbstrDatabase where the table resides
[in]tbstrTable to be openned
[in]max_num_fieldMaximum number of fields
[in]lock_typeHow to lock the table
[out]tableWe will store the open table here
[out]backupSave the lock info. here
Returns:
Return values:
TRUEopen and lock failed - an error message is pushed into the stack
FALSEsuccess
enum enum_return_id Rpl_info_table_access::scan_info ( TABLE table,
uint  instance 
)

Positions the internal pointer of `table` to the n-instance row.

Parameters:
[in]tableReference to a table object.
[in]instancen-instance row.

The code built on top of this function needs to ensure there is no concurrent threads trying to update the table. So if an error different from HA_ERR_END_OF_FILE is returned, we abort with an error because this implies that someone has manualy and concurrently changed something.

Returns:
Return values:
FOUNDThe row was found.
NOT_FOUNDThe row was not found.
ERRORThere was a failure.
bool Rpl_info_table_access::store_info_values ( uint  max_num_field,
Field **  fields,
Rpl_info_values field_values 
)

Stores information from a sequence of fields into a set of LEX_STRING structures, where the sequence of values is specified through the object Rpl_info_values.

Parameters:
[in]max_num_fieldMaximum number of fields
[in]fieldsThe sequence of fields
[in]field_valuesThe sequence of values
Returns:
Return values:
FALSENo error
TRUEFailure

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