MySQL 9.1.0
Source Code Documentation
|
Macros | |
#define | GET_LOCK_UNLOCK 1 |
#define | GET_LOCK_STORE_LOCKS 2 |
Functions | |
static MYSQL_LOCK * | get_lock_data (THD *thd, TABLE **table_ptr, size_t count, uint flags) |
Get lock structures from table structs and initialize locks. More... | |
static int | lock_external (THD *thd, TABLE **table, uint count) |
static int | unlock_external (THD *thd, TABLE **table, uint count) |
Unlock a set of external. More... | |
static void | print_lock_error (int error, const char *) |
static int | lock_tables_check (THD *thd, TABLE **tables, size_t count, uint flags) |
Perform semantic checks for mysql_lock_tables. More... | |
static void | reset_lock_data (MYSQL_LOCK *sql_lock) |
Reset lock type in lock data. More... | |
static void | track_table_access (THD *thd, TABLE **tables, size_t count) |
Scan array of tables for access types; update transaction tracker accordingly. More... | |
static void | reset_lock_data_and_free (MYSQL_LOCK **mysql_lock) |
Reset lock type in lock data and free. More... | |
MYSQL_LOCK * | mysql_lock_tables (THD *thd, TABLE **tables, size_t count, uint flags) |
Lock tables. More... | |
void | mysql_unlock_tables (THD *thd, MYSQL_LOCK *sql_lock) |
void | mysql_unlock_some_tables (THD *thd, TABLE **table, uint count) |
Unlock some of the tables locked by mysql_lock_tables. More... | |
void | mysql_unlock_read_tables (THD *thd, MYSQL_LOCK *sql_lock) |
unlock all tables locked for read. More... | |
void | mysql_lock_remove (THD *thd, MYSQL_LOCK *locked, TABLE *table) |
Try to find the table in the list of locked tables. More... | |
void | mysql_lock_abort_for_thread (THD *thd, TABLE *table) |
Abort one thread / table combination. More... | |
MYSQL_LOCK * | mysql_lock_merge (MYSQL_LOCK *a, MYSQL_LOCK *b) |
bool | lock_schema_name (THD *thd, const char *db) |
Obtain an exclusive metadata lock on a schema name. More... | |
bool | lock_tablespace_names (THD *thd, Tablespace_hash_set *tablespace_set, ulong lock_wait_timeout, MEM_ROOT *mem_root) |
Acquire IX MDL lock each tablespace name from the given set. More... | |
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. More... | |
bool | acquire_shared_global_read_lock (THD *thd, unsigned long lock_wait_timeout) |
Acquire protection against the global read lock. More... | |
bool | Global_read_lock::lock_global_read_lock (THD *thd) |
Take global read lock, wait if there is protection against lock. More... | |
void | Global_read_lock::unlock_global_read_lock (THD *thd) |
Unlock global read lock. More... | |
bool | Global_read_lock::make_global_read_lock_block_commit (THD *thd) |
Make global read lock also block commits. More... | |
void | Global_read_lock::set_explicit_lock_duration (THD *thd) |
Set explicit duration for metadata locks which are used to implement GRL. More... | |
Variables | |
static int | thr_lock_errno_to_mysql [] |
#define GET_LOCK_STORE_LOCKS 2 |
#define GET_LOCK_UNLOCK 1 |
bool acquire_shared_global_read_lock | ( | THD * | thd, |
unsigned long | lock_wait_timeout | ||
) |
Acquire protection against the global read lock.
Acquire an intention exclusive lock to protect against others setting the global read lock. We follow the naming used by the backup lock help functions when naming this function.
thd | Thread context. |
lock_wait_timeout | Time to wait for lock acquisition. |
false | No error, meta data lock acquired. |
true | Error, meta data lock not acquired. |
|
static |
Get lock structures from table structs and initialize locks.
thd | Thread handler |
table_ptr | Pointer to tables that should be locks |
count | Number of tables |
flags | One of:
|
bool Global_read_lock::lock_global_read_lock | ( | THD * | thd | ) |
Take global read lock, wait if there is protection against lock.
If the global read lock is already taken by this thread, then nothing is done.
See also "Handling of global read locks" above.
thd | Reference to thread. |
False | Success, global read lock set, commits are NOT blocked. |
True | Failure, thread was killed. |
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.
thd | Thread handle. |
mdl_type | Object type (currently functions, procedures and events can be name-locked). |
db | The schema the object belongs to. |
name | Object name in the schema. |
This function cannot be called while holding LOCK_open_mutex. This invariant is 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.
false | Success. |
true | Failure: we're in LOCK TABLES mode, or out of memory, or this connection was killed. |
bool lock_schema_name | ( | THD * | thd, |
const char * | db | ||
) |
Obtain an exclusive metadata lock on a schema name.
thd | Thread handle. |
db | The 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.
false | Success. |
true | Failure: we're in LOCK TABLES mode, or out of memory, or this connection was killed. |
Perform semantic checks for mysql_lock_tables.
thd | The current thread |
tables | The tables to lock |
count | The number of tables to lock |
flags | Lock flags |
bool lock_tablespace_names | ( | THD * | thd, |
Tablespace_hash_set * | tablespace_set, | ||
ulong | lock_wait_timeout, | ||
MEM_ROOT * | mem_root | ||
) |
Acquire IX MDL lock each tablespace name from the given set.
thd | - Thread invoking this function. |
tablespace_set | - Set of tablespace names to be lock. |
lock_wait_timeout | - Lock timeout. |
mem_root | - Memory root on which MDL_request objects can be allocated. |
bool Global_read_lock::make_global_read_lock_block_commit | ( | THD * | thd | ) |
Make global read lock also block commits.
The scenario is:
See also "Handling of global read locks" above.
thd | Reference to thread. |
False | Success, global read lock set, commits are blocked. |
True | Failure, thread was killed. |
Abort one thread / table combination.
thd | Thread handler |
table | Table that should be removed from lock queue |
MYSQL_LOCK * mysql_lock_merge | ( | MYSQL_LOCK * | a, |
MYSQL_LOCK * | b | ||
) |
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.
thd | thread context |
locked | list of locked tables |
table | the table to unlock |
MYSQL_LOCK * mysql_lock_tables | ( | THD * | thd, |
TABLE ** | tables, | ||
size_t | count, | ||
uint | flags | ||
) |
Lock tables.
thd | The current thread. |
tables | An array of pointers to the tables to lock. |
count | The number of tables to lock. |
flags | Options: MYSQL_LOCK_IGNORE_GLOBAL_READ_ONLY Ignore SET GLOBAL READ_ONLY MYSQL_LOCK_IGNORE_TIMEOUT Use maximum timeout value. |
A | lock structure pointer on success. |
NULL | if an error or if wait on a lock was killed. |
void mysql_unlock_read_tables | ( | THD * | thd, |
MYSQL_LOCK * | sql_lock | ||
) |
unlock all tables locked for read.
Unlock some of the tables locked by mysql_lock_tables.
This will work even if get_lock_data fails (next unlock will free all)
void mysql_unlock_tables | ( | THD * | thd, |
MYSQL_LOCK * | sql_lock | ||
) |
|
static |
|
static |
Reset lock type in lock data.
sql_lock | Lock structures to reset. |
|
static |
Reset lock type in lock data and free.
mysql_lock | Lock structures to reset. |
void Global_read_lock::set_explicit_lock_duration | ( | THD * | thd | ) |
Set explicit duration for metadata locks which are used to implement GRL.
thd | Reference to thread. |
Scan array of tables for access types; update transaction tracker accordingly.
thd | The current thread. |
tables | An array of pointers to the tables to lock. |
count | The number of tables to lock. |
Unlock a set of external.
void Global_read_lock::unlock_global_read_lock | ( | THD * | thd | ) |
Unlock global read lock.
Commits may or may not be blocked when this function is called.
See also "Handling of global read locks" above.
thd | Reference to thread. |
|
static |