MySQL 8.0.39
Source Code Documentation
mysql_sp.h
Go to the documentation of this file.
1/* Copyright (c) 2013, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MYSQL_SP_H
25#define MYSQL_SP_H
26
27/**
28 @file include/mysql/psi/mysql_sp.h
29 Instrumentation helpers for stored programs.
30*/
31
32/* HAVE_PSI_*_INTERFACE */
33#include "my_psi_config.h" // IWYU pragma: keep
34
36
37#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
38/* PSI_SP_CALL() as direct call. */
39#include "pfs_statement_provider.h" // IWYU pragma: keep
40#endif
41
42#ifndef PSI_SP_CALL
43#define PSI_SP_CALL(M) psi_statement_service->M
44#endif
45
46/**
47 @defgroup psi_api_sp Stored Program Instrumentation (API)
48 @ingroup psi_api
49 @{
50*/
51
52/**
53 @def MYSQL_START_SP(STATE, SP_SHARE)
54 Instrument a stored program execution start.
55 @param STATE Event state data
56 @param SP_SHARE Stored Program share instrumentation
57 @return An event locker
58*/
59#ifdef HAVE_PSI_SP_INTERFACE
60#define MYSQL_START_SP(STATE, SP_SHARE) inline_mysql_start_sp(STATE, SP_SHARE)
61#else
62#define MYSQL_START_SP(STATE, SP_SHARE) NULL
63#endif
64
65/**
66 @def MYSQL_END_SP(LOCKER)
67 Instrument a stored program execution end.
68 @param LOCKER Event locker
69*/
70#ifdef HAVE_PSI_SP_INTERFACE
71#define MYSQL_END_SP(LOCKER) inline_mysql_end_sp(LOCKER)
72#else
73#define MYSQL_END_SP(LOCKER) \
74 do { \
75 } while (0)
76#endif
77
78/**
79 @def MYSQL_DROP_SP(OT, SN, SNL, ON, ONL)
80 Instrument a drop stored program event.
81 @param OT Object type
82 @param SN Schema name
83 @param SNL Schema name length
84 @param ON Object name
85 @param ONL Object name length
86*/
87#ifdef HAVE_PSI_SP_INTERFACE
88#define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
89 inline_mysql_drop_sp(OT, SN, SNL, ON, ONL)
90#else
91#define MYSQL_DROP_SP(OT, SN, SNL, ON, ONL) \
92 do { \
93 } while (0)
94#endif
95
96/**
97 @def MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL)
98 Instrument a stored program share.
99 @param OT Object type
100 @param SN Schema name
101 @param SNL Schema name length
102 @param ON Object name
103 @param ONL Object name length
104 @return The instrumented stored program share.
105*/
106#ifdef HAVE_PSI_SP_INTERFACE
107#define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) \
108 inline_mysql_get_sp_share(OT, SN, SNL, ON, ONL)
109#else
110#define MYSQL_GET_SP_SHARE(OT, SN, SNL, ON, ONL) NULL
111#endif
112
113#ifdef HAVE_PSI_SP_INTERFACE
115 PSI_sp_locker_state *state, PSI_sp_share *sp_share) {
116 return PSI_SP_CALL(start_sp)(state, sp_share);
117}
118
119static inline void inline_mysql_end_sp(PSI_sp_locker *locker) {
120 if (likely(locker != nullptr)) {
121 PSI_SP_CALL(end_sp)(locker);
122 }
123}
124
125static inline void inline_mysql_drop_sp(uint sp_type, const char *schema_name,
126 uint shcema_name_length,
127 const char *object_name,
128 uint object_name_length) {
129 PSI_SP_CALL(drop_sp)
130 (sp_type, schema_name, shcema_name_length, object_name, object_name_length);
131}
132
134 const char *schema_name,
135 uint shcema_name_length,
136 const char *object_name,
137 uint object_name_length) {
138 return PSI_SP_CALL(get_sp_share)(sp_type, schema_name, shcema_name_length,
139 object_name, object_name_length);
140}
141#endif
142
143/** @} (end of group psi_api_sp) */
144
145#endif
struct PSI_sp_locker PSI_sp_locker
Definition: psi_statement_bits.h:126
struct PSI_sp_share PSI_sp_share
Definition: psi_statement_bits.h:119
static void inline_mysql_end_sp(PSI_sp_locker *locker)
Definition: mysql_sp.h:119
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:125
static struct PSI_sp_locker * inline_mysql_start_sp(PSI_sp_locker_state *state, PSI_sp_share *sp_share)
Definition: mysql_sp.h:114
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:133
constexpr bool likely(bool expr)
Definition: my_compiler.h:55
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
#define PSI_SP_CALL(M)
Definition: mysql_sp.h:43
Performance schema instrumentation (declarations).
Performance schema instrumentation interface.
Definition: psi_statement_bits.h:255
unsigned int uint
Definition: uca9-dump.cc:75