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