1 /* Copyright (c) 2015, 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ 22 23 #ifndef TABLE_SESSION_STATUS_H 24 #define TABLE_SESSION_STATUS_H 25 26 /** 27 @file storage/perfschema/table_session_status.h 28 Table SESSION_STATUS (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 #include "pfs_variable.h" 37 /** 38 @addtogroup Performance_schema_tables 39 @{ 40 */ 41 42 /** 43 A row of table 44 PERFORMANCE_SCHEMA.SESSION_STATUS. 45 */ 46 struct row_session_status 47 { 48 /** Column THREAD_ID. */ 49 ulonglong m_thread_internal_id; 50 /** Column VARIABLE_NAME. */ 51 PFS_variable_name_row m_variable_name; 52 /** Column VARIABLE_VALUE. */ 53 PFS_variable_value_row m_variable_value; 54 }; 55 56 /** 57 Store and retrieve table state information for queries that reinstantiate 58 the table object. 59 */ 60 class table_session_status_context : public PFS_table_context 61 { 62 public: table_session_status_context(ulonglong current_version,bool restore)63 table_session_status_context(ulonglong current_version, bool restore) : 64 PFS_table_context(current_version, restore, THR_PFS_SS) { } 65 }; 66 67 /** Table PERFORMANCE_SCHEMA.SESSION_STATUS. */ 68 class table_session_status : public PFS_engine_table 69 { 70 typedef PFS_simple_index pos_t; 71 72 public: 73 /** Table share */ 74 static PFS_engine_table_share m_share; 75 static PFS_engine_table* create(); 76 static ha_rows get_row_count(); 77 78 virtual int rnd_init(bool scan); 79 virtual int rnd_next(); 80 virtual int rnd_pos(const void *pos); 81 virtual void reset_position(void); 82 83 protected: 84 virtual int read_row_values(TABLE *table, 85 unsigned char *buf, 86 Field **fields, 87 bool read_all); 88 table_session_status(); 89 90 public: ~table_session_status()91 ~table_session_status() 92 {} 93 94 protected: 95 void make_row(const Status_variable *status_var); 96 97 private: 98 /** Table share lock. */ 99 static THR_LOCK m_table_lock; 100 /** Fields definition. */ 101 static TABLE_FIELD_DEF m_field_def; 102 103 /** Current THD variables. */ 104 PFS_status_variable_cache m_status_cache; 105 /** Current row. */ 106 row_session_status m_row; 107 /** True if the current row exists. */ 108 bool m_row_exists; 109 /** Current position. */ 110 pos_t m_pos; 111 /** Next position. */ 112 pos_t m_next_pos; 113 114 /** Table context with global status array version. */ 115 table_session_status_context *m_context; 116 }; 117 118 /** @} */ 119 #endif 120