21 #include "my_global.h"
22 #include "my_pthread.h"
26 THR_LOCK table_host_cache::m_table_lock;
31 { C_STRING_WITH_LEN(
"IP") },
32 { C_STRING_WITH_LEN(
"varchar(64)") },
36 { C_STRING_WITH_LEN(
"HOST") },
37 { C_STRING_WITH_LEN(
"varchar(255)") },
41 { C_STRING_WITH_LEN(
"HOST_VALIDATED") },
42 { C_STRING_WITH_LEN(
"enum(\'YES\',\'NO\')") },
46 { C_STRING_WITH_LEN(
"SUM_CONNECT_ERRORS") },
47 { C_STRING_WITH_LEN(
"bigint(20)") },
51 { C_STRING_WITH_LEN(
"COUNT_HOST_BLOCKED_ERRORS") },
52 { C_STRING_WITH_LEN(
"bigint(20)") },
56 { C_STRING_WITH_LEN(
"COUNT_NAMEINFO_TRANSIENT_ERRORS") },
57 { C_STRING_WITH_LEN(
"bigint(20)") },
61 { C_STRING_WITH_LEN(
"COUNT_NAMEINFO_PERMANENT_ERRORS") },
62 { C_STRING_WITH_LEN(
"bigint(20)") },
66 { C_STRING_WITH_LEN(
"COUNT_FORMAT_ERRORS") },
67 { C_STRING_WITH_LEN(
"bigint(20)") },
71 { C_STRING_WITH_LEN(
"COUNT_ADDRINFO_TRANSIENT_ERRORS") },
72 { C_STRING_WITH_LEN(
"bigint(20)") },
76 { C_STRING_WITH_LEN(
"COUNT_ADDRINFO_PERMANENT_ERRORS") },
77 { C_STRING_WITH_LEN(
"bigint(20)") },
81 { C_STRING_WITH_LEN(
"COUNT_FCRDNS_ERRORS") },
82 { C_STRING_WITH_LEN(
"bigint(20)") },
86 { C_STRING_WITH_LEN(
"COUNT_HOST_ACL_ERRORS") },
87 { C_STRING_WITH_LEN(
"bigint(20)") },
91 { C_STRING_WITH_LEN(
"COUNT_NO_AUTH_PLUGIN_ERRORS") },
92 { C_STRING_WITH_LEN(
"bigint(20)") },
96 { C_STRING_WITH_LEN(
"COUNT_AUTH_PLUGIN_ERRORS") },
97 { C_STRING_WITH_LEN(
"bigint(20)") },
101 { C_STRING_WITH_LEN(
"COUNT_HANDSHAKE_ERRORS") },
102 { C_STRING_WITH_LEN(
"bigint(20)") },
106 { C_STRING_WITH_LEN(
"COUNT_PROXY_USER_ERRORS") },
107 { C_STRING_WITH_LEN(
"bigint(20)") },
111 { C_STRING_WITH_LEN(
"COUNT_PROXY_USER_ACL_ERRORS") },
112 { C_STRING_WITH_LEN(
"bigint(20)") },
116 { C_STRING_WITH_LEN(
"COUNT_AUTHENTICATION_ERRORS") },
117 { C_STRING_WITH_LEN(
"bigint(20)") },
121 { C_STRING_WITH_LEN(
"COUNT_SSL_ERRORS") },
122 { C_STRING_WITH_LEN(
"bigint(20)") },
126 { C_STRING_WITH_LEN(
"COUNT_MAX_USER_CONNECTIONS_ERRORS") },
127 { C_STRING_WITH_LEN(
"bigint(20)") },
131 { C_STRING_WITH_LEN(
"COUNT_MAX_USER_CONNECTIONS_PER_HOUR_ERRORS") },
132 { C_STRING_WITH_LEN(
"bigint(20)") },
136 { C_STRING_WITH_LEN(
"COUNT_DEFAULT_DATABASE_ERRORS") },
137 { C_STRING_WITH_LEN(
"bigint(20)") },
141 { C_STRING_WITH_LEN(
"COUNT_INIT_CONNECT_ERRORS") },
142 { C_STRING_WITH_LEN(
"bigint(20)") },
146 { C_STRING_WITH_LEN(
"COUNT_LOCAL_ERRORS") },
147 { C_STRING_WITH_LEN(
"bigint(20)") },
151 { C_STRING_WITH_LEN(
"COUNT_UNKNOWN_ERRORS") },
152 { C_STRING_WITH_LEN(
"bigint(20)") },
156 { C_STRING_WITH_LEN(
"FIRST_SEEN") },
157 { C_STRING_WITH_LEN(
"timestamp") },
161 { C_STRING_WITH_LEN(
"LAST_SEEN") },
162 { C_STRING_WITH_LEN(
"timestamp") },
166 { C_STRING_WITH_LEN(
"FIRST_ERROR_SEEN") },
167 { C_STRING_WITH_LEN(
"timestamp") },
171 { C_STRING_WITH_LEN(
"LAST_ERROR_SEEN") },
172 { C_STRING_WITH_LEN(
"timestamp") },
178 table_host_cache::m_field_def=
184 { C_STRING_WITH_LEN(
"host_cache") },
186 &table_host_cache::create,
188 table_host_cache::delete_all_rows,
202 THD *thd= current_thd;
203 DBUG_ASSERT(thd != NULL);
210 table_host_cache::delete_all_rows(
void)
217 hostname_cache_refresh();
221 table_host_cache::table_host_cache()
223 m_all_rows(NULL), m_row_count(0),
224 m_row(NULL), m_pos(0), m_next_pos(0)
227 void table_host_cache::materialize(THD *thd)
236 DBUG_ASSERT(m_all_rows == NULL);
237 DBUG_ASSERT(m_row_count == 0);
239 hostname_cache_lock();
241 size= hostname_cache_size();
258 first= hostname_cache_first();
261 while ((current != NULL) && (index < size))
263 make_row(current, row);
266 current= current->next();
273 hostname_cache_unlock();
278 row->m_ip_length= strlen(entry->
ip_key);
281 if (row->m_hostname_length > 0)
330 m_pos.
set_at(&m_next_pos);
332 if (m_pos.
m_index < m_row_count)
334 m_row= &m_all_rows[m_pos.
m_index];
341 result= HA_ERR_END_OF_FILE;
350 DBUG_ASSERT(m_pos.
m_index < m_row_count);
351 m_row= &m_all_rows[m_pos.
m_index];
365 DBUG_ASSERT(table->s->null_bytes == 1);
368 for (; (f= *fields) ; fields++)
370 if (read_all || bitmap_is_set(table->read_set, f->field_index))
372 switch(f->field_index)
378 if (m_row->m_hostname_length > 0)