Debian Codegraph @

storage/perfschema/table_mems_global_by_event_name.h

raw symbols SCIP
1 /* Copyright (c) 2011, 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_MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME_H
25 #define TABLE_MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME_H
26
27 /**
28 @file storage/perfschema/table_mems_global_by_event_name.h
29 Table MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME (declarations).
30 */
31
32 #include <sys/types.h>
33
34 #include "my_base.h"
35 #include "storage/perfschema/pfs_engine_table.h"
36 #include "storage/perfschema/table_helper.h"
37
38 class Field;
39 class Plugin_table;
40 struct PFS_builtin_memory_class;
41 struct PFS_instr_class;
42 struct PFS_memory_class;
43 struct TABLE;
44 struct THR_LOCK;
45
46 /**
47 @addtogroup performance_schema_tables
48 @{
49 */
50
51 class PFS_index_mems_global_by_event_name : public PFS_engine_index {
52 public:
53 PFS_index_mems_global_by_event_name()
54 : PFS_engine_index(&m_key), m_key("EVENT_NAME") {}
55
56 ~PFS_index_mems_global_by_event_name() override = default;
57
58 virtual bool match(PFS_instr_class *instr_class);
59
60 private:
61 PFS_key_event_name m_key;
62 };
63
64 /** A row of PERFORMANCE_SCHEMA.MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME. */
65 struct row_mems_global_by_event_name {
66 /** Column EVENT_NAME. */
67 PFS_event_name_row m_event_name;
68 /** Columns COUNT_ALLOC, ... */
69 PFS_memory_stat_row m_stat;
70 };
71
72 /**
73 Position of a cursor on
74 PERFORMANCE_SCHEMA.MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME.
75 Index 1 on view
76 Index 2 on instrument key (1 based)
77 */
78 struct pos_mems_global_by_event_name : public PFS_double_index {
79 static const uint FIRST_VIEW = 1;
80 static const uint VIEW_BUILTIN_MEMORY = 1;
81 static const uint VIEW_MEMORY = 2;
82 static const uint LAST_VIEW = 2;
83
84 pos_mems_global_by_event_name() : PFS_double_index(FIRST_VIEW, 1) {}
85
86 inline void reset() {
87 m_index_1 = FIRST_VIEW;
88 m_index_2 = 1;
89 }
90
91 inline bool has_more_view() { return (m_index_1 <= LAST_VIEW); }
92
93 inline void next_view() {
94 m_index_1++;
95 m_index_2 = 1;
96 }
97 };
98
99 /** Table PERFORMANCE_SCHEMA.MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME. */
100 class table_mems_global_by_event_name : public PFS_engine_table {
101 typedef pos_mems_global_by_event_name pos_t;
102
103 public:
104 /** Table share */
105 static PFS_engine_table_share m_share;
106 static PFS_engine_table *create(PFS_engine_table_share *);
107 static int delete_all_rows();
108 static ha_rows get_row_count();
109
110 void reset_position() override;
111
112 int rnd_next() override;
113 int rnd_pos(const void *pos) override;
114
115 int index_init(uint idx, bool sorted) override;
116 int index_next() override;
117
118 private:
119 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
120 bool read_all) override;
121
122 table_mems_global_by_event_name();
123
124 public:
125 ~table_mems_global_by_event_name() override = default;
126
127 private:
128 int make_row(PFS_builtin_memory_class *klass);
129 int make_row(PFS_memory_class *klass);
130
131 /** Table share lock. */
132 static THR_LOCK m_table_lock;
133 /** Table definition. */
134 static Plugin_table m_table_def;
135
136 /** Current row. */
137 row_mems_global_by_event_name m_row;
138 /** Current position. */
139 pos_t m_pos;
140 /** Next position. */
141 pos_t m_next_pos;
142
143 PFS_index_mems_global_by_event_name *m_opened_index;
144 };
145
146 /** @} */
147 #endif