MySQL 8.0.30
Source Code Documentation
mysql_sp.h
Go to the documentation of this file.
1/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
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
31/* HAVE_PSI_*_INTERFACE */
32#include "my_psi_config.h" // IWYU pragma: keep
33
35
36#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
37/* PSI_SP_CALL() as direct call. */
38#include "pfs_statement_provider.h" // IWYU pragma: keep
39#endif
40
41#ifndef PSI_SP_CALL
42#define PSI_SP_CALL(M) psi_statement_service->M
43#endif
44
45/**
46 @defgroup psi_api_sp Stored Program Instrumentation (API)
47 @ingroup psi_api
48 @{
49*/
50
51/**
52 @def MYSQL_START_SP(STATE, SP_SHARE)
53 Instrument a stored program execution start.
54 @param STATE Event state data
55 @param SP_SHARE Stored Program share instrumentation
56 @return An event locker
57*/
58#ifdef HAVE_PSI_SP_INTERFACE
59#define MYSQL_START_SP(STATE, SP_SHARE) inline_mysql_start_sp(STATE, SP_SHARE)
60#else
61#define MYSQL_START_SP(STATE, SP_SHARE) NULL
62#endif
63
64/**
65 @def MYSQL_END_SP(LOCKER)
66 Instrument a stored program execution end.
67 @param LOCKER Event locker
68*/
69#ifdef HAVE_PSI_SP_INTERFACE
70#define MYSQL_END_SP(LOCKER) inline_mysql_end_sp(LOCKER)
71#else
72#define MYSQL_END_SP(LOCKER) \
73 do { \
74 } while (0)
75#endif
76
77/**
78 @def MYSQL_DROP_SP(OT, SN, SNL, ON, ONL)
79 Instrument a drop stored program event.
80 @param OT Object type
81 @param SN Schema name
82 @param SNL Schema name length
83 @param ON Object name
84 @param ONL Object name length
85*/
86#ifdef HAVE_PSI_SP_INTERFACE
87#define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
88 inline_mysql_drop_sp(OT, SN, SNL, ON, ONL)
89#else
90#define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
91 do { \
92 } while (0)
93#endif
94
95/**
96 @def MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL)
97 Instrument a stored program share.
98 @param OT Object type
99 @param SN Schema name
100 @param SNL Schema name length
101 @param ON Object name
102 @param ONL Object name length
103 @return The instrumented stored program share.
104*/
105#ifdef HAVE_PSI_SP_INTERFACE
106#define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
107 inline_mysql_get_sp_share(OT, SN, SNL, ON, ONL)
108#else
109#define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) NULL
110#endif
111
112#ifdef HAVE_PSI_SP_INTERFACE
114 PSI_sp_locker_state *state, PSI_sp_share *sp_share) {
115 return PSI_SP_CALL(start_sp)(state, sp_share);
116}
117
118static inline void inline_mysql_end_sp(PSI_sp_locker *locker) {
119 if (likely(locker != nullptr)) {
120 PSI_SP_CALL(end_sp)(locker);
121 }
122}
123
124static inline void inline_mysql_drop_sp(uint sp_type, const char *schema_name,
125 uint shcema_name_length,
126 const char *object_name,
127 uint object_name_length) {
128 PSI_SP_CALL(drop_sp)
129 (sp_type, schema_name, shcema_name_length, object_name, object_name_length);
130}
131
133 const char *schema_name,
134 uint shcema_name_length,
135 const char *object_name,
136 uint object_name_length) {
137 return PSI_SP_CALL(get_sp_share)(sp_type, schema_name, shcema_name_length,
138 object_name, object_name_length);
139}
140#endif
141
142/** @} (end of group psi_api_sp) */
143
144#endif
struct PSI_sp_locker PSI_sp_locker
Definition: psi_statement_bits.h:110
struct PSI_sp_share PSI_sp_share
Definition: psi_statement_bits.h:103
static void inline_mysql_end_sp(PSI_sp_locker *locker)
Definition: mysql_sp.h:118
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:124
static struct PSI_sp_locker * inline_mysql_start_sp(PSI_sp_locker_state *state, PSI_sp_share *sp_share)
Definition: mysql_sp.h:113
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:132
constexpr bool likely(bool expr)
Definition: my_compiler.h:54
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
#define PSI_SP_CALL(M)
Definition: mysql_sp.h:42
Performance schema instrumentation (declarations).
Performance schema instrumentation interface.
Definition: psi_statement_bits.h:214
unsigned int uint
Definition: uca-dump.cc:29