mirror of
https://github.com/MariaDB/server.git
synced 2025-07-20 10:24:14 +03:00
This allows one to run the test suite even if any of the following options are changed: - character-set-server - collation-server - join-cache-level - log-basename - max-allowed-packet - optimizer-switch - query-cache-size and query-cache-type - skip-name-resolve - table-definition-cache - table-open-cache - Some innodb options etc Changes: - Don't print out the value of system variables as one can't depend on them to being constants. - Don't set global variables to 'default' as the default may not be the same as the test was started with if there was an additional option file. Instead save original value and reset it at end of test. - Test that depends on the latin1 character set should include default_charset.inc or set the character set to latin1 - Test that depends on the original optimizer switch, should include default_optimizer_switch.inc - Test that depends on the value of a specific system variable should set it in the test (like optimizer_use_condition_selectivity) - Split subselect3.test into subselect3.test and subselect3.inc to make it easier to set and reset system variables. - Added .opt files for test that required specfic options that could be changed by external configuration files. - Fixed result files in rockdsb & tokudb that had not been updated for a while.
116 lines
5.3 KiB
Plaintext
116 lines
5.3 KiB
Plaintext
# Can't test with embedded server that doesn't support grants
|
|
-- source include/not_embedded.inc
|
|
--source include/default_charset.inc
|
|
|
|
|
|
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;
|
|
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;
|
|
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"
|
|
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 ORDER BY EVENT_SCHEMA, EVENT_NAME;
|
|
|
|
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"
|
|
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 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;
|
|
--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';
|
|
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';
|
|
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';
|
|
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"
|
|
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;
|
|
disconnect ev_con1;
|
|
--source include/wait_until_disconnected.inc
|
|
connection default;
|
|
DROP USER ev_test@localhost;
|
|
DROP DATABASE events_test2;
|
|
|
|
#
|
|
# End of tests
|
|
#
|
|
|
|
--source include/check_events_off.inc
|
|
|
|
DROP DATABASE events_test;
|