MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Locking

Macros

#define GET_LOCK_UNLOCK   1
#define GET_LOCK_STORE_LOCKS   2

Functions

MYSQL_LOCKmysql_lock_tables (THD *thd, TABLE **tables, uint count, uint flags)
void mysql_unlock_tables (THD *thd, MYSQL_LOCK *sql_lock)
void mysql_unlock_some_tables (THD *thd, TABLE **table, uint count)
void mysql_unlock_read_tables (THD *thd, MYSQL_LOCK *sql_lock)
void mysql_lock_remove (THD *thd, MYSQL_LOCK *locked, TABLE *table)
void mysql_lock_abort (THD *thd, TABLE *table, bool upgrade_lock)
bool mysql_lock_abort_for_thread (THD *thd, TABLE *table)
MYSQL_LOCKmysql_lock_merge (MYSQL_LOCK *a, MYSQL_LOCK *b)
bool lock_schema_name (THD *thd, const char *db)
bool lock_object_name (THD *thd, MDL_key::enum_mdl_namespace mdl_type, const char *db, const char *name)

Variables

HASH open_cache

Detailed Description

Function Documentation

bool lock_object_name ( THD *  thd,
MDL_key::enum_mdl_namespace  mdl_type,
const char *  db,
const char *  name 
)

Obtain an exclusive metadata lock on an object name.

Parameters
thdThread handle.
mdl_typeObject type (currently functions, procedures and events can be name-locked).
dbThe schema the object belongs to.
nameObject name in the schema.

This function assumes that no metadata locks were acquired before calling it. Additionally, it cannot be called while holding LOCK_open mutex. Both these invariants are enforced by asserts in MDL_context::acquire_locks(). To avoid deadlocks, we do not try to obtain exclusive metadata locks in LOCK TABLES mode, since in this mode there may be other metadata locks already taken by the current connection, and we must not wait for MDL locks while holding locks.

Return values
FALSESuccess.
TRUEFailure: we're in LOCK TABLES mode, or out of memory, or this connection was killed.

Definition at line 829 of file lock.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool lock_schema_name ( THD *  thd,
const char *  db 
)

Obtain an exclusive metadata lock on a schema name.

Parameters
thdThread handle.
dbThe database name.

This function cannot be called while holding LOCK_open mutex. To avoid deadlocks, we do not try to obtain exclusive metadata locks in LOCK TABLES mode, since in this mode there may be other metadata locks already taken by the current connection, and we must not wait for MDL locks while holding locks.

Return values
FALSESuccess.
TRUEFailure: we're in LOCK TABLES mode, or out of memory, or this connection was killed.

Definition at line 775 of file lock.cc.

Here is the call graph for this function:

void mysql_lock_abort ( THD *  thd,
TABLE table,
bool  upgrade_lock 
)

Abort all other threads waiting to get lock in table.

Definition at line 542 of file lock.cc.

bool mysql_lock_abort_for_thread ( THD *  thd,
TABLE table 
)

Abort one thread / table combination.

Parameters
thdThread handler
tableTable that should be removed from lock queue
Return values
0Table was not locked by another thread
1Table was locked by at least one other thread

Definition at line 569 of file lock.cc.

void mysql_lock_remove ( THD *  thd,
MYSQL_LOCK locked,
TABLE table 
)

Try to find the table in the list of locked tables. In case of success, unlock the table and remove it from this list. If a table has more than one lock instance, removes them all.

Parameters
thdthread context
lockedlist of locked tables
tablethe table to unlock

Definition at line 479 of file lock.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

MYSQL_LOCK* mysql_lock_tables ( THD *  thd,
TABLE **  tables,
uint  count,
uint  flags 
)

Lock tables.

Parameters
thdThe current thread.
tablesAn array of pointers to the tables to lock.
countThe number of tables to lock.
flagsOptions: MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY Ignore SET GLOBAL READ_ONLY MYSQL_LOCK_IGNORE_TIMEOUT Use maximum timeout value.
Return values
Alock structure pointer on success.
NULLif an error or if wait on a lock was killed.

Definition at line 289 of file lock.cc.

Here is the caller graph for this function:

void mysql_unlock_read_tables ( THD *  thd,
MYSQL_LOCK sql_lock 
)

unlock all tables locked for read.

Definition at line 412 of file lock.cc.

Here is the caller graph for this function:

void mysql_unlock_some_tables ( THD *  thd,
TABLE **  table,
uint  count 
)

Unlock some of the tables locked by mysql_lock_tables.

This will work even if get_lock_data fails (next unlock will free all)

Definition at line 400 of file lock.cc.

Here is the caller graph for this function: