MySQL 9.1.0
Source Code Documentation
System_table_access Class Referenceabstract

A base class for accessing a system table. More...

#include <rpl_table_access.h>

Inheritance diagram for System_table_access:
[legend]

Public Member Functions

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

Public Attributes

uint m_flags
 

Detailed Description

A base class for accessing a system table.

Constructor & Destructor Documentation

◆ ~System_table_access()

virtual System_table_access::~System_table_access ( )
virtualdefault

Member Function Documentation

◆ before_open()

virtual void System_table_access::before_open ( THD thd)
pure virtual

Prepares before opening table.

Parameters
[in]thdThread requesting to open the table

Implemented in Gtid_table_access_context, and Rpl_info_table_access.

◆ close_table()

bool System_table_access::close_table ( THD thd,
TABLE table,
Open_tables_backup backup,
bool  error,
bool  need_commit 
)

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
[in]need_commitNeed to commit current transaction if it is true.
Return values
truefailed
falsesuccess

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
thdThread requesting to be destroyed

◆ open_table() [1/2]

bool System_table_access::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.

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 opened
[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
Return values
trueopen and lock failed - an error message is pushed into the stack
falsesuccess

◆ open_table() [2/2]

bool System_table_access::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.

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 opened
[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
Return values
trueopen and lock failed - an error message is pushed into the stack
falsesuccess

Member Data Documentation

◆ m_flags

uint System_table_access::m_flags

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