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_THREADS_H 24 #define TABLE_THREADS_H 25 26 #include "pfs_column_types.h" 27 #include "cursor_by_thread.h" 28 29 struct PFS_thread; 30 31 /** 32 \addtogroup Performance_schema_tables 33 @{ 34 */ 35 36 /** 37 A row of PERFORMANCE_SCHEMA.THREADS. 38 */ 39 struct row_threads 40 { 41 /** Column THREAD_ID. */ 42 ulonglong m_thread_internal_id; 43 /** Column PROCESSLIST_ID. */ 44 ulonglong m_processlist_id; 45 /** Column NAME. */ 46 const char* m_name; 47 /** Length in bytes of @c m_name. */ 48 uint m_name_length; 49 /** Column PROCESSLIST_USER. */ 50 char m_username[USERNAME_LENGTH]; 51 /** Length in bytes of @c m_username. */ 52 uint m_username_length; 53 /** Column PROCESSLIST_HOST. */ 54 char m_hostname[HOSTNAME_LENGTH]; 55 /** Length in bytes of @c m_hostname. */ 56 uint m_hostname_length; 57 /** Column PROCESSLIST_DB. */ 58 char m_dbname[NAME_LEN]; 59 /** Length in bytes of @c m_dbname. */ 60 uint m_dbname_length; 61 /** Column PROCESSLIST_COMMAND. */ 62 int m_command; 63 /** Column PROCESSLIST_TIME. */ 64 time_t m_start_time; 65 /** Column PROCESSLIST_STATE. */ 66 const char* m_processlist_state_ptr; 67 /** Length in bytes of @c m_processlist_state_ptr. */ 68 uint m_processlist_state_length; 69 /** Column PROCESSLIST_INFO. */ 70 const char* m_processlist_info_ptr; 71 /** Length in bytes of @c m_processlist_info_ptr. */ 72 uint m_processlist_info_length; 73 /** Column INSTRUMENTED (read). */ 74 bool m_enabled; 75 /** Column HISTORY (read). */ 76 bool m_history; 77 /** INSTRUMENTED and HISTORY (write). */ 78 PFS_thread *m_psi; 79 /** Column PARENT_THREAD_ID. */ 80 ulonglong m_parent_thread_internal_id; 81 /** Column CONNECTION_TYPE. */ 82 enum_vio_type m_connection_type; 83 /** Column THREAD_OS_ID. */ 84 my_thread_os_id_t m_thread_os_id; 85 }; 86 87 /** Table PERFORMANCE_SCHEMA.THREADS. */ 88 class table_threads : public cursor_by_thread 89 { 90 public: 91 /** Table share */ 92 static PFS_engine_table_share m_share; 93 /** Table builder */ 94 static PFS_engine_table* create(); 95 96 protected: 97 virtual int read_row_values(TABLE *table, 98 unsigned char *buf, 99 Field **fields, 100 bool read_all); 101 102 103 virtual int update_row_values(TABLE *table, 104 const unsigned char *old_buf, 105 unsigned char *new_buf, 106 Field **fields); 107 108 protected: 109 table_threads(); 110 111 public: ~table_threads()112 ~table_threads() 113 {} 114 115 private: 116 virtual void make_row(PFS_thread *pfs); 117 118 /** Table share lock. */ 119 static THR_LOCK m_table_lock; 120 /** Fields definition. */ 121 static TABLE_FIELD_DEF m_field_def; 122 123 /** Current row. */ 124 row_threads m_row; 125 /** True if the current row exists. */ 126 bool m_row_exists; 127 }; 128 129 /** @} */ 130 #endif 131