Debian Codegraph @

storage/perfschema/table_ews_by_thread_by_event_name.h

raw symbols SCIP
1 /* Copyright (c) 2010, 2026, 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_EWS_BY_THREAD_BY_EVENT_NAME_H
25 #define TABLE_EWS_BY_THREAD_BY_EVENT_NAME_H
26
27 /**
28 @file storage/perfschema/table_ews_by_thread_by_event_name.h
29 Table EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (declarations).
30 */
31
32 #include <sys/types.h>
33
34 #include "my_base.h"
35 #include "my_inttypes.h"
36 #include "storage/perfschema/pfs_engine_table.h"
37 #include "storage/perfschema/table_helper.h"
38
39 class Field;
40 class Plugin_table;
41 struct PFS_instr_class;
42 struct PFS_thread;
43 struct TABLE;
44 struct THR_LOCK;
45
46 /**
47 @addtogroup performance_schema_tables
48 @{
49 */
50
51 class PFS_index_ews_by_thread_by_event_name : public PFS_engine_index {
52 public:
53 PFS_index_ews_by_thread_by_event_name()
54 : PFS_engine_index(&m_key_1, &m_key_2),
55 m_key_1("THREAD_ID"),
56 m_key_2("EVENT_NAME") {}
57
58 ~PFS_index_ews_by_thread_by_event_name() override = default;
59
60 virtual bool match(PFS_thread *pfs);
61 virtual bool match_view(uint view);
62 virtual bool match(PFS_instr_class *instr_class);
63
64 private:
65 PFS_key_thread_id m_key_1;
66 PFS_key_event_name m_key_2;
67 };
68
69 /**
70 A row of table
71 PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
72 */
73 struct row_ews_by_thread_by_event_name {
74 /** Column THREAD_ID. */
75 ulonglong m_thread_internal_id;
76 /** Column EVENT_NAME. */
77 PFS_event_name_row m_event_name;
78 /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */
79 PFS_stat_row m_stat;
80 };
81
82 /**
83 Position of a cursor on
84 PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
85 Index 1 on thread (0 based)
86 Index 2 on instrument view
87 Index 3 on instrument class (1 based)
88 */
89 struct pos_ews_by_thread_by_event_name : public PFS_triple_index,
90 public PFS_instrument_view_constants {
91 pos_ews_by_thread_by_event_name() : PFS_triple_index(0, FIRST_VIEW, 1) {}
92
93 inline void reset() {
94 m_index_1 = 0;
95 m_index_2 = FIRST_VIEW;
96 m_index_3 = 1;
97 }
98
99 inline void next_thread() {
100 m_index_1++;
101 m_index_2 = FIRST_VIEW;
102 m_index_3 = 1;
103 }
104
105 inline bool has_more_view() { return (m_index_2 <= LAST_VIEW); }
106
107 inline void next_view() {
108 m_index_2++;
109 m_index_3 = 1;
110 }
111 };
112
113 /** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME. */
114 class table_ews_by_thread_by_event_name : public PFS_engine_table {
115 public:
116 /** Table share */
117 static PFS_engine_table_share m_share;
118 static PFS_engine_table *create(PFS_engine_table_share *);
119 static int delete_all_rows();
120 static ha_rows get_row_count();
121
122 void reset_position() override;
123
124 int rnd_next() override;
125 int rnd_pos(const void *pos) override;
126
127 int index_init(uint idx, bool sorted) override;
128 int index_next() override;
129
130 protected:
131 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
132 bool read_all) override;
133
134 table_ews_by_thread_by_event_name();
135
136 public:
137 ~table_ews_by_thread_by_event_name() override = default;
138
139 protected:
140 int make_row(PFS_thread *thread, PFS_instr_class *klass);
141
142 private:
143 /** Table share lock. */
144 static THR_LOCK m_table_lock;
145 /** Table definition. */
146 static Plugin_table m_table_def;
147
148 /** Current row. */
149 row_ews_by_thread_by_event_name m_row;
150 /** Current position. */
151 pos_ews_by_thread_by_event_name m_pos;
152 /** Next position. */
153 pos_ews_by_thread_by_event_name m_next_pos;
154
155 PFS_index_ews_by_thread_by_event_name *m_opened_index;
156 };
157
158 /** @} */
159 #endif