MySQL 8.0.39
Source Code Documentation
mysql_ps.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_PS_H
25#define MYSQL_PS_H
26
27/**
28 @file include/mysql/psi/mysql_ps.h
29 Instrumentation helpers for prepared statements.
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_PS_CALL() as direct call. */
39#include "pfs_statement_provider.h" // IWYU pragma: keep
40#endif
41
42#ifndef PSI_PS_CALL
43#define PSI_PS_CALL(M) psi_statement_service->M
44#endif
45
46#ifdef HAVE_PSI_PS_INTERFACE
47
48#define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, \
49 SQLTEXT_LENGTH) \
50 inline_mysql_create_prepared_stmt(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, \
51 SQLTEXT, SQLTEXT_LENGTH)
52#define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \
53 inline_mysql_execute_prepared_stmt(LOCKER, PREPARED_STMT)
54#define MYSQL_DESTROY_PS(PREPARED_STMT) \
55 inline_mysql_destroy_prepared_stmt(PREPARED_STMT)
56#define MYSQL_REPREPARE_PS(PREPARED_STMT) \
57 inline_mysql_reprepare_prepared_stmt(PREPARED_STMT)
58#define MYSQL_SET_PS_TEXT(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH) \
59 inline_mysql_set_prepared_stmt_text(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH)
60#define MYSQL_SET_PS_SECONDARY_ENGINE(PREPARED_STMT, SECONDARY) \
61 inline_mysql_set_prepared_stmt_secondary_engine(PREPARED_STMT, SECONDARY)
62
63#else
64
65#define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, \
66 SQLTEXT_LENGTH) \
67 NULL
68#define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \
69 do { \
70 } while (0)
71#define MYSQL_DESTROY_PS(PREPARED_STMT) \
72 do { \
73 } while (0)
74#define MYSQL_REPREPARE_PS(PREPARED_STMT) \
75 do { \
76 } while (0)
77#define MYSQL_SET_PS_TEXT(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH) \
78 do { \
79 } while (0)
80#define MYSQL_SET_PS_SECONDARY_ENGINE(PREPARED_STMT, SECONDARY) \
81 do { \
82 } while (0)
83
84#endif
85
86#ifdef HAVE_PSI_PS_INTERFACE
88 void *identity, uint stmt_id, PSI_statement_locker *locker,
89 const char *stmt_name, size_t stmt_name_length, const char *sqltext,
90 size_t sqltext_length) {
91 if (locker == nullptr) {
92 return nullptr;
93 }
94 return PSI_PS_CALL(create_prepared_stmt)(identity, stmt_id, locker, stmt_name,
95 stmt_name_length, sqltext,
96 sqltext_length);
97}
98
100 PSI_statement_locker *locker, PSI_prepared_stmt *prepared_stmt) {
101 if (prepared_stmt != nullptr && locker != nullptr) {
102 PSI_PS_CALL(execute_prepared_stmt)(locker, prepared_stmt);
103 }
104}
105
107 PSI_prepared_stmt *prepared_stmt) {
108 if (prepared_stmt != nullptr) {
109 PSI_PS_CALL(destroy_prepared_stmt)(prepared_stmt);
110 }
111}
112
114 PSI_prepared_stmt *prepared_stmt) {
115 if (prepared_stmt != nullptr) {
116 PSI_PS_CALL(reprepare_prepared_stmt)(prepared_stmt);
117 }
118}
119
121 PSI_prepared_stmt *prepared_stmt, const char *text, uint text_len) {
122 if (prepared_stmt != nullptr) {
123 PSI_PS_CALL(set_prepared_stmt_text)(prepared_stmt, text, text_len);
124 }
125}
126
128 PSI_prepared_stmt *prepared_stmt, bool secondary) {
129 if (prepared_stmt != nullptr) {
130 PSI_PS_CALL(set_prepared_stmt_secondary_engine)(prepared_stmt, secondary);
131 }
132}
133
134#endif
135
136#endif
struct PSI_prepared_stmt PSI_prepared_stmt
Definition: psi_statement_bits.h:105
struct PSI_statement_locker PSI_statement_locker
Definition: psi_statement_bits.h:98
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
static void inline_mysql_reprepare_prepared_stmt(PSI_prepared_stmt *prepared_stmt)
Definition: mysql_ps.h:113
static struct PSI_prepared_stmt * inline_mysql_create_prepared_stmt(void *identity, uint stmt_id, PSI_statement_locker *locker, const char *stmt_name, size_t stmt_name_length, const char *sqltext, size_t sqltext_length)
Definition: mysql_ps.h:87
static void inline_mysql_set_prepared_stmt_text(PSI_prepared_stmt *prepared_stmt, const char *text, uint text_len)
Definition: mysql_ps.h:120
static void inline_mysql_destroy_prepared_stmt(PSI_prepared_stmt *prepared_stmt)
Definition: mysql_ps.h:106
static void inline_mysql_set_prepared_stmt_secondary_engine(PSI_prepared_stmt *prepared_stmt, bool secondary)
Definition: mysql_ps.h:127
static void inline_mysql_execute_prepared_stmt(PSI_statement_locker *locker, PSI_prepared_stmt *prepared_stmt)
Definition: mysql_ps.h:99
PFS_prepared_stmt * create_prepared_stmt(void *identity, PFS_thread *thread, PFS_program *pfs_program, PFS_events_statements *pfs_stmt, uint stmt_id, const char *stmt_name, uint stmt_name_length, const char *sqltext, uint sqltext_length)
Definition: pfs_prepared_stmt.cc:73
Performance schema instrumentation (declarations).
#define PSI_PS_CALL(M)
Definition: pfs_statement_provider.h:52
Performance schema instrumentation interface.
unsigned int uint
Definition: uca9-dump.cc:75