MySQL 8.4.0
Source Code Documentation
table_sync_instances.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 TABLE_SYNC_INSTANCE_H
25#define TABLE_SYNC_INSTANCE_H
26
27/**
28 @file storage/perfschema/table_sync_instances.h
29 Table MUTEX_INSTANCES, RWLOCK_INSTANCES and COND_INSTANCES (declarations).
30*/
31
32#include <sys/types.h>
33
34#include "my_base.h"
35#include "my_inttypes.h"
38
39class Field;
40class Plugin_table;
41struct PFS_cond;
42struct PFS_mutex;
43struct PFS_rwlock;
44struct TABLE;
45struct THR_LOCK;
46
47/**
48 @addtogroup performance_schema_tables
49 @{
50*/
51
52/** A row of table PERFORMANCE_SCHEMA.MUTEX_INSTANCES. */
54 /** Column NAME. */
55 const char *m_name;
56 /** Length in bytes of @c m_name. */
58 /** Column OBJECT_INSTANCE_BEGIN. */
59 const void *m_identity;
60 /** True if column LOCKED_BY_THREAD_ID is not null. */
62 /** Column LOCKED_BY_THREAD_ID. */
64};
65
67 public:
69 : PFS_engine_index(key_1) {}
70
71 ~PFS_index_mutex_instances() override = default;
72
73 virtual bool match(PFS_mutex *pfs) = 0;
74};
75
77 public:
79 : PFS_index_mutex_instances(&m_key), m_key("OBJECT_INSTANCE_BEGIN") {}
80
82
83 bool match(PFS_mutex *pfs) override;
84
85 private:
87};
88
90 public:
93
95
96 bool match(PFS_mutex *pfs) override;
97
98 private:
100};
101
104 public:
106 : PFS_index_mutex_instances(&m_key), m_key("LOCKED_BY_THREAD_ID") {}
107
109
110 bool match(PFS_mutex *pfs) override;
111
112 private:
114};
115
116/** Table PERFORMANCE_SCHEMA.MUTEX_INSTANCES. */
118 public:
119 /** Table share. */
122 static ha_rows get_row_count();
123
124 void reset_position() override;
125
126 int rnd_next() override;
127 int rnd_pos(const void *pos) override;
128
129 int index_init(uint idx, bool sorted) override;
130 int index_next() override;
131
132 private:
133 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
134 bool read_all) override;
136
137 public:
138 ~table_mutex_instances() override = default;
139
140 protected:
141 int make_row(PFS_mutex *pfs);
142
143 /** Table share lock. */
145 /** Table definition. */
147
148 /** Current row. */
150 /** Current position. */
152 /** Next position. */
154
156};
157
158/** A row of table PERFORMANCE_SCHEMA.RWLOCK_INSTANCES. */
160 /** Column NAME. */
161 const char *m_name;
162 /** Length in bytes of @c m_name. */
164 /** Column OBJECT_INSTANCE_BEGIN. */
165 const void *m_identity;
166 /** True if column WRITE_LOCKED_BY_THREAD_ID is not null. */
168 /** Column WRITE_LOCKED_BY_THREAD_ID. */
170 /** Column READ_LOCKED_BY_COUNT. */
172};
173
175 public:
177 : PFS_engine_index(key_1) {}
178
179 ~PFS_index_rwlock_instances() override = default;
180
181 virtual bool match(PFS_rwlock *pfs) = 0;
182};
183
186 public:
188 : PFS_index_rwlock_instances(&m_key), m_key("OBJECT_INSTANCE_BEGIN") {}
189
191
192 bool match(PFS_rwlock *pfs) override;
193
194 private:
196};
197
199 public:
202
204
205 bool match(PFS_rwlock *pfs) override;
206
207 private:
209};
210
213 public:
216 m_key("WRITE_LOCKED_BY_THREAD_ID") {}
217
219
220 bool match(PFS_rwlock *pfs) override;
221
222 private:
224};
225
226/** Table PERFORMANCE_SCHEMA.RWLOCK_INSTANCES. */
228 public:
229 /** Table share */
232 static ha_rows get_row_count();
233
234 void reset_position() override;
235
236 int rnd_next() override;
237 int rnd_pos(const void *pos) override;
238
239 int index_init(uint idx, bool sorted) override;
240 int index_next() override;
241
242 private:
243 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
244 bool read_all) override;
246
247 public:
248 ~table_rwlock_instances() override = default;
249
250 protected:
251 int make_row(PFS_rwlock *pfs);
252
253 /** Table share lock. */
255 /** Table definition. */
257
258 /** Current row. */
260 /** Current position. */
262 /** Next position. */
264
266};
267
268/** A row of table PERFORMANCE_SCHEMA.COND_INSTANCES. */
270 /** Column NAME. */
271 const char *m_name;
272 /** Length in bytes of @c m_name. */
274 /** Column OBJECT_INSTANCE_BEGIN. */
275 const void *m_identity;
276};
277
279 public:
281 : PFS_engine_index(key_1) {}
282
283 ~PFS_index_cond_instances() override = default;
284
285 virtual bool match(PFS_cond *pfs) = 0;
286};
287
289 public:
291 : PFS_index_cond_instances(&m_key), m_key("OBJECT_INSTANCE_BEGIN") {}
292
294
295 bool match(PFS_cond *pfs) override;
296
297 private:
299};
300
302 public:
304 : PFS_index_cond_instances(&m_key), m_key("NAME") {}
305
307
308 bool match(PFS_cond *pfs) override;
309
310 private:
312};
313
314/** Table PERFORMANCE_SCHEMA.COND_INSTANCES. */
316 public:
317 /** Table share. */
320 static ha_rows get_row_count();
321
322 void reset_position() override;
323
324 int rnd_next() override;
325 int rnd_pos(const void *pos) override;
326
327 int index_init(uint idx, bool sorted) override;
328 int index_next() override;
329
330 private:
331 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
332 bool read_all) override;
334
335 public:
336 ~table_cond_instances() override = default;
337
338 protected:
339 int make_row(PFS_cond *pfs);
340
341 /** Table share lock. */
343 /** Table definition. */
345
346 /** Current row. */
348 /** Current position. */
350 /** Next position. */
352
354};
355
356/** @} */
357#endif
Definition: field.h:575
Definition: pfs_engine_table.h:300
Definition: pfs_engine_table.h:268
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:70
Definition: table_sync_instances.h:288
PFS_key_object_instance m_key
Definition: table_sync_instances.h:298
PFS_index_cond_instances_by_instance()
Definition: table_sync_instances.h:290
~PFS_index_cond_instances_by_instance() override=default
bool match(PFS_cond *pfs) override
Definition: table_sync_instances.cc:510
Definition: table_sync_instances.h:301
PFS_index_cond_instances_by_name()
Definition: table_sync_instances.h:303
~PFS_index_cond_instances_by_name() override=default
bool match(PFS_cond *pfs) override
Definition: table_sync_instances.cc:519
PFS_key_event_name m_key
Definition: table_sync_instances.h:311
Definition: table_sync_instances.h:278
PFS_index_cond_instances(PFS_engine_key *key_1)
Definition: table_sync_instances.h:280
~PFS_index_cond_instances() override=default
virtual bool match(PFS_cond *pfs)=0
Definition: table_sync_instances.h:76
PFS_key_object_instance m_key
Definition: table_sync_instances.h:86
~PFS_index_mutex_instances_by_instance() override=default
PFS_index_mutex_instances_by_instance()
Definition: table_sync_instances.h:78
bool match(PFS_mutex *pfs) override
Definition: table_sync_instances.cc:81
Definition: table_sync_instances.h:89
PFS_key_event_name m_key
Definition: table_sync_instances.h:99
PFS_index_mutex_instances_by_name()
Definition: table_sync_instances.h:91
bool match(PFS_mutex *pfs) override
Definition: table_sync_instances.cc:90
~PFS_index_mutex_instances_by_name() override=default
Definition: table_sync_instances.h:103
~PFS_index_mutex_instances_by_thread_id() override=default
PFS_index_mutex_instances_by_thread_id()
Definition: table_sync_instances.h:105
bool match(PFS_mutex *pfs) override
Definition: table_sync_instances.cc:99
PFS_key_thread_id m_key
Definition: table_sync_instances.h:113
Definition: table_sync_instances.h:66
virtual bool match(PFS_mutex *pfs)=0
~PFS_index_mutex_instances() override=default
PFS_index_mutex_instances(PFS_engine_key *key_1)
Definition: table_sync_instances.h:68
Definition: table_sync_instances.h:185
PFS_key_object_instance m_key
Definition: table_sync_instances.h:195
~PFS_index_rwlock_instances_by_instance() override=default
PFS_index_rwlock_instances_by_instance()
Definition: table_sync_instances.h:187
bool match(PFS_rwlock *pfs) override
Definition: table_sync_instances.cc:294
Definition: table_sync_instances.h:198
bool match(PFS_rwlock *pfs) override
Definition: table_sync_instances.cc:303
PFS_key_event_name m_key
Definition: table_sync_instances.h:208
PFS_index_rwlock_instances_by_name()
Definition: table_sync_instances.h:200
~PFS_index_rwlock_instances_by_name() override=default
Definition: table_sync_instances.h:212
bool match(PFS_rwlock *pfs) override
Definition: table_sync_instances.cc:312
~PFS_index_rwlock_instances_by_thread_id() override=default
PFS_key_thread_id m_key
Definition: table_sync_instances.h:223
PFS_index_rwlock_instances_by_thread_id()
Definition: table_sync_instances.h:214
Definition: table_sync_instances.h:174
PFS_index_rwlock_instances(PFS_engine_key *key_1)
Definition: table_sync_instances.h:176
virtual bool match(PFS_rwlock *pfs)=0
~PFS_index_rwlock_instances() override=default
Definition: table_helper.h:1459
Definition: table_helper.h:1719
Definition: table_helper.h:1279
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
Table PERFORMANCE_SCHEMA.COND_INSTANCES.
Definition: table_sync_instances.h:315
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_sync_instances.cc:544
static ha_rows get_row_count()
Definition: table_sync_instances.cc:532
int index_init(uint idx, bool sorted) override
Definition: table_sync_instances.cc:571
static THR_LOCK m_table_lock
Table share lock.
Definition: table_sync_instances.h:342
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_sync_instances.cc:635
row_cond_instances m_row
Current row.
Definition: table_sync_instances.h:347
~table_cond_instances() override=default
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_sync_instances.cc:558
static PFS_engine_table_share m_share
Table share.
Definition: table_sync_instances.h:318
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_sync_instances.cc:528
int index_next() override
Find key in index, read record.
Definition: table_sync_instances.cc:590
PFS_index_cond_instances * m_opened_index
Definition: table_sync_instances.h:353
table_cond_instances()
Definition: table_sync_instances.cc:536
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_sync_instances.cc:539
static Plugin_table m_table_def
Table definition.
Definition: table_sync_instances.h:344
PFS_simple_index m_pos
Current position.
Definition: table_sync_instances.h:349
PFS_simple_index m_next_pos
Next position.
Definition: table_sync_instances.h:351
int make_row(PFS_cond *pfs)
Definition: table_sync_instances.cc:612
Table PERFORMANCE_SCHEMA.MUTEX_INSTANCES.
Definition: table_sync_instances.h:117
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_sync_instances.cc:124
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_sync_instances.cc:226
row_mutex_instances m_row
Current row.
Definition: table_sync_instances.h:149
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_sync_instances.cc:119
table_mutex_instances()
Definition: table_sync_instances.cc:116
PFS_simple_index m_next_pos
Next position.
Definition: table_sync_instances.h:153
PFS_index_mutex_instances * m_opened_index
Definition: table_sync_instances.h:155
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_sync_instances.cc:108
static Plugin_table m_table_def
Table definition.
Definition: table_sync_instances.h:146
~table_mutex_instances() override=default
static PFS_engine_table_share m_share
Table share.
Definition: table_sync_instances.h:120
PFS_simple_index m_pos
Current position.
Definition: table_sync_instances.h:151
int make_row(PFS_mutex *pfs)
Definition: table_sync_instances.cc:194
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_sync_instances.cc:138
int index_next() override
Find key in index, read record.
Definition: table_sync_instances.cc:173
static THR_LOCK m_table_lock
Table share lock.
Definition: table_sync_instances.h:144
int index_init(uint idx, bool sorted) override
Definition: table_sync_instances.cc:151
static ha_rows get_row_count()
Definition: table_sync_instances.cc:112
Table PERFORMANCE_SCHEMA.RWLOCK_INSTANCES.
Definition: table_sync_instances.h:227
int make_row(PFS_rwlock *pfs)
Definition: table_sync_instances.cc:408
PFS_index_rwlock_instances * m_opened_index
Definition: table_sync_instances.h:265
static PFS_engine_table_share m_share
Table share.
Definition: table_sync_instances.h:230
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_sync_instances.cc:442
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_sync_instances.cc:321
PFS_simple_index m_next_pos
Next position.
Definition: table_sync_instances.h:263
~table_rwlock_instances() override=default
PFS_simple_index m_pos
Current position.
Definition: table_sync_instances.h:261
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_sync_instances.cc:337
int index_init(uint idx, bool sorted) override
Definition: table_sync_instances.cc:364
static THR_LOCK m_table_lock
Table share lock.
Definition: table_sync_instances.h:254
row_rwlock_instances m_row
Current row.
Definition: table_sync_instances.h:259
static Plugin_table m_table_def
Table definition.
Definition: table_sync_instances.h:256
int index_next() override
Find key in index, read record.
Definition: table_sync_instances.cc:386
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_sync_instances.cc:351
static ha_rows get_row_count()
Definition: table_sync_instances.cc:325
table_rwlock_instances()
Definition: table_sync_instances.cc:329
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_sync_instances.cc:332
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1141
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: buf0block_hint.cc:30
Performance schema tables (declarations).
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:66
Instrumented condition implementation.
Definition: pfs_instr.h:162
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:358
Instrumented mutex implementation.
Definition: pfs_instr.h:103
Instrumented rwlock implementation.
Definition: pfs_instr.h:129
Position of a cursor, for simple iterations.
Definition: pfs_engine_table.h:558
Definition: table.h:1405
Definition: thr_lock.h:139
A row of table PERFORMANCE_SCHEMA.COND_INSTANCES.
Definition: table_sync_instances.h:269
uint m_name_length
Length in bytes of m_name.
Definition: table_sync_instances.h:273
const char * m_name
Column NAME.
Definition: table_sync_instances.h:271
const void * m_identity
Column OBJECT_INSTANCE_BEGIN.
Definition: table_sync_instances.h:275
A row of table PERFORMANCE_SCHEMA.MUTEX_INSTANCES.
Definition: table_sync_instances.h:53
const char * m_name
Column NAME.
Definition: table_sync_instances.h:55
ulonglong m_locked_by_thread_id
Column LOCKED_BY_THREAD_ID.
Definition: table_sync_instances.h:63
bool m_locked
True if column LOCKED_BY_THREAD_ID is not null.
Definition: table_sync_instances.h:61
uint m_name_length
Length in bytes of m_name.
Definition: table_sync_instances.h:57
const void * m_identity
Column OBJECT_INSTANCE_BEGIN.
Definition: table_sync_instances.h:59
A row of table PERFORMANCE_SCHEMA.RWLOCK_INSTANCES.
Definition: table_sync_instances.h:159
ulong m_readers
Column READ_LOCKED_BY_COUNT.
Definition: table_sync_instances.h:171
ulonglong m_write_locked_by_thread_id
Column WRITE_LOCKED_BY_THREAD_ID.
Definition: table_sync_instances.h:169
bool m_write_locked
True if column WRITE_LOCKED_BY_THREAD_ID is not null.
Definition: table_sync_instances.h:167
const void * m_identity
Column OBJECT_INSTANCE_BEGIN.
Definition: table_sync_instances.h:165
uint m_name_length
Length in bytes of m_name.
Definition: table_sync_instances.h:163
const char * m_name
Column NAME.
Definition: table_sync_instances.h:161
Helpers to implement a performance schema table.