MySQL 8.0.39
Source Code Documentation
table_host_cache.h
Go to the documentation of this file.
1/* Copyright (c) 2011, 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_HOST_CACHE_H
25#define TABLE_HOST_CACHE_H
26
27/**
28 @file storage/perfschema/table_host_cache.h
29 Table HOST_CACHE (declarations).
30*/
31
32#include <sys/types.h>
33
34#include "my_base.h"
35#include "my_inttypes.h"
38
39class Field;
40class Host_entry;
41class Plugin_table;
42class THD;
43struct TABLE;
44struct THR_LOCK;
45
46/**
47 @addtogroup performance_schema_tables
48 @{
49*/
50
51/** A row of PERFORMANCE_SCHEMA.HOST_CACHE. */
53 /** Column IP. */
54 char m_ip[64];
56 /** Column HOST. */
59 /** Column HOST_VALIDATED. */
61 /** Column SUM_CONNECT_ERRORS. */
63 /** Column COUNT_HOST_BLOCKED_ERRORS. */
65 /** Column COUNT_NAMEINFO_TRANSIENT_ERRORS. */
67 /** Column COUNT_NAMEINFO_PERMANENT_ERRORS. */
69 /** Column COUNT_FORMAT_ERRORS. */
71 /** Column COUNT_ADDRINFO_TRANSIENT_ERRORS. */
73 /** Column COUNT_ADDRINFO_PERMANENT_ERRORS. */
75 /** Column COUNT_FCRDNS_ERRORS. */
77 /** Column COUNT_HOST_ACL_ERRORS. */
79 /** Column COUNT_NO_AUTH_PLUGIN_ERRORS. */
81 /** Column COUNT_AUTH_PLUGIN_ERRORS. */
83 /** Column COUNT_HANDSHAKE_ERRORS. */
85 /** Column COUNT_PROXY_USER_ERRORS. */
87 /** Column COUNT_PROXY_USER_ACL_ERRORS. */
89 /** Column COUNT_AUTHENTICATION_ERRORS. */
91 /** Column COUNT_SSL_ERRORS. */
93 /** Column COUNT_MAX_USER_CONNECTION_ERRORS. */
95 /** Column COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS. */
97 /** Column COUNT_DEFAULT_DATABASE_ERRORS. */
99 /** Column COUNT_INIT_CONNECT_ERRORS. */
101 /** Column COUNT_LOCAL_ERRORS. */
103 /** Column COUNT_UNKNOWN_ERRORS. */
105 /** Column FIRST_SEEN. */
107 /** Column LAST_SEEN. */
109 /** Column FIRST_ERROR_SEEN. */
111 /** Column LAST_ERROR_SEEN. */
113};
114
116 public:
118 : PFS_engine_index(key_1) {}
119
120 ~PFS_index_host_cache() override = default;
121
122 virtual bool match(const row_host_cache *row) = 0;
123};
124
126 public:
128
129 ~PFS_index_host_cache_by_ip() override = default;
130
131 bool match(const row_host_cache *row) override;
132
133 private:
135};
136
138 public:
140 : PFS_index_host_cache(&m_key), m_key("HOST") {}
141
142 ~PFS_index_host_cache_by_host() override = default;
143
144 bool match(const row_host_cache *row) override;
145
146 private:
148};
149
150/** Table PERFORMANCE_SCHEMA.HOST_CACHE. */
152 public:
153 /** Table share. */
156 static int delete_all_rows();
157 static ha_rows get_row_count();
158
159 void reset_position() override;
160
161 int rnd_next() override;
162 int rnd_pos(const void *pos) override;
163
164 int index_init(uint idx, bool sorted) override;
165 int index_next() override;
166
167 protected:
168 int read_row_values(TABLE *table, unsigned char *buf, Field **fields,
169 bool read_all) override;
171
172 public:
173 ~table_host_cache() override = default;
174
175 private:
176 void materialize(THD *thd);
177 static int make_row(Host_entry *entry, row_host_cache *row);
178
179 /** Table share lock. */
181 /** Table definition. */
183
186 /** Current row. */
188 /** Current position. */
190 /** Next position. */
192
194};
195
196/** @} */
197#endif
Definition: field.h:575
An entry in the hostname hash table cache.
Definition: hostname_cache.h:126
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_host_cache.h:137
bool match(const row_host_cache *row) override
Definition: table_host_cache.cc:109
PFS_index_host_cache_by_host()
Definition: table_host_cache.h:139
~PFS_index_host_cache_by_host() override=default
PFS_key_host m_key
Definition: table_host_cache.h:147
Definition: table_host_cache.h:125
PFS_index_host_cache_by_ip()
Definition: table_host_cache.h:127
bool match(const row_host_cache *row) override
Definition: table_host_cache.cc:100
PFS_key_ip m_key
Definition: table_host_cache.h:134
~PFS_index_host_cache_by_ip() override=default
Definition: table_host_cache.h:115
PFS_index_host_cache(PFS_engine_key *key_1)
Definition: table_host_cache.h:117
~PFS_index_host_cache() override=default
virtual bool match(const row_host_cache *row)=0
Definition: table_helper.h:1485
Definition: table_helper.h:1592
Class to hold information regarding a table to be created on behalf of a plugin.
Definition: plugin_table.h:40
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
Table PERFORMANCE_SCHEMA.HOST_CACHE.
Definition: table_host_cache.h:151
int rnd_pos(const void *pos) override
Fetch a row by position.
Definition: table_host_cache.cc:267
static PFS_engine_table_share m_share
Table share.
Definition: table_host_cache.h:154
PFS_simple_index m_next_pos
Next position.
Definition: table_host_cache.h:191
table_host_cache()
Definition: table_host_cache.cc:146
int index_next() override
Find key in index, read record.
Definition: table_host_cache.cc:294
static THR_LOCK m_table_lock
Table share lock.
Definition: table_host_cache.h:180
static Plugin_table m_table_def
Table definition.
Definition: table_host_cache.h:182
int rnd_next() override
Fetch the next row in this cursor.
Definition: table_host_cache.cc:250
row_host_cache * m_all_rows
Definition: table_host_cache.h:184
PFS_index_host_cache * m_opened_index
Definition: table_host_cache.h:193
static ha_rows get_row_count()
Definition: table_host_cache.cc:138
static int delete_all_rows()
Definition: table_host_cache.cc:128
void materialize(THD *thd)
Definition: table_host_cache.cc:154
row_host_cache * m_row
Current row.
Definition: table_host_cache.h:187
int index_init(uint idx, bool sorted) override
Definition: table_host_cache.cc:274
static PFS_engine_table * create(PFS_engine_table_share *)
Definition: table_host_cache.cc:118
~table_host_cache() override=default
static int make_row(Host_entry *entry, row_host_cache *row)
Definition: table_host_cache.cc:196
void reset_position() override
Reset the cursor position to the beginning of the table.
Definition: table_host_cache.cc:245
int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all) override
Read the current row values.
Definition: table_host_cache.cc:313
uint m_row_count
Definition: table_host_cache.h:185
PFS_simple_index m_pos
Current position.
Definition: table_host_cache.h:189
#define PSI_HOSTNAME_LENGTH
Definition: psi_thread_bits.h:464
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1140
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Definition: buf0block_hint.cc:30
Performance schema tables (declarations).
A PERFORMANCE_SCHEMA table share.
Definition: pfs_engine_table.h:358
Position of a cursor, for simple iterations.
Definition: pfs_engine_table.h:566
Definition: table.h:1399
Definition: thr_lock.h:139
Definition: completion_hash.h:35
A row of PERFORMANCE_SCHEMA.HOST_CACHE.
Definition: table_host_cache.h:52
ulonglong m_count_host_acl_errors
Column COUNT_HOST_ACL_ERRORS.
Definition: table_host_cache.h:78
ulonglong m_count_nameinfo_permanent_errors
Column COUNT_NAMEINFO_PERMANENT_ERRORS.
Definition: table_host_cache.h:68
char m_ip[64]
Column IP.
Definition: table_host_cache.h:54
uint m_hostname_length
Definition: table_host_cache.h:58
ulonglong m_count_max_user_connection_per_hour_errors
Column COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS.
Definition: table_host_cache.h:96
ulonglong m_count_init_connect_errors
Column COUNT_INIT_CONNECT_ERRORS.
Definition: table_host_cache.h:100
ulonglong m_count_ssl_errors
Column COUNT_SSL_ERRORS.
Definition: table_host_cache.h:92
ulonglong m_count_proxy_user_acl_errors
Column COUNT_PROXY_USER_ACL_ERRORS.
Definition: table_host_cache.h:88
ulonglong m_last_error_seen
Column LAST_ERROR_SEEN.
Definition: table_host_cache.h:112
ulonglong m_count_authentication_errors
Column COUNT_AUTHENTICATION_ERRORS.
Definition: table_host_cache.h:90
ulonglong m_count_no_auth_plugin_errors
Column COUNT_NO_AUTH_PLUGIN_ERRORS.
Definition: table_host_cache.h:80
ulonglong m_count_auth_plugin_errors
Column COUNT_AUTH_PLUGIN_ERRORS.
Definition: table_host_cache.h:82
ulonglong m_count_host_blocked_errors
Column COUNT_HOST_BLOCKED_ERRORS.
Definition: table_host_cache.h:64
ulonglong m_count_nameinfo_transient_errors
Column COUNT_NAMEINFO_TRANSIENT_ERRORS.
Definition: table_host_cache.h:66
ulonglong m_count_addrinfo_permanent_errors
Column COUNT_ADDRINFO_PERMANENT_ERRORS.
Definition: table_host_cache.h:74
ulonglong m_count_handshake_errors
Column COUNT_HANDSHAKE_ERRORS.
Definition: table_host_cache.h:84
ulonglong m_first_seen
Column FIRST_SEEN.
Definition: table_host_cache.h:106
char m_hostname[PSI_HOSTNAME_LENGTH]
Column HOST.
Definition: table_host_cache.h:57
ulonglong m_count_default_database_errors
Column COUNT_DEFAULT_DATABASE_ERRORS.
Definition: table_host_cache.h:98
ulonglong m_count_format_errors
Column COUNT_FORMAT_ERRORS.
Definition: table_host_cache.h:70
ulonglong m_first_error_seen
Column FIRST_ERROR_SEEN.
Definition: table_host_cache.h:110
ulonglong m_count_fcrdns_errors
Column COUNT_FCRDNS_ERRORS.
Definition: table_host_cache.h:76
bool m_host_validated
Column HOST_VALIDATED.
Definition: table_host_cache.h:60
ulonglong m_count_local_errors
Column COUNT_LOCAL_ERRORS.
Definition: table_host_cache.h:102
ulonglong m_sum_connect_errors
Column SUM_CONNECT_ERRORS.
Definition: table_host_cache.h:62
ulonglong m_count_addrinfo_transient_errors
Column COUNT_ADDRINFO_TRANSIENT_ERRORS.
Definition: table_host_cache.h:72
ulonglong m_count_max_user_connection_errors
Column COUNT_MAX_USER_CONNECTION_ERRORS.
Definition: table_host_cache.h:94
uint m_ip_length
Definition: table_host_cache.h:55
ulonglong m_last_seen
Column LAST_SEEN.
Definition: table_host_cache.h:108
ulonglong m_count_unknown_errors
Column COUNT_UNKNOWN_ERRORS.
Definition: table_host_cache.h:104
ulonglong m_count_proxy_user_errors
Column COUNT_PROXY_USER_ERRORS.
Definition: table_host_cache.h:86
Helpers to implement a performance schema table.
unsigned int uint
Definition: uca9-dump.cc:75