1 | /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
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 as published by |
5 | the Free Software Foundation; version 2 of the License. |
6 | |
7 | This program is distributed in the hope that it will be useful, |
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | GNU General Public License for more details. |
11 | |
12 | You should have received a copy of the GNU General Public License |
13 | along with this program; if not, write to the Free Software Foundation, |
14 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ |
15 | |
16 | #ifndef TABLE_SOCKET_INSTANCES_H |
17 | #define TABLE_SOCKET_INSTANCES_H |
18 | |
19 | /** |
20 | @file storage/perfschema/table_socket_instances.h |
21 | Table SOCKET_INSTANCES (declarations). |
22 | */ |
23 | |
24 | #include "pfs_column_types.h" |
25 | #include "pfs_engine_table.h" |
26 | |
27 | /** |
28 | @addtogroup Performance_schema_tables |
29 | @{ |
30 | */ |
31 | |
32 | /** A row of PERFORMANCE_SCHEMA.SOCKET_INSTANCES. */ |
33 | struct row_socket_instances |
34 | { |
35 | /** Column EVENT_NAME. */ |
36 | const char *m_event_name; |
37 | /** Length in bytes of @c m_event_name. */ |
38 | uint m_event_name_length; |
39 | /** Column OBJECT_INSTANCE_BEGIN */ |
40 | const void *m_identity; |
41 | /** Column THREAD_ID */ |
42 | ulonglong m_thread_id; |
43 | /** True if thread_is is set */ |
44 | bool m_thread_id_set; |
45 | /** Column SOCKET_ID */ |
46 | uint m_fd; |
47 | /** Socket ip address, IPV4 or IPV6 */ |
48 | char m_ip[INET6_ADDRSTRLEN+1]; |
49 | /** Length in bytes of @c m_ip. */ |
50 | uint m_ip_length; |
51 | /** Column PORT */ |
52 | uint m_port; |
53 | /** Socket state: ACTIVE or IDLE */ |
54 | PSI_socket_state m_state; |
55 | |
56 | row_socket_instances() {m_thread_id_set= false;} |
57 | }; |
58 | |
59 | /** Table PERFORMANCE_SCHEMA.SOCKET_INSTANCES. */ |
60 | class table_socket_instances : public PFS_engine_table |
61 | { |
62 | public: |
63 | /** Table share */ |
64 | static PFS_engine_table_share m_share; |
65 | static PFS_engine_table* create(); |
66 | |
67 | virtual int rnd_next(); |
68 | virtual int rnd_pos(const void *pos); |
69 | virtual void reset_position(void); |
70 | |
71 | private: |
72 | virtual int read_row_values(TABLE *table, |
73 | unsigned char *buf, |
74 | Field **fields, |
75 | bool read_all); |
76 | |
77 | table_socket_instances(); |
78 | |
79 | public: |
80 | ~table_socket_instances() |
81 | {} |
82 | |
83 | private: |
84 | void make_row(PFS_socket *pfs); |
85 | |
86 | /** Table share lock. */ |
87 | static THR_LOCK m_table_lock; |
88 | |
89 | /** Current row. */ |
90 | row_socket_instances m_row; |
91 | /** True if the current row exists. */ |
92 | bool m_row_exists; |
93 | /** Current position. */ |
94 | PFS_simple_index m_pos; |
95 | /** Next position. */ |
96 | PFS_simple_index m_next_pos; |
97 | }; |
98 | |
99 | /** @} */ |
100 | #endif |
101 | |