List:Commits« Previous MessageNext Message »
From:ahristov Date:May 9 2006 9:37am
Subject:bk commit into 5.1 tree (andrey:1.2394) BUG#18896
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of andrey. When andrey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2394 06/05/09 11:36:49 andrey@lmy004. +7 -0
  fix for bug #18896: Events: crash if create within create
  - disables recursive EVENT DDLs except for the case of DROP EVENT and ALTER EVENT
  which does not change the body.
  - disables CREATE EVENT in SP/TRIGGER and EVENT BODY (see above)

  sql/sql_yacc.yy
    1.475 06/05/09 11:36:35 andrey@lmy004. +5 -33
    disable nested events and create event in a SP/TRIGGER/FUNCTION
    ALTER EVENT is possible if does not touch the body.
    DROP EVENT is possible always.

  sql/share/errmsg.txt
    1.97 06/05/09 11:36:35 andrey@lmy004. +2 -0
    new error

  sql/event_timed.cc
    1.51 06/05/09 11:36:35 andrey@lmy004. +5 -0
    change security context before compilation and return it back to what it was.
    fix for bug #18896: Events: crash if create within create

  mysql-test/t/events_bugs.test
    1.7 06/05/09 11:36:35 andrey@lmy004. +11 -12
    test case for bug #18896 Events: crash if create within create

  mysql-test/t/events.test
    1.29 06/05/09 11:36:35 andrey@lmy004. +22 -12
    update test

  mysql-test/r/events_bugs.result
    1.9 06/05/09 11:36:35 andrey@lmy004. +5 -12
    update result

  mysql-test/r/events.result
    1.33 06/05/09 11:36:35 andrey@lmy004. +17 -3
    update result

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	andrey
# Host:	lmy004.
# Root:	/work/mysql-5.1-bug18896

--- 1.474/sql/sql_yacc.yy	2006-05-02 07:45:25 +02:00
+++ 1.475/sql/sql_yacc.yy	2006-05-09 11:36:35 +02:00
@@ -1263,17 +1263,6 @@ create:
           {
             LEX *lex=Lex;
 
-            if (lex->et)
-            {
-              /*
-                Recursive events are not possible because recursive SPs
-                are not also possible. lex->sp_head is not stacked.
-              */
-              // ToDo Andrey : Change the error message
-              my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "EVENT");
-              YYABORT;
-            }
-
             lex->create_info.options= $3;
 
             if (!(lex->et= new(YYTHD->mem_root) Event_timed())) // implicitly calls Event_timed::init()
@@ -1497,9 +1486,12 @@ ev_sql_stmt:
             LEX *lex= Lex;
             sp_head *sp;
 
-            $<sphead>$= lex->sphead;
+            if (lex->sphead)
+            {
+              my_error(ER_EVENT_RECURSIVITY_FORBIDDEN, MYF(0));
+              YYABORT;
+            }
 
