MySQL 8.3.0
Source Code Documentation
MDL_request Class Reference

A pending metadata lock request. More...

#include <mdl.h>

Public Member Functions

void init_with_source (MDL_key::enum_mdl_namespace namespace_arg, const char *db_arg, const char *name_arg, enum_mdl_type mdl_type_arg, enum_mdl_duration mdl_duration_arg, const char *src_file, uint src_line)
 Initialize a lock request. More...
 
void init_by_key_with_source (const MDL_key *key_arg, enum_mdl_type mdl_type_arg, enum_mdl_duration mdl_duration_arg, const char *src_file, uint src_line)
 Initialize a lock request using pre-built MDL_key. More...
 
void init_by_part_key_with_source (MDL_key::enum_mdl_namespace namespace_arg, const char *part_key_arg, size_t part_key_length_arg, size_t db_length_arg, enum_mdl_type mdl_type_arg, enum_mdl_duration mdl_duration_arg, const char *src_file, uint src_line)
 Initialize a lock request using partial MDL key. More...
 
void set_type (enum_mdl_type type_arg)
 Set type of lock request. More...
 
bool is_write_lock_request () const
 Is this a request for a lock which allow data to be updated? More...
 
bool is_ddl_or_lock_tables_lock_request () const
 Is this a request for a strong, DDL/LOCK TABLES-type, of lock? More...
 
 MDL_request ()=default
 This constructor exists for two reasons: More...
 
 MDL_request (const MDL_request &rhs)
 
 MDL_request (MDL_request &&)=default
 
MDL_requestoperator= (MDL_request &&)=default
 

Static Public Member Functions

static void * operator new (size_t size, MEM_ROOT *mem_root, const std::nothrow_t &arg=std::nothrow) noexcept
 
static void operator delete (void *, MEM_ROOT *, const std::nothrow_t &) noexcept
 

Public Attributes

enum_mdl_type type {MDL_INTENTION_EXCLUSIVE}
 Type of metadata lock. More...
 
enum_mdl_duration duration {MDL_STATEMENT}
 Duration for requested lock. More...
 
MDL_requestnext_in_list {nullptr}
 Pointers for participating in the list of lock requests for this context. More...
 
MDL_request ** prev_in_list {nullptr}
 
MDL_ticketticket {nullptr}
 Pointer to the lock ticket object for this lock request. More...
 
MDL_key key
 A lock is requested based on a fully qualified name and type. More...
 
const char * m_src_file {nullptr}
 
uint m_src_line {0}
 

Detailed Description

A pending metadata lock request.

A lock request and a granted metadata lock are represented by different classes because they have different allocation sites and hence different lifetimes. The allocation of lock requests is controlled from outside of the MDL subsystem, while allocation of granted locks (tickets) is controlled within the MDL subsystem.

Constructor & Destructor Documentation

◆ MDL_request() [1/3]

MDL_request::MDL_request ( )
default

This constructor exists for two reasons:

  • Table_ref objects are sometimes default-constructed. We plan to remove this as there is no practical reason, the call to the default constructor is always followed by either a call to Table_ref::operator= or memberwise assignments.
  • In some legacy cases Table_ref objects are copy-assigned without intention to copy the Table_ref::mdl_request member. In this cases they are overwritten with an uninitialized MDL_request object. The cases are:

    • Sql_cmd_handler_open::execute()
    • mysql_execute_command()
    • Query_expression::prepare()
    • fill_defined_view_parts()

    No new cases are expected. In all other cases, so far only Locked_tables_list::rename_locked_table(), a move assignment is actually what is intended.

◆ MDL_request() [2/3]

MDL_request::MDL_request ( const MDL_request rhs)
inline

◆ MDL_request() [3/3]

MDL_request::MDL_request ( MDL_request &&  )
default

Member Function Documentation

◆ init_by_key_with_source()

void MDL_request::init_by_key_with_source ( const MDL_key key_arg,
enum_mdl_type  mdl_type_arg,
enum_mdl_duration  mdl_duration_arg,
const char *  src_file,
uint  src_line 
)

Initialize a lock request using pre-built MDL_key.

