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-1301 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
23struct TABLE;
24struct TABLE_LIST;
25class THD;
26typedef struct st_mysql_lock MYSQL_LOCK;
27
28
29MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, uint flags);
30bool mysql_lock_tables(THD *thd, MYSQL_LOCK *sql_lock, uint flags);
31void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock, bool free_lock);
32void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock);
33void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock);
34void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count, uint flag);
35void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table);
36void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock);
37bool mysql_lock_abort_for_thread(THD *thd, TABLE *table);
38MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b);
39/* Lock based on name */
40bool lock_schema_name(THD *thd, const char *db);
41/* Lock based on stored routine name */
42bool lock_object_name(THD *thd, MDL_key::enum_mdl_namespace mdl_type,
43 const char *db, const char *name);
44
45/* flags for get_lock_data */
46#define GET_LOCK_UNLOCK 0
47#define GET_LOCK_STORE_LOCKS 1
48#define GET_LOCK_ACTION_MASK 1
49#define GET_LOCK_ON_THD (1 << 1)
50#define GET_LOCK_SKIP_SEQUENCES (1 << 2)
51
52MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, uint flags);
53void reset_lock_data(MYSQL_LOCK *sql_lock, bool unlock);
54
55#endif /* LOCK_INCLUDED */
56