Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
606abf25
Commit
606abf25
authored
May 29, 2006
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing events_grant test
parent
4f295835
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
226 additions
and
0 deletions
+226
-0
mysql-test/r/events_grant.result
mysql-test/r/events_grant.result
+121
-0
mysql-test/t/events_grant.test
mysql-test/t/events_grant.test
+105
-0
No files found.
mysql-test/r/events_grant.result
0 → 100644
View file @
606abf25
CREATE DATABASE IF NOT EXISTS events_test;
use events_test;
CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123;
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_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT from information_schema.events;
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
NULL events_test one_event root@localhost SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE
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;
select "NEW CONNECTION";
NEW CONNECTION
NEW CONNECTION
SELECT USER(), DATABASE();
USER() DATABASE()
ev_test@localhost events_test2
SHOW GRANTS;
Grants for ev_test@localhost
GRANT USAGE ON *.* TO 'ev_test'@'localhost'
GRANT ALL PRIVILEGES ON `events_test`.* TO 'ev_test'@'localhost'
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, TRIGGER ON `events_test2`.* TO 'ev_test'@'localhost'
"Here comes an error:";
SHOW EVENTS;
ERROR 42000: Access denied for user 'ev_test'@'localhost' to database 'events_test2'
USE events_test;
"We should see one event";
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 CONCAT("Let's create some new events from the name of ", USER());
CONCAT("Let's create some new events from the name of ", USER())
Let's create some new events from the name of ev_test@localhost
CREATE EVENT one_event ON SCHEDULE EVERY 20 SECOND DO SELECT 123;
ERROR HY000: Event 'one_event' already exists
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;
"Now we should see 3 events:";
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
events_test three_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED
events_test two_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED
"This should show us only 2 events:";
SHOW EVENTS LIKE 't%event';
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test three_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED
events_test two_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED
"This should show us no events:";
SHOW EVENTS FROM test LIKE '%';
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
GRANT EVENT ON events_test2.* TO ev_test@localhost;
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_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
NULL events_test one_event root@localhost SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE
NULL events_test two_event ev_test@localhost SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event
NULL events_test three_event ev_test@localhost SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event
NULL events_test2 four_event ev_test@localhost 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_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
NULL events_test one_event root@localhost SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE
NULL events_test two_event ev_test@localhost SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event
NULL events_test three_event ev_test@localhost SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three 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_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
NULL events_test one_event root@localhost SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE
NULL events_test two_event ev_test@localhost SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event
NULL events_test three_event ev_test@localhost SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event
NULL events_test2 five_event root@localhost 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_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
NULL events_test one_event root@localhost SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE
NULL events_test two_event ev_test@localhost SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event
NULL events_test three_event ev_test@localhost SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event
"Let's test ALTER EVENT which changes the definer"
USE events_test;
ALTER EVENT one_event ON SCHEDULE EVERY 10 SECOND;
"The definer should be ev_test@localhost"
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
NULL events_test one_event ev_test@localhost SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE
USE events_test;
ALTER EVENT one_event COMMENT "comment";
"The definer should be root@localhost"
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
NULL events_test one_event root@localhost SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE comment
ALTER EVENT one_event DO SELECT 12;
"The definer should be ev_test@localhost"
SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event';
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
NULL events_test one_event ev_test@localhost SELECT 12 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE comment
"make the definer again root@localhost"
ALTER EVENT one_event COMMENT "new comment";
"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_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS;
EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT
NULL events_test two_event ev_test@localhost SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event
NULL events_test three_event ev_test@localhost SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event
NULL events_test2 five_event root@localhost SELECT 42 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE
DROP USER ev_test@localhost;
DROP DATABASE events_test2;
DROP DATABASE events_test;
mysql-test/t/events_grant.test
0 → 100644
View file @
606abf25
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_TYPE
,
EXECUTE_AT
,
INTERVAL_VALUE
,
INTERVAL_FIELD
,
STATUS
,
ON_COMPLETION
,
EVENT_COMMENT
from
information_schema
.
events
;
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_TYPE
,
EXECUTE_AT
,
INTERVAL_VALUE
,
INTERVAL_FIELD
,
STATUS
,
ON_COMPLETION
,
EVENT_COMMENT
FROM
INFORMATION_SCHEMA
.
EVENTS
;
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_TYPE
,
EXECUTE_AT
,
INTERVAL_VALUE
,
INTERVAL_FIELD
,
STATUS
,
ON_COMPLETION
,
EVENT_COMMENT
FROM
INFORMATION_SCHEMA
.
EVENTS
;
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_TYPE
,
EXECUTE_AT
,
INTERVAL_VALUE
,
INTERVAL_FIELD
,
STATUS
,
ON_COMPLETION
,
EVENT_COMMENT
FROM
INFORMATION_SCHEMA
.
EVENTS
;
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_TYPE
,
EXECUTE_AT
,
INTERVAL_VALUE
,
INTERVAL_FIELD
,
STATUS
,
ON_COMPLETION
,
EVENT_COMMENT
FROM
INFORMATION_SCHEMA
.
EVENTS
;
--
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_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_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_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_TYPE
,
EXECUTE_AT
,
INTERVAL_VALUE
,
INTERVAL_FIELD
,
STATUS
,
ON_COMPLETION
,
EVENT_COMMENT
FROM
INFORMATION_SCHEMA
.
EVENTS
;
disconnect
ev_con1
;
connection
default
;
DROP
USER
ev_test
@
localhost
;
DROP
DATABASE
events_test2
;
#
## EVENTS grants test end
#
DROP
DATABASE
events_test
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment