MySQL  8.0.19
Source Code Documentation
lock.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef LOCK_INCLUDED
24 #define LOCK_INCLUDED
25 
26 #include <stddef.h>
27 #include <sys/types.h>
28 #include <string>
29 
30 #include "map_helpers.h"
31 #include "sql/mdl.h"
32 
33 class THD;
34 // Forward declarations
35 struct TABLE;
36 struct THR_LOCK_DATA;
37 
38 struct MYSQL_LOCK {
42 };
43 
44 MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, size_t count,
45  uint flags);
46 void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock);
47 void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
48 void mysql_unlock_some_tables(THD *thd, TABLE **table, uint count);
49 void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked, TABLE *table);
50 void mysql_lock_abort_for_thread(THD *thd, TABLE *table);
52 /* Lock based on name */
53 bool lock_schema_name(THD *thd, const char *db);
54 
55 // Hash set to hold set of tablespace names.
57 
58 // Lock tablespace names.
59 bool lock_tablespace_names(THD *thd, Tablespace_hash_set *tablespace_set,
60  ulong lock_wait_timeout);
61 
62 /* Lock based on stored routine name */
64  const char *db, const char *name);
65 
66 /* Acquire protection against the global read lock. */
67 bool acquire_shared_global_read_lock(THD *thd, unsigned long lock_wait_timeout);
68 
69 #endif /* LOCK_INCLUDED */
lock_object_name
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:833
THD
Definition: sql_class.h:764
mysql_lock_tables
MYSQL_LOCK * mysql_lock_tables(THD *thd, TABLE **table, size_t count, uint flags)
Lock tables.
Definition: lock.cc:315
MDL_key::enum_mdl_namespace
enum_mdl_namespace
Object namespaces.
Definition: mdl.h:383
Tablespace_hash_set
malloc_unordered_set< std::string > Tablespace_hash_set
Definition: lock.h:56
mysql_unlock_tables
void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock)
Definition: lock.cc:405
TABLE
Definition: table.h:1305
mdl.h
lock_schema_name
bool lock_schema_name(THD *thd, const char *db)
Obtain an exclusive metadata lock on a schema name.
Definition: lock.cc:734
acquire_shared_global_read_lock
bool acquire_shared_global_read_lock(THD *thd, unsigned long lock_wait_timeout)
Acquire protection against the global read lock.
Definition: lock.cc:992
lock_tablespace_names
bool lock_tablespace_names(THD *thd, Tablespace_hash_set *tablespace_set, ulong lock_wait_timeout)
Acquire IX MDL lock each tablespace name from the given set.
Definition: lock.cc:781
mysql_lock_merge
MYSQL_LOCK * mysql_lock_merge(MYSQL_LOCK *a, MYSQL_LOCK *b)
Definition: lock.cc:562
mysql_unlock_some_tables
void mysql_unlock_some_tables(THD *thd, TABLE **table, uint count)
Unlock some of the tables locked by mysql_lock_tables.
Definition: lock.cc:420
mysql_unlock_read_tables
void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock)
unlock all tables locked for read.
Definition: lock.cc:430
mysql_lock_abort_for_thread
void mysql_lock_abort_for_thread(THD *thd, TABLE *table)
Abort one thread / table combination.
Definition: lock.cc:549
malloc_unordered_set
std::unordered_set, but with my_malloc, so that you can track the memory used using PSI memory keys.
Definition: map_helpers.h:196
mysql_lock_remove
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:487
uint
unsigned int uint
Definition: uca-dump.cc:29
MYSQL_LOCK::table
TABLE ** table
Definition: lock.h:39
map_helpers.h
name
const string name("\"Name\"")
MYSQL_LOCK::table_count
uint table_count
Definition: lock.h:40
count
ssize_t count
Definition: memcached.c:386
THR_LOCK_DATA
Definition: thr_lock.h:123
ulong
unsigned long ulong
Definition: my_inttypes.h:48
MYSQL_LOCK::lock_count
uint lock_count
Definition: lock.h:40
MYSQL_LOCK::locks
THR_LOCK_DATA ** locks
Definition: lock.h:41
MYSQL_LOCK
Definition: lock.h:38
flags
static int flags[50]
Definition: hp_test1.cc:39