MySQL  8.0.19
Source Code Documentation
mysql_sp.h
Go to the documentation of this file.
1 /* Copyright (c) 2013, 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_SP_H
24 #define MYSQL_SP_H
25 
26 /**
27  @file include/mysql/psi/mysql_sp.h
28  Instrumentation helpers for stored programs.
29 */
30 
32 
33 #ifndef PSI_SP_CALL
34 #define PSI_SP_CALL(M) psi_statement_service->M
35 #endif
36 
37 /**
38  @defgroup psi_api_sp Stored Program Instrumentation (API)
39  @ingroup psi_api
40  @{
41 */
42 
43 /**
44  @def MYSQL_START_SP(STATE, SP_SHARE)
45  Instrument a stored program execution start.
46  @param STATE Event state data
47  @param SP_SHARE Stored Program share instrumentation
48  @return An event locker
49 */
50 #ifdef HAVE_PSI_SP_INTERFACE
51 #define MYSQL_START_SP(STATE, SP_SHARE) inline_mysql_start_sp(STATE, SP_SHARE)
52 #else
53 #define MYSQL_START_SP(STATE, SP_SHARE) NULL
54 #endif
55 
56 /**
57  @def MYSQL_END_SP(LOCKER)
58  Instrument a stored program execution end.
59  @param LOCKER Event locker
60 */
61 #ifdef HAVE_PSI_SP_INTERFACE
62 #define MYSQL_END_SP(LOCKER) inline_mysql_end_sp(LOCKER)
63 #else
64 #define MYSQL_END_SP(LOCKER) \
65  do { \
66  } while (0)
67 #endif
68 
69 /**
70  @def MYSQL_DROP_SP(OT, SN, SNL, ON, ONL)
71  Instrument a drop stored program event.
72  @param OT Object type
73  @param SN Schema name
74  @param SNL Schema name length
75  @param ON Object name
76  @param ONL Object name length
77 */
78 #ifdef HAVE_PSI_SP_INTERFACE
79 #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
80  inline_mysql_drop_sp(OT, SN, SNL, ON, ONL)
81 #else
82 #define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
83  do { \
84  } while (0)
85 #endif
86 
87 /**
88  @def MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL)
89  Instrument a stored program share.
90  @param OT Object type
91  @param SN Schema name
92  @param SNL Schema name length
93  @param ON Object name
94  @param ONL Object name length
95  @return The instrumented stored program share.
96 */
97 #ifdef HAVE_PSI_SP_INTERFACE
98 #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
99  inline_mysql_get_sp_share(OT, SN, SNL, ON, ONL)
100 #else
101 #define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) NULL
102 #endif
103 
104 #ifdef HAVE_PSI_SP_INTERFACE
105 static inline struct PSI_sp_locker *inline_mysql_start_sp(
106  PSI_sp_locker_state *state, PSI_sp_share *sp_share) {
107  return PSI_SP_CALL(start_sp)(state, sp_share);
108 }
109 
110 static inline void inline_mysql_end_sp(PSI_sp_locker *locker) {
111  if (likely(locker != NULL)) {
112  PSI_SP_CALL(end_sp)(locker);
113  }
114 }
115 
116 static inline void inline_mysql_drop_sp(uint sp_type, const char *schema_name,
117  uint shcema_name_length,
118  const char *object_name,
119  uint object_name_length) {
120  PSI_SP_CALL(drop_sp)
121  (sp_type, schema_name, shcema_name_length, object_name, object_name_length);
122 }
123 
125  const char *schema_name,
126  uint shcema_name_length,
127  const char *object_name,
128  uint object_name_length) {
129  return PSI_SP_CALL(get_sp_share)(sp_type, schema_name, shcema_name_length,
130  object_name, object_name_length);
131 }
132 #endif
133 
134 /** @} (end of group psi_api_sp) */
135 
136 #endif
NULL
#define NULL
Definition: types.h:55
inline_mysql_end_sp
static void inline_mysql_end_sp(PSI_sp_locker *locker)
Definition: mysql_sp.h:110
PSI_SP_CALL
#define PSI_SP_CALL(M)
Definition: mysql_sp.h:34
PSI_sp_locker
struct PSI_sp_locker PSI_sp_locker
Definition: psi_statement_bits.h:101
psi_statement.h
inline_mysql_start_sp
static struct PSI_sp_locker * inline_mysql_start_sp(PSI_sp_locker_state *state, PSI_sp_share *sp_share)
Definition: mysql_sp.h:105
inline_mysql_get_sp_share
static PSI_sp_share * inline_mysql_get_sp_share(uint sp_type, const char *schema_name, uint shcema_name_length, const char *object_name, uint object_name_length)
Definition: mysql_sp.h:124
uint
unsigned int uint
Definition: uca-dump.cc:29
inline_mysql_drop_sp
static void inline_mysql_drop_sp(uint sp_type, const char *schema_name, uint shcema_name_length, const char *object_name, uint object_name_length)
Definition: mysql_sp.h:116
PSI_sp_locker_state_v1
Definition: psi_statement_bits.h:205
PSI_sp_share
struct PSI_sp_share PSI_sp_share
Definition: psi_statement_bits.h:94
likely
bool likely(bool expr)
Definition: my_compiler.h:64