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