MySQL  8.0.17
Source Code Documentation
mysql_stage.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_STAGE_H
24 #define MYSQL_STAGE_H
25 
26 /**
27  @file include/mysql/psi/mysql_stage.h
28  Instrumentation helpers for stages.
29 */
30 
31 #include "mysql/psi/psi_stage.h"
32 
33 #include "my_inttypes.h"
34 #include "pfs_stage_provider.h"
35 
36 #ifndef PSI_STAGE_CALL
37 #define PSI_STAGE_CALL(M) psi_stage_service->M
38 #endif
39 
40 /**
41  @defgroup psi_api_stage Stage Instrumentation (API)
42  @ingroup psi_api
43  @{
44 */
45 
46 /**
47  @def mysql_stage_register(P1, P2, P3)
48  Stage registration.
49 */
50 #ifdef HAVE_PSI_STAGE_INTERFACE
51 #define mysql_stage_register(P1, P2, P3) inline_mysql_stage_register(P1, P2, P3)
52 #else
53 #define mysql_stage_register(P1, P2, P3) \
54  do { \
55  } while (0)
56 #endif
57 
58 /**
59  @def MYSQL_SET_STAGE
60  Set the current stage.
61  Use this API when the file and line
62  is passed from the caller.
63  @param K the stage key
64  @param F the source file name
65  @param L the source file line
66  @return the current stage progress
67 */
68 #ifdef HAVE_PSI_STAGE_INTERFACE
69 #define MYSQL_SET_STAGE(K, F, L) inline_mysql_set_stage(K, F, L)
70 #else
71 #define MYSQL_SET_STAGE(K, F, L) NULL
72 #endif
73 
74 /**
75  @def mysql_set_stage
76  Set the current stage.
77  @param K the stage key
78  @return the current stage progress
79 */
80 #ifdef HAVE_PSI_STAGE_INTERFACE
81 #define mysql_set_stage(K) inline_mysql_set_stage(K, __FILE__, __LINE__)
82 #else
83 #define mysql_set_stage(K) NULL
84 #endif
85 
86 /**
87  @def mysql_end_stage
88  End the last stage
89 */
90 #ifdef HAVE_PSI_STAGE_INTERFACE
91 #define mysql_end_stage inline_mysql_end_stage
92 #else
93 #define mysql_end_stage() \
94  do { \
95  } while (0)
96 #endif
97 
98 #ifdef HAVE_PSI_STAGE_INTERFACE
99 static inline void inline_mysql_stage_register(const char *category,
101  int count) {
102  PSI_STAGE_CALL(register_stage)(category, info, count);
103 }
104 #endif
105 
106 #ifdef HAVE_PSI_STAGE_INTERFACE
108  const char *src_file,
109  int src_line) {
110  return PSI_STAGE_CALL(start_stage)(key, src_file, src_line);
111 }
112 #endif
113 
114 #ifdef HAVE_PSI_STAGE_INTERFACE
115 static inline void inline_mysql_end_stage() { PSI_STAGE_CALL(end_stage)(); }
116 #endif
117 
118 #ifdef HAVE_PSI_STAGE_INTERFACE
119 #define mysql_stage_set_work_completed(P1, P2) \
120  inline_mysql_stage_set_work_completed(P1, P2)
121 
122 #define mysql_stage_get_work_completed(P1) \
123  inline_mysql_stage_get_work_completed(P1)
124 #else
125 #define mysql_stage_set_work_completed(P1, P2) \
126  do { \
127  } while (0)
128 
129 #define mysql_stage_get_work_completed(P1) \
130  do { \
131  } while (0)
132 #endif
133 
134 #ifdef HAVE_PSI_STAGE_INTERFACE
135 #define mysql_stage_inc_work_completed(P1, P2) \
136  inline_mysql_stage_inc_work_completed(P1, P2)
137 #else
138 #define mysql_stage_inc_work_completed(P1, P2) \
139  do { \
140  } while (0)
141 #endif
142 
143 #ifdef HAVE_PSI_STAGE_INTERFACE
144 #define mysql_stage_set_work_estimated(P1, P2) \
145  inline_mysql_stage_set_work_estimated(P1, P2)
146 
147 #define mysql_stage_get_work_estimated(P1) \
148  inline_mysql_stage_get_work_estimated(P1)
149 #else
150 #define mysql_stage_set_work_estimated(P1, P2) \
151  do { \
152  } while (0)
153 
154 #define mysql_stage_get_work_estimated(P1) \
155  do { \
156  } while (0)
157 #endif
158 
159 #ifdef HAVE_PSI_STAGE_INTERFACE
161  PSI_stage_progress *progress, ulonglong val) {
162  if (progress != NULL) {
163  progress->m_work_completed = val;
164  }
165 }
166 
168  PSI_stage_progress *progress) {
169  return progress->m_work_completed;
170 }
171 #endif
172 
173 #ifdef HAVE_PSI_STAGE_INTERFACE
175  PSI_stage_progress *progress, ulonglong val) {
176  if (progress != NULL) {
177  progress->m_work_completed += val;
178  }
179 }
180 #endif
181 
182 #ifdef HAVE_PSI_STAGE_INTERFACE
184  PSI_stage_progress *progress, ulonglong val) {
185  if (progress != NULL) {
186  progress->m_work_estimated = val;
187  }
188 }
189 
191  PSI_stage_progress *progress) {
192  return progress->m_work_estimated;
193 }
194 #endif
195 
196 /** @} (end of group psi_api_stage) */
197 
198 #endif
unsigned long long int ulonglong
Definition: my_inttypes.h:74
static void inline_mysql_stage_inc_work_completed(PSI_stage_progress *progress, ulonglong val)
Definition: mysql_stage.h:174
ssize_t count
Definition: memcached.c:386
Some integer typedefs for easier portability.
static PSI_stage_progress * inline_mysql_set_stage(PSI_stage_key key, const char *src_file, int src_line)
Definition: mysql_stage.h:107
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352
#define PSI_STAGE_CALL(M)
Definition: psi_stage.h:31
static void inline_mysql_stage_set_work_estimated(PSI_stage_progress *progress, ulonglong val)
Definition: mysql_stage.h:183
unsigned long long m_work_completed
Definition: psi_stage_bits.h:61
Performance schema instrumentation interface.
Stage instrument information.
Definition: psi_stage_bits.h:71
static void inline_mysql_stage_register(const char *category, PSI_stage_info **info, int count)
Definition: mysql_stage.h:99
Performance schema instrumentation (declarations).
static ulonglong inline_mysql_stage_get_work_completed(PSI_stage_progress *progress)
Definition: mysql_stage.h:167
static const char * key
Definition: suite_stubs.c:14
static const char * category
Definition: sha2_password.cc:168
Interface for an instrumented stage progress.
Definition: psi_stage_bits.h:60
unsigned long long m_work_estimated
Definition: psi_stage_bits.h:62
static ulonglong inline_mysql_stage_get_work_estimated(PSI_stage_progress *progress)
Definition: mysql_stage.h:190
unsigned int PSI_stage_key
Instrumented stage key.
Definition: psi_stage_bits.h:40
Log info(cout, "NOTE")
static void inline_mysql_end_stage()
Definition: mysql_stage.h:115
static void inline_mysql_stage_set_work_completed(PSI_stage_progress *progress, ulonglong val)
Definition: mysql_stage.h:160