List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:April 19 2011 12:01pm
Subject:bzr commit into mysql-5.1 branch (Dmitry.Shulga:3662) Bug#57156 Bug#11764334
View as plain text  
#At file:///Users/shulga/projects/mysql/mysql-5.1-bug11764334/ based on revid:sergey.glukhov@stripped

 3662 Dmitry Shulga	2011-04-19
      Fixed bug#11764334 (formerly bug#57156): ALTER EVENT CHANGES
      THE EVENT STATUS.
      
      The problem was that when ALTER EVENT statement being processed
      a value of status field is saved uncoditionnaly even if it wasn't
      specified in ALTER STATEMENT. As a consequence this field
      is set to default value that corresponds to ENABLE value.
      
      The solution is to check if status field was specified in
      ALTER EVENT statememt before make assignment of new value to
      this 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 this value was set in ALTER EVENT
        statement.
     @ 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.

    modified:
      mysql-test/r/events_bugs.result
      mysql-test/t/events_bugs.test
      sql/event_db_repository.cc
      sql/event_parse_data.cc
      sql/event_parse_data.h
      sql/sql_yacc.yy
=== modified file 'mysql-test/r/events_bugs.result'
--- a/mysql-test/r/events_bugs.result	2011-03-28 15:31:37 +0000
+++ b/mysql-test/r/events_bugs.result	2011-04-19 12:01:16 +0000
@@ -419,7 +419,7 @@ SET TIME_ZONE= '+04:00';
 ALTER EVENT e1 DO SELECT 2;
 SHOW EVENTS;
 Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
-events_test	e1	root@localhost	-03:00	RECURRING	NULL	1	DAY	2005-12-31 20:58:59	2030-01-03 00:00:00	ENABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
+events_test	e1	root@localhost	-03:00	RECURRING	NULL	1	DAY	2005-12-31 20:58:59	2030-01-03 00:00:00	DISABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
 DROP EVENT e1;
 SET TIME_ZONE='+05:00';
 CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO
@@ -518,7 +518,7 @@ DO
 SELECT 1;
 SHOW EVENTS;
 Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
-events_test	e1	root@localhost	+00:00	RECURRING	NULL	1	HOUR	1999-01-01 00:00:00	1999-01-02 00:00:00	DISABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
+events_test	e1	root@localhost	+00:00	RECURRING	NULL	1	HOUR	1999-01-01 00:00:00	1999-01-02 00:00:00	ENABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
 events_test	e2	root@localhost	+00:00	RECURRING	NULL	1	HOUR	1999-01-01 00:00:00	NULL	ENABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
 events_test	e3	root@localhost	+00:00	RECURRING	NULL	1	HOUR	1999-01-01 00:00:00	1999-01-02 00:00:00	DISABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
 events_test	e4	root@localhost	+00:00	RECURRING	NULL	1	HOUR	1999-01-01 00:00:00	1999-01-02 00:00:00	DISABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
@@ -756,6 +756,19 @@ SHOW EVENTS;
 Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
 DROP DATABASE event_test1;
 DROP DATABASE event_test12;
+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;
+SHOW EVENTS WHERE NAME='ev1';
+Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
+event_test11764334	ev1	root@localhost	SYSTEM	RECURRING	NULL	3	SECOND	2006-01-01 02:59:01	NULL	DISABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
+ALTER EVENT ev1 ON SCHEDULE EVERY 4 SECOND;
+SHOW EVENTS WHERE NAME='ev1';
+Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator	character_set_client	collation_connection	Database Collation
+event_test11764334	ev1	root@localhost	SYSTEM	RECURRING	NULL	4	SECOND	2006-01-01 02:59:01	NULL	DISABLED	1	latin1	latin1_swedish_ci	latin1_swedish_ci
+DROP EVENT ev1;
+DROP DATABASE event_test11764334;
 DROP DATABASE events_test;
 SET GLOBAL event_scheduler= 'ON';
 SET @@global.concurrent_insert= @concurrent_insert;

=== modified file 'mysql-test/t/events_bugs.test'
--- a/mysql-test/t/events_bugs.test	2011-03-28 15:31:37 +0000
+++ b/mysql-test/t/events_bugs.test	2011-04-19 12:01:16 +0000
@@ -1236,6 +1236,21 @@ DROP DATABASE event_test1;
 DROP DATABASE event_test12;
 
 
