MySQL 9.1.0
Source Code Documentation
lock.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef LOCK_INCLUDED
25#define LOCK_INCLUDED
26
27#include <stddef.h>
28#include <sys/types.h>
29#include <string>
30
31#include "map_helpers.h"
32#include "sql/mdl.h"
33
34class THD;
35// Forward declarations
36struct TABLE;
37struct THR_LOCK_DATA;
38
39struct MYSQL_LOCK {
43};
44
46 uint flags);
47void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock);
48void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
49void mysql_unlock_some_tables(THD *thd, TABLE **table, uint count);
50void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked, TABLE *table);
53/* Lock based on name */
54bool lock_schema_name(THD *thd, const char *db);
55
56// Hash set to hold set of tablespace names.
58
59// Lock tablespace names.
60bool lock_tablespace_names(THD *thd, Tablespace_hash_set *tablespace_set,
61 ulong lock_wait_timeout, MEM_ROOT *mem_root);
62
63/* Lock based on stored routine name */
65 const char *db, const char *name);
66
67/* Acquire protection against the global read lock. */
68bool acquire_shared_global_read_lock(THD *thd, unsigned long lock_wait_timeout);
69
70#endif /* LOCK_INCLUDED */
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
std::unordered_set, but with my_malloc, so that you can track the memory used using PSI memory keys.
Definition: map_helpers.h:177
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock)
unlock all tables locked for read.
Definition: lock.cc:435
void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock)
Definition: lock.cc:410
bool acquire_shared_global_read_lock(THD *thd, unsigned long lock_wait_timeout)
Acquire protection against the global read lock.
Definition: lock.cc:1011
MYSQL_LOCK * mysql_lock_merge(MYSQL_LOCK *a, MYSQL_LOCK *b)
Definition: lock.cc:567
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.
Definition: lock.cc:847
MYSQL_LOCK * mysql_lock_tables(THD *thd, TABLE **table, size_t count, uint flags)
Lock tables.
Definition: lock.cc:316
bool lock_schema_name(THD *thd, const char *db)
Obtain an exclusive metadata lock on a schema name.
Definition: lock.cc:739
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.
Definition: lock.cc:795
void mysql_lock_abort_for_thread(THD *thd, TABLE *table)
Abort one thread / table combination.
Definition: lock.cc:554
void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked, TABLE *table)
Try to find the table in the list of locked tables.
Definition: lock.cc:492
void mysql_unlock_some_tables(THD *thd, TABLE **table, uint count)
Unlock some of the tables locked by mysql_lock_tables.
Definition: lock.cc:425
static int flags[50]
Definition: hp_test1.cc:40
malloc_unordered_set< std::string > Tablespace_hash_set
Definition: lock.h:57
static int count
Definition: myisam_ftdump.cc:45
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
case opt name
Definition: sslopt-case.h:29
enum_mdl_namespace
Object namespaces.
Definition: mdl.h:401
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: lock.h:39
THR_LOCK_DATA ** locks
Definition: lock.h:42
uint table_count
Definition: lock.h:41
TABLE ** table
Definition: lock.h:40
uint lock_count
Definition: lock.h:41
Definition: table.h:1421
Definition: thr_lock.h:124