~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/funcs_1/r/myisam_trig_03.result

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION';
 
2
USE test;
 
3
drop table if exists tb3;
 
4
create table tb3 (
 
5
f118 char not null DEFAULT 'a',
 
6
f119 char binary not null DEFAULT b'101',
 
7
f120 char ascii not null DEFAULT b'101',
 
8
f121 char(50),
 
9
f122 char(50),
 
10
f129 binary not null DEFAULT b'101',
 
11
f130 tinyint not null DEFAULT 99,
 
12
f131 tinyint unsigned not null DEFAULT 99,
 
13
f132 tinyint zerofill not null DEFAULT 99,
 
14
f133 tinyint unsigned zerofill not null DEFAULT 99,
 
15
f134 smallint not null DEFAULT 999,
 
16
f135 smallint unsigned not null DEFAULT 999,
 
17
f136 smallint zerofill not null DEFAULT 999,
 
18
f137 smallint unsigned zerofill not null DEFAULT 999,
 
19
f138 mediumint not null DEFAULT 9999,
 
20
f139 mediumint unsigned not null DEFAULT 9999,
 
21
f140 mediumint zerofill not null DEFAULT 9999,
 
22
f141 mediumint unsigned zerofill not null DEFAULT 9999,
 
23
f142 int not null DEFAULT 99999,
 
24
f143 int unsigned not null DEFAULT 99999,
 
25
f144 int zerofill not null DEFAULT 99999,
 
26
f145 int unsigned zerofill not null DEFAULT 99999,
 
27
f146 bigint not null DEFAULT 999999,
 
28
f147 bigint unsigned not null DEFAULT 999999,
 
29
f148 bigint zerofill not null DEFAULT 999999,
 
30
f149 bigint unsigned zerofill not null DEFAULT 999999,
 
31
f150 decimal not null DEFAULT 999.999,
 
32
f151 decimal unsigned not null DEFAULT 999.17,
 
33
f152 decimal zerofill not null DEFAULT 999.999,
 
34
f153 decimal unsigned zerofill,
 
35
f154 decimal (0),
 
36
f155 decimal (64),
 
37
f156 decimal (0) unsigned,
 
38
f157 decimal (64) unsigned,
 
39
f158 decimal (0) zerofill,
 
40
f159 decimal (64) zerofill,
 
41
f160 decimal (0) unsigned zerofill,
 
42
f161 decimal (64) unsigned zerofill,
 
43
f162 decimal (0,0),
 
44
f163 decimal (63,30),
 
45
f164 decimal (0,0) unsigned,
 
46
f165 decimal (63,30) unsigned,
 
47
f166 decimal (0,0) zerofill,
 
48
f167 decimal (63,30) zerofill,
 
49
f168 decimal (0,0) unsigned zerofill,
 
50
f169 decimal (63,30) unsigned zerofill,
 
51
f170 numeric,
 
52
f171 numeric unsigned,
 
53
f172 numeric zerofill,
 
54
f173 numeric unsigned zerofill,
 
55
f174 numeric (0),
 
56
f175 numeric (64)
 
57
) engine = <engine_to_be_used>;
 
58
Warnings:
 
59
Note    1265    Data truncated for column 'f150' at row 1
 
60
Note    1265    Data truncated for column 'f151' at row 1
 
61
Note    1265    Data truncated for column 'f152' at row 1
 
62
 
 
63
Testcase 3.5.3:
 
64
---------------
 
65
drop database if exists priv_db;
 
66
create database priv_db;
 
67
use priv_db;
 
68
create table t1 (f1 char(20)) engine= <engine_to_be_used>;
 
69
create User test_noprivs@localhost;
 
70
set password for test_noprivs@localhost = password('PWD');
 
71
create User test_yesprivs@localhost;
 
72
set password for test_yesprivs@localhost = password('PWD');
 
73
 
 
74
Testcase 3.5.3.2/6:
 
75
-------------------
 
76
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
 
77
grant ALL  on *.* to test_noprivs@localhost;
 
78
revoke TRIGGER on *.* from test_noprivs@localhost;
 
