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.cc45
1 files changed, 27 insertions, 18 deletions
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 465f53cc30c..0fe299d4505 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -27,6 +27,8 @@
#include <sys/malloc.h>
#endif
+#include "events.h"
+
static const char *lock_descriptions[] =
{
"No lock",
@@ -71,17 +73,18 @@ void print_cached_tables(void)
uint idx,count,unused;
TABLE *start_link,*lnk;
+ /* purecov: begin tested */
VOID(pthread_mutex_lock(&LOCK_open));
- puts("DB Table Version Thread L.thread Open Lock");
+ puts("DB Table Version Thread Open Lock");
for (idx=unused=0 ; idx < open_cache.records ; idx++)
{
TABLE *entry=(TABLE*) hash_element(&open_cache,idx);
- printf("%-14.14s %-32s%6ld%8ld%10ld%6d %s\n",
- entry->s->db, entry->s->table_name, entry->s->version,
+ printf("%-14.14s %-32s%6ld%8ld%6d %s\n",
+ entry->s->db.str, entry->s->table_name.str, entry->s->version,
entry->in_use ? entry->in_use->thread_id : 0L,
- entry->in_use ? entry->in_use->dbug_thread_id : 0L,
- entry->db_stat ? 1 : 0, entry->in_use ? lock_descriptions[(int)entry->reginfo.lock_type] : "Not in use");
+ entry->db_stat ? 1 : 0,
+ entry->in_use ? lock_descriptions[(int)entry->reginfo.lock_type] : "Not in use");
if (!entry->in_use)
unused++;
}
@@ -108,6 +111,7 @@ void print_cached_tables(void)
printf("Error: File hash table is corrupted\n");
fflush(stdout);
VOID(pthread_mutex_unlock(&LOCK_open));
+ /* purecov: end */
return;
}
@@ -245,14 +249,15 @@ print_plan(JOIN* join, uint idx, double record_count, double read_time,
if (join->best_read == DBL_MAX)
{
fprintf(DBUG_FILE,
- "%s; idx:%u, best: DBL_MAX, atime: %g, itime: %g, count: %g\n",
- info, idx, current_read_time, read_time, record_count);
+ "%s; idx: %u best: DBL_MAX atime: %g itime: %g count: %g\n",
+ info, idx, current_read_time, read_time, record_count);
}
else
{
fprintf(DBUG_FILE,
- "%s; idx:%u, best: %g, accumulated: %g, increment: %g, count: %g\n",
- info, idx, join->best_read, current_read_time, read_time, record_count);
+ "%s; idx :%u best: %g accumulated: %g increment: %g count: %g\n",
+ info, idx, join->best_read, current_read_time, read_time,
+ record_count);
}
/* Print the tables in JOIN->positions */
@@ -262,7 +267,7 @@ print_plan(JOIN* join, uint idx, double record_count, double read_time,
pos = join->positions[i];
table= pos.table->table;
if (table)
- fputs(table->s->table_name, DBUG_FILE);
+ fputs(table->s->table_name.str, DBUG_FILE);
fputc(' ', DBUG_FILE);
}
fputc('\n', DBUG_FILE);
@@ -279,7 +284,7 @@ print_plan(JOIN* join, uint idx, double record_count, double read_time,
pos= join->best_positions[i];
table= pos.table->table;
if (table)
- fputs(table->s->table_name, DBUG_FILE);
+ fputs(table->s->table_name.str, DBUG_FILE);
fputc(' ', DBUG_FILE);
}
}
@@ -290,7 +295,7 @@ print_plan(JOIN* join, uint idx, double record_count, double read_time,
for (plan_nodes= join->best_ref ; *plan_nodes ; plan_nodes++)
{
join_table= (*plan_nodes);
- fputs(join_table->table->s->table_name, DBUG_FILE);
+ fputs(join_table->table->s->table_name.str, DBUG_FILE);
fprintf(DBUG_FILE, "(%lu,%lu,%lu)",
(ulong) join_table->found_records,
(ulong) join_table->records,
@@ -337,14 +342,14 @@ static void push_locks_into_array(DYNAMIC_ARRAY *ar, THR_LOCK_DATA *data,
{
TABLE_LOCK_INFO table_lock_info;
table_lock_info.thread_id= table->in_use->thread_id;
- memcpy(table_lock_info.table_name, table->s->table_cache_key,
- table->s->key_length);
+ memcpy(table_lock_info.table_name, table->s->table_cache_key.str,
+ table->s->table_cache_key.length);
table_lock_info.table_name[strlen(table_lock_info.table_name)]='.';
table_lock_info.waiting=wait;
table_lock_info.lock_text=text;
// lock_type is also obtainable from THR_LOCK_DATA
table_lock_info.type=table->reginfo.lock_type;
- VOID(push_dynamic(ar,(gptr) &table_lock_info));
+ VOID(push_dynamic(ar,(uchar*) &table_lock_info));
}
}
}
@@ -389,7 +394,7 @@ static void display_table_locks(void)
VOID(pthread_mutex_unlock(&THR_LOCK_lock));
if (!saved_table_locks.elements) goto end;
- qsort((gptr) dynamic_element(&saved_table_locks,0,TABLE_LOCK_INFO *),saved_table_locks.elements,sizeof(TABLE_LOCK_INFO),(qsort_cmp) dl_compare);
+ qsort((uchar*) dynamic_element(&saved_table_locks,0,TABLE_LOCK_INFO *),saved_table_locks.elements,sizeof(TABLE_LOCK_INFO),(qsort_cmp) dl_compare);
freeze_size(&saved_table_locks);
puts("\nThread database.table_name Locked/Waiting Lock_type\n");
@@ -485,7 +490,7 @@ Open tables: %10lu\n\
Open files: %10lu\n\
Open streams: %10lu\n",
tmp.opened_tables,
- (ulong) cached_tables(),
+ (ulong) cached_open_tables(),
(ulong) my_file_opened,
(ulong) my_stream_opened);
@@ -503,7 +508,9 @@ Next alarm time: %lu\n",
display_table_locks();
fflush(stdout);
my_checkmalloc();
- TERMINATE(stdout); // Write malloc information
+ fprintf(stdout,"\nBegin safemalloc memory dump:\n"); // tag needed for test suite
+ TERMINATE(stdout, 1); // Write malloc information
+ fprintf(stdout,"\nEnd safemalloc memory dump.\n");
#ifdef HAVE_MALLINFO
struct mallinfo info= mallinfo();
@@ -531,5 +538,7 @@ Estimated memory (with thread stack): %ld\n",
(int) info.keepcost,
(long) (thread_count * thread_stack + info.hblkhd + info.arena));
#endif
+
+ Events::dump_internal_status();
puts("");
}