OSDN Git Service

First version
[st-ro/stro.git] / 3rdparty / mysql / include / mysql / psi / mysql_table.h
1 /* Copyright (c) 2010, 2014, 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
19 /**
20   @file mysql/psi/mysql_table.h
21   Instrumentation helpers for table io.
22 */
23
24 #include "mysql/psi/psi.h"
25
26 #ifndef PSI_TABLE_CALL
27 #define PSI_TABLE_CALL(M) PSI_DYNAMIC_CALL(M)
28 #endif
29
30 /**
31   @defgroup Table_instrumentation Table Instrumentation
32   @ingroup Instrumentation_interface
33   @{
34 */
35
36 /**
37   @def MYSQL_TABLE_WAIT_VARIABLES
38   Instrumentation helper for table waits.
39   This instrumentation declares local variables.
40   Do not use a ';' after this macro
41   @param LOCKER the locker
42   @param STATE the locker state
43   @sa MYSQL_START_TABLE_IO_WAIT.
44   @sa MYSQL_END_TABLE_IO_WAIT.
45   @sa MYSQL_START_TABLE_LOCK_WAIT.
46   @sa MYSQL_END_TABLE_LOCK_WAIT.
47 */
48 #ifdef HAVE_PSI_TABLE_INTERFACE
49   #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE) \
50     struct PSI_table_locker* LOCKER; \
51     PSI_table_locker_state STATE;
52 #else
53   #define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE)
54 #endif
55
56 /**
57   @def MYSQL_START_TABLE_LOCK_WAIT
58   Instrumentation helper for table lock waits.
59   This instrumentation marks the start of a wait event.
60   @param LOCKER the locker
61   @param STATE the locker state
62   @param PSI the instrumented table
63   @param OP the table operation to be performed
64   @param FLAGS per table operation flags.
65   @sa MYSQL_END_TABLE_LOCK_WAIT.
66 */
67 #ifdef HAVE_PSI_TABLE_INTERFACE
68   #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
69     LOCKER= inline_mysql_start_table_lock_wait(STATE, PSI, \
70                                                OP, FLAGS, __FILE__, __LINE__)
71 #else
72   #define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
73     do {} while (0)
74 #endif
75
76 /**
77   @def MYSQL_END_TABLE_LOCK_WAIT
78   Instrumentation helper for table lock waits.
79   This instrumentation marks the end of a wait event.
80   @param LOCKER the locker
81   @sa MYSQL_START_TABLE_LOCK_WAIT.
82 */
83 #ifdef HAVE_PSI_TABLE_INTERFACE
84   #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
85     inline_mysql_end_table_lock_wait(LOCKER)
86 #else
87   #define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
88     do {} while (0)
89 #endif
90
91 #ifdef HAVE_PSI_TABLE_INTERFACE
92   #define MYSQL_UNLOCK_TABLE(T) \
93     inline_mysql_unlock_table(T)
94 #else
95   #define MYSQL_UNLOCK_TABLE(T) \
96     do {} while (0)
97 #endif
98
99 #ifdef HAVE_PSI_TABLE_INTERFACE
100 /**
101   Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
102   @sa MYSQL_END_TABLE_LOCK_WAIT.
103 */
104 static inline struct PSI_table_locker *
105 inline_mysql_start_table_lock_wait(PSI_table_locker_state *state,
106                                    struct PSI_table *psi,
107                                    enum PSI_table_lock_operation op,
108                                    ulong flags, const char *src_file, int src_line)
109 {
110   if (psi != NULL)
111   {
112     struct PSI_table_locker *locker;
113     locker= PSI_TABLE_CALL(start_table_lock_wait)
114       (state, psi, op, flags, src_file, src_line);
115     return locker;
116   }
117   return NULL;
118 }
119
120 /**
121   Instrumentation calls for MYSQL_END_TABLE_LOCK_WAIT.
122   @sa MYSQL_START_TABLE_LOCK_WAIT.
123 */
124 static inline void
125 inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
126 {
127   if (locker != NULL)
128     PSI_TABLE_CALL(end_table_lock_wait)(locker);
129 }
130
131 static inline void
132 inline_mysql_unlock_table(struct PSI_table *table)
133 {
134   if (table != NULL)
135     PSI_TABLE_CALL(unlock_table)(table);
136 }
137 #endif
138
139 /** @} (end of group Table_instrumentation) */
140
141 #endif
142