1 #======================================================================
4 # test cases for TRIGGER privilege on db, table and column level
5 #======================================================================
7 --disable_abort_on_error
9 #########################################################
10 ################ Section 3.5.3 ##########################
11 # Check for mix of user and db level of Triggers #
12 #########################################################
14 # General setup to be used in all testcases
15 let $message= #### Testcase
for mix of user(global) and db
level:
####;
16 --source include/show_msg.inc
19 drop database
if exists priv_db;
20 drop database
if exists no_priv_db;
22 create database priv_db;
23 create database no_priv_db;
25 eval create
table t1 (f1
char(20)) engine= $engine_type;
27 eval create
table t1 (f1
char(20)) engine= $engine_type;
29 create User test_yesprivs@localhost;
30 set password for test_yesprivs@localhost = password('PWD');
31 revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
32 grant ALL on *.*
to test_yesprivs@localhost;
33 show grants for test_yesprivs@localhost;
35 create User test_noprivs@localhost;
36 set password for test_noprivs@localhost = password('PWD');
37 revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
38 grant SELECT,INSERT on *.*
to test_noprivs@localhost;
39 show grants for test_noprivs@localhost;
41 connect (yes_privs,localhost,test_yesprivs,PWD,
test,$MASTER_MYPORT,$MASTER_MYSOCK);
43 connect (no_privs,localhost,test_noprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK);
47 let $message= trigger privilege on user
level for create:;
48 --source include/show_msg.inc
51 create trigger trg1_1 before INSERT on t1 for each row
52 set new.f1 = 'trig 1_1-yes';
53 insert into t1 (f1) values ('insert-no');
54 select f1 from t1 order by f1;
57 create trigger priv_db.trg1_5 before UPDATE on priv_db.t1
59 set new.f1 = 'trig 1_5-yes';
60 insert into priv_db.t1 (f1) values ('insert-no');
61 select f1 from priv_db.t1 order by f1;
62 drop trigger priv_db.trg1_5;
67 insert into t1 (f1) values ('insert-no');
68 select f1 from t1 order by f1;
73 insert into t1 (f1) values ('insert-no');
74 select f1 from t1 order by f1;
76 revoke TRIGGER on *.* from test_yesprivs@localhost;
77 show grants for test_yesprivs@localhost;
79 # change of privilege only active after reconnecting the session
84 connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK);
88 select * from information_schema.triggers;
89 --error ER_TABLEACCESS_DENIED_ERROR
98 ################ Section 3.5.3 ############
99 # Check for the db level of Triggers #
100 ###########################################
101 let $message= no trigger privilege on db
level for create:;
102 --source include/show_msg.inc
104 connection yes_privs;
106 --error ER_TABLEACCESS_DENIED_ERROR
107 create trigger trg1_1 before INSERT on t1
for each row
108 set new.f1 =
'trig 1_1-no';
113 insert into t1 (f1) values ('insert-yes');
114 select f1 from t1 order by f1;
118 grant TRIGGER on priv_db.*
to test_yesprivs@localhost;
119 show grants for test_yesprivs@localhost;
121 let $message= trigger privilege on db
level for create:;
122 --source include/show_msg.inc
123 connection yes_privs;
126 # active after 'use db'
129 create trigger trg1_2 before INSERT on t1
for each row
130 set new.f1 =
'trig 1_2-yes';
131 --error ER_TABLEACCESS_DENIED_ERROR
132 create trigger no_priv_db.trg1_9 before insert on no_priv_db.t1
134 set new.f1 =
'trig 1_9-yes';
136 --error ER_TABLEACCESS_DENIED_ERROR
137 create trigger trg1_2 before INSERT on t1
for each row
138 set new.f1 =
'trig 1_2-no';
139 create trigger priv_db.trg1_9 before UPDATE on priv_db.t1
141 set new.f1 =
'trig 1_9-yes';
146 insert into t1 (f1) values ('insert-yes');
147 select f1 from t1 order by f1;
149 insert into t1 (f1) values ('insert-yes');
150 select f1 from t1 order by f1;
151 --error ER_TABLEACCESS_DENIED_ERROR
152 drop trigger priv_db.trg1_9;
156 drop trigger priv_db.trg1_9;
157 revoke TRIGGER on priv_db.* from test_yesprivs@localhost;
159 --error ER_TABLEACCESS_DENIED_ERROR
160 insert into t1 (f1) values ('insert-yes');
161 select f1 from t1 order by f1;
162 grant TRIGGER on *.*
to test_yesprivs@localhost;
163 show grants for test_yesprivs@localhost;
165 connection yes_privs;
168 --error ER_TABLEACCESS_DENIED_ERROR
169 create trigger trg1_2 before INSERT on t1 for each row
170 set new.f1 = 'trig 1_2-no';
175 insert into t1 (f1) values ('insert-no');
176 select f1 from t1 order by f1;
178 insert into t1 (f1) values ('insert-yes');
179 select f1 from t1 order by f1;
182 disconnect yes_privs;
184 connect (yes_privs,localhost,test_yesprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK);
187 create trigger trg1_2 before INSERT on t1 for each row
188 set new.f1 = 'trig 1_2-yes';
190 disconnect yes_privs;
196 insert into t1 (f1) values ('insert-no');
197 select f1 from t1 order by f1;
199 insert into t1 (f1) values ('insert-no');
200 select f1 from t1 order by f1;
204 # Cleanup table level
209 drop database
if exists priv_db;
210 drop database
if exists no_priv_db;
211 drop database
if exists h1;
212 drop user test_yesprivs@localhost;
213 drop user test_noprivs@localhost;