diff -Nru mysql-5.1.35/sql/hostname.cc mysql-5.1.35-known-hosts/sql/hostname.cc --- mysql-5.1.35/sql/hostname.cc 2009-05-14 20:34:57.000000000 +0900 +++ mysql-5.1.35-known-hosts/sql/hostname.cc 2009-06-30 22:03:15.000000000 +0900 @@ -276,3 +276,44 @@ add_wrong_ip(in); DBUG_RETURN(0); } + +bool fill_hostname_entries(THD* thd, TABLE *table) +{ + DBUG_ENTER("show_hostname_cache"); + if (hostname_cache == NULL) + goto err; + + CHARSET_INFO *cs= system_charset_info; + VOID(pthread_mutex_lock(&hostname_cache->lock)); + HASH *hash = &hostname_cache->cache; + uint idx, total = hash->records; + for (idx= 0; idx < total; idx++) + { + host_entry *ent= (class host_entry *) hash_element(hash, idx); + if(!ent) continue; + + restore_record(table, s->default_values); + + struct in_addr addr; + char in_str[40]; + bzero(in_str, sizeof(in_str)); + bcopy(ent->ip, &addr, sizeof(addr)); + my_inet_ntoa(addr, in_str); + table->field[0]->store(in_str, strlen(in_str), cs); + if(ent->hostname == NULL) + table->field[1]->set_null(); + else { + table->field[1]->set_notnull(); + table->field[1]->store(ent->hostname, strlen(ent->hostname), cs); + } + table->field[2]->store(ent->errors, TRUE); + if(schema_table_store_record(thd, table)) goto err; + } + + VOID(pthread_mutex_unlock(&hostname_cache->lock)); + DBUG_RETURN(FALSE); +err: + VOID(pthread_mutex_unlock(&hostname_cache->lock)); + DBUG_RETURN(TRUE); +} + diff -Nru mysql-5.1.35/sql/mysql_priv.h mysql-5.1.35-known-hosts/sql/mysql_priv.h --- mysql-5.1.35/sql/mysql_priv.h 2009-05-14 20:34:58.000000000 +0900 +++ mysql-5.1.35-known-hosts/sql/mysql_priv.h 2009-06-30 22:03:15.000000000 +0900 @@ -2283,6 +2283,7 @@ bool hostname_cache_init(); void hostname_cache_free(); void hostname_cache_refresh(void); +bool fill_hostname_entries(THD* thd, TABLE *table); /* sql_cache.cc */ extern bool sql_cache_init(); diff -Nru mysql-5.1.35/sql/sql_show.cc mysql-5.1.35-known-hosts/sql/sql_show.cc --- mysql-5.1.35/sql/sql_show.cc 2009-05-14 20:35:04.000000000 +0900 +++ mysql-5.1.35-known-hosts/sql/sql_show.cc 2009-06-30 22:03:15.000000000 +0900 @@ -203,6 +203,22 @@ DBUG_RETURN(0); } +/*************************************************************************** +** List all entries in host cache +***************************************************************************/ + +int fill_cached_hosts(THD *thd, TABLE_LIST *tables, COND *cond) +{ + DBUG_ENTER("fill_cached_hosts"); + TABLE *table= tables->table; + + if (fill_hostname_entries(thd, table)) + DBUG_RETURN(1); + + DBUG_RETURN(0); +} + + /*************************************************************************** ** List all Authors. @@ -6672,6 +6688,14 @@ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; +ST_FIELD_INFO host_cache_fields_info[]= +{ + {"IP_ADDRESS", 40, MYSQL_TYPE_STRING, 0, 0, "IP_Address", SKIP_OPEN_TABLE}, + {"HOSTNAME", HOSTNAME_LENGTH, MYSQL_TYPE_STRING, 0, 1, "Hostname", SKIP_OPEN_TABLE}, + {"ERRORS", 10, MYSQL_TYPE_LONG, 0, 0, "Errors", SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} +}; + /* Description of ST_FIELD_INFO in table.h @@ -6711,6 +6735,8 @@ {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table, get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0, OPEN_TABLE_ONLY}, + {"KNOWN_HOSTS", host_cache_fields_info, create_schema_table, + fill_cached_hosts, make_old_format, 0, -1, -1, 0, 0}, {"OPEN_TABLES", open_tables_fields_info, create_schema_table, fill_open_tables, make_old_format, 0, -1, -1, 1, 0}, {"PARTITIONS", partitions_fields_info, create_schema_table, diff -Nru mysql-5.1.35/sql/table.h mysql-5.1.35-known-hosts/sql/table.h --- mysql-5.1.35/sql/table.h 2009-05-14 20:35:05.000000000 +0900 +++ mysql-5.1.35-known-hosts/sql/table.h 2009-06-30 22:03:15.000000000 +0900 @@ -880,6 +880,7 @@ SCH_GLOBAL_STATUS, SCH_GLOBAL_VARIABLES, SCH_KEY_COLUMN_USAGE, + SCH_KNOWN_HOSTS, SCH_OPEN_TABLES, SCH_PARTITIONS, SCH_PLUGINS,