diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2014-12-28 19:42:17 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2014-12-28 19:46:18 +0400 |
commit | 6dbc48ca79e5fdd8d4022b00b862e08a4198155b (patch) | |
tree | 1904e477f09dd958af2b6696d4b7c8dbb0a1772d /sql/sql_test.cc | |
parent | 8883c54ac08a555bc7d9b09395f49893ad4d80b5 (diff) | |
download | mariadb-git-6dbc48ca79e5fdd8d4022b00b862e08a4198155b.tar.gz |
MDEV-7324 - Lock-free hash for table definition cache
Diffstat (limited to 'sql/sql_test.cc')
-rw-r--r-- | sql/sql_test.cc | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 8992ff24a1e..cad2bf4ba56 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -76,35 +76,37 @@ print_where(COND *cond,const char *info, enum_query_type query_type) /* This is for debugging purposes */ -static void print_cached_tables(void) +static my_bool print_cached_tables_callback(TDC_element *element, + void *arg __attribute__((unused))) { - TABLE_SHARE *share; TABLE *entry; - TDC_iterator tdc_it; + mysql_mutex_lock(&element->LOCK_table_share); + TDC_element::All_share_tables_list::Iterator it(element->all_tables); + while ((entry= it++)) + { + THD *in_use= entry->in_use; + printf("%-14.14s %-32s%6ld%8ld%6d %s\n", + entry->s->db.str, entry->s->table_name.str, element->version, + in_use ? in_use->thread_id : 0, + entry->db_stat ? 1 : 0, + in_use ? lock_descriptions[(int)entry->reginfo.lock_type] : + "Not in use"); + } + mysql_mutex_unlock(&element->LOCK_table_share); + return FALSE; +} + + +static void print_cached_tables(void) +{ compile_time_assert(TL_WRITE_ONLY+1 == array_elements(lock_descriptions)); /* purecov: begin tested */ puts("DB Table Version Thread Open Lock"); - tdc_it.init(); - while ((share= tdc_it.next())) - { - mysql_mutex_lock(&share->tdc.LOCK_table_share); - TABLE_SHARE::All_share_tables_list::Iterator it(share->tdc.all_tables); - while ((entry= it++)) - { - THD *in_use= entry->in_use; - printf("%-14.14s %-32s%6ld%8ld%6d %s\n", - entry->s->db.str, entry->s->table_name.str, entry->s->tdc.version, - in_use ? in_use->thread_id : 0, - entry->db_stat ? 1 : 0, - in_use ? lock_descriptions[(int)entry->reginfo.lock_type] : - "Not in use"); - } - mysql_mutex_unlock(&share->tdc.LOCK_table_share); - } - tdc_it.deinit(); + tdc_iterate(0, (my_hash_walk_action) print_cached_tables_callback, NULL, true); + printf("\nCurrent refresh version: %ld\n", tdc_refresh_version()); fflush(stdout); /* purecov: end */ |