MySQL 8.0.39
Source Code Documentation
mysql_table.h
Go to the documentation of this file.
1/* Copyright (c) 2010, 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_TABLE_H
25#define MYSQL_TABLE_H
26
27/**
28 @file include/mysql/psi/mysql_table.h
29 Instrumentation helpers for table io.
30*/
31
32#include "mysql/psi/psi_table.h"
33
34#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
35/* PSI_TABLE_CALL() as direct call. */
36#include "pfs_table_provider.h" // IWYU pragma: keep
37#endif
38
39#ifndef PSI_TABLE_CALL
40#define PSI_TABLE_CALL(M) psi_table_service->M
41#endif
42
43/**
44 @defgroup psi_api_table Table Instrumentation (API)
45 @ingroup psi_api
46 @{
47*/
48
49/**
50 @def MYSQL_TABLE_WAIT_VARIABLES
51 Instrumentation helper for table waits.
52 This instrumentation declares local variables.
53 Do not use a ';' after this macro
54 @param LOCKER the locker
55 @param STATE the locker state
56 @sa MYSQL_START_TABLE_IO_WAIT.
57 @sa MYSQL_END_TABLE_IO_WAIT.
58 @sa MYSQL_START_TABLE_LOCK_WAIT.
59 @sa MYSQL_END_TABLE_LOCK_WAIT.
60*/
61#ifdef HAVE_PSI_TABLE_INTERFACE
62#define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE) \
63 struct PSI_table_locker *LOCKER; \
64 PSI_table_locker_state STATE;
65#else
66#define MYSQL_TABLE_WAIT_VARIABLES(LOCKER, STATE)
67#endif
68
69/**
70 @def MYSQL_START_TABLE_LOCK_WAIT
71 Instrumentation helper for table lock waits.
72 This instrumentation marks the start of a wait event.
73 @param LOCKER the locker
74 @param STATE the locker state
75 @param PSI the instrumented table
76 @param OP the table operation to be performed
77 @param FLAGS per table operation flags.
78 @sa MYSQL_END_TABLE_LOCK_WAIT.
79*/
80#ifdef HAVE_PSI_TABLE_INTERFACE
81#define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
82 LOCKER = inline_mysql_start_table_lock_wait(STATE, PSI, OP, FLAGS, __FILE__, \
83 __LINE__)
84#else
85#define MYSQL_START_TABLE_LOCK_WAIT(LOCKER, STATE, PSI, OP, FLAGS) \
86 do { \
87 } while (0)
88#endif
89
90/**
91 @def MYSQL_END_TABLE_LOCK_WAIT
92 Instrumentation helper for table lock waits.
93 This instrumentation marks the end of a wait event.
94 @param LOCKER the locker
95 @sa MYSQL_START_TABLE_LOCK_WAIT.
96*/
97#ifdef HAVE_PSI_TABLE_INTERFACE
98#define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
99 inline_mysql_end_table_lock_wait(LOCKER)
100#else
101#define MYSQL_END_TABLE_LOCK_WAIT(LOCKER) \
102 do { \
103 } while (0)
104#endif
105
106#ifdef HAVE_PSI_TABLE_INTERFACE
107#define MYSQL_UNLOCK_TABLE(T) inline_mysql_unlock_table(T)
108#else
109#define MYSQL_UNLOCK_TABLE(T) \
110 do { \
111 } while (0)
112#endif
113
114#ifdef HAVE_PSI_TABLE_INTERFACE
115/**
116 Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
117 @sa MYSQL_END_TABLE_LOCK_WAIT.
118*/
120 PSI_table_locker_state *state, struct PSI_table *psi,
121 enum PSI_table_lock_operation op, ulong flags, const char *src_file,
122 int src_line) {
123 if (psi != nullptr) {
124 struct PSI_table_locker *locker;
125 locker = PSI_TABLE_CALL(start_table_lock_wait)(state, psi, op, flags,
126 src_file, src_line);
127 return locker;
128 }
129 return nullptr;
130}
131
132/**
133 Instrumentation calls for MYSQL_END_TABLE_LOCK_WAIT.
134 @sa MYSQL_START_TABLE_LOCK_WAIT.
135*/
137 struct PSI_table_locker *locker) {
138 if (locker != nullptr) {
139 PSI_TABLE_CALL(end_table_lock_wait)(locker);
140 }
141}
142
143static inline void inline_mysql_unlock_table(struct PSI_table *table) {
144 if (table != nullptr) {
145 PSI_TABLE_CALL(unlock_table)(table);
146 }
147}
148#endif
149
150/** @} (end of group psi_api_table) */
151
152#endif
#define PSI_TABLE_CALL(M)
Definition: psi_table.h:36
struct PSI_table_locker PSI_table_locker
Definition: psi_table_bits.h:43
PSI_table_lock_operation
Lock operation performed on an instrumented table.
Definition: psi_table_bits.h:110
struct PSI_table PSI_table
Definition: psi_table_bits.h:107
static void inline_mysql_unlock_table(struct PSI_table *table)
Definition: mysql_table.h:143
static void inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
Instrumentation calls for MYSQL_END_TABLE_LOCK_WAIT.
Definition: mysql_table.h:136
static struct PSI_table_locker * inline_mysql_start_table_lock_wait(PSI_table_locker_state *state, struct PSI_table *psi, enum PSI_table_lock_operation op, ulong flags, const char *src_file, int src_line)
Instrumentation calls for MYSQL_START_TABLE_LOCK_WAIT.
Definition: mysql_table.h:119
static int flags[50]
Definition: hp_test1.cc:40
Performance schema instrumentation (declarations).
Performance schema instrumentation interface.
State data storage for start_table_io_wait_v1_t, start_table_lock_wait_v1_t.
Definition: psi_table_bits.h:69