Commit b6179919 authored by sergefp@mysql.com's avatar sergefp@mysql.com

Change Last_query_cost status variable from global to thread-local.

parent 25cf90ed
...@@ -1048,7 +1048,6 @@ extern char language[FN_REFLEN], reg_ext[FN_EXTLEN]; ...@@ -1048,7 +1048,6 @@ extern char language[FN_REFLEN], reg_ext[FN_EXTLEN];
extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN]; extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file; extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
extern char log_error_file[FN_REFLEN], *opt_tc_log_file; extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
extern double last_query_cost;
extern double log_10[32]; extern double log_10[32];
extern ulonglong log_10_int[20]; extern ulonglong log_10_int[20];
extern ulonglong keybuff_size; extern ulonglong keybuff_size;
......
...@@ -345,7 +345,6 @@ ulong expire_logs_days = 0; ...@@ -345,7 +345,6 @@ ulong expire_logs_days = 0;
ulong rpl_recovery_rank=0; ulong rpl_recovery_rank=0;
ulong my_bind_addr; /* the address we bind to */ ulong my_bind_addr; /* the address we bind to */
volatile ulong cached_thread_count= 0; volatile ulong cached_thread_count= 0;
double last_query_cost= -1; /* -1 denotes that no query was compiled yet */
double log_10[32]; /* 10 potences */ double log_10[32]; /* 10 potences */
time_t start_time; time_t start_time;
...@@ -5714,7 +5713,7 @@ struct show_var_st status_vars[]= { ...@@ -5714,7 +5713,7 @@ struct show_var_st status_vars[]= {
{"Key_reads", (char*) &dflt_key_cache_var.global_cache_read, SHOW_KEY_CACHE_LONG}, {"Key_reads", (char*) &dflt_key_cache_var.global_cache_read, SHOW_KEY_CACHE_LONG},
{"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests, SHOW_KEY_CACHE_LONG}, {"Key_write_requests", (char*) &dflt_key_cache_var.global_cache_w_requests, SHOW_KEY_CACHE_LONG},
{"Key_writes", (char*) &dflt_key_cache_var.global_cache_write, SHOW_KEY_CACHE_LONG}, {"Key_writes", (char*) &dflt_key_cache_var.global_cache_write, SHOW_KEY_CACHE_LONG},
{"Last_query_cost", (char*) &last_query_cost, SHOW_DOUBLE}, {"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE},
{"Max_used_connections", (char*) &max_used_connections, SHOW_LONG}, {"Max_used_connections", (char*) &max_used_connections, SHOW_LONG},
#ifdef HAVE_NDBCLUSTER_DB #ifdef HAVE_NDBCLUSTER_DB
{"Ndb_", (char*) &ndb_status_variables, SHOW_VARS}, {"Ndb_", (char*) &ndb_status_variables, SHOW_VARS},
......
...@@ -444,6 +444,7 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var) ...@@ -444,6 +444,7 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var)
while (to != end) while (to != end)
*(to++)+= *(from++); *(to++)+= *(from++);
/* it doesn't make sense to add last_query_cost values */
} }
......
...@@ -635,6 +635,8 @@ typedef struct system_status_var ...@@ -635,6 +635,8 @@ typedef struct system_status_var
ulong filesort_range_count; ulong filesort_range_count;
ulong filesort_rows; ulong filesort_rows;
ulong filesort_scan_count; ulong filesort_scan_count;
double last_query_cost;
} STATUS_VAR; } STATUS_VAR;
/* /*
......
...@@ -3739,8 +3739,7 @@ choose_plan(JOIN *join, table_map join_tables) ...@@ -3739,8 +3739,7 @@ choose_plan(JOIN *join, table_map join_tables)
Don't update last_query_cost for 'show status' command Don't update last_query_cost for 'show status' command
*/ */
if (join->thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS) if (join->thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS)
last_query_cost= join->best_read; join->thd->status_var.last_query_cost= join->best_read;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -1358,6 +1358,7 @@ static bool show_status_array(THD *thd, const char *wild, ...@@ -1358,6 +1358,7 @@ static bool show_status_array(THD *thd, const char *wild,
} }
case SHOW_DOUBLE: case SHOW_DOUBLE:
{ {
value= ((char *) status_var + (ulong) value);
end= buff + sprintf(buff, "%f", *(double*) value); end= buff + sprintf(buff, "%f", *(double*) value);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment