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 Street, Suite 500, Boston, MA 02110-1335 USA */ 22 23 #ifndef TABLE_ETS_BY_ACCOUNT_BY_EVENT_NAME_H 24 #define TABLE_ETS_BY_ACCOUNT_BY_EVENT_NAME_H 25 26 /** 27 @file storage/perfschema/table_ets_by_account_by_event_name.h 28 Table EVENTS_TRANSACTIONS_SUMMARY_BY_ACCOUNT_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 "pfs_account.h" 36 #include "table_helper.h" 37 38 /** 39 @addtogroup Performance_schema_tables 40 @{ 41 */ 42 43 /** 44 A row of table 45 PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME. 46 */ 47 struct row_ets_by_account_by_event_name 48 { 49 /** Columns USER, HOST. */ 50 PFS_account_row m_account; 51 /** Column EVENT_NAME. */ 52 PFS_event_name_row m_event_name; 53 /** 54 Columns COUNT_STAR, SUM/MIN/AVG/MAX_TIMER_WAIT, 55 COUNT_READ_WRITE, SUM/MIN/AVG/MAX_TIMER_READ_WRITE, 56 COUNT_READ_ONLY, SUM/MIN/AVG/MAX_TIMER_READ_ONLY 57 */ 58 PFS_transaction_stat_row m_stat; 59 }; 60 61 /** 62 Position of a cursor on 63 PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME. 64 Index 1 on account (0 based) 65 Index 2 on transaction class (1 based) 66 */ 67 struct pos_ets_by_account_by_event_name 68 : public PFS_double_index 69 { pos_ets_by_account_by_event_namepos_ets_by_account_by_event_name70 pos_ets_by_account_by_event_name() 71 : PFS_double_index(0, 1) 72 {} 73 resetpos_ets_by_account_by_event_name74 inline void reset(void) 75 { 76 m_index_1= 0; 77 m_index_2= 1; 78 } 79 next_accountpos_ets_by_account_by_event_name80 inline void next_account(void) 81 { 82 m_index_1++; 83 m_index_2= 1; 84 } 85 }; 86 87 /** Table PERFORMANCE_SCHEMA.EVENTS_TRANSACTIONS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME. */ 88 class table_ets_by_account_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_ets_by_account_by_event_name(); 109 110 public: ~table_ets_by_account_by_event_name()111 ~table_ets_by_account_by_event_name() 112 {} 113 114 protected: 115 void make_row(PFS_account *account, PFS_transaction_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_ets_by_account_by_event_name m_row; 125 /** True is the current row exists. */ 126 bool m_row_exists; 127 /** Current position. */ 128 pos_ets_by_account_by_event_name m_pos; 129 /** Next position. */ 130 pos_ets_by_account_by_event_name m_next_pos; 131 }; 132 133 /** @} */ 134 #endif 135