79
show grants for test_noprivs@localhost;
 
80
Grants for test_noprivs@localhost
 
81
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
82
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
 
83
grant TRIGGER on *.* to test_yesprivs@localhost;
 
84
grant SELECT on priv_db.t1 to test_yesprivs@localhost;
 
85
show grants for test_yesprivs@localhost;
 
86
Grants for test_yesprivs@localhost
 
87
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
88
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
 
89
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
90
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
91
 
 
92
Testcase 3.5.3.2:
 
93
-----------------
 
94
select current_user;
 
95
current_user
 
96
test_noprivs@localhost
 
97
use priv_db;
 
98
create trigger trg1_1 before INSERT on t1 for each row
 
99
set new.f1 = 'trig 3.5.3.2_1-no';
 
100
ERROR 42000: TRIGGER command denied to user 'test_noprivs'@'localhost' for table 't1'
 
101
use priv_db;
 
102
insert into t1 (f1) values ('insert 3.5.3.2-no');
 
103
select f1 from t1 order by f1;
 
104
f1
 
105
insert 3.5.3.2-no
 
106
select current_user;
 
107
current_user
 
108
test_yesprivs@localhost
 
109
use priv_db;
 
110
create trigger trg1_2 before INSERT  on t1 for each row
 
111
set new.f1 = 'trig 3.5.3.2_2-yes';
 
112
select current_user;
 
113
current_user
 
114
root@localhost
 
115
use priv_db;
 
116
insert into t1 (f1) values ('insert 3.5.3.2-yes');
 
117
ERROR 42000: UPDATE command denied to user 'test_yesprivs'@'localhost' for column 'f1' in table 't1'
 
118
select f1 from t1 order by f1;
 
119
f1
 
120
insert 3.5.3.2-no
 
121
grant UPDATE on priv_db.t1 to test_yesprivs@localhost;
 
122
insert into t1 (f1) values ('insert 3.5.3.2-yes');
 
123
select f1 from t1 order by f1;
 
124
f1
 
125
insert 3.5.3.2-no
 
126
trig 3.5.3.2_2-yes
 
127
 
 
128
Testcase 3.5.3.6:
 
129
-----------------
 
130
use priv_db;
 
131
drop trigger trg1_2;
 
132
ERROR 42000: TRIGGER command denied to user 'test_noprivs'@'localhost' for table 't1'
 
133
use priv_db;
 
134
insert into t1 (f1) values ('insert 3.5.3.6-yes');
 
135
select f1 from t1 order by f1;
 
136
f1
 
137
insert 3.5.3.2-no
 
138
trig 3.5.3.2_2-yes
 
139
trig 3.5.3.2_2-yes
 
140
use priv_db;
 
141
drop trigger trg1_2;
 
142
use priv_db;
 
143
insert into t1 (f1) values ('insert 3.5.3.6-no');
 
144
select f1 from t1 order by f1;
 
145
f1
 
146
insert 3.5.3.2-no
 
147
insert 3.5.3.6-no
 
148
trig 3.5.3.2_2-yes
 
149
trig 3.5.3.2_2-yes
 
150
drop trigger trg1_2;
 
151
 
 
152
Testcase 3.5.3.7a:
 
153
------------------
 
154
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
 
155
grant ALL  on *.* to test_noprivs@localhost;
 
156
revoke UPDATE  on *.* from test_noprivs@localhost;
 
157
show grants for test_noprivs@localhost;
 
158
Grants for test_noprivs@localhost
 
159
GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
160
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
 
161
grant TRIGGER, UPDATE on *.* to test_yesprivs@localhost;
 
162
show grants for test_yesprivs@localhost;
 
163
Grants for test_yesprivs@localhost
 
164
GRANT UPDATE, TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
165
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
166
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
167
select current_user;
 
168
current_user
 
169
test_noprivs@localhost
 
170
use priv_db;
 
171
show grants;
 
172
Grants for test_noprivs@localhost
 
173
GRANT SELECT, INSERT, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
174
select f1 from t1 order by f1;
 
175
f1
 
176
insert 3.5.3.2-no
 
