List:Commits« Previous MessageNext Message »
From:ahristov Date:October 31 2006 5:23pm
Subject:bk commit into 5.1 tree (andrey:1.2331) BUG#22830
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@stripped, 2006-10-31 18:22:56+01:00, andrey@stripped +8 -0
  Better fix for bug#22830
  Events: crash with procedure which alters events with function
  
  This fix also changes the handling of KILL command combined with
  subquery. It changes the error message given back to "not supported",
  from parse error. The error for CREATE|ALTER EVENT has also been changed
  to generate "not supported yet" instead of parse error.
  In case of a SP call, the error is "not supported yet". This change
  cleans the parser from code which should not belong to there. Still
  LEX::expr_allows_subselect is existant because it simplifies the handling
   of SQLCOM_HA_READ which forbids subselects.

  mysql-test/r/events_bugs.result@stripped, 2006-10-31 18:22:46+01:00, andrey@stripped +46 -4
    update resut

  mysql-test/r/events_grant.result@stripped, 2006-10-31 18:22:46+01:00, andrey@stripped +11 -11
    update result

  mysql-test/r/kill.result@stripped, 2006-10-31 18:22:46+01:00, andrey@stripped +1 -1
    the error message has been changed for KILL

  mysql-test/t/events_bugs.test@stripped, 2006-10-31 18:22:46+01:00, andrey@stripped +47 -4
    Update old tests with the new emitted error
    
    Add a test case for
    BUG#22830 Events: crash with procedure which alters events with function

  mysql-test/t/events_grant.test@stripped, 2006-10-31 18:22:47+01:00, andrey@stripped +6 -6
    add ORDER BY clause to keep the result deterministic.

  mysql-test/t/kill.test@stripped, 2006-10-31 18:22:47+01:00, andrey@stripped +1 -1
    use name of the error, and change the error
    from parse error, to not supported

  sql/sql_parse.cc@stripped, 2006-10-31 18:22:47+01:00, andrey@stripped +38 -0
    Add an auxiliary function that checks whether SP and/or
    tables are used in the statement. This function is helpful for
    statements that cannot handle subqueries ans SP calls. Adding out
    of the parser cleans the latter of handling of special cases and
    letting it do its job of parsing.
    
    Use check_for_table_n_sp_usage() for SQLCOM_CREATE_EVENT, SQLCOM_ALTER_EVENT
    and SQLCOM_KILL. SQLCOM_DROP event does not use `expr` rule and thus a check is
    not needed.

  sql/sql_yacc.yy@stripped, 2006-10-31 18:22:47+01:00, andrey@stripped +0 -7
    Remove usage of LEX::expr_allows_subselect for CREATE|ALTER EVENT
    and KILL. There is only one left occurence - SQLCOM_HAREAD, but it 
    adds one table to the list of tables

# 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:	example.com
# Root:	/work/mysql-5.1-runtime-bug22830-new

--- 1.589/sql/sql_parse.cc	2006-10-31 18:23:14 +01:00
+++ 1.590/sql/sql_parse.cc	2006-10-31 18:23:14 +01:00
@@ -68,6 +68,7 @@ static void decrease_user_connections(US
 #endif /* NO_EMBEDDED_ACCESS_CHECKS */
 static bool check_multi_update_lock(THD *thd);
 static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables);
+static bool check_for_table_n_sp_usage(LEX *lex);
 
 const char *any_db="*any*";	// Special symbol for check_access
 
