A base class for accessing a system table.
More...
#include <rpl_table_access.h>
|
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...
|
|
virtual void | before_open (THD *thd)=0 |
| Prepares before opening 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...
|
|
A base class for accessing a system table.
◆ ~System_table_access()
virtual System_table_access::~System_table_access |
( |
| ) |
|
|
virtualdefault |
◆ before_open()
virtual void System_table_access::before_open |
( |
THD * |
thd | ) |
|
|
pure virtual |
◆ close_table()
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] | 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 |
[in] | need_commit | Need to commit current transaction if it is true. |
- Return values
-
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.
◆ create_thd()
THD * System_table_access::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.
- Returns
- THD* Pointer to thread structure
◆ drop_thd()
void System_table_access::drop_thd |
( |
THD * |
thd | ) |
|
Destroys the created thread and restores the system_thread information.
- Parameters
-
thd | Thread requesting to be destroyed |
◆ open_table() [1/2]
Opens and locks a system 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] | thd | Thread requesting to open the table |
[in] | dbstr | Database where the table resides |
[in] | tbstr | Table to be opened |
[in] | max_num_field | Maximum number of fields |
[in] | lock_type | How to lock the table |
[out] | table | We will store the open table here |
[out] | backup | Save the lock info. here |
- Return values
-
true | open and lock failed - an error message is pushed into the stack |
false | success |
◆ open_table() [2/2]
Opens and locks a system 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] | thd | Thread requesting to open the table |
[in] | dbstr | Database where the table resides |
[in] | tbstr | Table to be opened |
[in] | max_num_field | Maximum number of fields |
[in] | lock_type | How to lock the table |
[out] | table | We will store the open table here |
[out] | backup | Save the lock info. here |
- Return values
-
true | open and lock failed - an error message is pushed into the stack |
false | success |
◆ m_flags
uint System_table_access::m_flags |
The documentation for this class was generated from the following files: