~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to include/mysql/psi/mysql_table.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
19
/**
 
20
  @file mysql/psi/mysql_table.h
 
21
  Instrumentation helpers for table io.
 
22
*/
 
23
 
 
24
#include "mysql/psi/psi.h"
 
25
 
 
26
/**
 
27
  @defgroup Table_instrumentation Table Instrumentation
 
28
  @ingroup Instrumentation_interface
 
29
  @{
 
30
*/
 
31
 
 
32
/**
 
33
  @def MYSQL_TABLE_WAIT_VARIABLES
 
34
  Instrumentation helper for table waits.
 
35
  This instrumentation declares local variables.
 
36
  Do not use a ';' after this macro
 
37
  @param LOCKER the locker
 
38
  @param STATE the locker state
 
39
  @sa MYSQL_START_TABLE_IO_WAIT.
 
40
  @sa MYSQL_END_TABLE_IO_WAIT.
 
41
  @sa MYSQL_START_TABLE_LOCK_WAIT.
 
42
  @sa MYSQL_END_TABLE_LOCK_WAIT.
 
43
*/
 
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
 
 
52
/**
 
53
  @def MYSQL_TABLE_IO_WAIT
 
54
  Instrumentation helper for table io_waits.
 
55
  This instrumentation marks the start of a wait event.
 
56
  @param PSI the instrumented table
 
57
  @param OP the table operation to be performed
 
58
  @param INDEX the table index used if any, or MAY_KEY.
 
59
  @param FLAGS per table operation flags.
 
60
  @sa MYSQL_END_TABLE_WAIT.
 
61
*/
 
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
 
 
85
/**
 
86
  @def MYSQL_TABLE_LOCK_WAIT
 
87
  Instrumentation helper for table io_waits.
 
88
  This instrumentation marks the start of a wait event.
 
89
  @param PSI the instrumented table
 
90
  @param OP the table operation to be performed
 
91
  @param INDEX the table index used if any, or MAY_KEY.
 
92
  @param FLAGS per table operation flags.
 
93
  @sa MYSQL_END_TABLE_WAIT.
 
94
*/
 
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
 
 
118
/**
 
119
  @def MYSQL_START_TABLE_LOCK_WAIT
 
120
  Instrumentation helper for table lock waits.
 
121
  This instrumentation marks the start of a wait event.
 
122
  @param LOCKER the locker
 
123
  @param STATE the locker state
 
124
  @param PSI the instrumented table
 
125
  @param OP the table operation to be performed
 
126
  @param FLAGS per table operation flags.
 
127
  @sa MYSQL_END_TABLE_LOCK_WAIT.
 
128
*/
 
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
 
 
138
/**
 
139
  @def MYSQL_END_TABLE_LOCK_WAIT
 
140
  Instrumentation helper for table lock waits.
 
141
  This instrumentation marks the end of a wait event.
 
142
  @param LOCKER the locker
 
143
  @sa MYSQL_START_TABLE_LOCK_WAIT.
 
144
*/
 
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
/**
 
155
  Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
 
156
  @sa MYSQL_END_TABLE_LOCK_WAIT.
 
157
*/
 
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
 
 
174
/**
 
175
  Instrumentation calls for MYSQL_END_TABLE_LOCK_WAIT.
 
176
  @sa MYSQL_START_TABLE_LOCK_WAIT.
 
177
*/
 
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
 
 
186
/** @} (end of group Table_instrumentation) */
 
187
 
 
188
#endif
 
189