177
insert 3.5.3.6-no
 
178
trig 3.5.3.2_2-yes
 
179
trig 3.5.3.2_2-yes
 
180
create trigger trg4a_1 before INSERT on t1 for each row
 
181
set new.f1 = 'trig 3.5.3.7-1a';
 
182
insert into t1 (f1) values ('insert 3.5.3.7-1a');
 
183
ERROR 42000: UPDATE command denied to user 'test_noprivs'@'localhost' for column 'f1' in table 't1'
 
184
select f1 from t1 order by f1;
 
185
f1
 
186
insert 3.5.3.2-no
 
187
insert 3.5.3.6-no
 
188
trig 3.5.3.2_2-yes
 
189
trig 3.5.3.2_2-yes
 
190
drop trigger trg4a_1;
 
191
use priv_db;
 
192
select current_user;
 
193
current_user
 
194
test_yesprivs@localhost
 
195
show grants;
 
196
Grants for test_yesprivs@localhost
 
197
GRANT UPDATE, TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
198
create trigger trg4a_2 before INSERT  on t1 for each row
 
199
set new.f1 = 'trig 3.5.3.7-2a';
 
200
insert into t1 (f1) values ('insert 3.5.3.7-2b');
 
201
select f1 from t1 order by f1;
 
202
f1
 
203
insert 3.5.3.2-no
 
204
insert 3.5.3.6-no
 
205
trig 3.5.3.2_2-yes
 
206
trig 3.5.3.2_2-yes
 
207
trig 3.5.3.7-2a
 
208
drop trigger trg4a_2;
 
209
 
 
210
Testcase 3.5.3.7b:
 
211
------------------
 
212
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
 
213
grant TRIGGER on *.* to test_noprivs;
 
214
grant ALL  on priv_db.* to test_noprivs@localhost;
 
215
revoke UPDATE  on priv_db.* from test_noprivs@localhost;
 
216
show grants for test_noprivs;
 
217
Grants for test_noprivs@%
 
218
GRANT TRIGGER ON *.* TO 'test_noprivs'@'%'
 
219
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
 
220
grant TRIGGER on *.* to test_yesprivs@localhost;
 
221
grant UPDATE on priv_db.* to test_yesprivs@localhost;
 
222
show grants for test_yesprivs@localhost;
 
223
Grants for test_yesprivs@localhost
 
224
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
225
GRANT UPDATE ON `priv_db`.* TO 'test_yesprivs'@'localhost'
 
226
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
227
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
228
show grants;
 
229
Grants for test_noprivs@localhost
 
230
GRANT USAGE ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
231
GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost'
 
232
use priv_db;
 
233
create trigger trg4b_1 before UPDATE on t1 for each row
 
234
set new.f1 = 'trig 3.5.3.7-1b';
 
235
insert into t1 (f1) values ('insert 3.5.3.7-1b');
 
236
select f1 from t1 order by f1;
 
237
f1
 
238
insert 3.5.3.2-no
 
239
insert 3.5.3.6-no
 
240
insert 3.5.3.7-1b
 
241
trig 3.5.3.2_2-yes
 
242
trig 3.5.3.2_2-yes
 
243
trig 3.5.3.7-2a
 
244
update t1 set  f1 = 'update 3.5.3.7-1b' where f1 = 'insert 3.5.3.7-1b';
 
245
ERROR 42000: UPDATE command denied to user 'test_noprivs'@'localhost' for column 'f1' in table 't1'
 
246
select f1 from t1 order by f1;
 
247
f1
 
248
insert 3.5.3.2-no
 
249
insert 3.5.3.6-no
 
250
insert 3.5.3.7-1b
 
251
trig 3.5.3.2_2-yes
 
252
trig 3.5.3.2_2-yes
 
253
trig 3.5.3.7-2a
 
254
drop trigger trg4b_1;
 
255
show grants;
 
256
Grants for test_yesprivs@localhost
 
257
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
258
GRANT UPDATE ON `priv_db`.* TO 'test_yesprivs'@'localhost'
 
259
use priv_db;
 