@@ -3906,6 +3907,12 @@ end_with_restore_list:
   case SQLCOM_ALTER_EVENT:
   {
     DBUG_ASSERT(lex->event_parse_data);
+    if (check_for_table_n_sp_usage(lex))
+    {
+      my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Usage of subqueries and stored "
+               "procedures calls as part of this statement");
+      break;
+    }
     switch (lex->sql_command) {
     case SQLCOM_CREATE_EVENT:
       res= Events::get_instance()->
@@ -4207,6 +4214,13 @@ end_with_restore_list:
   {
     Item *it= (Item *)lex->value_list.head();
 
+    if (check_for_table_n_sp_usage(lex))
+    {
+      my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Usage of subqueries and stored "
+               "procedures calls as part of this statement");
+      break;
+    }
+
     if ((!it->fixed && it->fix_fields(lex->thd, &it)) || it->check_cols(1))
     {
       my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY),
@@ -4243,6 +4257,7 @@ end_with_restore_list:
     break;
   case SQLCOM_HA_READ:
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
+
     /*
       There is no need to check for table permissions here, because
       if a user has no permissions to read a table, he won't be
@@ -7822,4 +7837,27 @@ bool check_string_length(LEX_STRING *str
   my_error(ER_WRONG_STRING_LENGTH, MYF(0), str->str, err_msg, max_length);
 
   return TRUE;
+}
+
+
+/*
+  Checks for usage of routines and/or tables in a parsed statement
+
+  SYNOPSIS
+    check_for_table_n_sp_usage()
+      lex   LEX object
+
+  RETURN
+    FALSE  No routines and tables used
+    TRUE   Either or both routines and tables are used.
+*/
+
+static bool check_for_table_n_sp_usage(LEX *lex)
+{
+  DBUG_ENTER("check_for_table_n_sp_usage");
+
+  if (lex->sroutines.records || lex->query_tables)
+    DBUG_RETURN(TRUE);
+
+  DBUG_RETURN(FALSE);
 }

--- 1.510/sql/sql_yacc.yy	2006-10-31 18:23:14 +01:00
+++ 1.511/sql/sql_yacc.yy	2006-10-31 18:23:14 +01:00
@@ -1329,7 +1329,6 @@ event_tail:
 
             Lex->sql_command= SQLCOM_CREATE_EVENT;
             /* We need that for disallowing subqueries */
-            Lex->expr_allows_subselect= FALSE;
           }
           ON SCHEDULE_SYM ev_schedule_time
           opt_ev_on_completion
@@ -1351,7 +1350,6 @@ event_tail:
               can overwrite it
             */
             Lex->sql_command= SQLCOM_CREATE_EVENT;
-            Lex->expr_allows_subselect= TRUE;
           }
       ;
 
@@ -4736,8 +4734,6 @@ alter:
             YYTHD->client_capabilities &= ~CLIENT_MULTI_QUERIES;
 
             Lex->sql_command= SQLCOM_ALTER_EVENT;
-            /* we need that for disallowing subqueries */
-            Lex->expr_allows_subselect= FALSE;
           }
           ev_alter_on_schedule_completion
           opt_ev_rename_to
@@ -4763,7 +4759,6 @@ alter:
               can overwrite it
             */
             Lex->sql_command= SQLCOM_ALTER_EVENT;
-            Lex->expr_allows_subselect= TRUE;
           }
         | ALTER TABLESPACE alter_tablespace_info
           {
@@ -8641,14 +8636,12 @@ kill:
 	KILL_SYM
         {
           Lex->sql_command= SQLCOM_KILL;
-          Lex->expr_allows_subselect= FALSE;
         }
         kill_option expr
 	{
 	  LEX *lex=Lex;
 	  lex->value_list.empty();
 	  lex->value_list.push_front($4);
-          Lex->expr_allows_subselect= TRUE;
 	};
 
 kill_option:

--- 1.22/mysql-test/r/events_bugs.result	2006-10-31 18:23:14 +01:00
+++ 1.23/mysql-test/r/events_bugs.result	2006-10-31 18:23:14 +01:00
@@ -206,13 +206,13 @@ drop event events_test.mysqltest_user1;
 drop user mysqltest_user1@localhost;
 drop database mysqltest_db1;
 create event e_53 on schedule at (select s1 from ttx) do drop table t;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select s1 from ttx) do drop table t' at line 1
+ERROR 42000: This version of MySQL doesn't yet support 'Usage of subqueries and stored procedures calls as part of this statement'
 create event e_53 on schedule every (select s1 from ttx) second do drop table t;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select s1 from ttx) second do drop table t' at line 1
+ERROR 42000: This version of MySQL doesn't yet support 'Usage of subqueries and stored procedures calls as part of this statement'
 create event e_53 on schedule every 5 second starts (select s1 from ttx) do drop table t;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select s1 from ttx) do drop table t' at line 1
+ERROR 42000: This version of MySQL doesn't yet support 'Usage of subqueries and stored procedures calls as part of this statement'
 create event e_53 on schedule every 5 second ends (select s1 from ttx) do drop table t;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select s1 from ttx) do drop table t' at line 1
+ERROR 42000: This version of MySQL doesn't yet support 'Usage of subqueries and stored procedures calls as part of this statement'
 drop event if exists e_16;
 drop procedure if exists p_16;
 create event e_16 on schedule every 1 second do set @a=5;
@@ -226,4 +226,46 @@ set @a= 6;
 call p_16();
 drop procedure p_16;
 drop event e_16;
