summaryrefslogtreecommitdiff
path: root/sql/sql_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_test.cc')
-rw-r--r--sql/sql_test.cc71
1 files changed, 22 insertions, 49 deletions
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 3b382bfa50f..a18229daa51 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -16,11 +16,11 @@
/* Write some debug info */
-
+#include <my_global.h>
#include "sql_priv.h"
#include "unireg.h"
#include "sql_test.h"
-#include "sql_base.h" // table_def_cache, table_cache_count, unused_tables
+#include "sql_base.h"
#include "sql_show.h" // calc_sum_of_all_status
#include "sql_select.h"
#include "keycaches.h"
@@ -78,61 +78,35 @@ print_where(COND *cond,const char *info, enum_query_type query_type)
static void print_cached_tables(void)
{
- uint idx,count,unused;
TABLE_SHARE *share;
- TABLE *start_link, *lnk, *entry;
+ TABLE *entry;
+ TDC_iterator tdc_it;
compile_time_assert(TL_WRITE_ONLY+1 == array_elements(lock_descriptions));
/* purecov: begin tested */
- mysql_mutex_lock(&LOCK_open);
puts("DB Table Version Thread Open Lock");
- for (idx=unused=0 ; idx < table_def_cache.records ; idx++)
+ tdc_it.init();
+ while ((share= tdc_it.next()))
{
- share= (TABLE_SHARE*) my_hash_element(&table_def_cache, idx);
-
- I_P_List_iterator<TABLE, TABLE_share> it(share->used_tables);
- while ((entry= it++))
- {
- printf("%-14.14s %-32s%6ld%8ld%6d %s\n",
- entry->s->db.str, entry->s->table_name.str, entry->s->version,
- entry->in_use->thread_id, entry->db_stat ? 1 : 0,
- lock_descriptions[(int)entry->reginfo.lock_type]);
- }
- it.init(share->free_tables);
+ mysql_mutex_lock(&share->tdc.LOCK_table_share);
+ TABLE_SHARE::All_share_tables_list::Iterator it(share->tdc.all_tables);
while ((entry= it++))
{
- unused++;
+ 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->version,
- 0L, entry->db_stat ? 1 : 0, "Not in use");
+ 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);
}
- count=0;
- if ((start_link=lnk=unused_tables))
- {
- do
- {
- if (lnk != lnk->next->prev || lnk != lnk->prev->next)
- {
- printf("unused_links isn't linked properly\n");
- return;
- }
- } while (count++ < cached_open_tables() && (lnk=lnk->next) != start_link);
- if (lnk != start_link)
- {
- printf("Unused_links aren't connected\n");
- }
- }
- if (count != unused)
- printf("Unused_links (%d) doesn't match table_def_cache: %d\n", count,
- unused);
- printf("\nCurrent refresh version: %ld\n",refresh_version);
- if (my_hash_check(&table_def_cache))
- printf("Error: Table definition hash table is corrupted\n");
+ tdc_it.deinit();
+ printf("\nCurrent refresh version: %ld\n", tdc_refresh_version());
fflush(stdout);
- mysql_mutex_unlock(&LOCK_open);
/* purecov: end */
return;
}
@@ -246,7 +220,7 @@ TEST_join(JOIN *join)
}
-#define FT_KEYPART (MAX_REF_PARTS+10)
+#define FT_KEYPART (MAX_FIELDS+10)
static void print_keyuse(KEYUSE *keyuse)
{
@@ -490,7 +464,8 @@ static void display_table_locks(void)
void *saved_base;
DYNAMIC_ARRAY saved_table_locks;
- (void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO), cached_open_tables() + 20,50);
+ (void) my_init_dynamic_array(&saved_table_locks,sizeof(TABLE_LOCK_INFO),
+ tc_records() + 20, 50, MYF(0));
mysql_mutex_lock(&THR_LOCK_lock);
for (list= thr_lock_thread_list; list; list= list_rest(list))
{
@@ -597,7 +572,6 @@ void mysql_print_status()
/* Print key cache status */
puts("\nKey caches:");
process_key_caches(print_key_cache_status, 0);
- mysql_mutex_lock(&LOCK_status);
printf("\nhandler status:\n\
read_key: %10lu\n\
read_next: %10lu\n\
@@ -613,14 +587,13 @@ update: %10lu\n",
tmp.ha_write_count,
tmp.ha_delete_count,
tmp.ha_update_count);
- mysql_mutex_unlock(&LOCK_status);
printf("\nTable status:\n\
Opened tables: %10lu\n\
Open tables: %10lu\n\
Open files: %10lu\n\
Open streams: %10lu\n",
tmp.opened_tables,
- (ulong) cached_open_tables(),
+ (ulong) tc_records(),
(ulong) my_file_opened,
(ulong) my_stream_opened);
@@ -636,7 +609,6 @@ Next alarm time: %lu\n",
(ulong)alarm_info.next_alarm_time);
#endif
display_table_locks();
- fflush(stdout);
#ifdef HAVE_MALLINFO
struct mallinfo info= mallinfo();
printf("\nMemory status:\n\
@@ -668,4 +640,5 @@ Estimated memory (with thread stack): %ld\n",
Events::dump_internal_status();
#endif
puts("");
+ fflush(stdout);
}