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_IO_WAIT_SUMMARY_BY_INDEX_USAGE_H 24 #define TABLE_IO_WAIT_SUMMARY_BY_INDEX_USAGE_H 25 26 /** 27 @file storage/perfschema/table_tiws_by_index_usage.h 28 Table TABLE_IO_WAIT_SUMMARY_BY_INDEX_USAGE (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.TABLE_IO_WAIT_SUMMARY_BY_INDEX. 45 */ 46 struct row_tiws_by_index_usage 47 { 48 /** Column OBJECT_TYPE, SCHEMA_NAME, OBJECT_NAME, INDEX_NAME. */ 49 PFS_index_row m_index; 50 /** Columns COUNT/SUM/MIN/AVG/MAX (+_READ, +WRITE). */ 51 PFS_table_io_stat_row m_stat; 52 }; 53 54 /** 55 Position of a cursor on 56 PERFORMANCE_SCHEMA.TABLE_IO_WAIT_SUMMARY_BY_INDEX. 57 Index 1 on global_table_share_container (0 based) 58 Index 2 on index (0 based) 59 */ 60 struct pos_tiws_by_index_usage : public PFS_double_index 61 { pos_tiws_by_index_usagepos_tiws_by_index_usage62 pos_tiws_by_index_usage() 63 : PFS_double_index(0, 0) 64 {} 65 resetpos_tiws_by_index_usage66 inline void reset(void) 67 { 68 m_index_1= 0; 69 m_index_2= 0; 70 } 71 next_tablepos_tiws_by_index_usage72 inline void next_table(void) 73 { 74 m_index_1++; 75 m_index_2= 0; 76 } 77 }; 78 79 /** Table PERFORMANCE_SCHEMA.TABLE_IO_WAIT_SUMMARY_BY_INDEX. */ 80 class table_tiws_by_index_usage : public PFS_engine_table 81 { 82 public: 83 /** Table share */ 84 static PFS_engine_table_share m_share; 85 static PFS_engine_table* create(); 86 static int delete_all_rows(); 87 static ha_rows get_row_count(); 88 89 virtual int rnd_init(bool scan); 90 virtual int rnd_next(); 91 virtual int rnd_pos(const void *pos); 92 virtual void reset_position(void); 93 94 protected: 95 virtual int read_row_values(TABLE *table, 96 unsigned char *buf, 97 Field **fields, 98 bool read_all); 99 100 table_tiws_by_index_usage(); 101 102 public: ~table_tiws_by_index_usage()103 ~table_tiws_by_index_usage() 104 {} 105 106 protected: 107 void make_row(PFS_table_share *table_share, uint index); 108 109 private: 110 /** Table share lock. */ 111 static THR_LOCK m_table_lock; 112 /** Fields definition. */ 113 static TABLE_FIELD_DEF m_field_def; 114 115 /** Current row. */ 116 row_tiws_by_index_usage m_row; 117 /** True is the current row exists. */ 118 bool m_row_exists; 119 /** Current position. */ 120 pos_tiws_by_index_usage m_pos; 121 /** Next position. */ 122 pos_tiws_by_index_usage m_next_pos; 123 }; 124 125 /** @} */ 126 #endif 127