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_ETS_BY_THREAD_BY_EVENT_NAME_H 24 #define TABLE_ETS_BY_THREAD_BY_EVENT_NAME_H 25 26 /** 27 @file storage/perfschema/table_ets_by_thread_by_event_name.h 28 Table EVENTS_TRANSACTIONS_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_TRANSACTIONS_SUMMARY_BY_THREAD_BY_EVENT_NAME. 45 */ 46 struct row_ets_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 /** 53 Columns COUNT_STAR, SUM/MIN/AVG/MAX_TIMER_WAIT, 54 COUNT_READ_WRITE, SUM/MIN/AVG/MAX_TIMER_READ_WRITE, 55 COUNT_READ_ONLY, SUM/MIN/AVG/MAX_TIMER_READ_ONLY 56 */ 57 PFS_transaction_stat_row m_stat; 58 }; 59 60 /** 61 Position of a cursor on 62 PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_SUMMARY_BY_THREAD_BY_EVENT_NAME. 63 Index 1 on thread (0 based). 64 Index 2 on transaction class (1 based). 65 */ 66 struct pos_ets_by_thread_by_event_name 67 : public PFS_double_index, public PFS_instrument_view_constants 68 { pos_ets_by_thread_by_event_namepos_ets_by_thread_by_event_name69 pos_ets_by_thread_by_event_name() 70 : PFS_double_index(0, 1) 71 {} 72 resetpos_ets_by_thread_by_event_name73 inline void reset(void) 74 { 75 m_index_1= 0; 76 m_index_2= 1; 77 } 78 next_threadpos_ets_by_thread_by_event_name79 inline void next_thread(void) 80 { 81 m_index_1++; 82 m_index_2= 1; 83 } 84 next_transactionpos_ets_by_thread_by_event_name85 inline void next_transaction(void) 86 { 87 m_index_2++; 88 } 89 }; 90 91 /** Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_SUMMARY_BY_THREAD_BY_EVENT_NAME. */ 92 class table_ets_by_thread_by_event_name : public PFS_engine_table 93 { 94 public: 95 /** Table share */ 96 static PFS_engine_table_share m_share; 97 static PFS_engine_table* create(); 98 static int delete_all_rows(); 99 static ha_rows get_row_count(); 100 101 virtual int rnd_init(bool scan); 102 virtual int rnd_next(); 103 virtual int rnd_pos(const void *pos); 104 virtual void reset_position(void); 105 106 protected: 107 virtual int read_row_values(TABLE *table, 108 unsigned char *buf, 109 Field **fields, 110 bool read_all); 111 112 table_ets_by_thread_by_event_name(); 113 114 public: ~table_ets_by_thread_by_event_name()115 ~table_ets_by_thread_by_event_name() 116 {} 117 118 protected: 119 void make_row(PFS_thread *thread, PFS_transaction_class *klass); 120 121 private: 122 /** Table share lock. */ 123 static THR_LOCK m_table_lock; 124 /** Fields definition. */ 125 static TABLE_FIELD_DEF m_field_def; 126 127 /** Current row. */ 128 row_ets_by_thread_by_event_name m_row; 129 /** True is the current row exists. */ 130 bool m_row_exists; 131 /** Current position. */ 132 pos_ets_by_thread_by_event_name m_pos; 133 /** Next position. */ 134 pos_ets_by_thread_by_event_name m_next_pos; 135 }; 136 137 /** @} */ 138 #endif 139