From c8b724b2aa6dd0ccc5af1a2b7eb5b92271556ccb Mon Sep 17 00:00:00 2001 From: Mayank Prasad Date: Mon, 21 Mar 2011 21:32:47 +0530 Subject: Bug #11751148 : show events shows events in other schema Issue: ------ Due to prefix match, database like 'k' was matching with 'ka' and events of 'ka' we getting displayed for 'show event' of 'k'. Resolution: ----------- Scan for listing of events in a schema is made to be done on exact match of database (schema) name instead of just prefix. mysql-test/r/events_bugs.result: modified expected file with the expected results. mysql-test/t/events_bugs.test: added a test case to reproduce the scenario. sql/event_db_repository.cc: Scan for schema name is made to be done on exact db name match. --- mysql-test/t/events_bugs.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'mysql-test/t/events_bugs.test') diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 81397b333f9..83e37cdccdb 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -1221,6 +1221,21 @@ SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS; DROP EVENT ev1; SET GLOBAL server_id = @old_server_id; +# +# Bug#11751148: show events shows events in other schema +# + +CREATE DATABASE event_test1; +USE event_test1; +CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; +CREATE DATABASE event_test2; +USE event_test2; +# Following show events should not show ev1 +SHOW EVENTS; +DROP DATABASE event_test1; +DROP DATABASE event_test2; + + ########################################################################### # # End of tests -- cgit v1.2.1 From 08e472ff349bb5d21b4881828ed62748ecf7aa40 Mon Sep 17 00:00:00 2001 From: Mayank Prasad Date: Mon, 28 Mar 2011 21:01:37 +0530 Subject: Bug#11751148 : show events shows events in other schema Issue: ====== Test case Correction for bug#11751148. mysql-test/r/events_bugs.result: Result file Correction for bug#11751148. mysql-test/t/events_bugs.test: Test case Correction for bug#11751148. --- mysql-test/t/events_bugs.test | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mysql-test/t/events_bugs.test') diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 83e37cdccdb..420e7183621 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -1225,15 +1225,15 @@ SET GLOBAL server_id = @old_server_id; # Bug#11751148: show events shows events in other schema # +CREATE DATABASE event_test12; +USE event_test12; +CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; CREATE DATABASE event_test1; USE event_test1; -CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -CREATE DATABASE event_test2; -USE event_test2; # Following show events should not show ev1 SHOW EVENTS; DROP DATABASE event_test1; -DROP DATABASE event_test2; +DROP DATABASE event_test12; ########################################################################### -- cgit v1.2.1 From 56a735b78226f6de336c520936df3485d929d685 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Fri, 27 May 2011 16:23:08 +0700 Subject: Fixed bug#12546938 (formerly known as 61005) - CREATE IF NOT EXIST EVENT will create multiple running events. A CREATE IF NOT EXIST on an event that existed and was enabled caused multiple instances of the event to run. Disabling the event didn't help. If the event was dropped, the event stopped running, but when created again, multiple instances of the event were still running. The only way to get out of this situation was to restart the server. The problem was that Event_db_repository::create_event() didn't return enough information to discriminate between situation when event didn't exist and was created and when event did exist and was not created (but a warning was emitted). As result in the latter case event was added to in-memory queue of events second time. And this led to unwarranted multiple executions of the same event. The solution is to add out-parameter to Event_db_repository::create_event() method which will signal that event was not created because it already exists and so it should not be added to the in-memory queue. mysql-test/r/events_bugs.result: Added results for test for Bug#12546938. mysql-test/t/events_bugs.test: Added test for Bug#12546938. sql/event_db_repository.cc: Event_db_repository::create_event was modified: set newly added out-parameter event_already_exists to true value if event wasn't created because event already existed and IF NOT EXIST clause was present. sql/event_db_repository.h: Added out-parameter 'event_already_exists' to create_event() method. sql/events.cc: Events::create_event was modified: insert new element into event queue only if event was actually created. --- mysql-test/t/events_bugs.test | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'mysql-test/t/events_bugs.test') diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 420e7183621..4601448763c 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -857,6 +857,7 @@ DROP EVENT e2; DROP EVENT e1; SET TIME_ZONE=@save_time_zone; +SET TIMESTAMP=DEFAULT; # # START - BUG#28666 CREATE EVENT ... EVERY 0 SECOND let server crash @@ -1235,6 +1236,55 @@ SHOW EVENTS; DROP DATABASE event_test1; DROP DATABASE event_test12; +--echo # +--echo # Bug#12546938 (formerly known as bug#61005): +--echo # CREATE IF NOT EXIST EVENT WILL CREATE MULTIPLE RUNNING EVENTS +--echo # +USE events_test; +SET GLOBAL event_scheduler = ON; + +--disable_warnings +DROP TABLE IF EXISTS table_bug12546938; +DROP EVENT IF EXISTS event_Bug12546938; +--enable_warnings +CREATE TABLE table_bug12546938 (i INT); + +delimiter |; + +--echo # Create an event which will be executed with a small delay +--echo # and won't be automatically dropped after that. +CREATE EVENT event_Bug12546938 +ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND ON COMPLETION PRESERVE +ENABLE DO +BEGIN + INSERT INTO table_bug12546938 VALUES(1); +END +| + +--echo # Now try to create the same event using CREATE EVENT IF NOT EXISTS. +--echo # A warning should be emitted. A new event should not be created nor +--echo # the old event should be re-executed. +CREATE EVENT IF NOT EXISTS event_bug12546938 +ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND ON COMPLETION PRESERVE +ENABLE DO +BEGIN + INSERT INTO table_bug12546938 VALUES (1); +END +| + +delimiter ;| + +--echo # Wait until at least one instance of event is executed. +let $wait_condition= SELECT COUNT(*) FROM table_bug12546938; +--source include/wait_condition.inc + +--echo # Check that only one instance of our event was executed. +SELECT COUNT(*) FROM table_bug12546938; + +--echo # Clean-up. +DROP EVENT IF EXISTS event_Bug12546938; +DROP TABLE table_bug12546938; +SET GLOBAL EVENT_SCHEDULER = OFF; ########################################################################### # -- cgit v1.2.1 From fa913a0b987d94164449511cf0cef5baf1fb9a6f Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Fri, 10 Jun 2011 00:03:17 +0700 Subject: Fixed bug#11764334 (formerly bug#57156): ALTER EVENT CHANGES THE EVENT STATUS. Any ALTER EVENT statement on a disabled event enabled it back (unless this ALTER EVENT statement explicitly disabled the event). The problem was that during processing of an ALTER EVENT statement value of status field was overwritten unconditionally even if new value was not specified explicitly. As a consequence this field was set to default value for status which corresponds to ENABLE. The solution is to check if status field was explicitly specified in ALTER EVENT statement before assigning new value to status field. mysql-test/r/events_bugs.result: test's result for Bug#11764334 was added. mysql-test/t/events_bugs.test: new test for Bug#11764334 was added. sql/event_db_repository.cc: mysql_event_fill_row() was modified: set value for status field in events tables only in case if statement CREATE EVENT is being processed or if this value was set in ALTER EVENT statement. Event_db_repository::create_event was modified: removed redundant setting of status field after return from call to mysql_event_fill_row(). sql/event_parse_data.h: Event_parse_data structure was modified: added flag status_changed that is set to true if status's value was changed in ALTER EVENT statement. sql/sql_yacc.yy: Set flag status_changed if status was set in ALTER EVENT statement. --- mysql-test/t/events_bugs.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'mysql-test/t/events_bugs.test') diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 4601448763c..3617a96c008 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -1286,6 +1286,21 @@ DROP EVENT IF EXISTS event_Bug12546938; DROP TABLE table_bug12546938; SET GLOBAL EVENT_SCHEDULER = OFF; +# +# Bug#11764334 - 57156: ALTER EVENT CHANGES THE EVENT STATUS +# +--disable_warnings +DROP DATABASE IF EXISTS event_test11764334; +--enable_warnings +CREATE DATABASE event_test11764334; +USE event_test11764334; +CREATE EVENT ev1 ON SCHEDULE EVERY 3 SECOND DISABLE DO SELECT 1; +SHOW EVENTS IN event_test11764334 WHERE NAME='ev1'; +ALTER EVENT ev1 ON SCHEDULE EVERY 4 SECOND; +SHOW EVENTS IN event_test11764334 WHERE NAME='ev1'; +DROP EVENT ev1; +DROP DATABASE event_test11764334; +USE test; ########################################################################### # # End of tests -- cgit v1.2.1 From 53e4a8520493a33916c7c8079dcc4c09898ee4e4 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Fri, 10 Jun 2011 01:05:10 +0700 Subject: Follow-up for patch of bug#11764334. --- mysql-test/t/events_bugs.test | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mysql-test/t/events_bugs.test') diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 3617a96c008..a57235d744b 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -1295,8 +1295,10 @@ DROP DATABASE IF EXISTS event_test11764334; CREATE DATABASE event_test11764334; USE event_test11764334; CREATE EVENT ev1 ON SCHEDULE EVERY 3 SECOND DISABLE DO SELECT 1; +--replace_column 9 # 10 # SHOW EVENTS IN event_test11764334 WHERE NAME='ev1'; ALTER EVENT ev1 ON SCHEDULE EVERY 4 SECOND; +--replace_column 9 # 10 # SHOW EVENTS IN event_test11764334 WHERE NAME='ev1'; DROP EVENT ev1; DROP DATABASE event_test11764334; -- cgit v1.2.1