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