+drop function if exists f22830;
+drop event if exists e22830;
+drop event if exists e22830_1;
+drop event if exists e22830_2;
+drop event if exists e22830_3;
+drop event if exists e22830_4;
+drop table if exists t1;
+drop table if exists t2;
+create table t1 (a int);
+insert into t1 values (2);
+create table t2 (a char(20));
+insert into t2 values ("e22830_1");
+create function f22830 () returns int return 5;
+create event e22830 on schedule every f22830() second do select 123;
+ERROR 42000: This version of MySQL doesn't yet support 'Usage of subqueries and stored procedures calls as part of this statement'
+create event e22830_1 on schedule every 1 hour do alter event e22830_1 on schedule every (select 8 from dual) hour;
+create event e22830_2 on schedule every 1 hour do alter event e22830_2 on schedule every (select 8 from t1) hour;
+create event e22830_3 on schedule every 1 hour do alter event e22830_3 on schedule every f22830() hour;
+create event e22830_4 on schedule every 1 hour do alter event e22830_4 on schedule every (select f22830() from dual) hour;
+select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name;
+event_name	event_definition	interval_value	interval_field
+e22830_1	alter event e22830_1 on schedule every (select 8 from dual) hour	1	HOUR
+e22830_2	alter event e22830_2 on schedule every (select 8 from t1) hour	1	HOUR
+e22830_3	alter event e22830_3 on schedule every f22830() hour	1	HOUR
+e22830_4	alter event e22830_4 on schedule every (select f22830() from dual) hour	1	HOUR
+set global event_scheduler=on;
+set global event_scheduler=off;
+select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name;
+event_name	event_definition	interval_value	interval_field
+e22830_1	alter event e22830_1 on schedule every (select 8 from dual) hour	8	HOUR
+e22830_2	alter event e22830_2 on schedule every (select 8 from t1) hour	1	HOUR
+e22830_3	alter event e22830_3 on schedule every f22830() hour	1	HOUR
+e22830_4	alter event e22830_4 on schedule every (select f22830() from dual) hour	1	HOUR
+drop function f22830;
+drop event (select a from t2);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(select a from t2)' at line 1
+drop event e22830_1;
+drop event e22830_2;
+drop event e22830_3;
+drop event e22830_4;
+drop table t1;
+drop table t2;
 drop database events_test;

--- 1.2/mysql-test/r/events_grant.result	2006-10-31 18:23:14 +01:00
+++ 1.3/mysql-test/r/events_grant.result	2006-10-31 18:23:14 +01:00
@@ -4,7 +4,7 @@ CREATE EVENT one_event ON SCHEDULE EVERY
 SHOW EVENTS;
 Db	Name	Definer	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
 events_test	one_event	root@localhost	RECURRING	NULL	10	SECOND	#	#	ENABLED
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT from information_schema.events;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 EVENT_CATALOG	EVENT_SCHEMA	EVENT_NAME	DEFINER	EVENT_BODY	EVENT_DEFINITION	EVENT_TYPE	EXECUTE_AT	INTERVAL_VALUE	INTERVAL_FIELD	STATUS	ON_COMPLETION	EVENT_COMMENT
 NULL	events_test	one_event	root@localhost	SQL	SELECT 123	RECURRING	NULL	10	SECOND	ENABLED	NOT PRESERVE	
 CREATE DATABASE events_test2;
@@ -57,37 +57,37 @@ USE events_test2;
 CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
 USE events_test;
 "We should see 4 events : one_event, two_event, three_event & four_event"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 EVENT_CATALOG	EVENT_SCHEMA	EVENT_NAME	DEFINER	EVENT_BODY	EVENT_DEFINITION	EVENT_TYPE	EXECUTE_AT	INTERVAL_VALUE	INTERVAL_FIELD	STATUS	ON_COMPLETION	EVENT_COMMENT
 NULL	events_test	one_event	root@localhost	SQL	SELECT 123	RECURRING	NULL	10	SECOND	ENABLED	NOT PRESERVE	
-NULL	events_test	two_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	two event
 NULL	events_test	three_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	PRESERVE	three event
