MySQL 9.1.0
Source Code Documentation
|
#include <rpl_info_table_access.h>
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... | |
THD * | create_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... | |
THD * | create_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_access & | operator= (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 |
|
inline |
|
overridedefault |
|
private |
|
overridevirtual |
Prepares before opening table.
[in] | thd | Thread requesting to open the table |
Implements System_table_access.
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.
[in] | thd | Thread requesting to close the table |
[in] | table | Table to be closed |
[in] | backup | Restore the lock info from here |
[in] | error | If 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.
false | Success |
true | Failure |
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
[in] | table | Table |
[out] | counter | Registers the number of entries. |
false | No error |
true | Failure |
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.
void Rpl_info_table_access::drop_thd | ( | THD * | thd | ) |
Destroys the created thread if necessary and restores the system_thread information.
[in] | thd | Thread requesting to be destroyed |
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.
[in,out] | field_values | The sequence of values |
[in,out] | table | Table |
FOUND_ID | The row was found. |
NOT_FOUND_ID | The row was not found. |
ERROR_ID | There was a failure. |
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.
[in] | table | Table |
a | pair 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. |
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.
[in] | max_num_field | Maximum number of fields |
[in] | fields | The sequence of fields |
[in] | field_values | The sequence of values |
false | No error |
true | Failure |
|
private |
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.
[in] | table | Reference to a table object. |
[in] | instance | n-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.
FOUND | The row was found. |
NOT_FOUND | The row was not found. |
ERROR | There 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.
[in] | max_num_field | Maximum number of fields |
[in] | fields | The sequence of fields |
[in] | field_values | The sequence of values |
false | No error |
true | Failure |
|
private |