1 #======================================================================
4 # test cases for TRIGGER privilege on db, table and column level
5 # These tests ensure that at activation time (execute statement)
6 # the user must have trigger privilege.
7 #======================================================================
9 --disable_abort_on_error
11 ###########################################################
12 ################ Section 3.5.3 ############################
13 # Check for the trigger privilege in case of prepare/exec #
14 ###########################################################
16 # General setup to be used in all testcases
17 let $message= #### Testcase
for trigger privilege on execution time ########;
18 --source include/show_msg.inc
21 drop database
if exists priv_db;
23 create database priv_db;
25 eval create
table t1 (f1
char(20)) engine= $engine_type;
27 create User test_yesprivs@localhost;
28 set password for test_yesprivs@localhost = password('PWD');
29 create User test_useprivs@localhost;
30 set password for test_useprivs@localhost = password('PWD');
32 revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
33 revoke ALL PRIVILEGES, GRANT OPTION FROM test_useprivs@localhost;
35 connect (yes_privs,localhost,test_yesprivs,PWD,
test,$MASTER_MYPORT,$MASTER_MYSOCK);
40 grant select, insert, update ,trigger
41 on priv_db.t1
to test_yesprivs@localhost
44 on priv_db.t1
to test_useprivs@localhost;
45 show grants for test_yesprivs@localhost;
50 create trigger trg1_1 before INSERT on t1 for each row
51 set new.f1 = 'trig 1_1-yes';
52 grant insert on t1
to test_useprivs@localhost;
53 prepare ins1 from 'insert into t1 (f1) values (''insert1-no'')';
55 select f1 from t1 order by f1;
56 prepare ins1 from 'insert into t1 (f1) values (''insert2-no'')';
58 connect (use_privs,localhost,test_useprivs,PWD,test,$MASTER_MYPORT,$MASTER_MYSOCK);
61 prepare ins1 from 'insert into t1 (f1) values (''insert3-no'')';
63 select f1 from t1 order by f1;
67 revoke TRIGGER on priv_db.t1 from test_yesprivs@localhost;
68 show grants for test_yesprivs@localhost;
72 --error ER_TABLEACCESS_DENIED_ERROR
74 select f1 from t1 order by f1;
75 prepare ins1 from 'insert into t1 (f1) values (''insert4-no'')';
79 prepare ins1 from 'insert into t1 (f1) values (''insert5-no'')';
80 --error ER_TABLEACCESS_DENIED_ERROR
82 select f1 from t1 order by f1;
86 grant TRIGGER on priv_db.t1
to test_yesprivs@localhost;
87 show grants for test_yesprivs@localhost;
92 select f1 from t1 order by f1;
93 prepare ins1 from 'insert into t1 (f1) values (''insert6-no'')';
98 select f1 from t1 order by f1;
99 prepare ins1 from 'insert into t1 (f1) values (''insert7-no'')';
103 revoke TRIGGER on priv_db.t1 from test_yesprivs@localhost;
104 show grants for test_yesprivs@localhost;
106 connection yes_privs;
108 --error ER_TABLEACCESS_DENIED_ERROR
110 select f1 from t1 order by f1;
112 connection use_privs;
114 --error ER_TABLEACCESS_DENIED_ERROR
116 select f1 from t1 order by f1;
120 grant TRIGGER on priv_db.t1
to test_yesprivs@localhost;
121 show grants for test_yesprivs@localhost;
123 connection yes_privs;
126 select f1 from t1 order by f1;
128 connection use_privs;
131 select f1 from t1 order by f1;
135 revoke TRIGGER on priv_db.t1 from test_yesprivs@localhost;
136 show grants for test_yesprivs@localhost;
138 connection yes_privs;
141 select f1 from t1 order by f1;
142 deallocate prepare ins1;
144 connection use_privs;
147 select f1 from t1 order by f1;
148 deallocate prepare ins1;
152 grant TRIGGER on priv_db.t1
to test_yesprivs@localhost;
153 show grants for test_yesprivs@localhost;
155 connection yes_privs;
164 disconnect yes_privs;
173 drop database
if exists priv_db;
174 drop user test_yesprivs@localhost;
175 drop user test_useprivs@localhost;