1 /* Copyright (c) 2010, 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 as published by
5    the Free Software Foundation; version 2 of the License.
6 
7    This program is distributed in the hope that it will be useful,
8    but WITHOUT ANY WARRANTY; without even the implied warranty of
9    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10    GNU General Public License for more details.
11 
12    You should have received a copy of the GNU General Public License
13    along with this program; if not, write to the Free Software
14    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335  USA */
15 
16 #ifndef LOCK_INCLUDED
17 #define LOCK_INCLUDED
18 
19 #include "thr_lock.h"                           /* thr_lock_type */
20 #include "mdl.h"
21 
22 // Forward declarations
23 struct TABLE;
24 struct TABLE_LIST;
25 class THD;
26 typedef struct st_mysql_lock MYSQL_LOCK;
27 
28 
29 MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, uint flags);
30 bool mysql_lock_tables(THD *thd, MYSQL_LOCK *sql_lock, uint flags);
31 void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock, bool free_lock);
32 void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock);
33 void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
34 void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count, uint flag);
35 void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table);
36 bool mysql_lock_abort_for_thread(THD *thd, TABLE *table);
37 MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b);
38 /* Lock based on name */
39 bool lock_schema_name(THD *thd, const char *db);
40 /* Lock based on stored routine name */
41 bool lock_object_name(THD *thd, MDL_key::enum_mdl_namespace mdl_type,
42                       const char *db, const char *name);
43 
44 /* flags for get_lock_data */
45 #define GET_LOCK_UNLOCK         0
46 #define GET_LOCK_STORE_LOCKS    1
47 #define GET_LOCK_ACTION_MASK    1
48 #define GET_LOCK_ON_THD         (1 << 1)
49 #define GET_LOCK_SKIP_SEQUENCES (1 << 2)
50 
51 MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, uint flags);
52 void reset_lock_data(MYSQL_LOCK *sql_lock, bool unlock);
53 
54 #endif /* LOCK_INCLUDED */
55