summaryrefslogtreecommitdiff
path: root/mysql-test/t/status2.test
diff options
context:
space:
mode:
authorKristofer Pettersson <kristofer.pettersson@sun.com>2008-10-09 09:26:42 +0200
committerKristofer Pettersson <kristofer.pettersson@sun.com>2008-10-09 09:26:42 +0200
commitf985e787758e3081e18543b5490724d30296aebf (patch)
treeed1de81ea71bd5053e787bd3e804bcc5c0c9d4ec /mysql-test/t/status2.test
parenteb3c08069db60d61f41dacb10fd6b73635fec236 (diff)
downloadmariadb-git-f985e787758e3081e18543b5490724d30296aebf.tar.gz
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. This is a backport from 6.0 mysql-test/r/status2.result: Added test case mysql-test/t/status2.test: Added test case sql/mysqld.cc: 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: 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: 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. sql/sql_show.cc: Removed deprecated SHOW_QUESTION status code. sql/structs.h: Removed deprecated SHOW_QUESTION status code.
Diffstat (limited to 'mysql-test/t/status2.test')
-rw-r--r--mysql-test/t/status2.test64
1 files changed, 64 insertions, 0 deletions
diff --git a/mysql-test/t/status2.test b/mysql-test/t/status2.test
new file mode 100644
index 00000000000..b834cd0c6ad
--- /dev/null
+++ b/mysql-test/t/status2.test
@@ -0,0 +1,64 @@
+--echo #
+--echo # Bug#24289 Status Variable "Questions" gets wrong values with Stored Routines
+--echo #
+# The bogus connection below is needed to make the gobal statement count
+# deterministic when the test is run for the first time.
+connect (con1,localhost,root,,);
+connection con1;
+connection default;
+disconnect con1;
+FLUSH STATUS;
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+DROP PROCEDURE IF EXISTS p1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+DELIMITER $$;
+CREATE FUNCTION f1() RETURNS INTEGER
+BEGIN
+ DECLARE foo INTEGER;
+ DECLARE bar INTEGER;
+ SET foo=1;
+ SET bar=2;
+ RETURN foo;
+END $$
+CREATE PROCEDURE p1()
+BEGIN
+ SELECT 1;
+END $$
+DELIMITER ;$$
+CREATE TABLE t1 (c1 INT);
+CREATE TABLE t2 (c1 INT);
+INSERT INTO t1 VALUES (1);
+--echo Assert Questions == 9
+SHOW STATUS LIKE 'Questions';
+SELECT f1();
+--echo Assert Questions == 11
+SHOW STATUS LIKE 'Questions';
+CALL p1();
+--echo Assert Questions == 13
+SHOW STATUS LIKE 'Questions';
+SELECT 1;
+--echo Assert Questions == 15
+SHOW STATUS LIKE 'Questions';
+connect (con1,localhost,root,,);
+connection con1;
+FLUSH STATUS;
+let $org_questions= `SHOW GLOBAL STATUS LIKE 'questions'`;
+SELECT 1;
+connection default;
+disconnect con1;
+--echo Assert Questions == 16
+SHOW STATUS LIKE 'Questions';
+--echo Global status updated; Assert diff == 5
+FLUSH STATUS;
+let $new_questions= `SHOW GLOBAL STATUS LIKE 'questions'`;
+--disable_log
+let $diff= `SELECT SUBSTRING('$new_questions',10)-SUBSTRING('$org_questions',10)`;
+--enable_log
+eval SELECT $diff;
+DROP TABLE t1,t2;
+DROP PROCEDURE p1;
+DROP FUNCTION f1;
+--echo End of 6.0 tests
+