MySQL  8.0.18
Source Code Documentation
mysql_table.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, 2019, 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, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef MYSQL_TABLE_H
24 #define MYSQL_TABLE_H
25 
26 /**
27  @file include/mysql/psi/mysql_table.h
28  Instrumentation helpers for table io.
29 */
30 
31 #include "mysql/psi/psi_table.h"
32 
33 #ifndef PSI_TABLE_CALL
34 #define PSI_TABLE_CALL(M) psi_table_service->M
35 #endif
36 
37 /**
38  @defgroup psi_api_table Table Instrumentation (API)
39  @ingroup psi_api
40  @{
41 */
42 
43 /**
44  @def MYSQL_TABLE_WAIT_VARIABLES
45  Instrumentation helper for table waits.
46  This instrumentation declares local variables.
47  Do not use a ';' after this macro
48  @param LOCKER the locker
49  @param STATE the locker state
50  @sa MYSQL_START_TABLE_IO_WAIT.
51  @sa MYSQL_END_TABLE_IO_WAIT.
52  @sa MYSQL_START_TABLE_LOCK_WAIT.
53  @sa MYSQL_END_TABLE_LOCK_WAIT.
54 */
55 #ifdef HAVE_PSI_TABLE_INTERFACE
56 #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE) \
57  struct PSI_table_locker *LOCKER; \
58  PSI_table_locker_state STATE;
59 #else
60 #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE)
61 #endif
62 
63 /**
64  @def MYSQL_START_TABLE_LOCK_WAIT
65  Instrumentation helper for table lock waits.
66  This instrumentation marks the start of a wait event.
67  @param LOCKER the locker
68  @param STATE the locker state
69  @param PSI the instrumented table
70  @param OP the table operation to be performed
71  @param FLAGS per table operation flags.
72  @sa MYSQL_END_TABLE_LOCK_WAIT.
73 */
74 #ifdef HAVE_PSI_TABLE_INTERFACE
75 #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
76  LOCKER = inline_mysql_start_table_lock_wait(STATE, PSI, OP, FLAGS, __FILE__, \
77  __LINE__)
78 #else
79 #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
80  do { \
81  } while (0)
82 #endif
83 
84 /**
85  @def MYSQL_END_TABLE_LOCK_WAIT
86  Instrumentation helper for table lock waits.
87  This instrumentation marks the end of a wait event.
88  @param LOCKER the locker
89  @sa MYSQL_START_TABLE_LOCK_WAIT.
90 */
91 #ifdef HAVE_PSI_TABLE_INTERFACE
92 #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
93  inline_mysql_end_table_lock_wait(LOCKER)
94 #else
95 #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
96  do { \
97  } while (0)
98 #endif
99 
100 #ifdef HAVE_PSI_TABLE_INTERFACE
101 #define MYSQL_UNLOCK_TABLE(T) inline_mysql_unlock_table(T)
102 #else
103 #define MYSQL_UNLOCK_TABLE(T) \
104  do { \
105  } while (0)
106 #endif
107 
108 #ifdef HAVE_PSI_TABLE_INTERFACE
109 /**
110  Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
111  @sa MYSQL_END_TABLE_LOCK_WAIT.
112 */
114  PSI_table_locker_state *state, struct PSI_table *psi,
115  enum PSI_table_lock_operation op, ulong flags, const char *src_file,
116  int src_line) {
117  if (psi != NULL) {
118  struct PSI_table_locker *locker;
119  locker = PSI_TABLE_CALL(start_table_lock_wait)(state, psi, op, flags,
120  src_file, src_line);
121  return locker;
122  }
123  return NULL;
124 }
125 
126 /**
127  Instrumentation calls for MYSQL_END_TABLE_LOCK_WAIT.
128  @sa MYSQL_START_TABLE_LOCK_WAIT.
129 */
131  struct PSI_table_locker *locker) {
132  if (locker != NULL) {
133  PSI_TABLE_CALL(end_table_lock_wait)(locker);
134  }
135 }
136 
137 static inline void inline_mysql_unlock_table(struct PSI_table *table) {
138  if (table != NULL) {
139  PSI_TABLE_CALL(unlock_table)(table);
140  }
141 }
142 #endif
143 
144 /** @} (end of group psi_api_table) */
145 
146 #endif
State data storage for start_table_io_wait_v1_t, start_table_lock_wait_v1_t.
Definition: psi_table_bits.h:68
#define PSI_TABLE_CALL(M)
Definition: mysql_table.h:34
Performance schema instrumentation interface.
static struct PSI_table_locker * inline_mysql_start_table_lock_wait(PSI_table_locker_state *state, struct PSI_table *psi, enum PSI_table_lock_operation op, ulong flags, const char *src_file, int src_line)
Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
Definition: mysql_table.h:113
static void inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
Instrumentation calls for MYSQL_END_TABLE_LOCK_WAIT.
Definition: mysql_table.h:130
PSI_table_lock_operation
Lock operation performed on an instrumented table.
Definition: psi_table_bits.h:109
struct PSI_table_locker PSI_table_locker
Definition: psi_table_bits.h:42
#define NULL
Definition: types.h:55
struct PSI_table PSI_table
Definition: psi_table_bits.h:106
static int flags[50]
Definition: hp_test1.cc:39
static void inline_mysql_unlock_table(struct PSI_table *table)
Definition: mysql_table.h:137
unsigned long ulong
Definition: my_inttypes.h:48