+NULL	events_test	two_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	two event
 NULL	events_test2	four_event	ev_test@localhost	SQL	SELECT 42	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	
 DROP DATABASE events_test2;
 "We should see 3 events : one_event, two_event, three_event"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 EVENT_CATALOG	EVENT_SCHEMA	EVENT_NAME	DEFINER	EVENT_BODY	EVENT_DEFINITION	EVENT_TYPE	EXECUTE_AT	INTERVAL_VALUE	INTERVAL_FIELD	STATUS	ON_COMPLETION	EVENT_COMMENT
 NULL	events_test	one_event	root@localhost	SQL	SELECT 123	RECURRING	NULL	10	SECOND	ENABLED	NOT PRESERVE	
-NULL	events_test	two_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	two event
 NULL	events_test	three_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	PRESERVE	three event
+NULL	events_test	two_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	two event
 CREATE DATABASE events_test2;
 USE events_test2;
 CREATE EVENT five_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
 "Should see 4 events - one, two, three & five"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 EVENT_CATALOG	EVENT_SCHEMA	EVENT_NAME	DEFINER	EVENT_BODY	EVENT_DEFINITION	EVENT_TYPE	EXECUTE_AT	INTERVAL_VALUE	INTERVAL_FIELD	STATUS	ON_COMPLETION	EVENT_COMMENT
 NULL	events_test	one_event	root@localhost	SQL	SELECT 123	RECURRING	NULL	10	SECOND	ENABLED	NOT PRESERVE	
-NULL	events_test	two_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	two event
 NULL	events_test	three_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	PRESERVE	three event
+NULL	events_test	two_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	two event
 NULL	events_test2	five_event	root@localhost	SQL	SELECT 42	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	
 REVOKE EVENT ON events_test2.* FROM ev_test@localhost;
 USE test;
 "Should see 3 events - one, two & three"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 EVENT_CATALOG	EVENT_SCHEMA	EVENT_NAME	DEFINER	EVENT_BODY	EVENT_DEFINITION	EVENT_TYPE	EXECUTE_AT	INTERVAL_VALUE	INTERVAL_FIELD	STATUS	ON_COMPLETION	EVENT_COMMENT
 NULL	events_test	one_event	root@localhost	SQL	SELECT 123	RECURRING	NULL	10	SECOND	ENABLED	NOT PRESERVE	
-NULL	events_test	two_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	two event
 NULL	events_test	three_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	PRESERVE	three event
+NULL	events_test	two_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	two event
 "Let's test ALTER EVENT which changes the definer"
 USE events_test;
 ALTER EVENT one_event ON SCHEDULE EVERY 10 SECOND;
@@ -111,10 +111,10 @@ ALTER EVENT one_event COMMENT "new comme
 "test DROP by another user"
 DROP EVENT one_event;
 "One event should not be there"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 EVENT_CATALOG	EVENT_SCHEMA	EVENT_NAME	DEFINER	EVENT_BODY	EVENT_DEFINITION	EVENT_TYPE	EXECUTE_AT	INTERVAL_VALUE	INTERVAL_FIELD	STATUS	ON_COMPLETION	EVENT_COMMENT
-NULL	events_test	two_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	two event
 NULL	events_test	three_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	PRESERVE	three event
+NULL	events_test	two_event	ev_test@localhost	SQL	SELECT 123	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	two event
 NULL	events_test2	five_event	root@localhost	SQL	SELECT 42	RECURRING	NULL	20	SECOND	ENABLED	NOT PRESERVE	
 DROP USER ev_test@localhost;
 DROP DATABASE events_test2;

--- 1.18/mysql-test/t/events_bugs.test	2006-10-31 18:23:14 +01:00
+++ 1.19/mysql-test/t/events_bugs.test	2006-10-31 18:23:14 +01:00
@@ -222,13 +222,13 @@ drop database mysqltest_db1;
 #
 # START - BUG#16394: Events: Crash if schedule contains SELECT
 #
---error ER_PARSE_ERROR
+--error ER_NOT_SUPPORTED_YET
 create event e_53 on schedule at (select s1 from ttx) do drop table t;
---error ER_PARSE_ERROR
+--error ER_NOT_SUPPORTED_YET
 create event e_53 on schedule every (select s1 from ttx) second do drop table t;
---error ER_PARSE_ERROR
+--error ER_NOT_SUPPORTED_YET
 create event e_53 on schedule every 5 second starts (select s1 from ttx) do drop table t;
---error ER_PARSE_ERROR
+--error ER_NOT_SUPPORTED_YET
 create event e_53 on schedule every 5 second ends (select s1 from ttx) do drop table t;
 #
 # END   - BUG#16394: Events: Crash if schedule contains SELECT
