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