mariadb/mysql-test/main/events_grant.test

114 lines
5.3 KiB
Text
Raw Normal View History

# Can't test with embedded server that doesn't support grants
-- source include/not_embedded.inc
2006-05-29 13:16:29 +02:00
CREATE DATABASE IF NOT EXISTS events_test;
use events_test;
#
# Events grants test begin
#
CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123;
--replace_column 8 # 9 #
SHOW EVENTS;
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: update resut mysql-test/r/events_grant.result: update result mysql-test/r/kill.result: the error message has been changed for KILL mysql-test/t/events_bugs.test: 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: add ORDER BY clause to keep the result deterministic. mysql-test/t/kill.test: use name of the error, and change the error from parse error, to not supported sql/sql_lex.cc: 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: helper function to check whether a table or SP was used sql/sql_parse.cc: 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: 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
2006-11-02 13:51:43 +01:00
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;
2006-05-29 13:16:29 +02:00
CREATE DATABASE events_test2;
CREATE USER ev_test@localhost;
GRANT ALL ON events_test.* to ev_test@localhost;
GRANT ALL ON events_test2.* to ev_test@localhost;
REVOKE EVENT ON events_test2.* FROM ev_test@localhost;
#now we are on con1
connect (ev_con1,localhost,ev_test,,events_test2);
select "NEW CONNECTION";
SELECT USER(), DATABASE();
SHOW GRANTS;
--echo "Here comes an error:";
#NO EVENT_ACL on events_test2
--error 1044
SHOW EVENTS;
USE events_test;
--echo "We should see one event";
--replace_column 8 # 9 #
SHOW EVENTS;
#now create an event with the same name but we are different user
SELECT CONCAT("Let's create some new events from the name of ", USER());
--error ER_EVENT_ALREADY_EXISTS
CREATE EVENT one_event ON SCHEDULE EVERY 20 SECOND DO SELECT 123;
CREATE EVENT two_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION NOT PRESERVE COMMENT "two event" DO SELECT 123;
CREATE EVENT three_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION PRESERVE COMMENT "three event" DO SELECT 123;
--echo "Now we should see 3 events:";
--replace_column 8 # 9 #
SHOW EVENTS;
--echo "This should show us only 2 events:";
--replace_column 8 # 9 #
SHOW EVENTS LIKE 't%event';
--echo "This should show us no events:";
--replace_column 8 # 9 #
SHOW EVENTS FROM test LIKE '%';
#ok, we are back
connection default;
GRANT EVENT ON events_test2.* TO ev_test@localhost;
connection ev_con1;
USE events_test2;
CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
connection default;
USE events_test;
--echo "We should see 4 events : one_event, two_event, three_event & four_event"
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: update resut mysql-test/r/events_grant.result: update result mysql-test/r/kill.result: the error message has been changed for KILL mysql-test/t/events_bugs.test: 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: add ORDER BY clause to keep the result deterministic. mysql-test/t/kill.test: use name of the error, and change the error from parse error, to not supported sql/sql_lex.cc: 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: helper function to check whether a table or SP was used sql/sql_parse.cc: 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: 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
2006-11-02 13:51:43 +01:00
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;
2006-05-29 13:16:29 +02:00
DROP DATABASE events_test2;
--echo "We should see 3 events : one_event, two_event, three_event"
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: update resut mysql-test/r/events_grant.result: update result mysql-test/r/kill.result: the error message has been changed for KILL mysql-test/t/events_bugs.test: 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: add ORDER BY clause to keep the result deterministic. mysql-test/t/kill.test: use name of the error, and change the error from parse error, to not supported sql/sql_lex.cc: 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: helper function to check whether a table or SP was used sql/sql_parse.cc: 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: 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
2006-11-02 13:51:43 +01:00
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;
2006-05-29 13:16:29 +02:00
connection default;
CREATE DATABASE events_test2;
USE events_test2;
CREATE EVENT five_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42;
connection ev_con1;
--echo "Should see 4 events - one, two, three & five"
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: update resut mysql-test/r/events_grant.result: update result mysql-test/r/kill.result: the error message has been changed for KILL mysql-test/t/events_bugs.test: 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: add ORDER BY clause to keep the result deterministic. mysql-test/t/kill.test: use name of the error, and change the error from parse error, to not supported sql/sql_lex.cc: 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: helper function to check whether a table or SP was used sql/sql_parse.cc: 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: 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
2006-11-02 13:51:43 +01:00
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;
2006-05-29 13:16:29 +02:00
connection default;
REVOKE EVENT ON events_test2.* FROM ev_test@localhost;
connection ev_con1;
USE test;
--echo "Should see 3 events - one, two & three"
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: update resut mysql-test/r/events_grant.result: update result mysql-test/r/kill.result: the error message has been changed for KILL mysql-test/t/events_bugs.test: 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: add ORDER BY clause to keep the result deterministic. mysql-test/t/kill.test: use name of the error, and change the error from parse error, to not supported sql/sql_lex.cc: 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: helper function to check whether a table or SP was used sql/sql_parse.cc: 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: 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
2006-11-02 13:51:43 +01:00
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;
2006-05-29 13:16:29 +02:00
--echo "Let's test ALTER EVENT which changes the definer"
USE events_test;
ALTER EVENT one_event ON SCHEDULE EVERY 10 SECOND;
--echo "The definer should be ev_test@localhost"
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 WHERE EVENT_NAME='one_event';
2006-05-29 13:16:29 +02:00
connection default;
USE events_test;
ALTER EVENT one_event COMMENT "comment";
connection ev_con1;
--echo "The definer should be root@localhost"
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 WHERE EVENT_NAME='one_event';
2006-05-29 13:16:29 +02:00
ALTER EVENT one_event DO SELECT 12;
--echo "The definer should be ev_test@localhost"
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 WHERE EVENT_NAME='one_event';
2006-05-29 13:16:29 +02:00
connection default;
--echo "make the definer again root@localhost"
ALTER EVENT one_event COMMENT "new comment";
connection ev_con1;
--echo "test DROP by another user"
DROP EVENT one_event;
connection default;
--echo "One event should not be there"
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: update resut mysql-test/r/events_grant.result: update result mysql-test/r/kill.result: the error message has been changed for KILL mysql-test/t/events_bugs.test: 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: add ORDER BY clause to keep the result deterministic. mysql-test/t/kill.test: use name of the error, and change the error from parse error, to not supported sql/sql_lex.cc: 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: helper function to check whether a table or SP was used sql/sql_parse.cc: 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: 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
2006-11-02 13:51:43 +01:00
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 ev_con1;
2006-05-29 13:16:29 +02:00
disconnect ev_con1;
--source include/wait_until_disconnected.inc
2006-05-29 13:16:29 +02:00
connection default;
DROP USER ev_test@localhost;
DROP DATABASE events_test2;
Fix for bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/r/events_bugs.result: uppercase mysql-test/t/events.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_bugs.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_grant.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_logs_tests.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_scheduling.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_stress.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_time_zone.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_trans.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_trans_notembedded.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist"
2007-05-26 16:36:38 +02:00
#
# End of tests
2006-05-29 13:16:29 +02:00
#
Fix for bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/r/events_bugs.result: uppercase mysql-test/t/events.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_bugs.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_grant.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_logs_tests.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_scheduling.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_stress.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_time_zone.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_trans.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist" mysql-test/t/events_trans_notembedded.test: wait at the end of the script for event which haven't finished their execution. This should solve bug#26338 events_bugs.test fail on Debian and bug#28285 Test "events_bugs" has instable results of "select /*1*/ ... from processlist"
2007-05-26 16:36:38 +02:00
--source include/check_events_off.inc
2006-05-29 13:16:29 +02:00
DROP DATABASE events_test;