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, Suite 500, Boston, MA 02110-1335 USA */ 22 23 #ifndef TABLE_SETUP_INSTRUMENTS_H 24 #define TABLE_SETUP_INSTRUMENTS_H 25 26 /** 27 @file storage/perfschema/table_setup_instruments.h 28 Table SETUP_INSTRUMENTS (declarations). 29 */ 30 31 #include "pfs_instr_class.h" 32 #include "pfs_engine_table.h" 33 34 /** 35 @addtogroup Performance_schema_tables 36 @{ 37 */ 38 39 /** A row of PERFORMANCE_SCHEMA.SETUP_INSTRUMENTS. */ 40 struct row_setup_instruments 41 { 42 /** Columns NAME, ENABLED, TIMED. */ 43 PFS_instr_class *m_instr_class; 44 /** True if column ENABLED can be updated. */ 45 bool m_update_enabled; 46 /** True if column TIMED can be updated. */ 47 bool m_update_timed; 48 }; 49 50 /** Position of a cursor on PERFORMANCE_SCHEMA.SETUP_INSTRUMENTS. */ 51 struct pos_setup_instruments : public PFS_double_index 52 { 53 static const uint FIRST_VIEW= 1; 54 static const uint VIEW_MUTEX= 1; 55 static const uint VIEW_RWLOCK= 2; 56 static const uint VIEW_COND= 3; 57 static const uint VIEW_THREAD= 4; 58 static const uint VIEW_FILE= 5; 59 static const uint VIEW_TABLE= 6; 60 static const uint VIEW_STAGE= 7; 61 static const uint VIEW_STATEMENT= 8; 62 static const uint VIEW_TRANSACTION=9; 63 static const uint VIEW_SOCKET= 10; 64 static const uint VIEW_IDLE= 11; 65 static const uint VIEW_BUILTIN_MEMORY= 12; 66 static const uint VIEW_MEMORY= 13; 67 static const uint VIEW_METADATA= 14; 68 static const uint LAST_VIEW= 14; 69 pos_setup_instrumentspos_setup_instruments70 pos_setup_instruments() 71 : PFS_double_index(FIRST_VIEW, 1) 72 {} 73 resetpos_setup_instruments74 inline void reset(void) 75 { 76 m_index_1= FIRST_VIEW; 77 m_index_2= 1; 78 } 79 has_more_viewpos_setup_instruments80 inline bool has_more_view(void) 81 { return (m_index_1 <= LAST_VIEW); } 82 next_viewpos_setup_instruments83 inline void next_view(void) 84 { 85 m_index_1++; 86 m_index_2= 1; 87 } 88 }; 89 90 /** Table PERFORMANCE_SCHEMA.SETUP_INSTRUMENTS. */ 91 class table_setup_instruments : public PFS_engine_table 92 { 93 public: 94 /** Table share. */ 95 static PFS_engine_table_share m_share; 96 static PFS_engine_table* create(); 97 static ha_rows get_row_count(); 98 99 virtual int rnd_next(); 100 virtual int rnd_pos(const void *pos); 101 virtual void reset_position(void); 102 103 protected: 104 virtual int read_row_values(TABLE *table, 105 unsigned char *buf, 106 Field **fields, 107 bool read_all); 108 109 virtual int update_row_values(TABLE *table, 110 const unsigned char *old_buf, 111 unsigned char *new_buf, 112 Field **fields); 113 114 table_setup_instruments(); 115 116 public: ~table_setup_instruments()117 ~table_setup_instruments() 118 {} 119 120 private: 121 void make_row(PFS_instr_class *klass, bool update_enabled, bool update_timed); 122 123 /** Table share lock. */ 124 static THR_LOCK m_table_lock; 125 /** Fields definition. */ 126 static TABLE_FIELD_DEF m_field_def; 127 128 /** Current row. */ 129 row_setup_instruments m_row; 130 /** Current position. */ 131 pos_setup_instruments m_pos; 132 /** Next position. */ 133 pos_setup_instruments m_next_pos; 134 }; 135 136 /** @} */ 137 #endif 138