260
create trigger trg4b_2 before UPDATE  on t1 for each row
 
261
set new.f1 = 'trig 3.5.3.7-2b';
 
262
insert into t1 (f1) values ('insert 3.5.3.7-2b');
 
263
select f1 from t1 order by f1;
 
264
f1
 
265
insert 3.5.3.2-no
 
266
insert 3.5.3.6-no
 
267
insert 3.5.3.7-1b
 
268
insert 3.5.3.7-2b
 
269
trig 3.5.3.2_2-yes
 
270
trig 3.5.3.2_2-yes
 
271
trig 3.5.3.7-2a
 
272
update t1 set  f1 = 'update 3.5.3.7-2b' where f1 = 'insert 3.5.3.7-2b';
 
273
select f1 from t1 order by f1;
 
274
f1
 
275
insert 3.5.3.2-no
 
276
insert 3.5.3.6-no
 
277
insert 3.5.3.7-1b
 
278
trig 3.5.3.2_2-yes
 
279
trig 3.5.3.2_2-yes
 
280
trig 3.5.3.7-2a
 
281
trig 3.5.3.7-2b
 
282
drop trigger trg4b_2;
 
283
 
 
284
Testcase 3.5.3.7c
 
285
-----------------
 
286
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
 
287
grant TRIGGER on *.* to test_noprivs@localhost;
 
288
grant ALL  on priv_db.t1 to test_noprivs@localhost;
 
289
revoke UPDATE  on priv_db.t1 from test_noprivs@localhost;
 
290
show grants for test_noprivs;
 
291
Grants for test_noprivs@%
 
292
GRANT TRIGGER ON *.* TO 'test_noprivs'@'%'
 
293
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
 
294
grant TRIGGER on *.* to test_yesprivs@localhost;
 
295
grant UPDATE on priv_db.t1 to test_yesprivs@localhost;
 
296
show grants for test_yesprivs@localhost;
 
297
Grants for test_yesprivs@localhost
 
298
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
299
GRANT UPDATE ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
 
300
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
301
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
302
show grants;
 
303
Grants for test_noprivs@localhost
 
304
GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
305
GRANT SELECT, INSERT, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
 
306
use priv_db;
 
307
create trigger trg4c_1 before INSERT on t1 for each row
 
308
set new.f1 = 'trig 3.5.3.7-1c';
 
309
insert into t1 (f1) values ('insert 3.5.3.7-1c');
 
310
ERROR 42000: UPDATE command denied to user 'test_noprivs'@'localhost' for column 'f1' in table 't1'
 
311
select f1 from t1 order by f1;
 
312
f1
 
313
insert 3.5.3.2-no
 
314
insert 3.5.3.6-no
 
315
insert 3.5.3.7-1b
 
316
trig 3.5.3.2_2-yes
 
317
trig 3.5.3.2_2-yes
 
318
trig 3.5.3.7-2a
 
319
trig 3.5.3.7-2b
 
320
drop trigger trg4c_1;
 
321
show grants;
 
322
Grants for test_yesprivs@localhost
 
323
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
324
GRANT UPDATE ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
 
325
use priv_db;
 
326
create trigger trg4c_2 before INSERT  on t1 for each row
 
327
set new.f1 = 'trig 3.5.3.7-2c';
 
328
insert into t1 (f1) values ('insert 3.5.3.7-2c');
 
329
select f1 from t1 order by f1;
 
330
f1
 
331
insert 3.5.3.2-no
 
332
insert 3.5.3.6-no
 
333
insert 3.5.3.7-1b
 
334
trig 3.5.3.2_2-yes
 
335
trig 3.5.3.2_2-yes
 
336
trig 3.5.3.7-2a
 
337
trig 3.5.3.7-2b
 
338
trig 3.5.3.7-2c
 
339
drop trigger trg4c_2;
 
340
 
 
341
Testcase 3.5.3.7d:
 
342
------------------
 
343
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
 
344
grant TRIGGER on *.* to test_noprivs@localhost;
 
345
grant SELECT (f1), INSERT (f1) on priv_db.t1 to test_noprivs@localhost;
 
