* kpettersson@stripped <kpettersson@stripped> [08/04/02 22:15]:
> ChangeSet@stripped, 2008-04-02 17:36:32+02:00, thek@adventure.(none) +5 -0
> Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines
>
> When running Stored Routines the Status Variable "Questions" is wrongly
> incremented.
> According to the manual it should contain the "number of statements that clients
> have sent
> to the server"
> This patch introduces a new status variable which represents the number
> of statements sent to the server by the client.
Please explain why you need a new variable.
>
> +
> + /** The number of statements sent by the client to the server. */
> + ulong client_statements_count;
> } STATUS_VAR;
>
Please use the same name as the variable name. It's a matter of
taste, perhaps, but would make grepping simpler.
> 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);
> +
Please do not use a check to determine whether an increment is
needed.
Instead, please put the increment in the right place.
Do you have tests for the global value of the variable?
Do events and --init-file commands increment the count currently?
Do statements executed by the slave SQL thread increment the
variable?
How do they work with your patch?
> DBUG_ASSERT(thd->transaction.stmt.modified_non_trans_table == FALSE);
>
> switch (lex->sql_command) {
--
Konstantin