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