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 the definer of Triggers #
12 ###########################################
14 # General setup to be used in all testcases
15 let $message= ######### Testcase
for definer: ########;
16 --source include/show_msg.inc
19 drop database
if exists priv_db;
21 create database priv_db;
23 eval create
table t1 (f1
char(20)) engine= $engine_type;
25 create User test_yesprivs@localhost;
26 set password for test_yesprivs@localhost = password('PWD');
28 revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
30 connect (yes_privs,localhost,test_yesprivs,PWD,
test,$MASTER_MYPORT,$MASTER_MYSOCK);
32 # create trigger with not existing definer shall deliver a warning:
36 create definer=not_ex_user@localhost trigger trg1_0
37 before INSERT on t1
for each row
38 set new.f1 =
'trig 1_0-yes';
40 # create trigger with definer test_yesprivs@localhost->succeed:
41 create definer=test_yesprivs@localhost trigger trg1_0
42 before INSERT on t1
for each row
43 set new.f1 =
'trig 1_0-yes';
44 grant select, insert, update
45 on priv_db.t1
to test_yesprivs@localhost;
50 # user hasn't trigger privilege->fail:
51 --error ER_TABLEACCESS_DENIED_ERROR
52 insert into t1 (f1) values ('insert-no');
53 select f1 from t1 order by f1;
54 --error ER_TABLEACCESS_DENIED_ERROR
59 grant select, insert, update ,trigger
60 on priv_db.t1
to test_yesprivs@localhost;
61 show grants for test_yesprivs@localhost;
65 # user now has trigger privilege->succeed:
66 insert into t1 (f1) values ('insert-no');
67 select f1 from t1 order by f1;
69 # user has not super privilege->fail:
70 --error ER_SPECIFIC_ACCESS_DENIED_ERROR
71 create definer=not_ex_user@localhost trigger trg1_0
72 before INSERT on t1
for each row
73 set new.f1 =
'trig 1_0-yes';
74 # shall always succeed:
75 create definer=current_user trigger trg1_1
76 before INSERT on t1
for each row
77 set new.f1 =
'trig 1_1-yes';
78 insert into t1 (f1) values ('insert-no');
79 select f1 from t1 order by f1;
80 # shall always succeed:
81 create definer=test_yesprivs@localhost trigger trg1_2
82 before UPDATE on t1
for each row
83 set new.f1 =
'trig 1_2-yes';
84 update t1
set f1 =
'update-yes' where f1 like
'%trig%';
85 select f1 from t1 order by f1;
89 grant trigger on priv_db.*
to test_yesprivs@localhost
92 # user has not super privilege->fail:
96 --error ER_SPECIFIC_ACCESS_DENIED_ERROR
97 create definer=not_ex_user@localhost trigger trg1_3
98 after UPDATE on t1
for each row
99 set @var1 =
'trig 1_3-yes';
106 disconnect yes_privs;
115 drop database
if exists priv_db;
116 drop user test_yesprivs@localhost;