Commit b7adc199 authored by andrey@lmy004's avatar andrey@lmy004

test case for bug 19170

parent 1b6c3944
...@@ -43,7 +43,7 @@ SLEEP(3) ...@@ -43,7 +43,7 @@ SLEEP(3)
0 0
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log; SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host query_time db sql_text user_host query_time db sql_text
root[root] @ localhost [] 00:00:03 events_test SELECT SLEEP(3) root[root] @ localhost [] SLEEPVAL events_test SELECT SLEEP(3)
TRUNCATE mysql.slow_log; TRUNCATE mysql.slow_log;
CREATE TABLE slow_event_test (slo_val tinyint, val tinyint); CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
"This won't go to the slow log" "This won't go to the slow log"
...@@ -75,7 +75,7 @@ slo_val val ...@@ -75,7 +75,7 @@ slo_val val
"Check slow log. Should see 1 row because 5 is over the threshold of 4 for GLOBAL, though under SESSION which is 10" "Check slow log. Should see 1 row because 5 is over the threshold of 4 for GLOBAL, though under SESSION which is 10"
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log; SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
user_host query_time db sql_text user_host query_time db sql_text
root[root] @ localhost [localhost] 00:00:05 events_test INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(5) root[root] @ localhost [localhost] SLEEPVAL events_test INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(5)
DROP EVENT long_event2; DROP EVENT long_event2;
SET GLOBAL long_query_time =@old_global_long_query_time; SET GLOBAL long_query_time =@old_global_long_query_time;
SET SESSION long_query_time =@old_session_long_query_time; SET SESSION long_query_time =@old_session_long_query_time;
......
...@@ -4,7 +4,9 @@ CREATE TABLE table_1(a int); ...@@ -4,7 +4,9 @@ CREATE TABLE table_1(a int);
CREATE TABLE table_2(a int); CREATE TABLE table_2(a int);
CREATE TABLE table_3(a int); CREATE TABLE table_3(a int);
CREATE TABLE table_4(a int); CREATE TABLE table_4(a int);
CREATE TABLE T19170(s1 TIMESTAMP);
SET GLOBAL event_scheduler=1; SET GLOBAL event_scheduler=1;
CREATE EVENT E19170 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO T19170 VALUES(CURRENT_TIMESTAMP);
CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1); CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1);
CREATE EVENT start_n_end CREATE EVENT start_n_end
ON SCHEDULE EVERY 1 SECOND ON SCHEDULE EVERY 1 SECOND
...@@ -29,8 +31,8 @@ DROP EVENT two_sec; ...@@ -29,8 +31,8 @@ DROP EVENT two_sec;
SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='start_n_end' AND ENDS IS NOT NULL; SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='start_n_end' AND ENDS IS NOT NULL;
IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR')
OK OK
SELECT IF(LAST_EXECUTED-ENDS < 2, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='start_n_end' AND ENDS IS NOT NULL; SELECT IF(LAST_EXECUTED-ENDS < 3, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='start_n_end' AND ENDS IS NOT NULL;
IF(LAST_EXECUTED-ENDS < 2, 'OK', 'ERROR') IF(LAST_EXECUTED-ENDS < 3, 'OK', 'ERROR')
OK OK
DROP EVENT start_n_end; DROP EVENT start_n_end;
"Already dropped because ended. Therefore an error." "Already dropped because ended. Therefore an error."
...@@ -43,4 +45,8 @@ DROP TABLE table_1; ...@@ -43,4 +45,8 @@ DROP TABLE table_1;
DROP TABLE table_2; DROP TABLE table_2;
DROP TABLE table_3; DROP TABLE table_3;
DROP TABLE table_4; DROP TABLE table_4;
"Checking for multiple executions in one second, should not happen -> 0 as result"
SELECT COUNT(*) FROM (SELECT s1, COUNT(*) AS cnt FROM T19170 GROUP BY s1) AS tmp WHERE tmp.cnt > 1;
COUNT(*)
0
DROP DATABASE events_test; DROP DATABASE events_test;
...@@ -56,6 +56,7 @@ SET GLOBAL long_query_time=4; ...@@ -56,6 +56,7 @@ SET GLOBAL long_query_time=4;
SET SESSION long_query_time=2; SET SESSION long_query_time=2;
--echo "Check that logging is working" --echo "Check that logging is working"
SELECT SLEEP(3); SELECT SLEEP(3);
--replace_regex /00:00:0[3-5]/SLEEPVAL/
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log; SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
TRUNCATE mysql.slow_log; TRUNCATE mysql.slow_log;
CREATE TABLE slow_event_test (slo_val tinyint, val tinyint); CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
...@@ -79,6 +80,7 @@ CREATE EVENT long_event2 ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_te ...@@ -79,6 +80,7 @@ CREATE EVENT long_event2 ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_te
--echo "Check our table. Should see 2 rows" --echo "Check our table. Should see 2 rows"
SELECT * FROM slow_event_test; SELECT * FROM slow_event_test;
--echo "Check slow log. Should see 1 row because 5 is over the threshold of 4 for GLOBAL, though under SESSION which is 10" --echo "Check slow log. Should see 1 row because 5 is over the threshold of 4 for GLOBAL, though under SESSION which is 10"
--replace_regex /00:00:0[5-7]/SLEEPVAL/
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log; SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
DROP EVENT long_event2; DROP EVENT long_event2;
SET GLOBAL long_query_time =@old_global_long_query_time; SET GLOBAL long_query_time =@old_global_long_query_time;
......
...@@ -4,7 +4,9 @@ CREATE TABLE table_1(a int); ...@@ -4,7 +4,9 @@ CREATE TABLE table_1(a int);
CREATE TABLE table_2(a int); CREATE TABLE table_2(a int);
CREATE TABLE table_3(a int); CREATE TABLE table_3(a int);
CREATE TABLE table_4(a int); CREATE TABLE table_4(a int);
CREATE TABLE T19170(s1 TIMESTAMP);
SET GLOBAL event_scheduler=1; SET GLOBAL event_scheduler=1;
CREATE EVENT E19170 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO T19170 VALUES(CURRENT_TIMESTAMP);
CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1); CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1);
CREATE EVENT start_n_end CREATE EVENT start_n_end
ON SCHEDULE EVERY 1 SECOND ON SCHEDULE EVERY 1 SECOND
...@@ -21,7 +23,7 @@ SELECT IF(SUM(a) > 0, 'OK', 'ERROR') FROM table_3; ...@@ -21,7 +23,7 @@ SELECT IF(SUM(a) > 0, 'OK', 'ERROR') FROM table_3;
SELECT IF(SUM(a) > 0, 'OK', 'ERROR') FROM table_4; SELECT IF(SUM(a) > 0, 'OK', 'ERROR') FROM table_4;
DROP EVENT two_sec; DROP EVENT two_sec;
SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='start_n_end' AND ENDS IS NOT NULL; SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='start_n_end' AND ENDS IS NOT NULL;
SELECT IF(LAST_EXECUTED-ENDS < 2, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='start_n_end' AND ENDS IS NOT NULL; SELECT IF(LAST_EXECUTED-ENDS < 3, 'OK', 'ERROR') FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='start_n_end' AND ENDS IS NOT NULL;
DROP EVENT start_n_end; DROP EVENT start_n_end;
--echo "Already dropped because ended. Therefore an error." --echo "Already dropped because ended. Therefore an error."
--error ER_EVENT_DOES_NOT_EXIST --error ER_EVENT_DOES_NOT_EXIST
...@@ -33,4 +35,6 @@ DROP TABLE table_1; ...@@ -33,4 +35,6 @@ DROP TABLE table_1;
DROP TABLE table_2; DROP TABLE table_2;
DROP TABLE table_3; DROP TABLE table_3;
DROP TABLE table_4; DROP TABLE table_4;
--echo "Checking for multiple executions in one second, should not happen -> 0 as result"
SELECT COUNT(*) FROM (SELECT s1, COUNT(*) AS cnt FROM T19170 GROUP BY s1) AS tmp WHERE tmp.cnt > 1;
DROP DATABASE events_test; DROP DATABASE events_test;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment