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