MySQL 8.4.3
Source Code Documentation
psi_table_bits.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 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 COMPONENTS_SERVICES_BITS_PSI_TABLE_BITS_H
25#define COMPONENTS_SERVICES_BITS_PSI_TABLE_BITS_H
26
27/**
28 @file mysql/components/services/bits/psi_table_bits.h
29 Performance schema instrumentation interface.
30
31 @defgroup psi_abi_table Table Instrumentation (ABI)
32 @ingroup psi_abi
33 @{
34*/
35
36struct TABLE_SHARE;
37
38/**
39 Interface for an instrumented table operation.
40 This is an opaque structure.
41*/
42struct PSI_table_locker;
44
45/** IO operation performed on an instrumented table. */
47 /** Row fetch. */
49 /** Row write. */
51 /** Row update. */
53 /** Row delete. */
55};
57
58/**
59 State data storage for @c start_table_io_wait_v1_t,
60 @c start_table_lock_wait_v1_t.
61 This structure provide temporary storage to a table locker.
62 The content of this structure is considered opaque,
63 the fields are only hints of what an implementation
64 of the psi interface can use.
65 This memory is provided by the instrumented code for performance reasons.
66 @sa start_table_io_wait_v1_t
67 @sa start_table_lock_wait_v1_t
68*/
70 /** Internal state. */
71 unsigned int m_flags;
72 /** Current io operation. */
74 /** Current table handle. */
76 /** Current table share. */
78 /** Current thread. */
80 /** Timer start. */
81 unsigned long long m_timer_start;
82 /** Timer function. */
83 unsigned long long (*m_timer)(void);
84 /** Internal data. */
85 void *m_wait;
86 /**
87 Implementation specific.
88 For table io, the table io index.
89 For table lock, the lock type.
90 */
91 unsigned int m_index;
92};
94
95/**
96 Interface for an instrumented table share.
97 This is an opaque structure.
98*/
99struct PSI_table_share;
101
102/**
103 Interface for an instrumented table handle.
104 This is an opaque structure.
105*/
106struct PSI_table;
107typedef struct PSI_table PSI_table;
108
109/** Lock operation performed on an instrumented table. */
111 /** Table lock, in the server layer. */
113 /** Table lock, in the storage engine layer. */
117
118/**
119 Acquire a table share instrumentation.
120 @param temporary True for temporary tables
121 @param share The SQL layer table share
122 @return a table share instrumentation, or NULL
123*/
124typedef struct PSI_table_share *(*get_table_share_v1_t)(
125 bool temporary, struct TABLE_SHARE *share);
126
127/**
128 Release a table share.
129 @param share the table share to release
130*/
131typedef void (*release_table_share_v1_t)(struct PSI_table_share *share);
132
133/**
134 Drop a table share.
135 @param temporary True for temporary tables
136 @param schema_name the table schema name
137 @param schema_name_length the table schema name length
138 @param table_name the table name
139 @param table_name_length the table name length
140*/
141typedef void (*drop_table_share_v1_t)(bool temporary, const char *schema_name,
142 int schema_name_length,
143 const char *table_name,
144 int table_name_length);
145
146/**
147 Open an instrumentation table handle.
148 @param share the table to open
149 @param identity table handle identity
150 @return a table handle, or NULL
151*/
152typedef struct PSI_table *(*open_table_v1_t)(struct PSI_table_share *share,
153 const void *identity);
154
155/**
156 Unbind a table handle from the current thread.
157 This operation happens when an opened table is added to the open table cache.
158 @param table the table to unbind
159*/
160typedef void (*unbind_table_v1_t)(struct PSI_table *table);
161
162/**
163 Rebind a table handle to the current thread.
164 This operation happens when a table from the open table cache
165 is reused for a thread.
166 @param share Instrumented table share.
167 @param identity Table handle identity, typically a memory address.
168 @param table the table to unbind
169*/
170typedef PSI_table *(*rebind_table_v1_t)(PSI_table_share *share,
171 const void *identity, PSI_table *table);
172
173/**
174 Close an instrumentation table handle.
175 Note that the table handle is invalid after this call.
176 @param server_share TABLE_SHARE from the SQL layer.
177 @param table the table handle to close
178*/
179typedef void (*close_table_v1_t)(struct TABLE_SHARE *server_share,
180 struct PSI_table *table);
181
182/**
183 Record a table instrumentation io wait start event.
184 @param state data storage for the locker
185 @param table the instrumented table
186 @param op the operation to perform
187 @param index the operation index
188 @param src_file the source file name
189 @param src_line the source line number
190*/
191typedef struct PSI_table_locker *(*start_table_io_wait_v1_t)(
192 struct PSI_table_locker_state *state, struct PSI_table *table,
193 enum PSI_table_io_operation op, unsigned int index, const char *src_file,
194 unsigned int src_line);
195
196/**
197 Record a table instrumentation io wait end event.
198 @param locker a table locker for the running thread
199 @param numrows the number of rows involved in io
200*/
201typedef void (*end_table_io_wait_v1_t)(struct PSI_table_locker *locker,
202 unsigned long long numrows);
203
204/**
205 Record a table instrumentation lock wait start event.
206 @param state data storage for the locker
207 @param table the instrumented table
208 @param op the operation to perform
209 @param flags the operation flags
210 @param src_file the source file name
211 @param src_line the source line number
212*/
213typedef struct PSI_table_locker *(*start_table_lock_wait_v1_t)(
214 struct PSI_table_locker_state *state, struct PSI_table *table,
215 enum PSI_table_lock_operation op, unsigned long flags, const char *src_file,
216 unsigned int src_line);
217
218/**
219 Record a table instrumentation lock wait end event.
220 @param locker a table locker for the running thread
221*/
222typedef void (*end_table_lock_wait_v1_t)(struct PSI_table_locker *locker);
223
224/**
225 Record a table unlock event.
226 @param table instrumentation for the table being unlocked
227*/
228typedef void (*unlock_table_v1_t)(struct PSI_table *table);
229
230/** @} (end of group psi_abi_table) */
231
232#endif /* COMPONENTS_SERVICES_BITS_PSI_TABLE_BITS_H */
void(* end_table_io_wait_v1_t)(struct PSI_table_locker *locker, unsigned long long numrows)
Record a table instrumentation io wait end event.
Definition: psi_table_bits.h:201
void(* release_table_share_v1_t)(struct PSI_table_share *share)
Release a table share.
Definition: psi_table_bits.h:131
void(* end_table_lock_wait_v1_t)(struct PSI_table_locker *locker)
Record a table instrumentation lock wait end event.
Definition: psi_table_bits.h:222
struct PSI_table_locker PSI_table_locker
Definition: psi_table_bits.h:43
void(* unlock_table_v1_t)(struct PSI_table *table)
Record a table unlock event.
Definition: psi_table_bits.h:228
void(* close_table_v1_t)(struct TABLE_SHARE *server_share, struct PSI_table *table)
Close an instrumentation table handle.
Definition: psi_table_bits.h:179
void(* unbind_table_v1_t)(struct PSI_table *table)
Unbind a table handle from the current thread.
Definition: psi_table_bits.h:160
PSI_table_io_operation
IO operation performed on an instrumented table.
Definition: psi_table_bits.h:46
struct PSI_table_share PSI_table_share
Definition: psi_table_bits.h:100
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
void(* drop_table_share_v1_t)(bool temporary, const char *schema_name, int schema_name_length, const char *table_name, int table_name_length)
Drop a table share.
Definition: psi_table_bits.h:141
@ PSI_TABLE_UPDATE_ROW
Row update.
Definition: psi_table_bits.h:52
@ PSI_TABLE_FETCH_ROW
Row fetch.
Definition: psi_table_bits.h:48
@ PSI_TABLE_WRITE_ROW
Row write.
Definition: psi_table_bits.h:50
@ PSI_TABLE_DELETE_ROW
Row delete.
Definition: psi_table_bits.h:54
@ PSI_TABLE_EXTERNAL_LOCK
Table lock, in the storage engine layer.
Definition: psi_table_bits.h:114
@ PSI_TABLE_LOCK
Table lock, in the server layer.
Definition: psi_table_bits.h:112
struct PSI_thread PSI_thread
Definition: psi_thread_bits.h:82
static int flags[50]
Definition: hp_test1.cc:40
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
const char * table_name
Definition: rules_table_service.cc:56
State data storage for start_table_io_wait_v1_t, start_table_lock_wait_v1_t.
Definition: psi_table_bits.h:69
unsigned int m_index
Implementation specific.
Definition: psi_table_bits.h:91
struct PSI_table * m_table
Current table handle.
Definition: psi_table_bits.h:75
unsigned long long(* m_timer)(void)
Timer function.
Definition: psi_table_bits.h:83
unsigned int m_flags
Internal state.
Definition: psi_table_bits.h:71
unsigned long long m_timer_start
Timer start.
Definition: psi_table_bits.h:81
struct PSI_table_share * m_table_share
Current table share.
Definition: psi_table_bits.h:77
void * m_wait
Internal data.
Definition: psi_table_bits.h:85
enum PSI_table_io_operation m_io_operation
Current io operation.
Definition: psi_table_bits.h:73
struct PSI_thread * m_thread
Current thread.
Definition: psi_table_bits.h:79
This structure is shared between different table objects.
Definition: table.h:701