MySQL 8.4.0
Source Code Documentation
table_setup_meters.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 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_SETUP_METERS_H
25#define TABLE_SETUP_METERS_H
26
27/**
28 @file storage/perfschema/table_setup_meters.h
29 Table SETUP_METERS (declarations).
30*/
31
32#include <sys/types.h>
33
34#include "my_base.h"
37
38class Field;
39class Plugin_table;
40struct PFS_instr_class;
41struct PFS_meter_class;
42struct TABLE;
43struct THR_LOCK;
44
45/**
46 @addtogroup performance_schema_tables
47 @{
48*/
49
50/** A row of PERFORMANCE_SCHEMA.SETUP_METERS. */
52 /** Columns NAME, ENABLED. */
54
55 // materialized from PFS_meter_class
56 const char *m_meter;
59 const char *m_description;
62};
63
65 public:
67 : PFS_engine_index(key_1) {}
68
69 ~PFS_index_setup_meters() override = default;
70
71 virtual bool match(PFS_meter_class *pfs) = 0;
72};
73
75 public:
77 : PFS_index_setup_meters(&m_key), m_key("NAME") {}
78
79 ~PFS_index_setup_meters_by_name() override = default;
80
81 bool match(PFS_meter_class *pfs) override;
82
83 private:
85};
86
87/** Position of a cursor, for meter iterations. */
89 /** Current row index. */
90 uint m_index;
91
92 /**
93 Constructor.
94 @param index the index initial value.
95 */
96 explicit PFS_meter_index(uint index) : m_index(index) {}
97
98 /**
99 Set this index at a given position.
100 @param index an index
101 */
102 void set_at(uint index) { m_index = index; }
103
104 /**
105 Set this index at a given position.
106 @param other a position
107 */
108 void set_at(const PFS_meter_index *other) { m_index = other->m_index; }
109
110 /**
111 Set this index after a given position.
112 @param other a position
113 */
114 void set_after(const PFS_meter_index *other) {
115 m_index = other->m_index;
116 next();
117 }
118
119 /** Set this index to the next record. */
120 void next() {
121 do {
122 m_index++;
123 } while (m_index < meter_class_max &&
124 meter_class_array[m_index - 1].m_key == 0);
125 }
126};
127
128/** Table PERFORMANCE_SCHEMA.SETUP_METERS. */
131
132 public:
133 /** Table share. */
136 static ha_rows get_row_count();
137
138 void reset_position() override;
139
140 int rnd_next() override;
141 int rnd_pos(const void *pos) override;
142
143 int index_init(uint idx, bool sorted) override;
144 int index_next() override;
145
146 protected:
147 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
148 bool read_all) override;
149
150 int update_row_values(TABLE *table, const unsigned char *old_buf,
151 unsigned char *new_buf, Field **fields) override;
152
154
155 public:
156 ~table_setup_meters() override = default;
157
158 private:
159 int make_row(PFS_meter_class *klass);
160
161 /** Table share lock. */
163 /** Table definition. */
165
166 /** Current row. */
168 /** Current position. */
170 /** Next position. */
172
174};
175
176/** @} */
177#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_setup_meters.h:74
bool match(PFS_meter_class *pfs) override
Definition: table_setup_meters.cc:77
PFS_index_setup_meters_by_name()
Definition: table_setup_meters.h:76
~PFS_index_setup_meters_by_name() override=default
PFS_key_meter_name m_key
Definition: table_setup_meters.h:84
Definition: table_setup_meters.h:64
virtual bool match(PFS_meter_class *pfs)=0
~PFS_index_setup_meters() override=default
PFS_index_setup_meters(PFS_engine_key *key_1)
Definition: table_setup_meters.h:66
Definition: table_helper.h:1474
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
Table PERFORMANCE_SCHEMA.SETUP_METERS.
Definition: table_setup_meters.h:129
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_setup_meters.cc:85
static THR_LOCK m_table_lock
Table share lock.
Definition: table_setup_meters.h:162
int update_row_values(TABLE *table, const unsigned char *old_buf, unsigned char *new_buf, Field **fields) override
Update the current row values.
Definition: table_setup_meters.cc:237
static ha_rows get_row_count()
Definition: table_setup_meters.cc:89
int index_next() override
Find key in index, read record.
Definition: table_setup_meters.cc:151
static PFS_engine_table_share m_share
Table share.
Definition: table_setup_meters.h:134
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_setup_meters.cc:121
pos_t m_pos
Current position.
Definition: table_setup_meters.h:169
int make_row(PFS_meter_class *klass)
Definition: table_setup_meters.cc:177
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_setup_meters.cc:99
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_setup_meters.cc:199
PFS_index_setup_meters * m_opened_index
Definition: table_setup_meters.h:173
table_setup_meters()
Definition: table_setup_meters.cc:91
static Plugin_table m_table_def
Table definition.
Definition: table_setup_meters.h:164
PFS_meter_index pos_t
Definition: table_setup_meters.h:130
~table_setup_meters() override=default
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_setup_meters.cc:94
pos_t m_next_pos
Next position.
Definition: table_setup_meters.h:171
int index_init(uint idx, bool sorted) override
Definition: table_setup_meters.cc:140
row_setup_meters m_row
Current row.
Definition: table_setup_meters.h:167
ulong meter_class_max
Size of the meter class array.
Definition: pfs_instr_class.cc:144
PFS_meter_class * meter_class_array
Definition: pfs_instr_class.cc:169
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1141
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
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:358
Information for all instrumentation.
Definition: pfs_instr_class.h:212
Instrumentation metadata for a meter.
Definition: pfs_instr_class.h:395
Position of a cursor, for meter iterations.
Definition: table_setup_meters.h:88
uint m_index
Current row index.
Definition: table_setup_meters.h:90
void set_at(uint index)
Set this index at a given position.
Definition: table_setup_meters.h:102
PFS_meter_index(uint index)
Constructor.
Definition: table_setup_meters.h:96
void set_after(const PFS_meter_index *other)
Set this index after a given position.
Definition: table_setup_meters.h:114
void next()
Set this index to the next record.
Definition: table_setup_meters.h:120
void set_at(const PFS_meter_index *other)
Set this index at a given position.
Definition: table_setup_meters.h:108
Definition: table.h:1405
Definition: thr_lock.h:139
A row of PERFORMANCE_SCHEMA.SETUP_METERS.
Definition: table_setup_meters.h:51
const char * m_description
Definition: table_setup_meters.h:59
uint m_meter_length
Definition: table_setup_meters.h:57
PFS_meter_class * m_instr_class
Columns NAME, ENABLED.
Definition: table_setup_meters.h:53
bool m_enabled
Definition: table_setup_meters.h:61
uint m_description_length
Definition: table_setup_meters.h:60
uint m_frequency
Definition: table_setup_meters.h:58
const char * m_meter
Definition: table_setup_meters.h:56
Helpers to implement a performance schema table.