MySQL 8.0.39
Source Code Documentation
dd::Schema_MDL_locker Class Reference

RAII based class to acquire and release schema meta data locks. More...

#include <dd_schema.h>

Public Member Functions

 Schema_MDL_locker (THD *thd)
 
bool ensure_locked (const char *schema_name)
 Make sure we have an IX meta data lock on the schema name. More...
 
 ~Schema_MDL_locker ()
 Release the MDL ticket, if any, when the instance of this class leaves scope or is deleted. More...
 

Private Attributes

THDm_thd
 
MDL_ticketm_ticket
 

Detailed Description

RAII based class to acquire and release schema meta data locks.

When an instance of this class is created, and 'ensure_lock()' is called, it will acquire an IX lock on the submitted schema name, unless we already have one. When the instance goes out of scope or is deleted, the ticket registered will be released.

Note
It is vital that the order of releasing and unlocking the schema is correct. The Schema_MDL_locker must always be declared before the corresponding Auto_releaser to make sure that the schema locker is deleted after the auto releaser. Otherwise, there will be situations where we have the schema object referenced locally, but without a meta data lock. This may, in turn, violate asserts in the shared cache, and open up for improper usage.

Constructor & Destructor Documentation

◆ Schema_MDL_locker()

dd::Schema_MDL_locker::Schema_MDL_locker ( THD thd)
inline

◆ ~Schema_MDL_locker()

dd::Schema_MDL_locker::~Schema_MDL_locker ( )

Release the MDL ticket, if any, when the instance of this class leaves scope or is deleted.

Member Function Documentation

◆ ensure_locked()

bool dd::Schema_MDL_locker::ensure_locked ( const char *  schema_name)

Make sure we have an IX meta data lock on the schema name.

If the circumstances indicate that we need a meta data lock, and we do not already have one, then an IX meta data lock is acquired.

Parameters
schema_nameThe name of the schema.
Return values
trueFailed to ensure that the schema name is locked. false It is ensured that we have at least an IX lock on the schema name.

Member Data Documentation

◆ m_thd

THD* dd::Schema_MDL_locker::m_thd
private

◆ m_ticket

MDL_ticket* dd::Schema_MDL_locker::m_ticket
private

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