MySQL  8.0.27
Source Code Documentation
mysql_ps.h
Go to the documentation of this file.
1 /* Copyright (c) 2013, 2021, 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 
60 #else
61 
62 #define MYSQL_CREATE_PS(IDENTITY, ID, LOCKER, NAME, NAME_LENGTH, SQLTEXT, \
63  SQLTEXT_LENGTH) \
64  NULL
65 #define MYSQL_EXECUTE_PS(LOCKER, PREPARED_STMT) \
66  do { \
67  } while (0)
68 #define MYSQL_DESTROY_PS(PREPARED_STMT) \
69  do { \
70  } while (0)
71 #define MYSQL_REPREPARE_PS(PREPARED_STMT) \
72  do { \
73  } while (0)
74 #define MYSQL_SET_PS_TEXT(PREPARED_STMT, SQLTEXT, SQLTEXT_LENGTH) \
75  do { \
76  } while (0)
77 
78 #endif
79 
80 #ifdef HAVE_PSI_PS_INTERFACE
82  void *identity, uint stmt_id, PSI_statement_locker *locker,
83  const char *stmt_name, size_t stmt_name_length, const char *sqltext,
84  size_t sqltext_length) {
85  if (locker == nullptr) {
86  return nullptr;
87  }
88  return PSI_PS_CALL(create_prepared_stmt)(identity, stmt_id, locker, stmt_name,
89  stmt_name_length, sqltext,
90  sqltext_length);
91 }
92 
94  PSI_statement_locker *locker, PSI_prepared_stmt *prepared_stmt) {
95  if (prepared_stmt != nullptr && locker != nullptr) {
96  PSI_PS_CALL(execute_prepared_stmt)(locker, prepared_stmt);
97  }
98 }
99 
101  PSI_prepared_stmt *prepared_stmt) {
102  if (prepared_stmt != nullptr) {
103  PSI_PS_CALL(destroy_prepared_stmt)(prepared_stmt);
104  }
105 }
106 
108  PSI_prepared_stmt *prepared_stmt) {
109  if (prepared_stmt != nullptr) {
110  PSI_PS_CALL(reprepare_prepared_stmt)(prepared_stmt);
111  }
112 }
113 
115  PSI_prepared_stmt *prepared_stmt, const char *text, uint text_len) {
116  if (prepared_stmt != nullptr) {
117  PSI_PS_CALL(set_prepared_stmt_text)(prepared_stmt, text, text_len);
118  }
119 }
120 
121 #endif
122 
123 #endif
struct PSI_prepared_stmt PSI_prepared_stmt
Definition: psi_statement_bits.h:82
struct PSI_statement_locker PSI_statement_locker
Definition: psi_statement_bits.h:75
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:107
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:81
static void inline_mysql_set_prepared_stmt_text(PSI_prepared_stmt *prepared_stmt, const char *text, uint text_len)
Definition: mysql_ps.h:114
static void inline_mysql_destroy_prepared_stmt(PSI_prepared_stmt *prepared_stmt)
Definition: mysql_ps.h:100
static void inline_mysql_execute_prepared_stmt(PSI_statement_locker *locker, PSI_prepared_stmt *prepared_stmt)
Definition: mysql_ps.h:93
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