MySQL 9.1.0
Source Code Documentation
Rpl_info_table_access Class Reference

#include <rpl_info_table_access.h>

Inheritance diagram for Rpl_info_table_access:
[legend]

Public Member Functions

 Rpl_info_table_access ()
 
 ~Rpl_info_table_access () override=default
 
void before_open (THD *thd) override
 Prepares before opening table. More...
 
bool close_table (THD *thd, TABLE *table, Open_tables_backup *backup, bool error)
 Commits the changes, unlocks the table and closes it. More...
 
enum enum_return_id find_info (Rpl_info_values *field_values, TABLE *table)
 Positions the internal pointer of table according to the primary key. More...
 
enum enum_return_id scan_info (TABLE *table, uint instance)
 Positions the internal pointer of table to the n-instance row. More...
 
std::pair< bool, bool > is_table_in_use (TABLE *table)
 Returns if the table is being used, meaning it contains at least a line or some concurrency related error was returned when looking at the table. More...
 
bool count_info (TABLE *table, ulonglong *counter)
 Returns the number of entries in table. More...
 
bool 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. More...
 
bool 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. More...
 
THDcreate_thd ()
 Creates a new thread if necessary. More...
 
void drop_thd (THD *thd)
 Destroys the created thread if necessary and restores the system_thread information. More...
 
- Public Member Functions inherited from System_table_access
virtual ~System_table_access ()=default
 
bool open_table (THD *thd, const LEX_CSTRING dbstr, const LEX_CSTRING tbstr, uint max_num_field, enum thr_lock_type lock_type, TABLE **table, Open_tables_backup *backup)
 Opens and locks a system table. More...
 
bool open_table (THD *thd, std::string dbstr, std::string tbstr, uint max_num_field, enum thr_lock_type lock_type, TABLE **table, Open_tables_backup *backup)
 Opens and locks a system table. More...
 
bool close_table (THD *thd, TABLE *table, Open_tables_backup *backup, bool error, bool need_commit)
 Commits the changes, unlocks the table and closes it. More...
 
THDcreate_thd ()
 Creates a new thread in the bootstrap process or in the mysqld startup, a thread is created in order to be able to access a table. More...
 
void drop_thd (THD *thd)
 Destroys the created thread and restores the system_thread information. More...
 

Private Member Functions

Rpl_info_table_accessoperator= (const Rpl_info_table_access &info)
 
 Rpl_info_table_access (const Rpl_info_table_access &info)
 

Private Attributes

bool thd_created
 

Additional Inherited Members

- Public Attributes inherited from System_table_access
uint m_flags
 

Constructor & Destructor Documentation

◆ Rpl_info_table_access() [1/2]

Rpl_info_table_access::Rpl_info_table_access ( )
inline

◆ ~Rpl_info_table_access()

Rpl_info_table_access::~Rpl_info_table_access ( )
overridedefault

◆ Rpl_info_table_access() [2/2]

Rpl_info_table_access::Rpl_info_table_access ( const Rpl_info_table_access info)
private

Member Function Documentation

◆ before_open()

void Rpl_info_table_access::before_open ( THD thd)
overridevirtual

Prepares before opening table.

  • set flags
  • start lex and reset the part of THD responsible for the state of command processing if needed.
Parameters
[in]thdThread requesting to open the table

Implements System_table_access.

◆ close_table()

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.

Return values
falseSuccess
trueFailure

◆ count_info()

bool Rpl_info_table_access::count_info ( TABLE table,
ulonglong 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 access the table. So if an error different from HA_ERR_END_OF_FILE is returned, an error is returned meaning the count failed cause a deadlock or other issue was found

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

◆ create_thd()

THD * Rpl_info_table_access::create_thd ( )

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
THD* Pointer to thread structure

◆ drop_thd()

void 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

◆ find_info()

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
Return values
FOUND_IDThe row was found.
NOT_FOUND_IDThe row was not found.
ERROR_IDThere was a failure.

◆ is_table_in_use()

std::pair< bool, bool > Rpl_info_table_access::is_table_in_use ( TABLE table)

Returns if the table is being used, meaning it contains at least a line or some concurrency related error was returned when looking at the table.

Parameters
[in]tableTable
Return values
apair of booleans First element is true if an error occurred, false otherwise. Second element is true if the table is not empty or an access error occurred meaning someone else is accessing it. False if the table is empty.

◆ load_info_values()

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
Return values
falseNo error
trueFailure

◆ operator=()

Rpl_info_table_access & Rpl_info_table_access::operator= ( const Rpl_info_table_access info)
private

◆ scan_info()

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 manually and concurrently changed something.

Return values
FOUNDThe row was found.
NOT_FOUNDThe row was not found.
ERRORThere was a failure.

◆ store_info_values()

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
Return values
falseNo error
trueFailure

Member Data Documentation

◆ thd_created

bool Rpl_info_table_access::thd_created
private

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