MySQL 9.0.0
Source Code Documentation
table_socket_instances.h
Go to the documentation of this file.
1/* Copyright (c) 2008, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef TABLE_SOCKET_INSTANCES_H
25#define TABLE_SOCKET_INSTANCES_H
26
27/**
28 @file storage/perfschema/table_socket_instances.h
29 Table SOCKET_INSTANCES (declarations).
30*/
31
32#include "my_config.h"
33
34#ifdef HAVE_NETINET_IN_H
35#include <netinet/in.h>
36#endif
37#include <sys/types.h>
38
39#include "my_base.h"
40#include "my_inttypes.h"
44
45class Field;
46class Plugin_table;
47struct PFS_socket;
48struct TABLE;
49struct THR_LOCK;
50
51/**
52 @addtogroup performance_schema_tables
53 @{
54*/
55
56/** A row of PERFORMANCE_SCHEMA.SOCKET_INSTANCES. */
58 /** Column EVENT_NAME. */
59 const char *m_event_name{nullptr};
60 /** Length in bytes of @c m_event_name. */
62 /** Column OBJECT_INSTANCE_BEGIN */
63 const void *m_identity{nullptr};
64 /** Column THREAD_ID */
66 /** True if thread_is is set */
67 bool m_thread_id_set{false};
68 /** Column SOCKET_ID */
69 uint m_fd{0};
70 /** Socket ip address, IPV4 or IPV6 */
71 char m_ip[INET6_ADDRSTRLEN + 1];
72 /** Length in bytes of @c m_ip. */
73 uint m_ip_length{0};
74 /** Column PORT */
75 uint m_port{0};
76 /** Socket state: ACTIVE or IDLE */
78};
79
81 public:
83 : PFS_engine_index(key_1) {}
84
86 : PFS_engine_index(key_1, key_2) {}
87
88 ~PFS_index_socket_instances() override = default;
89
90 virtual bool match(const PFS_socket *pfs) = 0;
91};
92
95 public:
97 : PFS_index_socket_instances(&m_key), m_key("OBJECT_INSTANCE_BEGIN") {}
98
100
101 bool match(const PFS_socket *pfs) override;
102
103 private:
105};
106
108 public:
110 : PFS_index_socket_instances(&m_key), m_key("THREAD_ID") {}
111
113
114 bool match(const PFS_socket *pfs) override;
115
116 private:
118};
119
121 public:
123 : PFS_index_socket_instances(&m_key), m_key("SOCKET_ID") {}
124
126
127 bool match(const PFS_socket *pfs) override;
128
129 private:
131};
132
135 public:
138 m_key_1("IP"),
139 m_key_2("PORT") {}
140
142
143 bool match(const PFS_socket *pfs) override;
144
145 private:
148};
149
150/** Table PERFORMANCE_SCHEMA.SOCKET_INSTANCES. */
152 public:
153 /** Table share */
156 static ha_rows get_row_count();
157
158 void reset_position() override;
159
160 int rnd_next() override;
161 int rnd_pos(const void *pos) override;
162
163 int index_init(uint idx, bool sorted) override;
164 int index_next() override;
165
166 private:
167 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
168 bool read_all) override;
170
171 public:
172 ~table_socket_instances() override = default;
173
174 protected:
175 int make_row(PFS_socket *pfs);
176
177 /** Table share lock. */
179 /** Table definition. */
181
182 /** Current row. */
184 /** Current position. */
186 /** Next position. */
188
190};
191
192/** @} */
193#endif
Definition: field.h:577
Definition: pfs_engine_table.h:300
Definition: pfs_engine_table.h:268
An abstract PERFORMANCE_SCHEMA table.
Definition: pfs_engine_table.h:70
Definition: table_socket_instances.h:94
bool match(const PFS_socket *pfs) override
Definition: table_socket_instances.cc:85
~PFS_index_socket_instances_by_instance() override=default
PFS_index_socket_instances_by_instance()
Definition: table_socket_instances.h:96
PFS_key_object_instance m_key
Definition: table_socket_instances.h:104
Definition: table_socket_instances.h:134
PFS_key_port m_key_2
Definition: table_socket_instances.h:147
PFS_key_ip m_key_1
Definition: table_socket_instances.h:146
~PFS_index_socket_instances_by_ip_port() override=default
PFS_index_socket_instances_by_ip_port()
Definition: table_socket_instances.h:136
bool match(const PFS_socket *pfs) override
Definition: table_socket_instances.cc:112
Definition: table_socket_instances.h:120
bool match(const PFS_socket *pfs) override
Definition: table_socket_instances.cc:103
PFS_key_socket_id m_key
Definition: table_socket_instances.h:130
~PFS_index_socket_instances_by_socket() override=default
PFS_index_socket_instances_by_socket()
Definition: table_socket_instances.h:122
Definition: table_socket_instances.h:107
PFS_key_thread_id m_key
Definition: table_socket_instances.h:117
bool match(const PFS_socket *pfs) override
Definition: table_socket_instances.cc:94
~PFS_index_socket_instances_by_thread() override=default
PFS_index_socket_instances_by_thread()
Definition: table_socket_instances.h:109
Definition: table_socket_instances.h:80
virtual bool match(const PFS_socket *pfs)=0
PFS_index_socket_instances(PFS_engine_key *key_1)
Definition: table_socket_instances.h:82
~PFS_index_socket_instances() override=default
PFS_index_socket_instances(PFS_engine_key *key_1, PFS_engine_key *key_2)
Definition: table_socket_instances.h:85
Definition: table_helper.h:1613
Definition: table_helper.h:1721
Definition: table_helper.h:1364
Definition: table_helper.h:1355
Definition: table_helper.h:1279
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
Table PERFORMANCE_SCHEMA.SOCKET_INSTANCES.
Definition: table_socket_instances.h:151
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_socket_instances.cc:160
static PFS_engine_table_share m_share
Table share.
Definition: table_socket_instances.h:154
int index_next() override
Find key in index, read record.
Definition: table_socket_instances.cc:199
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_socket_instances.cc:258
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_socket_instances.cc:141
static THR_LOCK m_table_lock
Table share lock.
Definition: table_socket_instances.h:178
PFS_simple_index m_next_pos
Next position.
Definition: table_socket_instances.h:187
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_socket_instances.cc:146
table_socket_instances()
Definition: table_socket_instances.cc:135
row_socket_instances m_row
Current row.
Definition: table_socket_instances.h:183
static ha_rows get_row_count()
Definition: table_socket_instances.cc:131
~table_socket_instances() override=default
PFS_simple_index m_pos
Current position.
Definition: table_socket_instances.h:185
static Plugin_table m_table_def
Table definition.
Definition: table_socket_instances.h:180
int make_row(PFS_socket *pfs)
Definition: table_socket_instances.cc:220
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_socket_instances.cc:127
PFS_index_socket_instances * m_opened_index
Definition: table_socket_instances.h:189
int index_init(uint idx, bool sorted) override
Definition: table_socket_instances.cc:173
PSI_socket_state
State of an instrumented socket.
Definition: psi_socket_bits.h:80
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1141
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
Definition: buf0block_hint.cc:30
Performance schema tables (declarations).
Performance schema instrumentation interface.
static const LEX_CSTRING pfs
Definition: sql_show_processlist.cc:66
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:358
Position of a cursor, for simple iterations.
Definition: pfs_engine_table.h:566
Instrumented socket implementation.
Definition: pfs_instr.h:289
Definition: table.h:1407
Definition: thr_lock.h:139
A row of PERFORMANCE_SCHEMA.SOCKET_INSTANCES.
Definition: table_socket_instances.h:57
PSI_socket_state m_state
Socket state: ACTIVE or IDLE.
Definition: table_socket_instances.h:77
const void * m_identity
Column OBJECT_INSTANCE_BEGIN.
Definition: table_socket_instances.h:63
char m_ip[INET6_ADDRSTRLEN+1]
Socket ip address, IPV4 or IPV6.
Definition: table_socket_instances.h:71
uint m_ip_length
Length in bytes of m_ip.
Definition: table_socket_instances.h:73
uint m_port
Column PORT.
Definition: table_socket_instances.h:75
uint m_event_name_length
Length in bytes of m_event_name.
Definition: table_socket_instances.h:61
ulonglong m_thread_id
Column THREAD_ID.
Definition: table_socket_instances.h:65
const char * m_event_name
Column EVENT_NAME.
Definition: table_socket_instances.h:59
uint m_fd
Column SOCKET_ID.
Definition: table_socket_instances.h:69
bool m_thread_id_set
True if thread_is is set.
Definition: table_socket_instances.h:67
Helpers to implement a performance schema table.