1 /* Copyright (c) 2012, 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, Suite 500, Boston, MA 02110-1335 USA */ 22 23 #ifndef TABLE_TABLE_HANDLES_H 24 #define TABLE_TABLE_HANDLES_H 25 26 /** 27 @file storage/perfschema/table_table_handles.h 28 Table TABLE_HANDLES (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_HANDLES. 45 */ 46 struct row_table_handles 47 { 48 /** Column OBJECT_TYPE, SCHEMA_NAME, OBJECT_NAME. */ 49 PFS_object_row m_object; 50 /** Column OBJECT_INSTANCE_BEGIN. */ 51 const void *m_identity; 52 /** Column OWNER_THREAD_ID. */ 53 ulonglong m_owner_thread_id; 54 /** Column OWNER_EVENT_ID. */ 55 ulonglong m_owner_event_id; 56 /** Column INTERNAL_LOCK. */ 57 PFS_TL_LOCK_TYPE m_internal_lock; 58 /** Column EXTERNAL_LOCK. */ 59 PFS_TL_LOCK_TYPE m_external_lock; 60 }; 61 62 /** Table PERFORMANCE_SCHEMA.TABLE_HANDLES. */ 63 class table_table_handles : public PFS_engine_table 64 { 65 public: 66 /** Table share */ 67 static PFS_engine_table_share m_share; 68 static PFS_engine_table* create(); 69 static ha_rows get_row_count(); 70 71 virtual int rnd_init(bool scan); 72 virtual int rnd_next(); 73 virtual int rnd_pos(const void *pos); 74 virtual void reset_position(void); 75 76 protected: 77 virtual int read_row_values(TABLE *table, 78 unsigned char *buf, 79 Field **fields, 80 bool read_all); 81 82 table_table_handles(); 83 84 public: ~table_table_handles()85 ~table_table_handles() 86 {} 87 88 protected: 89 void make_row(PFS_table *table); 90 91 private: 92 /** Table share lock. */ 93 static THR_LOCK m_table_lock; 94 /** Fields definition. */ 95 static TABLE_FIELD_DEF m_field_def; 96 97 /** Current row. */ 98 row_table_handles m_row; 99 /** True is the current row exists. */ 100 bool m_row_exists; 101 /** Current position. */ 102 PFS_simple_index m_pos; 103 /** Next position. */ 104 PFS_simple_index m_next_pos; 105 }; 106 107 /** @} */ 108 #endif 109