+#
+# 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 WHERE NAME='ev1';
+ALTER EVENT ev1 ON SCHEDULE EVERY 4 SECOND;
+SHOW EVENTS WHERE NAME='ev1';
+DROP EVENT ev1;
+DROP DATABASE event_test11764334;
+ 
 ###########################################################################
 #
 # End of tests

=== modified file 'sql/event_db_repository.cc'
--- a/sql/event_db_repository.cc	2011-03-21 16:02:47 +0000
+++ b/sql/event_db_repository.cc	2011-04-19 12:01:16 +0000
@@ -226,9 +226,15 @@ mysql_event_fill_row(THD *thd,
   if (fields[f_num= ET_FIELD_NAME]->store(et->name.str, et->name.length, scs))
     goto err_truncate;
 
-  /* both ON_COMPLETION and STATUS are NOT NULL thus not calling set_notnull()*/
+  /* ON_COMPLETION are NOT NULL thus not calling set_notnull()*/
   rs|= fields[ET_FIELD_ON_COMPLETION]->store((longlong)et->on_completion, TRUE);
-  rs|= fields[ET_FIELD_STATUS]->store((longlong)et->status, TRUE);
+
+  /*
+    set STATUS value unconditionally in case of CREATE EVENT processing.
+    For ALTER EVENT sets this field only if it was changed.
+  */
+  if (!is_update || et->status_changed)
+    rs|= fields[ET_FIELD_STATUS]->store((longlong)et->status, TRUE);
   rs|= fields[ET_FIELD_ORIGINATOR]->store((longlong)et->originator, TRUE);
 
   /*

=== modified file 'sql/event_parse_data.cc'
--- a/sql/event_parse_data.cc	2009-02-13 16:41:47 +0000
+++ b/sql/event_parse_data.cc	2011-04-19 12:01:16 +0000
@@ -46,9 +46,8 @@ Event_parse_data::new_instance(THD *thd)
 
 Event_parse_data::Event_parse_data()
   :on_completion(Event_parse_data::ON_COMPLETION_DEFAULT),
-  status(Event_parse_data::ENABLED),
-  do_not_create(FALSE),
-  body_changed(FALSE),
+  status(Event_parse_data::ENABLED), status_changed(false),
+  do_not_create(FALSE), body_changed(FALSE),
   item_starts(NULL), item_ends(NULL), item_execute_at(NULL),
   starts_null(TRUE), ends_null(TRUE), execute_at_null(TRUE),
   item_expression(NULL), expression(0)

=== modified file 'sql/event_parse_data.h'
--- a/sql/event_parse_data.h	2008-11-10 20:21:49 +0000
+++ b/sql/event_parse_data.h	2011-04-19 12:01:16 +0000
@@ -49,6 +49,7 @@ public:
 
   int on_completion;
   int status;
+  bool status_changed;
   longlong originator;
   /*
     do_not_create will be set if STARTS time is in the past and

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2010-10-13 05:28:58 +0000
+++ b/sql/sql_yacc.yy	2011-04-19 12:01:16 +0000
@@ -2024,16 +2024,19 @@ opt_ev_status:
         | ENABLE_SYM
           {
             Lex->event_parse_data->status= Event_parse_data::ENABLED;
+            Lex->event_parse_data->status_changed= TRUE;
             $$= 1;
           }
         | DISABLE_SYM ON SLAVE
           {
             Lex->event_parse_data->status= Event_parse_data::SLAVESIDE_DISABLED;
+            Lex->event_parse_data->status_changed= TRUE; 
             $$= 1;
           }
         | DISABLE_SYM
           {
             Lex->event_parse_data->status= Event_parse_data::DISABLED;
+            Lex->event_parse_data->status_changed= TRUE;
             $$= 1;
           }
         ;


Attachment: [text/bzr-bundle] bzr/dmitry.shulga@oracle.com-20110419120116-0e8e5q72cp1g1443.bundle
Thread
bzr commit into mysql-5.1 branch (Dmitry.Shulga:3662) Bug#57156 Bug#11764334Dmitry Shulga19 Apr
  • Re: bzr commit into mysql-5.1 branch (Dmitry.Shulga:3662) Bug#57156Bug#11764334Alexander Nozdrin9 Jun