List:Commits« Previous MessageNext Message »
From:kpettersson Date:April 2 2008 3:36pm
Subject:bk commit into 5.0 tree (thek:1.2596) BUG#24289
View as plain text  
Below is the list of changes that have just been committed into a local
5.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-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.

  mysql-test/r/status.result@stripped, 2008-04-02 17:36:30+02:00, thek@adventure.(none) +38 -0
    Added test case for status variable 'Questions'

  mysql-test/t/status.test@stripped, 2008-04-02 17:36:30+02:00, thek@adventure.(none) +29 -1
    Added test case for status variable 'Questions'

  sql/mysqld.cc@stripped, 2008-04-02 17:36:30+02:00, thek@adventure.(none) +1 -1
    Added hook for status variable 'client_statements_count'

  sql/sql_class.h@stripped, 2008-04-02 17:36:30+02:00, thek@adventure.(none) +3 -0
    Added status variable 'client_statements_count'

  sql/sql_parse.cc@stripped, 2008-04-02 17:36:31+02:00, thek@adventure.(none) +6 -0
    Added hook for counting statements received by the client.

diff -Nrup a/mysql-test/r/status.result b/mysql-test/r/status.result
--- a/mysql-test/r/status.result	2007-08-28 17:51:02 +02:00
+++ b/mysql-test/r/status.result	2008-04-02 17:36:30 +02:00
@@ -91,3 +91,41 @@ SHOW SESSION STATUS LIKE 'Last_query_cos
 Variable_name	Value
 Last_query_cost	4.805836
 DROP TABLE t1;
+
+Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines
+
+FLUSH STATUS;
+CREATE FUNCTION testQuestion() RETURNS INTEGER
+BEGIN
+DECLARE foo INTEGER;
+DECLARE bar INTEGER;
+SET foo=1;
+SET bar=2;
+RETURN foo;
+END $$
+SHOW STATUS LIKE 'Questions';
+Variable_name	Value
+Questions	2
+SELECT testQuestion();
+testQuestion()
+1
+SHOW STATUS LIKE 'Questions';
+Variable_name	Value
+Questions	3
+SHOW STATUS LIKE 'Questions';
+Variable_name	Value
+Questions	4
+SELECT 1;
+1
+1
+SHOW STATUS LIKE 'Questions';
+Variable_name	Value
+Questions	6
+SELECT 1;
+1
+1
+SHOW STATUS LIKE 'Questions';
+Variable_name	Value
+Questions	7
+DROP FUNCTION testQuestion;
+End of 5.0 tests
diff -Nrup a/mysql-test/t/status.test b/mysql-test/t/status.test
--- a/mysql-test/t/status.test	2007-08-28 17:51:02 +02:00
+++ b/mysql-test/t/status.test	2008-04-02 17:36:30 +02:00
@@ -170,5 +170,33 @@ SHOW SESSION STATUS LIKE 'Last_query_cos
 
 DROP TABLE t1;
 
+--echo
+--echo Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines
+--echo
+FLUSH STATUS;
+DELIMITER $$;
+CREATE FUNCTION testQuestion() RETURNS INTEGER
+BEGIN
+  DECLARE foo INTEGER;
+  DECLARE bar INTEGER;
+  SET foo=1;
+  SET bar=2;
+  RETURN foo;
+END $$
+DELIMITER ;$$
 
-# End of 5.0 tests
+SHOW STATUS LIKE 'Questions';
+SELECT testQuestion();
+SHOW STATUS LIKE 'Questions';
+
+SHOW STATUS LIKE 'Questions';
+SELECT 1;
+SHOW STATUS LIKE 'Questions';
+connect (con1,localhost,root,,);
+connection con1;
+SELECT 1;
+connection default;
+disconnect con1;
+SHOW STATUS LIKE 'Questions';
+DROP FUNCTION testQuestion;
+--echo End of 5.0 tests
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- 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},
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);
+
   DBUG_ASSERT(thd->transaction.stmt.modified_non_trans_table == FALSE);
   
   switch (lex->sql_command) {
Thread
bk commit into 5.0 tree (thek:1.2596) BUG#24289kpettersson2 Apr
  • Re: bk commit into 5.0 tree (thek:1.2596) BUG#24289Davi Arnaut3 Apr
  • Re: bk commit into 5.0 tree (thek:1.2596) BUG#24289Konstantin Osipov3 Apr
  • Re: bk commit into 5.0 tree (thek:1.2596) BUG#24289Konstantin Osipov3 Apr