diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 541fc78..d92e57d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5938,15 +5938,6 @@ struct my_option my_long_options[]= {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; - -static int show_queries(THD *thd, SHOW_VAR *var, char *buff) -{ - var->type= SHOW_LONGLONG; - var->value= (char *)&thd->query_id; - return 0; -} - - static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff) { var->type= SHOW_MY_BOOL; @@ -6760,7 +6751,7 @@ SHOW_VAR status_vars[]= { {"Qcache_not_cached", (char*) &query_cache.refused, SHOW_LONG, SHOW_SCOPE_GLOBAL}, {"Qcache_queries_in_cache", (char*) &query_cache.queries_in_cache, SHOW_LONG_NOFLUSH, SHOW_SCOPE_GLOBAL}, {"Qcache_total_blocks", (char*) &query_cache.total_blocks, SHOW_LONG_NOFLUSH, SHOW_SCOPE_GLOBAL}, - {"Queries", (char*) &show_queries, SHOW_FUNC, SHOW_SCOPE_ALL}, + {"Queries", (char*) offsetof(STATUS_VAR, queries), SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, {"Questions", (char*) offsetof(STATUS_VAR, questions), SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, {"Select_full_join", (char*) offsetof(STATUS_VAR, select_full_join_count), SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, {"Select_full_range_join", (char*) offsetof(STATUS_VAR, select_full_range_join_count), SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, diff --git a/sql/sql_class.h b/sql/sql_class.h index 84ebdfb..5406607 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -636,6 +636,7 @@ typedef struct system_status_var /* Number of statements sent from the client. */ ulonglong questions; + ulonglong queries; ulong com_other; ulong com_stat[(uint) SQLCOM_END]; @@ -655,7 +656,7 @@ typedef struct system_status_var used as a global counter. It marks the end of a contiguous block of counters that can be iteratively totaled. See add_to_status(). */ -#define LAST_STATUS_VAR questions +#define LAST_STATUS_VAR queries /* This must reference the FIRST ulonglong variable in system_status_var that is @@ -5511,6 +5512,11 @@ public: */ #define CF_SKIP_QUESTIONS (1U << 1) +/** + Skip the increase of the number of maintenance commands (ie: COM_PING, COM_STATISTICS). +*/ +#define CF_SKIP_QUERIES (1U << 2) + /* 1U << 16 is reserved for Protocol Plugin statements and commands */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 67e9dc3..829a84d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -293,9 +293,9 @@ void init_update_queries(void) server_command_flags[COM_FIELD_LIST]= CF_ALLOW_PROTOCOL_PLUGIN; server_command_flags[COM_REFRESH]= CF_ALLOW_PROTOCOL_PLUGIN; server_command_flags[COM_SHUTDOWN]= CF_ALLOW_PROTOCOL_PLUGIN; - server_command_flags[COM_STATISTICS]= CF_SKIP_QUESTIONS; + server_command_flags[COM_STATISTICS]= CF_SKIP_QUESTIONS | CF_SKIP_QUERIES; server_command_flags[COM_PROCESS_KILL]= CF_ALLOW_PROTOCOL_PLUGIN; - server_command_flags[COM_PING]= CF_SKIP_QUESTIONS; + server_command_flags[COM_PING]= CF_SKIP_QUESTIONS | CF_SKIP_QUERIES; server_command_flags[COM_STMT_PREPARE]= CF_SKIP_QUESTIONS | CF_ALLOW_PROTOCOL_PLUGIN; server_command_flags[COM_STMT_EXECUTE]= CF_ALLOW_PROTOCOL_PLUGIN; @@ -1260,6 +1260,8 @@ bool dispatch_command(THD *thd, const COM_DATA *com_data, thd->rewritten_query.mem_free(); thd_manager->inc_thread_running(); + if (!(server_command_flags[command] & CF_SKIP_QUERIES)) + thd->status_var.queries++; if (!(server_command_flags[command] & CF_SKIP_QUESTIONS)) thd->status_var.questions++; @@ -1537,6 +1539,7 @@ bool dispatch_command(THD *thd, const COM_DATA *com_data, /* Count each statement from the client. */ + thd->status_var.queries++; thd->status_var.questions++; thd->set_time(); /* Reset the query start time. */ parser_state.reset(beginning_of_next_stmt, length);