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_SOCKET_INSTANCES_H 24 #define TABLE_SOCKET_INSTANCES_H 25 26 /** 27 @file storage/perfschema/table_socket_instances.h 28 Table SOCKET_INSTANCES (declarations). 29 */ 30 31 #include "pfs_column_types.h" 32 #include "pfs_engine_table.h" 33 34 /** 35 @addtogroup Performance_schema_tables 36 @{ 37 */ 38 39 /** A row of PERFORMANCE_SCHEMA.SOCKET_INSTANCES. */ 40 struct row_socket_instances 41 { 42 /** Column EVENT_NAME. */ 43 const char *m_event_name; 44 /** Length in bytes of @c m_event_name. */ 45 uint m_event_name_length; 46 /** Column OBJECT_INSTANCE_BEGIN */ 47 const void *m_identity; 48 /** Column THREAD_ID */ 49 ulonglong m_thread_id; 50 /** True if thread_is is set */ 51 bool m_thread_id_set; 52 /** Column SOCKET_ID */ 53 uint m_fd; 54 /** Socket ip address, IPV4 or IPV6 */ 55 char m_ip[INET6_ADDRSTRLEN+1]; 56 /** Length in bytes of @c m_ip. */ 57 uint m_ip_length; 58 /** Column PORT */ 59 uint m_port; 60 /** Socket state: ACTIVE or IDLE */ 61 PSI_socket_state m_state; 62 row_socket_instancesrow_socket_instances63 row_socket_instances() {m_thread_id_set= false;} 64 }; 65 66 /** Table PERFORMANCE_SCHEMA.SOCKET_INSTANCES. */ 67 class table_socket_instances : public PFS_engine_table 68 { 69 public: 70 /** Table share */ 71 static PFS_engine_table_share m_share; 72 static PFS_engine_table* create(); 73 static ha_rows get_row_count(); 74 75 virtual int rnd_next(); 76 virtual int rnd_pos(const void *pos); 77 virtual void reset_position(void); 78 79 private: 80 virtual int read_row_values(TABLE *table, 81 unsigned char *buf, 82 Field **fields, 83 bool read_all); 84 85 table_socket_instances(); 86 87 public: ~table_socket_instances()88 ~table_socket_instances() 89 {} 90 91 private: 92 void make_row(PFS_socket *pfs); 93 94 /** Table share lock. */ 95 static THR_LOCK m_table_lock; 96 /** Fields definition. */ 97 static TABLE_FIELD_DEF m_field_def; 98 99 /** Current row. */ 100 row_socket_instances m_row; 101 /** True if the current row exists. */ 102 bool m_row_exists; 103 /** Current position. */ 104 PFS_simple_index m_pos; 105 /** Next position. */ 106 PFS_simple_index m_next_pos; 107 }; 108 109 /** @} */ 110 #endif 111