1/* Copyright (c) 2011, 2012, 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_HOST_CACHE_H
17#define TABLE_HOST_CACHE_H
18
19/**
20 @file storage/perfschema/table_host_cache.h
21 Table HOST_CACHE (declarations).
22*/
23
24#include "pfs_column_types.h"
25#include "pfs_engine_table.h"
26
27class Host_entry;
28
29/**
30 @addtogroup Performance_schema_tables
31 @{
32*/
33
34/** A row of PERFORMANCE_SCHEMA.HOST_CACHE. */
35struct row_host_cache
36{
37 /** Column IP. */
38 char m_ip[64];
39 uint m_ip_length;
40 /** Column HOST. */
41 char m_hostname[255];
42 uint m_hostname_length;
43 /** Column HOST_VALIDATED. */
44 bool m_host_validated;
45 /** Column SUM_CONNECT_ERRORS. */
46 ulonglong m_sum_connect_errors;
47 /** Column COUNT_HOST_BLOCKED_ERRORS. */
48 ulonglong m_count_host_blocked_errors;
49 /** Column COUNT_NAMEINFO_TRANSIENT_ERRORS. */
50 ulonglong m_count_nameinfo_transient_errors;
51 /** Column COUNT_NAMEINFO_PERMANENT_ERRORS. */
52 ulonglong m_count_nameinfo_permanent_errors;
53 /** Column COUNT_FORMAT_ERRORS. */
54 ulonglong m_count_format_errors;
55 /** Column COUNT_ADDRINFO_TRANSIENT_ERRORS. */
56 ulonglong m_count_addrinfo_transient_errors;
57 /** Column COUNT_ADDRINFO_PERMANENT_ERRORS. */
58 ulonglong m_count_addrinfo_permanent_errors;
59 /** Column COUNT_FCRDNS_ERRORS. */
60 ulonglong m_count_fcrdns_errors;
61 /** Column COUNT_HOST_ACL_ERRORS. */
62 ulonglong m_count_host_acl_errors;
63 /** Column COUNT_NO_AUTH_PLUGIN_ERRORS. */
64 ulonglong m_count_no_auth_plugin_errors;
65 /** Column COUNT_AUTH_PLUGIN_ERRORS. */
66 ulonglong m_count_auth_plugin_errors;
67 /** Column COUNT_HANDSHAKE_ERRORS. */
68 ulonglong m_count_handshake_errors;
69 /** Column COUNT_PROXY_USER_ERRORS. */
70 ulonglong m_count_proxy_user_errors;
71 /** Column COUNT_PROXY_USER_ACL_ERRORS. */
72 ulonglong m_count_proxy_user_acl_errors;
73 /** Column COUNT_AUTHENTICATION_ERRORS. */
74 ulonglong m_count_authentication_errors;
75 /** Column COUNT_SSL_ERRORS. */
76 ulonglong m_count_ssl_errors;
77 /** Column COUNT_MAX_USER_CONNECTION_ERRORS. */
78 ulonglong m_count_max_user_connection_errors;
79 /** Column COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS. */
80 ulonglong m_count_max_user_connection_per_hour_errors;
81 /** Column COUNT_DEFAULT_DATABASE_ERRORS. */
82 ulonglong m_count_default_database_errors;
83 /** Column COUNT_INIT_CONNECT_ERRORS. */
84 ulonglong m_count_init_connect_errors;
85 /** Column COUNT_LOCAL_ERRORS. */
86 ulonglong m_count_local_errors;
87 /** Column COUNT_UNKNOWN_ERRORS. */
88 ulonglong m_count_unknown_errors;
89 /** Column FIRST_SEEN. */
90 ulonglong m_first_seen;
91 /** Column LAST_SEEN. */
92 ulonglong m_last_seen;
93 /** Column FIRST_ERROR_SEEN. */
94 ulonglong m_first_error_seen;
95 /** Column LAST_ERROR_SEEN. */
96 ulonglong m_last_error_seen;
97};
98
99/** Table PERFORMANCE_SCHEMA.HOST_CACHE. */
100class table_host_cache : public PFS_engine_table
101{
102public:
103 /** Table share. */
104 static PFS_engine_table_share m_share;
105 static PFS_engine_table* create();
106 static int delete_all_rows();
107
108 virtual int rnd_next();
109 virtual int rnd_pos(const void *pos);
110 virtual void reset_position(void);
111
112protected:
113 virtual int read_row_values(TABLE *table,
114 unsigned char *buf,
115 Field **fields,
116 bool read_all);
117
118 table_host_cache();
119
120public:
121 ~table_host_cache()
122 {}
123
124private:
125 void materialize(THD *thd);
126 static void make_row(Host_entry *entry, row_host_cache *row);
127
128 /** Table share lock. */
129 static THR_LOCK m_table_lock;
130
131 row_host_cache *m_all_rows;
132 uint m_row_count;
133 /** Current row. */
134 row_host_cache *m_row;
135 /** Current position. */
136 PFS_simple_index m_pos;
137 /** Next position. */
138 PFS_simple_index m_next_pos;
139};
140
141/** @} */
142#endif
143