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