1 /* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 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 table_share_array (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 has_more_tablepos_tiws_by_index_usage72 inline bool has_more_table(void) 73 { 74 return (m_index_1 < table_share_max); 75 } 76 next_tablepos_tiws_by_index_usage77 inline void next_table(void) 78 { 79 m_index_1++; 80 m_index_2= 0; 81 } 82 }; 83 84 /** Table PERFORMANCE_SCHEMA.TABLE_IO_WAIT_SUMMARY_BY_INDEX. */ 85 class table_tiws_by_index_usage : public PFS_engine_table 86 { 87 public: 88 /** Table share */ 89 static PFS_engine_table_share m_share; 90 static PFS_engine_table* create(); 91 static int delete_all_rows(); 92 93 virtual int rnd_init(bool scan); 94 virtual int rnd_next(); 95 virtual int rnd_pos(const void *pos); 96 virtual void reset_position(void); 97 98 protected: 99 virtual int read_row_values(TABLE *table, 100 unsigned char *buf, 101 Field **fields, 102 bool read_all); 103 104 table_tiws_by_index_usage(); 105 106 public: ~table_tiws_by_index_usage()107 ~table_tiws_by_index_usage() 108 {} 109 110 protected: 111 void make_row(PFS_table_share *table_share, uint index); 112 113 private: 114 /** Table share lock. */ 115 static THR_LOCK m_table_lock; 116 /** Fields definition. */ 117 static TABLE_FIELD_DEF m_field_def; 118 119 /** Current row. */ 120 row_tiws_by_index_usage m_row; 121 /** True is the current row exists. */ 122 bool m_row_exists; 123 /** Current position. */ 124 pos_tiws_by_index_usage m_pos; 125 /** Next position. */ 126 pos_tiws_by_index_usage m_next_pos; 127 }; 128 129 /** @} */ 130 #endif 131