-            if (!lex->sphead)
             {
               if (!(sp= new sp_head()))
                 YYABORT;
@@ -1524,7 +1516,6 @@ ev_sql_stmt:
           {
             LEX *lex=Lex;
 
-            if (!$<sphead>1)
             {
               sp_head *sp= lex->sphead;
               // return back to the original memory root ASAP
@@ -4656,15 +4647,6 @@ alter:
             LEX *lex=Lex;
             Event_timed *et;
 
-            if (lex->et)
-            {
-              /*
-                Recursive events are not possible because recursive SPs
-                are not also possible. lex->sp_head is not stacked.
-              */
-              my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "EVENT");
-              YYABORT;
-            }
             lex->spname= 0;//defensive programming
 
             if (!(et= new (YYTHD->mem_root) Event_timed()))// implicitly calls Event_timed::init()
@@ -7588,16 +7570,6 @@ drop:
         | DROP EVENT_SYM if_exists sp_name
           {
             LEX *lex=Lex;
-
-            if (lex->et)
-            {
-              /*
-                Recursive events are not possible because recursive SPs
-                are not also possible. lex->sp_head is not stacked.
-              */
-              my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "EVENT");
-              YYABORT;
-            }
 
             if (!(lex->et= new (YYTHD->mem_root) Event_timed()))
               YYABORT;

--- 1.32/mysql-test/r/events.result	2006-04-07 11:29:08 +02:00
+++ 1.33/mysql-test/r/events.result	2006-05-09 11:36:35 +02:00
@@ -85,13 +85,27 @@ SHOW EVENTS;
 Db	Name	Definer	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
 events_test	event_starts_test	root@localhost	RECURRING	NULL	20	SECOND	#	#	ENABLED
 DROP EVENT event_starts_test;
+create table test_nested(a int);
 create event e_43 on schedule every 1 second do set @a = 5;
-set global event_scheduler = 1;
 alter event e_43 do alter event e_43 do set @a = 4;
+ERROR HY000: Recursivity of EVENT DDL statements is forbidden when body is present
+alter event e_43 do
+begin
+alter event e_43 on schedule every 5 minute;
+insert into test_nested values(1);
+end|
+set global event_scheduler = 1;
 select db, name, body, status, interval_field, interval_value from mysql.event;
 db	name	body	status	interval_field	interval_value
-events_test	e_43	set @a = 4	ENABLED	SECOND	1
+events_test	e_43	begin
+alter event e_43 on schedule every 5 minute;
+insert into test_nested values(1);
+end	ENABLED	MINUTE	5
 drop event e_43;
+select * from test_nested;
+a
+1
+drop table test_nested;
 "Let's check whether we can use non-qualified names"
 create table non_qualif(a int);
 create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values (800219);
@@ -441,7 +455,7 @@ user	host	db	command	state	info
 drop event закачка21;
 create table t_16 (s1 int);
 create trigger t_16_bi before insert on t_16 for each row create event  e_16 on schedule every 1 second do set @a=5;
-ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
+ERROR HY000: Recursivity of EVENT DDL statements is forbidden when body is present
 drop table t_16;
 create event white_space
 on schedule every 10 hour

--- 1.8/mysql-test/r/events_bugs.result	2006-03-28 12:23:20 +02:00
+++ 1.9/mysql-test/r/events_bugs.result	2006-05-09 11:36:35 +02:00
 SET NAMES latin1;
 set @a=3;
 CREATE PROCEDURE p_16 () CREATE EVENT e_16 ON SCHEDULE EVERY @a SECOND DO SET @a=5;
-call p_16();
-"Here we used to crash!"
-call p_16();
-ERROR HY000: Event 'e_16' already exists
-call p_16();
-ERROR HY000: Event 'e_16' already exists
-DROP EVENT e_16;
-CALL p_16();
-CALL p_16();
-ERROR HY000: Event 'e_16' already exists
-DROP PROCEDURE p_16;
-DROP EVENT e_16;
+ERROR HY000: Recursivity of EVENT DDL statements is forbidden when body is present
+show procedure status;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment
 create event e_55 on schedule at 99990101000000 do drop table t;
 ERROR HY000: Incorrect AT value: '99990101000000'
 create event e_55 on schedule every 10 hour starts 99990101000000 do drop table t;
@@ -178,4 +169,6 @@ drop procedure ee_16407_6_pendant;
 set global event_scheduler= 0;
 drop table events_smode_test;
 set sql_mode=@old_sql_mode;
+create event e18896_1 on schedule every 1 second do create event e18896_2 on schedule every 1 second do set @a=5;
+ERROR HY000: Recursivity of EVENT DDL statements is forbidden when body is present
 drop database events_test;

--- 1.28/mysql-test/t/events.test	2006-04-22 04:29:18 +02:00
+++ 1.29/mysql-test/t/events.test	2006-05-09 11:36:35 +02:00
@@ -80,19 +80,29 @@ SHOW EVENTS;
 DROP EVENT event_starts_test;
 #
 #
+create table test_nested(a int);
 create event e_43 on schedule every 1 second do set @a = 5;
-set global event_scheduler = 1;
---sleep 2
+--error ER_EVENT_RECURSIVITY_FORBIDDEN
 alter event e_43 do alter event e_43 do set @a = 4;
---sleep 2
+delimiter |;
+alter event e_43 do
+begin
+  alter event e_43 on schedule every 5 minute;
+  insert into test_nested values(1);
+end|
+delimiter ;|
+
+#update mysql.event set body='alter event e_43 on schedule every 5 minute' where name='e_43';
+set global event_scheduler = 1;
+--sleep 1
 select db, name, body, status, interval_field, interval_value from mysql.event;
 drop event e_43;
---sleep 1
-
+select * from test_nested;
+drop table test_nested;
 --echo "Let's check whether we can use non-qualified names"
 create table non_qualif(a int);
 create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values (800219);
---sleep 2
+--sleep 1
 select * from non_qualif;
 drop event non_qualif_ev;
 drop table non_qualif;
@@ -150,9 +160,9 @@ set names cp1251;
 insert into mysql.event (db, name, body, definer, interval_value, interval_field) values (database(), "root22", "select 1", user(), 100, "SECOND_MICROSECOND");
---error 1235
+--error ER_NOT_SUPPORTED_YET
 show create event root22;
---error 1235
+--error ER_NOT_SUPPORTED_YET
 SHOW EVENTS;
 drop event root22;
 drop event root6;
@@ -262,7 +272,7 @@ SHOW GRANTS;
 
 --echo "Here comes an error:";
 #NO EVENT_ACL on events_test2
---error 1044
+--error ER_DBACCESS_DENIED_ERROR
 SHOW EVENTS;
 USE events_test;
 
@@ -330,10 +340,10 @@ create event задачка on schedule 
 drop event задачка;
 
 # event_scheduler is a global var
---error 1229
+--error ER_GLOBAL_VARIABLE
 set event_scheduler=0;
 # event_scheduler could be only either 0 or 1
---error 1231
+--error ER_WRONG_VALUE_FOR_VAR
 set global event_scheduler=2;
 
 --echo "DISABLE the scheduler. Testing that it does not work when the variable is 0"
@@ -397,7 +407,7 @@ drop event закачка21;
 # Bug #16410  Events: CREATE EVENT is legal in a CREATE TRIGGER statement
 #
 create table t_16 (s1 int);
---error 1422
+--error ER_EVENT_RECURSIVITY_FORBIDDEN
 create trigger t_16_bi before insert on t_16 for each row create event  e_16 on schedule every 1 second do set @a=5;
 drop table t_16;
 #

--- 1.6/mysql-test/t/events_bugs.test	2006-03-28 10:42:40 +02:00
+++ 1.7/mysql-test/t/events_bugs.test	2006-05-09 11:36:35 +02:00
@@ -27,19 +27,9 @@ SET NAMES latin1;
 # START - BUG#16408: Events: crash for an event in a procedure
 #
 set @a=3;
+--error ER_EVENT_RECURSIVITY_FORBIDDEN
 CREATE PROCEDURE p_16 () CREATE EVENT e_16 ON SCHEDULE EVERY @a SECOND DO SET @a=5;
-call p_16();
---echo "Here we used to crash!"
---error 1516
-call p_16();
---error 1516
-call p_16();
-DROP EVENT e_16;
-CALL p_16();
---error 1516
-CALL p_16();
-DROP PROCEDURE p_16;
-DROP EVENT e_16;
+show procedure status;
 #
 # END   - BUG#16408: Events: crash for an event in a procedure
 #
@@ -171,5 +161,14 @@ drop table events_smode_test;
 set sql_mode=@old_sql_mode;
 #
 # End  - 16407: Events: Changes in sql_mode won't be taken into account  
+#
+
+#
+# Start - 18896: Events: crash if create within create
+#
+--error ER_EVENT_RECURSIVITY_FORBIDDEN
+create event e18896_1 on schedule every 1 second do create event e18896_2 on schedule every 1 second do set @a=5;
+#
+# End   - 18896: Events: crash if create within create
 #
 drop database events_test;

--- 1.50/sql/event_timed.cc	2006-05-03 15:55:30 +02:00
+++ 1.51/sql/event_timed.cc	2006-05-09 11:36:35 +02:00
@@ -1449,6 +1449,9 @@ Event_timed::compile(THD *thd, MEM_ROOT 
   CHARSET_INFO *old_character_set_client,
                *old_collation_connection,
                *old_character_set_results;
+  Security_context *save_ctx;
+  /* this one is local and not needed after exec */
+  Security_context security_ctx;
 
   DBUG_ENTER("Event_timed::compile");
 
@@ -1494,6 +1497,7 @@ Event_timed::compile(THD *thd, MEM_ROOT 
   thd->query_length= show_create.length();
   DBUG_PRINT("Event_timed::compile", ("query:%s",thd->query));
 
+  change_security_context(thd, &security_ctx, &save_ctx);
   thd->lex= &lex;
   lex_start(thd, (uchar*)thd->query, thd->query_length);
   lex.et_compile_phase= TRUE;
@@ -1531,6 +1535,7 @@ done:
   lex.et->deinit_mutexes();
 
   lex_end(&lex);
+  restore_security_context(thd, save_ctx);
   DBUG_PRINT("note", ("return old data on its place. set back NAMES"));
 
   thd->lex= old_lex;

--- 1.96/sql/share/errmsg.txt	2006-04-30 18:43:22 +02:00
+++ 1.97/sql/share/errmsg.txt	2006-05-09 11:36:35 +02:00
@@ -5840,3 +5840,5 @@ ER_NULL_IN_VALUES_LESS_THAN
 ER_WRONG_PARTITION_NAME
         eng "Incorrect partition name"
         swe "Felaktigt partitionsnamn"
+ER_EVENT_RECURSIVITY_FORBIDDEN
+        eng "Recursivity of EVENT DDL statements is forbidden when body is present"
Thread
bk commit into 5.1 tree (andrey:1.2394) BUG#18896ahristov9 May