1 /* Copyright (c) 2010, 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 21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 23 #ifndef TABLE_ESGS_BY_THREAD_BY_EVENT_NAME_H 24 #define TABLE_ESGS_BY_THREAD_BY_EVENT_NAME_H 25 26 /** 27 @file storage/perfschema/table_esgs_by_thread_by_event_name.h 28 Table EVENTS_STAGES_SUMMARY_BY_THREAD_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_instr.h" 35 #include "table_helper.h" 36 37 /** 38 @addtogroup Performance_schema_tables 39 @{ 40 */ 41 42 /** 43 A row of table 44 PERFORMANCE_SCHEMA.EVENTS_STAGES_SUMMARY_BY_THREAD_BY_EVENT_NAME. 45 */ 46 struct row_esgs_by_thread_by_event_name 47 { 48 /** Column THREAD_ID. */ 49 ulonglong m_thread_internal_id; 50 /** Column EVENT_NAME. */ 51 PFS_event_name_row m_event_name; 52 /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */ 53 PFS_stage_stat_row m_stat; 54 }; 55 56 /** 57 Position of a cursor on 58 PERFORMANCE_SCHEMA.EVENTS_STAGES_SUMMARY_BY_THREAD_BY_EVENT_NAME. 59 Index 1 on thread (0 based). 60 Index 2 on stage class (1 based). 61 */ 62 struct pos_esgs_by_thread_by_event_name 63 : public PFS_double_index 64 { pos_esgs_by_thread_by_event_namepos_esgs_by_thread_by_event_name65 pos_esgs_by_thread_by_event_name() 66 : PFS_double_index(0, 1) 67 {} 68 resetpos_esgs_by_thread_by_event_name69 inline void reset(void) 70 { 71 m_index_1= 0; 72 m_index_2= 1; 73 } 74 next_threadpos_esgs_by_thread_by_event_name75 inline void next_thread(void) 76 { 77 m_index_1++; 78 m_index_2= 1; 79 } 80 next_stagepos_esgs_by_thread_by_event_name81 inline void next_stage(void) 82 { 83 m_index_2++; 84 } 85 }; 86 87 /** Table PERFORMANCE_SCHEMA.EVENTS_STAGES_SUMMARY_BY_THREAD_BY_EVENT_NAME. */ 88 class table_esgs_by_thread_by_event_name : public PFS_engine_table 89 { 90 public: 91 /** Table share */ 92 static PFS_engine_table_share m_share; 93 static PFS_engine_table* create(); 94 static int delete_all_rows(); 95 static ha_rows get_row_count(); 96 97 virtual int rnd_init(bool scan); 98 virtual int rnd_next(); 99 virtual int rnd_pos(const void *pos); 100 virtual void reset_position(void); 101 102 protected: 103 virtual int read_row_values(TABLE *table, 104 unsigned char *buf, 105 Field **fields, 106 bool read_all); 107 108 table_esgs_by_thread_by_event_name(); 109 110 public: ~table_esgs_by_thread_by_event_name()111 ~table_esgs_by_thread_by_event_name() 112 {} 113 114 protected: 115 void make_row(PFS_thread *thread, PFS_stage_class *klass); 116 117 private: 118 /** Table share lock. */ 119 static THR_LOCK m_table_lock; 120 /** Fields definition. */ 121 static TABLE_FIELD_DEF m_field_def; 122 123 /** Current row. */ 124 row_esgs_by_thread_by_event_name m_row; 125 /** True is the current row exists. */ 126 bool m_row_exists; 127 /** Current position. */ 128 pos_esgs_by_thread_by_event_name m_pos; 129 /** Next position. */ 130 pos_esgs_by_thread_by_event_name m_next_pos; 131 }; 132 133 /** @} */ 134 #endif 135