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