1 /* Copyright (c) 2008, 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 Foundation, 21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ 22 23 #ifndef TABLE_ALL_INSTR_H 24 #define TABLE_ALL_INSTR_H 25 26 /** 27 @file storage/perfschema/table_all_instr.h 28 Abstract tables for all instruments (declarations). 29 */ 30 31 #include "pfs_instr_class.h" 32 #include "pfs_instr.h" 33 #include "pfs_engine_table.h" 34 #include "table_helper.h" 35 36 /** 37 @addtogroup Performance_schema_tables 38 @{ 39 */ 40 41 /** Position of a cursor on table_all_instr. */ 42 struct pos_all_instr : public PFS_double_index, 43 public PFS_instrument_view_constants 44 { pos_all_instrpos_all_instr45 pos_all_instr() 46 : PFS_double_index(FIRST_VIEW, 0) 47 {} 48 resetpos_all_instr49 inline void reset(void) 50 { 51 m_index_1= FIRST_VIEW; 52 m_index_2= 0; 53 } 54 has_more_viewpos_all_instr55 inline bool has_more_view(void) 56 { return (m_index_1 <= LAST_VIEW); } 57 next_viewpos_all_instr58 inline void next_view(void) 59 { 60 m_index_1++; 61 m_index_2= 0; 62 } 63 }; 64 65 /** 66 Abstract table, a union of all instrumentations instances. 67 This table is a union of: 68 - a view on all mutex instances, 69 - a view on all rwlock instances, 70 - a view on all cond instances, 71 - a view on all file instances, 72 - a view on all socket instances 73 */ 74 class table_all_instr : public PFS_engine_table 75 { 76 public: 77 static ha_rows get_row_count(); 78 79 virtual int rnd_next(); 80 virtual int rnd_pos(const void *pos); 81 virtual void reset_position(void); 82 83 protected: 84 table_all_instr(const PFS_engine_table_share *share); 85 86 public: ~table_all_instr()87 ~table_all_instr() 88 {} 89 90 protected: 91 /** 92 Build a row in the mutex instance view. 93 @param pfs the mutex instance 94 */ 95 virtual void make_mutex_row(PFS_mutex *pfs)= 0; 96 /** 97 Build a row in the rwlock instance view. 98 @param pfs the rwlock instance 99 */ 100 virtual void make_rwlock_row(PFS_rwlock *pfs)= 0; 101 /** 102 Build a row in the condition instance view. 103 @param pfs the condition instance 104 */ 105 virtual void make_cond_row(PFS_cond *pfs)= 0; 106 /** 107 Build a row in the file instance view. 108 @param pfs the file instance 109 */ 110 virtual void make_file_row(PFS_file *pfs)= 0; 111 /** 112 Build a row in the socket instance view. 113 @param pfs the socket instance 114 */ 115 virtual void make_socket_row(PFS_socket *pfs)= 0; 116 117 /** Current position. */ 118 pos_all_instr m_pos; 119 /** Next position. */ 120 pos_all_instr m_next_pos; 121 }; 122 123 /** @} */ 124 #endif 125