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-11-02 13:51:43+01:00, andrey@stripped +10 -0
Better fix for bug#22830
Events: crash with procedure which alters events with function
Post-review CS
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-11-02 13:51:31+01:00, andrey@stripped +46
-4
update resut
mysql-test/r/events_grant.result@stripped, 2006-11-02 13:51:31+01:00, andrey@stripped +11
-11
update result
mysql-test/r/kill.result@stripped, 2006-11-02 13:51:31+01:00, andrey@stripped +1 -1
the error message has been changed for KILL
mysql-test/t/events_bugs.test@stripped, 2006-11-02 13:51:31+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-11-02 13:51:31+01:00, andrey@stripped +6 -6
add ORDER BY clause to keep the result deterministic.
mysql-test/t/kill.test@stripped, 2006-11-02 13:51:31+01:00, andrey@stripped +1 -1
use name of the error, and change the error
from parse error, to not supported
sql/sql_lex.cc@stripped, 2006-11-02 13:51:31+01:00, andrey@stripped +23 -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.
sql/sql_lex.h@stripped, 2006-11-02 13:51:32+01:00, andrey@stripped +2 -0
helper function to check whether a table or SP was used
sql/sql_parse.cc@stripped, 2006-11-02 13:51:32+01:00, andrey@stripped +13 -0
Use LEX::table_or_sp_used() 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-11-02 13:51:32+01:00, andrey@stripped +3 -13
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.203/sql/sql_lex.cc 2006-11-02 13:51:58 +01:00
+++ 1.204/sql/sql_lex.cc 2006-11-02 13:51:58 +01:00
@@ -2141,6 +2141,28 @@ void st_lex::restore_backup_query_tables
/*
+ Checks for usage of routines and/or tables in a parsed statement
+
+ SYNOPSIS
+ st_lex:table_or_sp_used()
+
+ RETURN
+ FALSE No routines and tables used
+ TRUE Either or both routines and tables are used.
+*/
+
+bool st_lex::table_or_sp_used()
+{
+ DBUG_ENTER("table_or_sp_used");
+
+ if (sroutines.records || query_tables)
+ DBUG_RETURN(TRUE);
+
+ DBUG_RETURN(FALSE);
+}
+
+
+/*
Do end-of-prepare fixup for list of tables and their merge-VIEWed tables
SYNOPSIS
@@ -2206,6 +2228,7 @@ void st_select_lex::fix_prepare_informat
fix_prepare_info_in_table_list(thd, (TABLE_LIST *)table_list.first);
}
}
+
/*
There are st_select_lex::add_table_to_list &
--- 1.248/sql/sql_lex.h 2006-11-02 13:51:58 +01:00
+++ 1.249/sql/sql_lex.h 2006-11-02 13:51:58 +01:00
@@ -1199,6 +1199,8 @@ typedef struct st_lex : public Query_tab
void reset_n_backup_query_tables_list(Query_tables_list *backup);
void restore_backup_query_tables_list(Query_tables_list *backup);
+
+ bool table_or_sp_used();
} LEX;
struct st_lex_local: public st_lex
--- 1.589/sql/sql_parse.cc 2006-11-02 13:51:58 +01:00
+++ 1.590/sql/sql_parse.cc 2006-11-02 13:51:58 +01:00
@@ -3906,6 +3906,12 @@ end_with_restore_list:
case SQLCOM_ALTER_EVENT:
{
DBUG_ASSERT(lex->event_parse_data);
+ if (lex->table_or_sp_used())
+ {
+ my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Usage of subqueries or stored "
+ "function calls as part of this statement");
+ break;
+ }
switch (lex->sql_command) {
case SQLCOM_CREATE_EVENT:
res= Events::get_instance()->
@@ -4206,6 +4212,13 @@ end_with_restore_list:
case SQLCOM_KILL:
{
Item *it= (Item *)lex->value_list.head();
+
+ if (lex->table_or_sp_used())
+ {
+ my_error(ER_NOT_SUPPORTED_YET, MYF(0), "Usage of subqueries or stored "
+ "function calls as part of this statement");
+ break;
+ }
if ((!it->fixed && it->fix_fields(lex->thd, &it)) ||
it->check_cols(1))
{
--- 1.510/sql/sql_yacc.yy 2006-11-02 13:51:58 +01:00
+++ 1.511/sql/sql_yacc.yy 2006-11-02 13:51:58 +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
{
@@ -8638,17 +8633,12 @@ purge_option:
/* kill threads */
kill:
- KILL_SYM
- {
- Lex->sql_command= SQLCOM_KILL;
- Lex->expr_allows_subselect= FALSE;
- }
- kill_option expr
+ KILL_SYM kill_option expr
{
LEX *lex=Lex;
lex->value_list.empty();
- lex->value_list.push_front($4);
- Lex->expr_allows_subselect= TRUE;
+ lex->value_list.push_front($3);
+ lex->sql_command= SQLCOM_KILL;
};
kill_option:
--- 1.22/mysql-test/r/events_bugs.result 2006-11-02 13:51:58 +01:00
+++ 1.23/mysql-test/r/events_bugs.result 2006-11-02 13:51:58 +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 or stored
function 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 or stored
function 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 or stored
function 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 or stored
function 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 or stored
function 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-11-02 13:51:58 +01:00
+++ 1.3/mysql-test/r/events_grant.result 2006-11-02 13:51:58 +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-11-02 13:51:58 +01:00
+++ 1.19/mysql-test/t/events_bugs.test 2006-11-02 13:51:58 +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-11-02 13:51:58 +01:00
+++ 1.4/mysql-test/t/events_grant.test 2006-11-02 13:51:58 +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-11-02 13:51:58 +01:00
+++ 1.15/mysql-test/r/kill.result 2006-11-02 13:51:58 +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 or stored
function 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-11-02 13:51:58 +01:00
+++ 1.24/mysql-test/t/kill.test 2006-11-02 13:51:58 +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#22830 | ahristov | 2 Nov |