MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mysql_table.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, 2012, 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 Foundation,
14  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
15 
16 #ifndef MYSQL_TABLE_H
17 #define MYSQL_TABLE_H
18 
24 #include "mysql/psi/psi.h"
25 
44 #ifdef HAVE_PSI_TABLE_INTERFACE
45  #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE) \
46  struct PSI_table_locker* LOCKER; \
47  PSI_table_locker_state STATE;
48 #else
49  #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE)
50 #endif
51 
62 #ifdef HAVE_PSI_TABLE_INTERFACE
63  #define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
64  { \
65  if (PSI != NULL) \
66  { \
67  PSI_table_locker *locker; \
68  PSI_table_locker_state state; \
69  locker= PSI_TABLE_CALL(start_table_io_wait) \
70  (& state, PSI, OP, INDEX, __FILE__, __LINE__); \
71  PAYLOAD \
72  if (locker != NULL) \
73  PSI_TABLE_CALL(end_table_io_wait)(locker); \
74  } \
75  else \
76  { \
77  PAYLOAD \
78  } \
79  }
80 #else
81  #define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
82  PAYLOAD
83 #endif
84 
95 #ifdef HAVE_PSI_TABLE_INTERFACE
96  #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
97  { \
98  if (PSI != NULL) \
99  { \
100  PSI_table_locker *locker; \
101  PSI_table_locker_state state; \
102  locker= PSI_TABLE_CALL(start_table_lock_wait) \
103  (& state, PSI, OP, FLAGS, __FILE__, __LINE__); \
104  PAYLOAD \
105  if (locker != NULL) \
106  PSI_TABLE_CALL(end_table_lock_wait)(locker); \
107  } \
108  else \
109  { \
110  PAYLOAD \
111  } \
112  }
113 #else
114  #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
115  PAYLOAD
116 #endif
117 
129 #ifdef HAVE_PSI_TABLE_INTERFACE
130  #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
131  LOCKER= inline_mysql_start_table_lock_wait(STATE, PSI, \
132  OP, FLAGS, __FILE__, __LINE__)
133 #else
134  #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
135  do {} while (0)
136 #endif
137 
145 #ifdef HAVE_PSI_TABLE_INTERFACE
146  #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
147  inline_mysql_end_table_lock_wait(LOCKER)
148 #else
149  #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
150  do {} while (0)
151 #endif
152 
153 #ifdef HAVE_PSI_TABLE_INTERFACE
154 
158 static inline struct PSI_table_locker *
159 inline_mysql_start_table_lock_wait(PSI_table_locker_state *state,
160  struct PSI_table *psi,
161  enum PSI_table_lock_operation op,
162  ulong flags, const char *src_file, int src_line)
163 {
164  if (psi != NULL)
165  {
166  struct PSI_table_locker *locker;
167  locker= PSI_TABLE_CALL(start_table_lock_wait)
168  (state, psi, op, flags, src_file, src_line);
169  return locker;
170  }
171  return NULL;
172 }
173 
178 static inline void
179 inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
180 {
181  if (locker != NULL)
182  PSI_TABLE_CALL(end_table_lock_wait)(locker);
183 }
184 #endif
185 
188 #endif
189