2006-06-23 09:40:06 +02:00
# Can't test with embedded server that doesn't support grants
-- source include/not_embedded.inc
2006-07-17 16:52:45 +02:00
-- source include/not_valgrind.inc
2006-06-23 09:40:06 +02:00
2006-04-07 09:08:58 +02:00
CREATE DATABASE IF NOT EXISTS events_test;
USE events_test;
2006-09-01 13:08:44 +02:00
SET GLOBAL event_scheduler=OFF;
SHOW VARIABLES LIKE 'event_scheduler';
SET GLOBAL event_scheduler=1;
SHOW VARIABLES LIKE 'event_scheduler';
SET GLOBAL event_scheduler=0;
SHOW VARIABLES LIKE 'event_scheduler';
SET GLOBAL event_scheduler=ON;
SHOW VARIABLES LIKE 'event_scheduler';
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL event_scheduler=DISABLED;
SHOW VARIABLES LIKE 'event_scheduler';
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL event_scheduler=-1;
SHOW VARIABLES LIKE 'event_scheduler';
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL event_scheduler=2;
SHOW VARIABLES LIKE 'event_scheduler';
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL event_scheduler=5;
SHOW VARIABLES LIKE 'event_scheduler';
2006-04-07 09:08:58 +02:00
CREATE TABLE table_1(a int);
CREATE TABLE table_2(a int);
CREATE TABLE table_3(a int);
CREATE TABLE table_4(a int);
2006-04-24 11:12:15 +02:00
CREATE TABLE T19170(s1 TIMESTAMP);
2006-09-01 13:08:44 +02:00
SET GLOBAL event_scheduler=ON;
2006-06-06 01:47:30 +02:00
# We need to have 2 to make it safe with valgrind. This is probably because
# of when we calculate the timestamp value
2006-04-07 09:08:58 +02:00
CREATE EVENT two_sec ON SCHEDULE EVERY 2 SECOND DO INSERT INTO table_1 VALUES(1);
CREATE EVENT start_n_end
ON SCHEDULE EVERY 1 SECOND
ENDS NOW() + INTERVAL 6 SECOND
ON COMPLETION PRESERVE
DO INSERT INTO table_2 VALUES(1);
--sleep 5
CREATE EVENT only_one_time ON SCHEDULE EVERY 2 SECOND ENDS NOW() + INTERVAL 1 SECOND DO INSERT INTO table_3 VALUES(1);
2006-05-22 20:46:13 +02:00
CREATE EVENT two_time ON SCHEDULE EVERY 1 SECOND ENDS NOW() + INTERVAL 1 SECOND ON COMPLETION PRESERVE DO INSERT INTO table_4 VALUES(1);
2006-04-07 09:08:58 +02:00
--sleep 5
SELECT IF(SUM(a) >= 4, 'OK', 'ERROR') FROM table_1;
SELECT IF(SUM(a) >= 5, 'OK', 'ERROR') FROM table_2;
SELECT IF(SUM(a) > 0, 'OK', 'ERROR') FROM table_3;
SELECT IF(SUM(a) > 0, 'OK', 'ERROR') FROM table_4;
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;
2006-04-24 11:12:15 +02:00
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;
2006-04-07 09:08:58 +02:00
DROP EVENT start_n_end;
--echo "Already dropped because ended. Therefore an error."
2006-04-07 11:29:15 +02:00
--error ER_EVENT_DOES_NOT_EXIST
2006-04-07 09:08:58 +02:00
DROP EVENT only_one_time;
2006-05-22 20:46:13 +02:00
--echo "Should be preserved"
2006-07-10 13:44:43 +02:00
SELECT EVENT_NAME, STATUS FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_NAME;
2006-04-07 09:08:58 +02:00
DROP EVENT two_time;
DROP TABLE table_1;
DROP TABLE table_2;
DROP TABLE table_3;
DROP TABLE table_4;
DROP DATABASE events_test;