Hi Kristopher,
kpettersson@stripped wrote:
[..]
I'm not sure if this is 5.0 material..
> --- a/sql/mysqld.cc 2008-02-19 12:37:35 +01:00
> +++ b/sql/mysqld.cc 2008-04-02 17:36:30 +02:00
> @@ -6568,7 +6568,7 @@ struct show_var_st status_vars[]= {
> {"Qcache_queries_in_cache", (char*) &query_cache.queries_in_cache,
> SHOW_LONG_CONST},
> {"Qcache_total_blocks", (char*) &query_cache.total_blocks,
> SHOW_LONG_CONST},
> #endif /*HAVE_QUERY_CACHE*/
> - {"Questions", (char*) 0, SHOW_QUESTION},
> + {"Questions", (char*) offsetof(STATUS_VAR,
> client_statements_count), SHOW_LONG_STATUS},
> {"Rpl_status", (char*) 0, SHOW_RPL_STATUS},
> {"Select_full_join", (char*) offsetof(STATUS_VAR, select_full_join_count),
> SHOW_LONG_STATUS},
> {"Select_full_range_join", (char*) offsetof(STATUS_VAR,
> select_full_range_join_count), SHOW_LONG_STATUS},
Don't forget to remove the dead code in sql_show.c:
case SHOW_QUESTION:
end= int10_to_str((long) thd->query_id, buff, 10);
break;
> diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
> --- a/sql/sql_class.h 2008-02-28 15:34:06 +01:00
> +++ b/sql/sql_class.h 2008-04-02 17:36:30 +02:00
> @@ -670,6 +670,9 @@ typedef struct system_status_var
> global status variable counter
> */
> double last_query_cost;
> +
> + /** The number of statements sent by the client to the server. */
> + ulong client_statements_count;
> } STATUS_VAR;
>
> /*
> diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
> --- a/sql/sql_parse.cc 2008-02-21 02:22:00 +01:00
> +++ b/sql/sql_parse.cc 2008-04-02 17:36:31 +02:00
> @@ -2654,6 +2654,12 @@ mysql_execute_command(THD *thd)
> statistic_increment(thd->status_var.com_stat[lex->sql_command],
> &LOCK_status);
>
> + /*
> + Count each statement from the client.
> + */
> + if (thd->lex->is_single_level_stmt())
> + statistic_increment(thd->status_var.client_statements_count,
> &LOCK_status);
> +
This fixes the case for stored procedures, but not for triggers or
prepared statements. Please investigate using THD::in_sub_stmt or
Query_arena::is_conventional.
Regards,
--
Davi Arnaut, Software Engineer
MySQL Inc, www.mysql.com
Are you MySQL certified? www.mysql.com/certification