MySQL 8.4.0
Source Code Documentation
mysql_mdl.h
Go to the documentation of this file.
1/* Copyright (c) 2012, 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_MDL_H
25#define MYSQL_MDL_H
26
27/**
28 @file include/mysql/psi/mysql_mdl.h
29 Instrumentation helpers for metadata locks.
30*/
31
32/* HAVE_PSI_*_INTERFACE */
33#include "my_psi_config.h" // IWYU pragma: keep
34
35#include "mysql/psi/psi_mdl.h"
36
37#if defined(MYSQL_SERVER) || defined(PFS_DIRECT_CALL)
38/* PSI_METADATA_CALL() as direct call. */
39#include "pfs_metadata_provider.h" // IWYU pragma: keep
40#endif
41
42#ifndef PSI_METADATA_CALL
43#define PSI_METADATA_CALL(M) psi_mdl_service->M
44#endif
45
46/**
47 @defgroup psi_api_mdl Metadata Instrumentation (API)
48 @ingroup psi_api
49 @{
50*/
51
52/**
53 @def mysql_mdl_create(K, M, A)
54 Instrumented metadata lock creation.
55 @param I Metadata lock identity
56 @param K Metadata key
57 @param T Metadata lock type
58 @param D Metadata lock duration
59 @param S Metadata lock status
60 @param F request source file
61 @param L request source line
62*/
63
64#ifdef HAVE_PSI_METADATA_INTERFACE
65#define mysql_mdl_create(I, K, T, D, S, F, L) \
66 inline_mysql_mdl_create(I, K, T, D, S, F, L)
67#else
68#define mysql_mdl_create(I, K, T, D, S, F, L) NULL
69#endif
70
71#ifdef HAVE_PSI_METADATA_INTERFACE
72#define mysql_mdl_set_status(L, S) inline_mysql_mdl_set_status(L, S)
73#else
74#define mysql_mdl_set_status(L, S) \
75 do { \
76 } while (0)
77#endif
78
79#ifdef HAVE_PSI_METADATA_INTERFACE
80#define mysql_mdl_set_duration(L, D) inline_mysql_mdl_set_duration(L, D)
81#else
82#define mysql_mdl_set_duration(L, D) \
83 do { \
84 } while (0)
85#endif
86
87/**
88 @def mysql_mdl_destroy(M)
89 Instrumented metadata lock destruction.
90 @param M Metadata lock
91*/
92#ifdef HAVE_PSI_METADATA_INTERFACE
93#define mysql_mdl_destroy(M) inline_mysql_mdl_destroy(M, __FILE__, __LINE__)
94#else
95#define mysql_mdl_destroy(M) \
96 do { \
97 } while (0)
98#endif
99
100#ifdef HAVE_PSI_METADATA_INTERFACE
101
103 void *identity, const MDL_key *mdl_key, enum_mdl_type mdl_type,
104 enum_mdl_duration mdl_duration, MDL_ticket::enum_psi_status mdl_status,
105 const char *src_file, uint src_line) {
107
108 /* static_cast: Fit a round C++ enum peg into a square C int hole ... */
110 identity, mdl_key, static_cast<opaque_mdl_type>(mdl_type),
111 static_cast<opaque_mdl_duration>(mdl_duration),
112 static_cast<opaque_mdl_status>(mdl_status), src_file, src_line);
113
114 return result;
115}
116
119 if (psi != nullptr) {
120 PSI_METADATA_CALL(set_metadata_lock_status)(psi, mdl_status);
121 }
122}
123
125 PSI_metadata_lock *psi, enum_mdl_duration mdl_duration) {
126 if (psi != nullptr) {
127 PSI_METADATA_CALL(set_metadata_lock_duration)(psi, mdl_duration);
128 }
129}
130
132 const char *, uint) {
133 if (psi != nullptr) {
135 }
136}
137#endif /* HAVE_PSI_METADATA_INTERFACE */
138
139/** @} (end of group psi_api_mdl) */
140
141#endif
enum_psi_status
Status of lock request represented by the ticket as reflected in P_S.
Definition: mdl.h:1032
void destroy_metadata_lock(PFS_metadata_lock *pfs)
Definition: pfs_instr.cc:1576
PFS_metadata_lock * create_metadata_lock(void *identity, const MDL_key *mdl_key, opaque_mdl_type mdl_type, opaque_mdl_duration mdl_duration, opaque_mdl_status mdl_status, const char *src_file, uint src_line)
Definition: pfs_instr.cc:1548
int opaque_mdl_duration
Definition: psi_mdl_bits.h:42
int opaque_mdl_status
Definition: psi_mdl_bits.h:45
int opaque_mdl_type
Definition: psi_mdl_bits.h:36
struct PSI_metadata_lock PSI_metadata_lock
Definition: psi_mdl_bits.h:52
static void inline_mysql_mdl_destroy(PSI_metadata_lock *psi, const char *, uint)
Definition: mysql_mdl.h:131
static void inline_mysql_mdl_set_duration(PSI_metadata_lock *psi, enum_mdl_duration mdl_duration)
Definition: mysql_mdl.h:124
static PSI_metadata_lock * inline_mysql_mdl_create(void *identity, const MDL_key *mdl_key, enum_mdl_type mdl_type, enum_mdl_duration mdl_duration, MDL_ticket::enum_psi_status mdl_status, const char *src_file, uint src_line)
Definition: mysql_mdl.h:102
static void inline_mysql_mdl_set_status(PSI_metadata_lock *psi, MDL_ticket::enum_psi_status mdl_status)
Definition: mysql_mdl.h:117
enum_mdl_duration
Duration of metadata lock.
Definition: mdl.h:333
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
Performance schema instrumentation (declarations).
#define PSI_METADATA_CALL(M)
Definition: pfs_metadata_provider.h:48
struct result result
Definition: result.h:34
Performance schema instrumentation interface.
enum_mdl_type
Type of metadata lock request.
Definition: sql_lexer_yacc_state.h:106
Metadata lock object key.
Definition: mdl.h:365
Definition: result.h:30