See also
MDL_request::init(namespace, db, name, type).
Parameters
key_argThe pre-built MDL key for the request.
mdl_type_argThe MDL lock type for the request.
mdl_duration_argThe MDL duration for the request.
src_fileSource file name issuing the request.
src_lineSource line number issuing the request.

◆ init_by_part_key_with_source()

void MDL_request::init_by_part_key_with_source ( MDL_key::enum_mdl_namespace  namespace_arg,
const char *  part_key_arg,
size_t  part_key_length_arg,
size_t  db_length_arg,
enum_mdl_type  mdl_type_arg,
enum_mdl_duration  mdl_duration_arg,
const char *  src_file,
uint  src_line 
)

Initialize a lock request using partial MDL key.

See also
MDL_request::init(namespace, db, name, type).
Remarks
The partial key must be "<database>\0<name>\0".
Parameters
namespace_argId of namespace of object to be locked
part_key_argPartial key.
part_key_length_argPartial key length
db_length_argDatabase name length.
mdl_type_argThe MDL lock type for the request.
mdl_duration_argThe MDL duration for the request.
src_fileSource file name issuing the request.
src_lineSource line number issuing the request.

◆ init_with_source()

void MDL_request::init_with_source ( MDL_key::enum_mdl_namespace  mdl_namespace,
const char *  db_arg,
const char *  name_arg,
enum_mdl_type  mdl_type_arg,
enum_mdl_duration  mdl_duration_arg,
const char *  src_file,
uint  src_line 
)

Initialize a lock request.

This is to be used for every lock request.

Note that initialization and allocation are split into two calls. This is to allow flexible memory management of lock requests. Normally a lock request is stored in statement memory (e.g. is a member of class Table_ref), but we would also like to allow allocation of lock requests in other memory roots, for example in the grant subsystem, to lock privilege tables.

The MDL subsystem does not own or manage memory of lock requests.

Parameters
mdl_namespaceId of namespace of object to be locked
db_argName of database to which the object belongs
name_argName of of the object
mdl_type_argThe MDL lock type for the request.
mdl_duration_argThe MDL duration for the request.
src_fileSource file name issuing the request.
src_lineSource line number issuing the request.

◆ is_ddl_or_lock_tables_lock_request()

bool MDL_request::is_ddl_or_lock_tables_lock_request ( ) const
inline

Is this a request for a strong, DDL/LOCK TABLES-type, of lock?

◆ is_write_lock_request()

bool MDL_request::is_write_lock_request ( ) const
inline

Is this a request for a lock which allow data to be updated?

Note
This method returns true for MDL_SHARED_UPGRADABLE type of lock. Even though this type of lock doesn't allow updates it will always be upgraded to one that does.

◆ operator delete()

static void MDL_request::operator delete ( void *  ,
MEM_ROOT ,
const std::nothrow_t &   
)
inlinestaticnoexcept

◆ operator new()

static void * MDL_request::operator new ( size_t  size,
MEM_ROOT mem_root,
const std::nothrow_t &  arg = std::nothrow 
)
inlinestaticnoexcept

◆ operator=()

MDL_request & MDL_request::operator= ( MDL_request &&  )
default

◆ set_type()

void MDL_request::set_type ( enum_mdl_type  type_arg)
inline

Set type of lock request.

Can be only applied to pending locks.

Member Data Documentation

◆ duration

enum_mdl_duration MDL_request::duration {MDL_STATEMENT}

Duration for requested lock.

◆ key

MDL_key MDL_request::key

A lock is requested based on a fully qualified name and type.

◆ m_src_file

const char* MDL_request::m_src_file {nullptr}

◆ m_src_line

uint MDL_request::m_src_line {0}

◆ next_in_list

MDL_request* MDL_request::next_in_list {nullptr}

Pointers for participating in the list of lock requests for this context.

◆ prev_in_list

MDL_request** MDL_request::prev_in_list {nullptr}

◆ ticket

MDL_ticket* MDL_request::ticket {nullptr}

Pointer to the lock ticket object for this lock request.

Valid only if this lock request is satisfied.

◆ type

Type of metadata lock.


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