| 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 |
| 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 | void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock); |
| 37 | bool mysql_lock_abort_for_thread(THD *thd, TABLE *table); |
| 38 | MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b); |
| 39 | /* Lock based on name */ |
| 40 | bool lock_schema_name(THD *thd, const char *db); |
| 41 | /* Lock based on stored routine name */ |
| 42 | bool 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 | |
| 52 | MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, uint flags); |
| 53 | void reset_lock_data(MYSQL_LOCK *sql_lock, bool unlock); |
| 54 | |
| 55 | #endif /* LOCK_INCLUDED */ |
| 56 | |