346
show grants for test_noprivs;
 
347
Grants for test_noprivs@%
 
348
GRANT TRIGGER ON *.* TO 'test_noprivs'@'%'
 
349
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
 
350
grant TRIGGER on *.* to test_yesprivs@localhost;
 
351
grant UPDATE (f1) on priv_db.t1 to test_yesprivs@localhost;
 
352
show grants for test_noprivs;
 
353
Grants for test_noprivs@%
 
354
GRANT TRIGGER ON *.* TO 'test_noprivs'@'%'
 
355
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
356
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
357
show grants;
 
358
Grants for test_noprivs@localhost
 
359
GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
360
GRANT SELECT (f1), INSERT (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
 
361
use priv_db;
 
362
create trigger trg4d_1 before INSERT on t1 for each row
 
363
set new.f1 = 'trig 3.5.3.7-1d';
 
364
insert into t1 (f1) values ('insert 3.5.3.7-1d');
 
365
ERROR 42000: UPDATE command denied to user 'test_noprivs'@'localhost' for column 'f1' in table 't1'
 
366
select f1 from t1 order by f1;
 
367
f1
 
368
insert 3.5.3.2-no
 
369
insert 3.5.3.6-no
 
370
insert 3.5.3.7-1b
 
371
trig 3.5.3.2_2-yes
 
372
trig 3.5.3.2_2-yes
 
373
trig 3.5.3.7-2a
 
374
trig 3.5.3.7-2b
 
375
trig 3.5.3.7-2c
 
376
drop trigger trg4d_1;
 
377
show grants;
 
378
Grants for test_yesprivs@localhost
 
379
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
380
GRANT UPDATE (f1) ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
 
381
use priv_db;
 
382
create trigger trg4d_2 before INSERT  on t1 for each row
 
383
set new.f1 = 'trig 3.5.3.7-2d';
 
384
insert into t1 (f1) values ('insert 3.5.3.7-2d');
 
385
select f1 from t1 order by f1;
 
386
f1
 
387
insert 3.5.3.2-no
 
388
insert 3.5.3.6-no
 
389
insert 3.5.3.7-1b
 
390
trig 3.5.3.2_2-yes
 
391
trig 3.5.3.2_2-yes
 
392
trig 3.5.3.7-2a
 
393
trig 3.5.3.7-2b
 
394
trig 3.5.3.7-2c
 
395
trig 3.5.3.7-2d
 
396
drop trigger trg4d_2;
 
397
 
 
398
Testcase 3.5.3.8a:
 
399
------------------
 
400
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
 
401
grant ALL  on *.* to test_noprivs@localhost;
 
402
revoke SELECT  on *.* from test_noprivs@localhost;
 
403
show grants for test_noprivs@localhost;
 
404
Grants for test_noprivs@localhost
 
405
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
406
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
 
407
grant TRIGGER, SELECT on *.* to test_yesprivs@localhost;
 
408
show grants for test_yesprivs@localhost;
 
409
Grants for test_yesprivs@localhost
 
410
GRANT SELECT, TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
411
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
412
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
413
select current_user;
 
414
current_user
 
415
test_noprivs@localhost
 
416
use priv_db;
 
417
show grants;
 
418
Grants for test_noprivs@localhost
 
419
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
420
create trigger trg5a_1 before INSERT on t1 for each row
 
421
set @test_var = new.f1;
 
422
set @test_var = 'before trig 3.5.3.8-1a';
 
423
select @test_var;
 
424
@test_var
 
425
before trig 3.5.3.8-1a
 
426
insert into t1 (f1) values ('insert 3.5.3.8-1a');
 
427
ERROR 42000: SELECT command denied to user 'test_noprivs'@'localhost' for column 'f1' in table 't1'
 
428
select @test_var;
 
429
@test_var
 
430
before trig 3.5.3.8-1a
 
431
drop trigger trg5a_1;
 
432
use priv_db;
 
433
select current_user;
 
434
current_user
 
435
test_yesprivs@localhost
 
436
show grants;
 
437
Grants for test_yesprivs@localhost
 
438
GRANT SELECT, TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
439
create trigger trg5a_2 before INSERT  on t1 for each row
 
440
set @test_var= new.f1;
 
441
set @test_var= 'before trig 3.5.3.8-2a';
 
442
select @test_var;
 
443
@test_var
 
444
before trig 3.5.3.8-2a
 
445
insert into t1 (f1) values ('insert 3.5.3.8-2a');
 
446
select @test_var;
 
447
@test_var
 
448
insert 3.5.3.8-2a
 
449
drop trigger trg5a_2;
 
450
 
 
451
Testcase: 3.5.3.8b
 
452
------------------
 
453
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
 
454
grant TRIGGER on *.* to test_noprivs@localhost;
 
455
grant ALL  on priv_db.* to test_noprivs@localhost;
 
456
revoke SELECT  on priv_db.* from test_noprivs@localhost;
 
457
show grants for test_noprivs@localhost;
 
458
Grants for test_noprivs@localhost
 
459
GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
460
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost'
 
461
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
 
462
grant TRIGGER on *.* to test_yesprivs@localhost;
 
463
grant SELECT on priv_db.* to test_yesprivs@localhost;
 
464
show grants for test_yesprivs@localhost;
 
465
Grants for test_yesprivs@localhost
 
466
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
467
GRANT SELECT ON `priv_db`.* TO 'test_yesprivs'@'localhost'
 
468
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
469
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
470
show grants;
 
471
Grants for test_noprivs@localhost
 
472
GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
473
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON `priv_db`.* TO 'test_noprivs'@'localhost'
 
474
use priv_db;
 
475
create trigger trg5b_1 before UPDATE on t1 for each row
 
476
set @test_var= new.f1;
 
477
set @test_var= 'before trig 3.5.3.8-1b';
 
478
insert into t1 (f1) values ('insert 3.5.3.8-1b');
 
479
select @test_var;
 
480
@test_var
 
481
before trig 3.5.3.8-1b
 
482
update t1 set  f1= 'update 3.5.3.8-1b' where f1 = 'insert 3.5.3.8-1b';
 
483
ERROR 42000: SELECT command denied to user 'test_noprivs'@'localhost' for column 'f1' in table 't1'
 
484
select @test_var;
 
485
@test_var
 
486
before trig 3.5.3.8-1b
 
487
drop trigger trg5b_1;
 
488
show grants;
 
489
Grants for test_yesprivs@localhost
 
490
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
491
GRANT SELECT ON `priv_db`.* TO 'test_yesprivs'@'localhost'
 
492
use priv_db;
 
493
create trigger trg5b_2 before UPDATE  on t1 for each row
 
494
set @test_var= new.f1;
 
495
set @test_var= 'before trig 3.5.3.8-2b';
 
496
insert into t1 (f1) values ('insert 3.5.3.8-2b');
 
497
select @test_var;
 
498
@test_var
 
499
before trig 3.5.3.8-2b
 
500
update t1 set  f1= 'update 3.5.3.8-2b' where f1 = 'insert 3.5.3.8-2b';
 
501
select @test_var;
 
502
@test_var
 
503
update 3.5.3.8-2b
 
504
drop trigger trg5b_2;
 
505
 
 
506
Testcase 3.5.3.8c:
 
507
------------------
 
508
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
 
509
grant TRIGGER on *.* to test_noprivs@localhost;
 
510
grant ALL  on priv_db.t1 to test_noprivs@localhost;
 
511
revoke SELECT  on priv_db.t1 from test_noprivs@localhost;
 
512
show grants for test_noprivs@localhost;
 
513
Grants for test_noprivs@localhost
 
514
GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
515
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
 
516
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
 
517
grant TRIGGER on *.* to test_yesprivs@localhost;
 
518
grant SELECT on priv_db.t1 to test_yesprivs@localhost;
 
519
show grants for test_yesprivs@localhost;
 
520
Grants for test_yesprivs@localhost
 
521
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
522
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
 
523
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
524
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
525
show grants;
 
526
Grants for test_noprivs@localhost
 
527
GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
528
GRANT INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE VIEW, SHOW VIEW, TRIGGER ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
 
529
use priv_db;
 
530
create trigger trg5c_1 before INSERT on t1 for each row
 
531
set @test_var= new.f1;
 
532
set @test_var= 'before trig 3.5.3.8-1c';
 
533
insert into t1 (f1) values ('insert 3.5.3.8-1c');
 
534
ERROR 42000: SELECT command denied to user 'test_noprivs'@'localhost' for column 'f1' in table 't1'
 
535
select @test_var;
 
536
@test_var
 
537
before trig 3.5.3.8-1c
 
538
drop trigger trg5c_1;
 
539
show grants;
 
540
Grants for test_yesprivs@localhost
 
541
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
542
GRANT SELECT ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
 
543
use priv_db;
 
544
create trigger trg5c_2 before INSERT  on t1 for each row
 
545
set @test_var= new.f1;
 
546
set @test_var='before trig 3.5.3.8-2c';
 
547
insert into t1 (f1) values ('insert 3.5.3.8-2c');
 
548
select @test_var;
 
549
@test_var
 
550
insert 3.5.3.8-2c
 
551
drop trigger trg5c_2;
 
552
 
 
553
Testcase: 3.5.3.8d:
 
554
-------------------
 
555
revoke ALL PRIVILEGES, GRANT OPTION FROM test_noprivs@localhost;
 
556
grant TRIGGER on *.* to test_noprivs@localhost;
 
557
grant UPDATE (f1), INSERT (f1) on priv_db.t1 to test_noprivs@localhost;
 
558
show grants for test_noprivs@localhost;
 
559
Grants for test_noprivs@localhost
 
560
GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
561
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
 
562
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
 
563
grant TRIGGER on *.* to test_yesprivs@localhost;
 
564
grant SELECT (f1) on priv_db.t1 to test_yesprivs@localhost;
 
565
show grants for test_noprivs@localhost;
 
566
Grants for test_noprivs@localhost
 
567
GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
568
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
 
569
connect(localhost,test_noprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
570
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
571
show grants;
 
572
Grants for test_noprivs@localhost
 
573
GRANT TRIGGER ON *.* TO 'test_noprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
574
GRANT INSERT (f1), UPDATE (f1) ON `priv_db`.`t1` TO 'test_noprivs'@'localhost'
 
575
use priv_db;
 
576
create trigger trg5d_1 before INSERT on t1 for each row
 
577
set @test_var= new.f1;
 
578
set @test_var='before trig 3.5.3.8-1d';
 
579
insert into t1 (f1) values ('insert 3.5.3.8-1d');
 
580
ERROR 42000: SELECT command denied to user 'test_noprivs'@'localhost' for column 'f1' in table 't1'
 
581
select @test_var;
 
582
@test_var
 
583
before trig 3.5.3.8-1d
 
584
drop trigger trg5d_1;
 
585
show grants;
 
586
Grants for test_yesprivs@localhost
 
587
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
588
GRANT SELECT (f1) ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
 
589
use priv_db;
 
590
create trigger trg5d_2 before INSERT  on t1 for each row
 
591
set @test_var= new.f1;
 
592
set @test_var='before trig 3.5.3.8-2d';
 
593
insert into t1 (f1) values ('insert 3.5.3.8-2d');
 
594
select @test_var;
 
595
@test_var
 
596
insert 3.5.3.8-2d
 
597
drop trigger trg5d_2;
 
598
 
 
599
Testcase: 3.5.3.x:
 
600
------------------
 
601
use priv_db;
 
602
drop table if exists t1;
 
603
drop table if exists t2;
 
604
create table t1 (f1 int) engine= <engine_to_be_used>;
 
605
create table t2 (f2 int) engine= <engine_to_be_used>;
 
606
revoke ALL PRIVILEGES, GRANT OPTION FROM test_yesprivs@localhost;
 
607
grant TRIGGER on *.* to test_yesprivs@localhost;
 
608
grant SELECT, UPDATE on priv_db.t1 to test_yesprivs@localhost;
 
609
grant SELECT on priv_db.t2 to test_yesprivs@localhost;
 
610
show grants for test_yesprivs@localhost;
 
611
Grants for test_yesprivs@localhost
 
612
GRANT TRIGGER ON *.* TO 'test_yesprivs'@'localhost' IDENTIFIED BY PASSWORD '*C49735D016A099C0CF104EF9183F374A54CA2576'
 
613
GRANT SELECT ON `priv_db`.`t2` TO 'test_yesprivs'@'localhost'
 
614
GRANT SELECT, UPDATE ON `priv_db`.`t1` TO 'test_yesprivs'@'localhost'
 
615
connect(localhost,test_yesprivs,PWD,test,MASTER_MYPORT,MASTER_MYSOCK);
 
616
select current_user;
 
617
current_user
 
618
test_yesprivs@localhost
 
619
use priv_db;
 
620
create trigger trg1 before insert  on t1 for each row
 
621
insert into t2 values (new.f1);
 
622
use priv_db;
 
623
insert into t1 (f1) values (4);
 
624
ERROR 42000: INSERT command denied to user 'test_yesprivs'@'localhost' for table 't2'
 
625
revoke SELECT on priv_db.t2 from test_yesprivs@localhost;
 
626
grant INSERT on priv_db.t2 to test_yesprivs@localhost;
 
627
insert into t1 (f1) values (4);
 
628
select f1 from t1 order by f1;
 
629
f1
 
630
4
 
631
select f2 from t2 order by f2;
 
632
f2
 
633
4
 
634
use priv_db;
 
635
drop trigger trg1;
 
636
create trigger trg2 before insert  on t1 for each row
 
637
update t2 set f2=new.f1-1;
 
638
use priv_db;
 
639
insert into t1 (f1) values (2);
 
640
ERROR 42000: UPDATE command denied to user 'test_yesprivs'@'localhost' for table 't2'
 
641
revoke INSERT on priv_db.t2 from test_yesprivs@localhost;
 
642
grant UPDATE on priv_db.t2 to test_yesprivs@localhost;
 
643
insert into t1 (f1) values (2);
 
644
select f1 from t1 order by f1;
 
645
f1
 
646
2
 
647
4
 
648
select f2 from t2 order by f2;
 
649
f2
 
650
1
 
651
use priv_db;
 
652
drop trigger trg2;
 
653
create trigger trg3 before insert  on t1 for each row
 
654
select f2 into @aaa from t2 where f2=new.f1;
 
655
use priv_db;
 
656
insert into t1 (f1) values (1);
 
657
ERROR 42000: SELECT command denied to user 'test_yesprivs'@'localhost' for table 't2'
 
658
revoke UPDATE on priv_db.t2 from test_yesprivs@localhost;
 
659
grant SELECT on priv_db.t2 to test_yesprivs@localhost;
 
660
insert into t1 (f1) values (1);
 
661
select f1 from t1 order by f1;
 
662
f1
 
663
1
 
664
2
 
665
4
 
666
select f2 from t2 order by f2;
 
667
f2
 
668
1
 
669
select @aaa;
 
670
@aaa
 
671
1
 
672
use priv_db;
 
673
drop trigger trg3;
 
674
create trigger trg4 before insert  on t1 for each row
 
675
delete from t2;
 
676
use priv_db;
 
677
insert into t1 (f1) values (1);
 
678
ERROR 42000: DELETE command denied to user 'test_yesprivs'@'localhost' for table 't2'
 
679
revoke SELECT on priv_db.t2 from test_yesprivs@localhost;
 
680
grant DELETE on priv_db.t2 to test_yesprivs@localhost;
 
681
insert into t1 (f1) values (1);
 
682
select f1 from t1 order by f1;
 
683
f1
 
684
1
 
685
1
 
686
2
 
687
4
 
688
select f2 from t2 order by f2;
 
689
f2
 
690
drop database if exists priv_db;
 
691
drop user test_yesprivs@localhost;
 
692
drop user test_noprivs@localhost;
 
693
drop user test_noprivs;
 
694
use test;
 
695
drop table tb3;