@@ -253,4 +253,47 @@ call p_16();
 
 drop procedure p_16;
 drop event e_16;
+
+#
+# START - BUG#22830 Events: crash with procedure which alters events with function
+#
+--disable_warnings
+drop function if exists f22830;
+drop event if exists e22830;
+drop event if exists e22830_1;
+drop event if exists e22830_2;
+drop event if exists e22830_3;
+drop event if exists e22830_4;
+drop table if exists t1;
+drop table if exists t2;
+--enable_warnings
+create table t1 (a int);
+insert into t1 values (2);
+create table t2 (a char(20));
+insert into t2 values ("e22830_1");
+create function f22830 () returns int return 5;
+--error ER_NOT_SUPPORTED_YET
+create event e22830 on schedule every f22830() second do select 123;
+create event e22830_1 on schedule every 1 hour do alter event e22830_1 on schedule every (select 8 from dual) hour;
+create event e22830_2 on schedule every 1 hour do alter event e22830_2 on schedule every (select 8 from t1) hour;
+create event e22830_3 on schedule every 1 hour do alter event e22830_3 on schedule every f22830() hour;
+create event e22830_4 on schedule every 1 hour do alter event e22830_4 on schedule every (select f22830() from dual) hour;
+select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name;
+set global event_scheduler=on;
+--sleep 0.7
+set global event_scheduler=off;
+select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name;
+drop function f22830;
+--error ER_PARSE_ERROR
+drop event (select a from t2);
+drop event e22830_1;
+drop event e22830_2;
+drop event e22830_3;
+drop event e22830_4;
+drop table t1;
+drop table t2;
+
+#
+# End of tests
+#
 drop database events_test;

--- 1.3/mysql-test/t/events_grant.test	2006-10-31 18:23:14 +01:00
+++ 1.4/mysql-test/t/events_grant.test	2006-10-31 18:23:14 +01:00
@@ -9,7 +9,7 @@ use events_test;
 CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123;
 --replace_column 8 # 9 #
 SHOW EVENTS;
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT from information_schema.events;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 CREATE DATABASE events_test2;
 CREATE USER ev_test@localhost;
 GRANT ALL ON events_test.* to ev_test@localhost;
@@ -55,10 +55,10 @@ CREATE EVENT four_event ON SCHEDULE EVER
 connection default;
 USE events_test;
 --echo "We should see 4 events : one_event, two_event, three_event & four_event"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 DROP DATABASE events_test2;
 --echo "We should see 3 events : one_event, two_event, three_event"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 
 connection default;
 CREATE DATABASE events_test2;
@@ -67,13 +67,13 @@ CREATE EVENT five_event ON SCHEDULE EVER
 
 connection ev_con1;
 --echo "Should see 4 events - one, two, three & five"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 connection default;
 REVOKE EVENT ON events_test2.* FROM ev_test@localhost;
 connection ev_con1;
 USE test;
 --echo "Should see 3 events - one, two & three"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 --echo "Let's test ALTER EVENT which changes the definer"
 USE events_test;
 ALTER EVENT one_event ON SCHEDULE EVERY 10 SECOND;
@@ -96,7 +96,7 @@ connection ev_con1;
 DROP EVENT one_event;
 connection default;
 --echo "One event should not be there"
-SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
+SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME;
 disconnect ev_con1;
 connection default;
 DROP USER ev_test@localhost;

--- 1.14/mysql-test/r/kill.result	2006-10-31 18:23:14 +01:00
+++ 1.15/mysql-test/r/kill.result	2006-10-31 18:23:14 +01:00
@@ -16,7 +16,7 @@ select 4;
 4
 drop table t1;
 kill (select count(*) from mysql.user);
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from mysql.user)' at line 1
+ERROR 42000: This version of MySQL doesn't yet support 'Usage of subqueries and stored procedures calls as part of this statement'
 create table t1 (id int primary key);
 create table t2 (id int unsigned not null);
 insert into t2 select id from t1;

--- 1.23/mysql-test/t/kill.test	2006-10-31 18:23:14 +01:00
+++ 1.24/mysql-test/t/kill.test	2006-10-31 18:23:14 +01:00
@@ -48,7 +48,7 @@ select 4;
 drop table t1;
 connection default;
 
---error 1064
+--error ER_NOT_SUPPORTED_YET
 kill (select count(*) from mysql.user);
 
 #
Thread
bk commit into 5.1 tree (andrey:1.2331) BUG#22830ahristov31 Oct