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, Fifth Floor, Boston, MA 02110-1301, USA */ 22 23 #ifndef TABLE_OBJECTS_SUMMARY_GLOBAL_BY_TYPE_H 24 #define TABLE_OBJECTS_SUMMARY_GLOBAL_BY_TYPE_H 25 26 /** 27 @file storage/perfschema/table_os_global_by_type.h 28 Table OBJECTS_SUMMARY_GLOBAL_BY_TYPE (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_program.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.OBJECTS_SUMMARY_GLOBAL_BY_TYPE. 46 */ 47 struct row_os_global_by_type 48 { 49 /** Column OBJECT_TYPE, SCHEMA_NAME, OBJECT_NAME. */ 50 PFS_object_row m_object; 51 52 /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */ 53 PFS_stat_row m_stat; 54 }; 55 56 /** 57 Position of a cursor on 58 PERFORMANCE_SCHEMA.OBJECTS_SUMMARY_GLOBAL_BY_TYPE. 59 Index 1 on object type 60 Index 2 on object instance (0 based) 61 */ 62 struct pos_os_global_by_type : public PFS_double_index, 63 public PFS_object_view_constants 64 { pos_os_global_by_typepos_os_global_by_type65 pos_os_global_by_type() 66 : PFS_double_index(FIRST_VIEW, 0) 67 {} 68 resetpos_os_global_by_type69 inline void reset(void) 70 { 71 m_index_1= FIRST_VIEW; 72 m_index_2= 0; 73 } 74 has_more_viewpos_os_global_by_type75 inline bool has_more_view(void) 76 { return (m_index_1 <= LAST_VIEW); } 77 next_viewpos_os_global_by_type78 inline void next_view(void) 79 { 80 m_index_1++; 81 m_index_2= 0; 82 } 83 }; 84 85 /** Table PERFORMANCE_SCHEMA.OBJECTS_SUMMARY_GLOBAL_BY_TYPE. */ 86 class table_os_global_by_type : public PFS_engine_table 87 { 88 public: 89 /** Table share */ 90 static PFS_engine_table_share m_share; 91 static PFS_engine_table* create(); 92 static int delete_all_rows(); 93 static ha_rows get_row_count(); 94 95 virtual int rnd_next(); 96 virtual int rnd_pos(const void *pos); 97 virtual void reset_position(void); 98 99 protected: 100 virtual int read_row_values(TABLE *table, 101 unsigned char *buf, 102 Field **fields, 103 bool read_all); 104 105 table_os_global_by_type(); 106 107 public: ~table_os_global_by_type()108 ~table_os_global_by_type() 109 {} 110 111 protected: 112 void make_table_row(PFS_table_share *table_share); 113 void make_program_row(PFS_program *pfs_program); 114 115 private: 116 /** Table share lock. */ 117 static THR_LOCK m_table_lock; 118 /** Fields definition. */ 119 static TABLE_FIELD_DEF m_field_def; 120 121 /** Current row. */ 122 row_os_global_by_type m_row; 123 /** True is the current row exists. */ 124 bool m_row_exists; 125 /** Current position. */ 126 pos_os_global_by_type m_pos; 127 /** Next position. */ 128 pos_os_global_by_type m_next_pos; 129 }; 130 131 132 /** @} */ 133 #endif 134