1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2021, Oracle and/or its affiliates.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8 
9 This program is also distributed with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation.  The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have included with MySQL.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 GNU General Public License, version 2.0, for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
24 
25 *****************************************************************************/
26 
27 /**************************************************//**
28 @file include/lock0types.h
29 The transaction lock system global types
30 
31 Created 5/7/1996 Heikki Tuuri
32 *******************************************************/
33 
34 #include "ut0lst.h"
35 
36 #ifndef lock0types_h
37 #define lock0types_h
38 
39 #define lock_t ib_lock_t
40 
41 struct lock_t;
42 struct lock_sys_t;
43 struct lock_table_t;
44 
45 /* Basic lock modes */
46 enum lock_mode {
47 	LOCK_IS = 0,	/* intention shared */
48 	LOCK_IX,	/* intention exclusive */
49 	LOCK_S,		/* shared */
50 	LOCK_X,		/* exclusive */
51 	LOCK_AUTO_INC,	/* locks the auto-inc counter of a table
52 			in an exclusive mode */
53 	LOCK_NONE,	/* this is used elsewhere to note consistent read */
54 	LOCK_NUM = LOCK_NONE, /* number of lock modes */
55 	LOCK_NONE_UNSET = 255
56 };
57 
58 /** Convert the given enum value into string.
59 @param[in]	mode	the lock mode
60 @return human readable string of the given enum value */
61 inline
lock_mode_string(enum lock_mode mode)62 const char* lock_mode_string(enum lock_mode mode)
63 {
64 	switch (mode) {
65 	case LOCK_IS:
66 		return("LOCK_IS");
67 	case LOCK_IX:
68 		return("LOCK_IX");
69 	case LOCK_S:
70 		return("LOCK_S");
71 	case LOCK_X:
72 		return("LOCK_X");
73 	case LOCK_AUTO_INC:
74 		return("LOCK_AUTO_INC");
75 	case LOCK_NONE:
76 		return("LOCK_NONE");
77 	case LOCK_NONE_UNSET:
78 		return("LOCK_NONE_UNSET");
79 	default:
80 		ut_error;
81 	}
82 }
83 
84 typedef UT_LIST_BASE_NODE_T(lock_t) trx_lock_list_t;
85 
86 #endif /* lock0types_h */
87