1 /* Copyright (c) 2011, 2021, 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 Foundation, 21 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 22 23 #ifndef TABLE_MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME_H 24 #define TABLE_MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME_H 25 26 /** 27 @file storage/perfschema/table_mems_global_by_event_name.h 28 Table MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME (declarations). 29 */ 30 31 #include "pfs_column_types.h" 32 #include "pfs_engine_table.h" 33 #include "pfs_instr_class.h" 34 #include "pfs_builtin_memory.h" 35 #include "table_helper.h" 36 37 /** 38 @addtogroup Performance_schema_tables 39 @{ 40 */ 41 42 /** A row of PERFORMANCE_SCHEMA.MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME. */ 43 struct row_mems_global_by_event_name 44 { 45 /** Column EVENT_NAME. */ 46 PFS_event_name_row m_event_name; 47 /** Columns COUNT_ALLOC, ... */ 48 PFS_memory_stat_row m_stat; 49 }; 50 51 /** 52 Position of a cursor on 53 PERFORMANCE_SCHEMA.MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME. 54 Index 1 on view 55 Index 2 on instrument key (1 based) 56 */ 57 struct pos_mems_global_by_event_name : public PFS_double_index 58 { 59 static const uint FIRST_VIEW= 1; 60 static const uint VIEW_BUILTIN_MEMORY= 1; 61 static const uint VIEW_MEMORY= 2; 62 static const uint LAST_VIEW= 2; 63 pos_mems_global_by_event_namepos_mems_global_by_event_name64 pos_mems_global_by_event_name() 65 : PFS_double_index(FIRST_VIEW, 1) 66 {} 67 resetpos_mems_global_by_event_name68 inline void reset(void) 69 { 70 m_index_1= FIRST_VIEW; 71 m_index_2= 1; 72 } 73 has_more_viewpos_mems_global_by_event_name74 inline bool has_more_view(void) 75 { return (m_index_1 <= LAST_VIEW); } 76 next_viewpos_mems_global_by_event_name77 inline void next_view(void) 78 { 79 m_index_1++; 80 m_index_2= 1; 81 } 82 }; 83 84 /** Table PERFORMANCE_SCHEMA.MEMORY_SUMMARY_GLOBAL_BY_EVENT_NAME. */ 85 class table_mems_global_by_event_name : public PFS_engine_table 86 { 87 typedef pos_mems_global_by_event_name pos_t; 88 89 public: 90 /** Table share */ 91 static PFS_engine_table_share m_share; 92 static PFS_engine_table* create(); 93 static int delete_all_rows(); 94 static ha_rows get_row_count(); 95 96 virtual int rnd_next(); 97 virtual int rnd_pos(const void *pos); 98 virtual void reset_position(void); 99 100 private: 101 virtual int read_row_values(TABLE *table, 102 unsigned char *buf, 103 Field **fields, 104 bool read_all); 105 106 table_mems_global_by_event_name(); 107 108 public: ~table_mems_global_by_event_name()109 ~table_mems_global_by_event_name() 110 {} 111 112 private: 113 void make_row(PFS_builtin_memory_class *klass); 114 void make_row(PFS_memory_class *klass); 115 116 /** Table share lock. */ 117 static THR_LOCK m_table_lock; 118 /** Fields definition. */ 119 static TABLE_FIELD_DEF m_field_def; 120 121 /** Current row. */ 122 row_mems_global_by_event_name m_row; 123 /** True is the current row exists. */ 124 bool m_row_exists; 125 /** Current position. */ 126 pos_t m_pos; 127 /** Next position. */ 128 pos_t m_next_pos; 129 }; 130 131 /** @} */ 132 #endif 133