Below is the list of changes that have just been committed into a local
6.0 repository of thek. When thek does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-04-03 15:40:17+02:00, thek@adventure.(none) +3 -0
Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines
When running Stored Routines the Status Variable "Questions" was wrongly incremented.
According to the manual it should contain the "number of statements that clients have sent
to the server"
Introduced a new status variable 'questions' to replace the query_id
variable which currently corresponds badly with the number of statements
sent by the client.
The new behavior is ment to be backward compatible with 4.0 and at the
same time work with new features in a similar way.
sql/mysqld.cc@stripped, 2008-04-03 15:40:12+02:00, thek@adventure.(none) +2 -2
Introduced a new status variable 'questions' to replace the query_id
variable which currently corresponds badly with the number of statements
sent by the client.
sql/sql_class.h@stripped, 2008-04-03 15:40:12+02:00, thek@adventure.(none) +6 -0
Introduced a new status variable 'questions' to replace the query_id
variable which currently corresponds badly with the number of statements
sent by the client.
sql/sql_parse.cc@stripped, 2008-04-03 15:40:12+02:00, thek@adventure.(none) +15 -0
To be backward compatible with 4.0 and at the same time extend the
interpretation of the Question variable, it should be increased on
all COM-commands but COM_STATISTICS, COM_PING, COM_STMT_PREPARE,
COM_STMT_CLOSE and COM_STMT_RESET.
Since COM_QUERY can process multiple statements, there has to be an
extra increase there as well.
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc 2008-03-19 13:16:03 +01:00
+++ b/sql/mysqld.cc 2008-04-03 15:40:12 +02:00
@@ -6928,8 +6928,8 @@ The minimum value for this variable is 4
static int show_question(THD *thd, SHOW_VAR *var, char *buff)
{
- var->type= SHOW_LONGLONG;
- var->value= (char *)&thd->query_id;
+ var->type= SHOW_LONG;
+ var->value= (char *)&thd->status_var.questions;
return 0;
}
diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
--- a/sql/sql_class.h 2008-03-18 11:54:34 +01:00
+++ b/sql/sql_class.h 2008-04-03 15:40:12 +02:00
@@ -461,6 +461,12 @@ typedef struct system_status_var
global status variable counter
*/
double last_query_cost;
+
+ /*
+ Number of statements sent from the client
+ */
+ ulong questions;
+
} STATUS_VAR;
/*
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc 2008-03-18 11:54:34 +01:00
+++ b/sql/sql_parse.cc 2008-04-03 15:40:12 +02:00
@@ -838,7 +838,17 @@ bool dispatch_command(enum enum_server_c
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id= global_query_id;
if (command != COM_STATISTICS && command != COM_PING)
+ {
next_query_id();
+ if (command != COM_STMT_PREPARE && command != COM_STMT_CLOSE &&
+ command != COM_STMT_RESET)
+ {
+ /*
+ Count each statement from the client.
+ */
+ statistic_increment(thd->status_var.questions, &LOCK_status);
+ }
+ }
thread_running++;
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
VOID(pthread_mutex_unlock(&LOCK_thread_count));
@@ -1058,10 +1068,15 @@ bool dispatch_command(enum enum_server_c
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_length= length;
thd->query= beginning_of_next_stmt;
+ /*
+ Count each statement from the client.
+ */
+ statistic_increment(thd->status_var.questions, &LOCK_status);
thd->query_id= next_query_id();
thd->set_time(); /* Reset the query start time. */
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
VOID(pthread_mutex_unlock(&LOCK_thread_count));
+
mysql_parse(thd, beginning_of_next_stmt, length, &end_of_stmt);
}