MySQL 8.4.0
Source Code Documentation
table_setup_metrics.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_METRICS_H
25#define TABLE_SETUP_METRICS_H
26
27/**
28 @file storage/perfschema/table_setup_metrics.h
29 Table SETUP_METRICS (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_metric_class;
42struct TABLE;
43struct THR_LOCK;
44
45/**
46 @addtogroup performance_schema_tables
47 @{
48*/
49
50/** A row of PERFORMANCE_SCHEMA.SETUP_METRICS. */
52 /** Columns NAME, METER, ENABLED, METRIC_TYPE, NUM_TYPE, UNIT, DESCRIPTION. */
54
55 // materialized from PFS_metric_class
56 const char *m_metric;
58 const char *m_group;
60 const char *m_unit;
62 const char *m_description;
66};
67
69 public:
71 : PFS_engine_index(key_1) {}
72
73 ~PFS_index_setup_metrics() override = default;
74
75 virtual bool match(PFS_metric_class *pfs) = 0;
76};
77
79 public:
81 : PFS_index_setup_metrics(&m_key), m_key("NAME") {}
82
84
85 bool match(PFS_metric_class *pfs) override;
86
87 private:
89};
90
91/** Position of a cursor, for metric iterations. */
93 /** Current row index. */
94 uint m_index;
95
96 /**
97 Constructor.
98 @param index the index initial value.
99 */
100 explicit PFS_metric_index(uint index) : m_index(index) {}
101
102 /**
103 Set this index at a given position.
104 @param index an index
105 */
106 void set_at(uint index) { m_index = index; }
107
108 /**
109 Set this index at a given position.
110 @param other a position
111 */
112 void set_at(const PFS_metric_index *other) { m_index = other->m_index; }
113
114 /**
115 Set this index after a given position.
116 @param other a position
117 */
118 void set_after(const PFS_metric_index *other) {
119 m_index = other->m_index;
120 next();
121 }
122
123 /** Set this index to the next record. */
124 void next() {
125 do {
126 m_index++;
127 } while (m_index < metric_class_max &&
128 metric_class_array[m_index - 1].m_key == 0);
129 }
130};
131
132/** Table PERFORMANCE_SCHEMA.SETUP_METRICS. */
135
136 public:
137 /** Table share. */
140 static ha_rows get_row_count();
141
142 void reset_position() override;
143
144 int rnd_next() override;
145 int rnd_pos(const void *pos) override;
146
147 int index_init(uint idx, bool sorted) override;
148 int index_next() override;
149
150 protected:
151 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
152 bool read_all) override;
153
155
156 public:
157 ~table_setup_metrics() override = default;
158
159 private:
160 int make_row(PFS_metric_class *klass);
161
162 /** Table share lock. */
164 /** Table definition. */
166
167 /** Current row. */
169 /** Current position. */
171 /** Next position. */
173
175};
176
177/** @} */
178#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_metrics.h:78
~PFS_index_setup_metrics_by_name() override=default
PFS_index_setup_metrics_by_name()
Definition: table_setup_metrics.h:80
PFS_key_metric_name m_key
Definition: table_setup_metrics.h:88
bool match(PFS_metric_class *pfs) override
Definition: table_setup_metrics.cc:79
Definition: table_setup_metrics.h:68
virtual bool match(PFS_metric_class *pfs)=0
~PFS_index_setup_metrics() override=default
PFS_index_setup_metrics(PFS_engine_key *key_1)
Definition: table_setup_metrics.h:70
Definition: table_helper.h:1483
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
Table PERFORMANCE_SCHEMA.SETUP_METRICS.
Definition: table_setup_metrics.h:133
pos_t m_next_pos
Next position.
Definition: table_setup_metrics.h:172
static ha_rows get_row_count()
Definition: table_setup_metrics.cc:91
int index_init(uint idx, bool sorted) override
Definition: table_setup_metrics.cc:142
table_setup_metrics()
Definition: table_setup_metrics.cc:93
pos_t m_pos
Current position.
Definition: table_setup_metrics.h:170
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_setup_metrics.cc:96
static THR_LOCK m_table_lock
Table share lock.
Definition: table_setup_metrics.h:163
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_setup_metrics.cc:87
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_setup_metrics.cc:101
static Plugin_table m_table_def
Table definition.
Definition: table_setup_metrics.h:165
PFS_index_setup_metrics * m_opened_index
Definition: table_setup_metrics.h:174
static PFS_engine_table_share m_share
Table share.
Definition: table_setup_metrics.h:138
PFS_metric_index pos_t
Definition: table_setup_metrics.h:134
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_setup_metrics.cc:205
int make_row(PFS_metric_class *klass)
Definition: table_setup_metrics.cc:179
int index_next() override
Find key in index, read record.
Definition: table_setup_metrics.cc:153
~table_setup_metrics() override=default
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_setup_metrics.cc:123
row_setup_metrics m_row
Current row.
Definition: table_setup_metrics.h:168
PFS_metric_class * metric_class_array
Definition: pfs_instr_class.cc:170
ulong metric_class_max
Size of the metric class array.
Definition: pfs_instr_class.cc:148
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).
MetricOTELType
Definition: psi_metric_bits.h:32
MetricNumType
Definition: psi_metric_bits.h:38
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 metric.
Definition: pfs_instr_class.h:372
Position of a cursor, for metric iterations.
Definition: table_setup_metrics.h:92
uint m_index
Current row index.
Definition: table_setup_metrics.h:94
void set_at(uint index)
Set this index at a given position.
Definition: table_setup_metrics.h:106
PFS_metric_index(uint index)
Constructor.
Definition: table_setup_metrics.h:100
void next()
Set this index to the next record.
Definition: table_setup_metrics.h:124
void set_at(const PFS_metric_index *other)
Set this index at a given position.
Definition: table_setup_metrics.h:112
void set_after(const PFS_metric_index *other)
Set this index after a given position.
Definition: table_setup_metrics.h:118
Definition: table.h:1405
Definition: thr_lock.h:139
A row of PERFORMANCE_SCHEMA.SETUP_METRICS.
Definition: table_setup_metrics.h:51
PFS_metric_class * m_instr_class
Columns NAME, METER, ENABLED, METRIC_TYPE, NUM_TYPE, UNIT, DESCRIPTION.
Definition: table_setup_metrics.h:53
const char * m_metric
Definition: table_setup_metrics.h:56
uint m_unit_length
Definition: table_setup_metrics.h:61
uint m_metric_length
Definition: table_setup_metrics.h:57
uint m_description_length
Definition: table_setup_metrics.h:63
const char * m_group
Definition: table_setup_metrics.h:58
uint m_group_length
Definition: table_setup_metrics.h:59
const char * m_unit
Definition: table_setup_metrics.h:60
MetricNumType m_num_type
Definition: table_setup_metrics.h:64
MetricOTELType m_metric_type
Definition: table_setup_metrics.h:65
const char * m_description
Definition: table_setup_metrics.h:62
Helpers to implement a performance schema table.