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

« back to all changes in this revision

Viewing changes to mysql-test/t/grant.test

  • 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
# Test of GRANT commands
 
2
 
 
3
# Grant tests not performed with embedded server
 
4
-- source include/not_embedded.inc
 
5
 
 
6
# Save the initial number of concurrent sessions
 
7
--source include/count_sessions.inc
 
8
 
 
9
SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
 
10
SET GLOBAL log_bin_trust_function_creators = 1;
 
11
 
 
12
# Cleanup
 
13
--disable_warnings
 
14
drop table if exists t1;
 
15
drop database if exists mysqltest;
 
16
--enable_warnings
 
17
 
 
18
connect (master,localhost,root,,);
 
19
connection master;
 
20
SET NAMES binary;
 
21
 
 
22
#
 
23
# Test that SSL options works properly
 
24
#
 
25
 
 
26
delete from mysql.user where user='mysqltest_1';
 
27
delete from mysql.db where user='mysqltest_1';
 
28
flush privileges;
 
29
grant select on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA";
 
30
show grants for mysqltest_1@localhost;
 
31
grant delete on mysqltest.* to mysqltest_1@localhost;
 
32
select * from mysql.user where user="mysqltest_1";
 
33
show grants for mysqltest_1@localhost;
 
34
revoke delete on mysqltest.* from mysqltest_1@localhost;
 
35
show grants for mysqltest_1@localhost;
 
36
grant select on mysqltest.* to mysqltest_1@localhost require NONE;
 
37
show grants for mysqltest_1@localhost;
 
38
grant USAGE on mysqltest.* to mysqltest_1@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "testsubject" ISSUER "MySQL AB";
 
39
show grants for mysqltest_1@localhost;
 
40
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
 
41
show grants for mysqltest_1@localhost;
 
42
delete from mysql.user where user='mysqltest_1';
 
43
flush privileges;
 
44
 
 
45
#
 
46
# Test of GRANTS specifying user limits
 
47
#
 
48
delete from mysql.user where user='mysqltest_1';
 
49
flush privileges;
 
50
grant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 10;
 
51
select * from mysql.user where user="mysqltest_1";
 
52
show grants for mysqltest_1@localhost;
 
53
grant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 20 max_connections_per_hour 30;
 
54
select * from mysql.user where user="mysqltest_1";
 
55
show grants for mysqltest_1@localhost;
 
56
# This is just to double check that one won't ignore results of selects
 
57
flush privileges;
 
58
show grants for mysqltest_1@localhost;
 
59
delete from mysql.user where user='mysqltest_1';
 
60
flush privileges;
 
61
 
 
62
#
 
63
# Test that the new db privileges are stored/retrieved correctly
 
64
#
 
65
 
 
66
grant CREATE TEMPORARY TABLES, LOCK TABLES on mysqltest.* to mysqltest_1@localhost;
 
67
show grants for mysqltest_1@localhost;
 
68
flush privileges;
 
69
show grants for mysqltest_1@localhost;
 
70
revoke CREATE TEMPORARY TABLES on mysqltest.* from mysqltest_1@localhost;
 
71
show grants for mysqltest_1@localhost;
 
72
grant ALL PRIVILEGES on mysqltest.* to mysqltest_1@localhost with GRANT OPTION;
 
73
flush privileges;
 
74
show grants for mysqltest_1@localhost;
 
75
revoke LOCK TABLES, ALTER on mysqltest.* from mysqltest_1@localhost;
 
76
show grants for mysqltest_1@localhost;
 
77
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
 
78
delete from mysql.user where user='mysqltest_1';
 
79
flush privileges;
 
80
grant usage on test.* to mysqltest_1@localhost with grant option;
 
81
show grants for mysqltest_1@localhost;
 
82
delete from mysql.user where user='mysqltest_1';
 
83
delete from mysql.db where user='mysqltest_1';
 
84
delete from mysql.tables_priv where user='mysqltest_1';
 
85
delete from mysql.columns_priv where user='mysqltest_1';
 
86
flush privileges;
 
87
--error ER_NONEXISTING_GRANT
 
88
show grants for mysqltest_1@localhost;
 
89
 
 
90
#
 
91
# Test what happens when you have same table and colum level grants
 
92
#
 
93
 
 
94
create table t1 (a int);
 
95
GRANT select,update,insert on t1 to mysqltest_1@localhost;
 
96
GRANT select (a), update (a),insert(a), references(a) on t1 to mysqltest_1@localhost;
 
97
show grants for mysqltest_1@localhost;
 
98
select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1";
 
99
REVOKE select (a), update on t1 from mysqltest_1@localhost;
 
100
show grants for mysqltest_1@localhost;
 
101
REVOKE select,update,insert,insert (a) on t1 from mysqltest_1@localhost;
 
102
show grants for mysqltest_1@localhost;
 
103
GRANT select,references on t1 to mysqltest_1@localhost;
 
104
select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1";
 
105
grant all on test.* to mysqltest_3@localhost with grant option;
 
106
revoke all on test.* from mysqltest_3@localhost;
 
107
show grants for mysqltest_3@localhost;
 
108
revoke grant option on test.* from mysqltest_3@localhost;
 
109
show grants for mysqltest_3@localhost;
 
110
grant all on test.t1 to mysqltest_2@localhost with grant option;
 
111
revoke all on test.t1 from mysqltest_2@localhost;
 
112
show grants for mysqltest_2@localhost;
 
113
revoke grant option on test.t1 from mysqltest_2@localhost;
 
114
show grants for mysqltest_2@localhost;
 
115
delete from mysql.user where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
 
116
delete from mysql.db where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
 
117
delete from mysql.tables_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
 
118
delete from mysql.columns_priv where user='mysqltest_1' or user="mysqltest_2" or user="mysqltest_3";
 
119
flush privileges;
 
120
drop table t1;
 
121
 
 
122
#
 
123
# Test some error conditions
 
124
#
 
125
--error ER_WRONG_USAGE
 
126
GRANT FILE on mysqltest.*  to mysqltest_1@localhost;
 
127
select 1;     # To test that the previous command didn't cause problems
 
128
 
 
129
#
 
130
# Bug#4898 User privileges depending on ORDER BY Settings of table db
 
131
#
 
132
insert into mysql.user (host, user) values ('localhost', 'test11');
 
133
insert into mysql.db (host, db, user, select_priv) values
 
134
('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y');
 
135
alter table mysql.db order by db asc;
 
136
flush privileges;
 
137
show grants for test11@localhost;
 
138
alter table mysql.db order by db desc;
 
139
flush privileges;
 
140
show grants for test11@localhost;
 
141
delete from mysql.user where user='test11';
 
142
delete from mysql.db where user='test11';
 
143
 
 
144
#
 
145
# Bug#6123 GRANT USAGE inserts useless Db row
 
146
#
 
147
create database mysqltest1;
 
148
grant usage on mysqltest1.* to test6123 identified by 'magic123';
 
149
select host,db,user,select_priv,insert_priv from mysql.db where db="mysqltest1";
 
150
delete from mysql.user where user='test6123';
 
151
drop database mysqltest1;
 
152
 
 
153
#
 
154
# Test for 'drop user', 'revoke privileges, grant'
 
155
#
 
156
 
 
157
create table t1 (a int);
 
158
grant ALL PRIVILEGES on *.* to drop_user2@localhost with GRANT OPTION;
 
159
show grants for drop_user2@localhost;
 
160
revoke all privileges, grant option from drop_user2@localhost;
 
161
drop user drop_user2@localhost;
 
162
 
 
163
grant ALL PRIVILEGES on *.* to drop_user@localhost with GRANT OPTION;
 
164
grant ALL PRIVILEGES on test.* to drop_user@localhost with GRANT OPTION;
 
165
grant select(a) on test.t1 to drop_user@localhost;
 
166
show grants for drop_user@localhost;
 
167
 
 
168
#
 
169
# Bug#3086 SHOW GRANTS doesn't follow ANSI_QUOTES
 
170
#
 
171
set sql_mode=ansi_quotes;
 
172
show grants for drop_user@localhost;
 
173
set sql_mode=default;
 
174
 
 
175
set sql_quote_show_create=0;
 
176
show grants for drop_user@localhost;
 
177
set sql_mode="ansi_quotes";
 
178
show grants for drop_user@localhost;
 
179
set sql_quote_show_create=1;
 
180
show grants for drop_user@localhost;
 
181
set sql_mode="";
 
182
show grants for drop_user@localhost;
 
183
 
 
184
revoke all privileges, grant option from drop_user@localhost;
 
185
show grants for drop_user@localhost;
 
186
drop user drop_user@localhost;
 
187
--error ER_REVOKE_GRANTS
 
188
revoke all privileges, grant option from drop_user@localhost;
 
189
 
 
190
grant select(a) on test.t1 to drop_user1@localhost;
 
191
grant select on test.t1 to drop_user2@localhost;
 
192
grant select on test.* to drop_user3@localhost;
 
193
grant select on *.* to drop_user4@localhost;
 
194
# Drop user now implicitly revokes all privileges.
 
195
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
 
196
drop_user4@localhost;
 
197
--error ER_REVOKE_GRANTS
 
198
revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost,
 
199
drop_user3@localhost, drop_user4@localhost;
 
200
--error ER_CANNOT_USER
 
201
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
 
202
drop_user4@localhost;
 
203
drop table t1;
 
204
grant usage on *.* to mysqltest_1@localhost identified by "password";
 
205
grant select, update, insert on test.* to mysqltest_1@localhost;
 
206
show grants for mysqltest_1@localhost;
 
207
drop user mysqltest_1@localhost;
 
208
 
 
209
#
 
210
# Bug#3403 Wrong encoding in SHOW GRANTS output
 
211
#
 
212
SET NAMES koi8r;
 
213
CREATE DATABASE ��;
 
214
USE ��;
 
215
CREATE TABLE ��� (��� INT);
 
216
 
 
217
GRANT SELECT ON ��.* TO ����@localhost;
 
218
SHOW GRANTS FOR ����@localhost;
 
219
REVOKE SELECT ON ��.* FROM ����@localhost;
 
220
 
 
221
GRANT SELECT ON ��.��� TO ����@localhost;
 
222
SHOW GRANTS FOR ����@localhost;
 
223
REVOKE SELECT ON ��.��� FROM ����@localhost;
 
224
 
 
225
GRANT SELECT (���) ON ��.��� TO ����@localhost;
 
226
SHOW GRANTS FOR ����@localhost;
 
227
REVOKE SELECT (���) ON ��.��� FROM ����@localhost;
 
228
 
 
229
# Revoke does not drop user. Leave a clean user table for the next tests.
 
230
DROP USER ����@localhost;
 
231
 
 
232
DROP DATABASE ��;
 
233
SET NAMES latin1;
 
234
 
 
235
#
 
236
# Bug#5831 REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke everything
 
237
#
 
238
USE test;
 
239
CREATE TABLE t1 (a int );
 
240
CREATE TABLE t2 LIKE t1;
 
241
CREATE TABLE t3 LIKE t1;
 
242
CREATE TABLE t4 LIKE t1;
 
243
CREATE TABLE t5 LIKE t1;
 
244
CREATE TABLE t6 LIKE t1;
 
245
CREATE TABLE t7 LIKE t1;
 
246
CREATE TABLE t8 LIKE t1;
 
247
CREATE TABLE t9 LIKE t1;
 
248
CREATE TABLE t10 LIKE t1;
 
249
CREATE DATABASE testdb1;
 
250
CREATE DATABASE testdb2;
 
251
CREATE DATABASE testdb3;
 
252
CREATE DATABASE testdb4;
 
253
CREATE DATABASE testdb5;
 
254
CREATE DATABASE testdb6;
 
255
CREATE DATABASE testdb7;
 
256
CREATE DATABASE testdb8;
 
257
CREATE DATABASE testdb9;
 
258
CREATE DATABASE testdb10;
 
259
GRANT ALL ON testdb1.* TO testuser@localhost;
 
260
GRANT ALL ON testdb2.* TO testuser@localhost;
 
261
GRANT ALL ON testdb3.* TO testuser@localhost;
 
262
GRANT ALL ON testdb4.* TO testuser@localhost;
 
263
GRANT ALL ON testdb5.* TO testuser@localhost;
 
264
GRANT ALL ON testdb6.* TO testuser@localhost;
 
265
GRANT ALL ON testdb7.* TO testuser@localhost;
 
266
GRANT ALL ON testdb8.* TO testuser@localhost;
 
267
GRANT ALL ON testdb9.* TO testuser@localhost;
 
268
GRANT ALL ON testdb10.* TO testuser@localhost;
 
269
GRANT SELECT ON test.t1 TO testuser@localhost;
 
270
GRANT SELECT ON test.t2 TO testuser@localhost;
 
271
GRANT SELECT ON test.t3 TO testuser@localhost;
 
272
GRANT SELECT ON test.t4 TO testuser@localhost;
 
273
GRANT SELECT ON test.t5 TO testuser@localhost;
 
274
GRANT SELECT ON test.t6 TO testuser@localhost;
 
275
GRANT SELECT ON test.t7 TO testuser@localhost;
 
276
GRANT SELECT ON test.t8 TO testuser@localhost;
 
277
GRANT SELECT ON test.t9 TO testuser@localhost;
 
278
GRANT SELECT ON test.t10 TO testuser@localhost;
 
279
GRANT SELECT (a) ON test.t1 TO testuser@localhost;
 
280
GRANT SELECT (a) ON test.t2 TO testuser@localhost;
 
281
GRANT SELECT (a) ON test.t3 TO testuser@localhost;
 
282
GRANT SELECT (a) ON test.t4 TO testuser@localhost;
 
283
GRANT SELECT (a) ON test.t5 TO testuser@localhost;
 
284
GRANT SELECT (a) ON test.t6 TO testuser@localhost;
 
285
GRANT SELECT (a) ON test.t7 TO testuser@localhost;
 
286
GRANT SELECT (a) ON test.t8 TO testuser@localhost;
 
287
GRANT SELECT (a) ON test.t9 TO testuser@localhost;
 
288
GRANT SELECT (a) ON test.t10 TO testuser@localhost;
 
289
REVOKE ALL PRIVILEGES, GRANT OPTION FROM testuser@localhost;
 
290
SHOW GRANTS FOR testuser@localhost;
 
291
DROP USER testuser@localhost;
 
292
DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
 
293
DROP DATABASE testdb1;
 
294
DROP DATABASE testdb2;
 
295
DROP DATABASE testdb3;
 
296
DROP DATABASE testdb4;
 
297
DROP DATABASE testdb5;
 
298
DROP DATABASE testdb6;
 
299
DROP DATABASE testdb7;
 
300
DROP DATABASE testdb8;
 
301
DROP DATABASE testdb9;
 
302
DROP DATABASE testdb10;
 
303
 
 
304
#
 
305
# Bug#6932 a problem with 'revoke ALL PRIVILEGES'
 
306
#
 
307
 
 
308
create table t1(a int, b int, c int, d int);
 
309
grant insert(b), insert(c), insert(d), insert(a) on t1 to grant_user@localhost;
 
310
show grants for grant_user@localhost;
 
311
select Host,Db,User,Table_name,Column_name,Column_priv from mysql.columns_priv order by Column_name;
 
312
revoke ALL PRIVILEGES on t1 from grant_user@localhost;
 
313
show grants for grant_user@localhost;
 
314
select Host,Db,User,Table_name,Column_name,Column_priv from mysql.columns_priv;
 
315
drop user grant_user@localhost;
 
316
drop table t1;
 
317
 
 
318
#
 
319
# Bug#7391 Cross-database multi-table UPDATE security problem
 
320
#
 
321
create database mysqltest_1;
 
322
create database mysqltest_2;
 
323
create table mysqltest_1.t1 select 1 a, 2 q;
 
324
create table mysqltest_1.t2 select 1 b, 2 r;
 
325
create table mysqltest_2.t1 select 1 c, 2 s;
 
326
create table mysqltest_2.t2 select 1 d, 2 t;
 
327
 
 
328
# test the column privileges
 
329
grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost;
 
330
grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost;
 
331
grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost;
 
332
grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost;
 
333
connect (conn1,localhost,mysqltest_3,,);
 
334
connection conn1;
 
335
SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
 
336
 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
 
337
 ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE;
 
338
SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES
 
339
 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
 
340
 ORDER BY TABLE_NAME,PRIVILEGE_TYPE;
 
341
SELECT * from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES
 
342
 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
 
343
 ORDER BY TABLE_SCHEMA,PRIVILEGE_TYPE;
 
344
SELECT * from INFORMATION_SCHEMA.USER_PRIVILEGES
 
345
 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
 
346
 ORDER BY TABLE_CATALOG,PRIVILEGE_TYPE;
 
347
--error ER_COLUMNACCESS_DENIED_ERROR
 
348
update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1;
 
349
--error ER_COLUMNACCESS_DENIED_ERROR
 
350
update mysqltest_1.t2, mysqltest_2.t2 set d=20 where d=1;
 
351
--error ER_TABLEACCESS_DENIED_ERROR
 
352
update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1;
 
353
--error ER_TABLEACCESS_DENIED_ERROR
 
354
update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1;
 
355
--error ER_COLUMNACCESS_DENIED_ERROR
 
356
update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2;
 
357
# the following two should work
 
358
update mysqltest_1.t1, mysqltest_2.t2 set a=10,d=10;
 
359
update mysqltest_1.t1, mysqltest_2.t1 set a=20 where c=20;
 
360
connection master;
 
361
select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
 
362
select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
 
363
revoke all on mysqltest_1.t1 from mysqltest_3@localhost;
 
364
revoke all on mysqltest_1.t2 from mysqltest_3@localhost;
 
365
revoke all on mysqltest_2.t1 from mysqltest_3@localhost;
 
366
revoke all on mysqltest_2.t2 from mysqltest_3@localhost;
 
367
 
 
368
# test the db/table level privileges
 
369
grant all on mysqltest_2.* to mysqltest_3@localhost;
 
370
grant select on *.* to mysqltest_3@localhost;
 
371
# Next grant is needed to trigger bug#7391. Do not optimize!
 
372
grant select on mysqltest_2.t1 to mysqltest_3@localhost;
 
373
flush privileges;
 
374
disconnect conn1;
 
375
connect (conn2,localhost,mysqltest_3,,);
 
376
connection conn2;
 
377
use mysqltest_1;
 
378
update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600;
 
379
# the following failed before, should fail now.
 
380
--error ER_TABLEACCESS_DENIED_ERROR
 
381
update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
 
382
use mysqltest_2;
 
383
# the following used to succeed, it must fail now.
 
384
--error ER_TABLEACCESS_DENIED_ERROR
 
385
update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
 
386
--error ER_TABLEACCESS_DENIED_ERROR
 
387
update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200;
 
388
--error ER_TABLEACCESS_DENIED_ERROR
 
389
update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200;
 
390
# lets see the result
 
391
connection master;
 
392
select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
 
393
select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
 
394
 
 
395
delete from mysql.user where user='mysqltest_3';
 
396
delete from mysql.db where user="mysqltest_3";
 
397
delete from mysql.tables_priv where user="mysqltest_3";
 
398
delete from mysql.columns_priv where user="mysqltest_3";
 
399
flush privileges;
 
400
drop database mysqltest_1;
 
401
drop database mysqltest_2;
 
402
disconnect conn2;
 
403
 
 
404
#
 
405
# just SHOW PRIVILEGES test
 
406
#
 
407
SHOW PRIVILEGES;
 
408
 
 
409
#
 
410
# Rights for renaming test (Bug#3270)
 
411
#
 
412
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
 
413
connection root;
 
414
--disable_warnings
 
415
create database mysqltest;
 
416
--enable_warnings
 
417
create table mysqltest.t1 (a int,b int,c int);
 
418
grant all on mysqltest.t1 to mysqltest_1@localhost;
 
419
connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
 
420
connection user1;
 
421
-- error ER_TABLEACCESS_DENIED_ERROR
 
422
alter table t1 rename t2;
 
423
disconnect user1;
 
424
connection root;
 
425
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
 
426
delete from mysql.user where user=_binary'mysqltest_1';
 
427
drop database mysqltest;
 
428
connection default;
 
429
disconnect root;
 
430
 
 
431
#
 
432
# check all new table privileges
 
433
#
 
434
CREATE USER dummy@localhost;
 
435
CREATE DATABASE mysqltest;
 
436
CREATE TABLE mysqltest.dummytable (dummyfield INT);
 
437
CREATE VIEW mysqltest.dummyview AS SELECT dummyfield FROM mysqltest.dummytable;
 
438
GRANT ALL PRIVILEGES ON mysqltest.dummytable TO dummy@localhost;
 
439
GRANT ALL PRIVILEGES ON mysqltest.dummyview TO dummy@localhost;
 
440
SHOW GRANTS FOR dummy@localhost;
 
441
use INFORMATION_SCHEMA;
 
442
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
 
443
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
 
444
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
 
445
FLUSH PRIVILEGES;
 
446
SHOW GRANTS FOR dummy@localhost;
 
447
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
 
448
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
 
449
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
 
450
SHOW FIELDS FROM mysql.tables_priv;
 
451
use test;
 
452
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
 
453
DROP USER dummy@localhost;
 
454
DROP DATABASE mysqltest;
 
455
# check view only privileges
 
456
CREATE USER dummy@localhost;
 
457
CREATE DATABASE mysqltest;
 
458
CREATE TABLE mysqltest.dummytable (dummyfield INT);
 
459
CREATE VIEW mysqltest.dummyview AS SELECT dummyfield FROM mysqltest.dummytable;
 
460
GRANT CREATE VIEW ON mysqltest.dummytable TO dummy@localhost;
 
461
GRANT CREATE VIEW ON mysqltest.dummyview TO dummy@localhost;
 
462
SHOW GRANTS FOR dummy@localhost;
 
463
use INFORMATION_SCHEMA;
 
464
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
 
465
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
 
466
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
 
467
FLUSH PRIVILEGES;
 
468
SHOW GRANTS FOR dummy@localhost;
 
469
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
 
470
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
 
471
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
 
472
use test;
 
473
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
 
474
DROP USER dummy@localhost;
 
475
DROP DATABASE mysqltest;
 
476
CREATE USER dummy@localhost;
 
477
CREATE DATABASE mysqltest;
 
478
CREATE TABLE mysqltest.dummytable (dummyfield INT);
 
479
CREATE VIEW mysqltest.dummyview AS SELECT dummyfield FROM mysqltest.dummytable;
 
480
GRANT SHOW VIEW ON mysqltest.dummytable TO dummy@localhost;
 
481
GRANT SHOW VIEW ON mysqltest.dummyview TO dummy@localhost;
 
482
SHOW GRANTS FOR dummy@localhost;
 
483
use INFORMATION_SCHEMA;
 
484
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
 
485
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
 
486
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
 
487
FLUSH PRIVILEGES;
 
488
SHOW GRANTS FOR dummy@localhost;
 
489
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
 
490
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
 
491
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
 
492
use test;
 
493
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
 
494
DROP USER dummy@localhost;
 
495
DROP DATABASE mysqltest;
 
496
#
 
497
# Bug#11330 Entry in tables_priv with host = '' causes crash
 
498
#
 
499
connection default;
 
500
use mysql;
 
501
insert into tables_priv values ('','test_db','mysqltest_1','test_table','test_grantor',CURRENT_TIMESTAMP,'Select','Select');
 
502
flush privileges;
 
503
delete from tables_priv where host = '' and user = 'mysqltest_1';
 
504
flush privileges;
 
505
use test;
 
506
 
 
507
#
 
508
# Bug#10892 user variables not auto cast for comparisons
 
509
# Check that we don't get illegal mix of collations
 
510
#
 
511
set @user123="non-existent";
 
512
select * from mysql.db where user=@user123;
 
513
 
 
514
set names koi8r;
 
515
create database ��;
 
516
grant select on ��.* to root@localhost;
 
517
select hex(Db) from mysql.db where Db='��';
 
518
show grants for root@localhost;
 
519
flush privileges;
 
520
show grants for root@localhost;
 
521
drop database ��;
 
522
revoke all privileges on ��.* from root@localhost;
 
523
show grants for root@localhost;
 
524
set names latin1;
 
525
 
 
526
#
 
527
# Bug#15598 Server crashes in specific case during setting new password
 
528
# - Caused by a user with host ''
 
529
#
 
530
create user mysqltest_7@;
 
531
set password for mysqltest_7@ = password('systpass');
 
532
show grants for mysqltest_7@;
 
533
drop user mysqltest_7@;
 
534
--error ER_NONEXISTING_GRANT
 
535
show grants for mysqltest_7@;
 
536
 
 
537
#
 
538
# Bug#14385 GRANT and mapping to correct user account problems
 
539
#
 
540
create database mysqltest;
 
541
use mysqltest;
 
542
create table t1(f1 int);
 
543
GRANT DELETE ON mysqltest.t1 TO mysqltest1@'%';
 
544
GRANT SELECT ON mysqltest.t1 TO mysqltest1@'192.%';
 
545
show grants for mysqltest1@'192.%';
 
546
show grants for mysqltest1@'%';
 
547
delete from mysql.user where user='mysqltest1';
 
548
delete from mysql.db where user='mysqltest1';
 
549
delete from mysql.tables_priv where user='mysqltest1';
 
550
flush privileges;
 
551
drop database mysqltest;
 
552
 
 
553
#
 
554
# Bug#27515 DROP previlege is not required for RENAME TABLE
 
555
#
 
556
connection master;
 
557
create database db27515;
 
558
use db27515;
 
559
create table t1 (a int);
 
560
grant alter on db27515.t1 to user27515@localhost;
 
561
grant insert, create on db27515.t2 to user27515@localhost;
 
562
 
 
563
connect (conn27515, localhost, user27515, , db27515);
 
564
connection conn27515;
 
565
--error ER_TABLEACCESS_DENIED_ERROR
 
566
rename table t1 to t2;
 
567
disconnect conn27515;
 
568
 
 
569
connection master;
 
570
revoke all privileges, grant option from user27515@localhost;
 
571
drop user user27515@localhost;
 
572
drop database db27515;
 
573
 
 
574
--echo End of 4.1 tests
 
575
 
 
576
#
 
577
# Bug#16297 In memory grant tables not flushed when users's hostname is ""
 
578
#
 
579
use test;
 
580
create table t1 (a int);
 
581
 
 
582
# Backup anonymous users and remove them. (They get in the way of
 
583
# the one we test with here otherwise.)
 
584
create table t2 as select * from mysql.user where user='';
 
585
delete from mysql.user where user='';
 
586
flush privileges;
 
587
 
 
588
# Create some users with different hostnames
 
589
create user mysqltest_8@'';
 
590
create user mysqltest_8;
 
591
create user mysqltest_8@host8;
 
592
 
 
593
# Try to create them again
 
594
--error ER_CANNOT_USER
 
595
create user mysqltest_8@'';
 
596
--error ER_CANNOT_USER
 
597
create user mysqltest_8;
 
598
--error ER_CANNOT_USER
 
599
create user mysqltest_8@host8;
 
600
 
 
601
select user, QUOTE(host) from mysql.user where user="mysqltest_8";
 
602
 
 
603
--echo Schema privileges
 
604
grant select on mysqltest.* to mysqltest_8@'';
 
605
show grants for mysqltest_8@'';
 
606
grant select on mysqltest.* to mysqltest_8@;
 
607
show grants for mysqltest_8@;
 
608
grant select on mysqltest.* to mysqltest_8;
 
609
show grants for mysqltest_8;
 
610
select * from  information_schema.schema_privileges
 
611
where grantee like "'mysqltest_8'%";
 
612
connect (conn3,localhost,mysqltest_8,,);
 
613
select * from t1;
 
614
disconnect conn3;
 
615
connection master;
 
616
revoke select on mysqltest.* from mysqltest_8@'';
 
617
revoke select on mysqltest.* from mysqltest_8;
 
618
show grants for mysqltest_8@'';
 
619
show grants for mysqltest_8;
 
620
select * from  information_schema.schema_privileges
 
621
where grantee like "'mysqltest_8'%";
 
622
flush privileges;
 
623
show grants for mysqltest_8@'';
 
624
show grants for mysqltest_8@;
 
625
grant select on mysqltest.* to mysqltest_8@'';
 
626
flush privileges;
 
627
show grants for mysqltest_8@;
 
628
revoke select on mysqltest.* from mysqltest_8@'';
 
629
flush privileges;
 
630
 
 
631
--echo Column privileges
 
632
grant update (a) on t1 to mysqltest_8@'';
 
633
grant update (a) on t1 to mysqltest_8;
 
634
show grants for mysqltest_8@'';
 
635
show grants for mysqltest_8;
 
636
flush privileges;
 
637
show grants for mysqltest_8@'';
 
638
show grants for mysqltest_8;
 
639
select * from  information_schema.column_privileges;
 
640
connect (conn4,localhost,mysqltest_8,,);
 
641
select * from t1;
 
642
disconnect conn4;
 
643
connection master;
 
644
revoke update (a) on t1 from mysqltest_8@'';
 
645
revoke update (a) on t1 from mysqltest_8;
 
646
show grants for mysqltest_8@'';
 
647
show grants for mysqltest_8;
 
648
select * from  information_schema.column_privileges;
 
649
flush privileges;
 
650
show grants for mysqltest_8@'';
 
651
show grants for mysqltest_8;
 
652
 
 
653
--echo Table privileges
 
654
grant update on t1 to mysqltest_8@'';
 
655
grant update on t1 to mysqltest_8;
 
656
show grants for mysqltest_8@'';
 
657
show grants for mysqltest_8;
 
658
flush privileges;
 
659
show grants for mysqltest_8@'';
 
660
show grants for mysqltest_8;
 
661
select * from  information_schema.table_privileges;
 
662
connect (conn5,localhost,mysqltest_8,,);
 
663
select * from t1;
 
664
disconnect conn5;
 
665
connection master;
 
666
revoke update on t1 from mysqltest_8@'';
 
667
revoke update on t1 from mysqltest_8;
 
668
show grants for mysqltest_8@'';
 
669
show grants for mysqltest_8;
 
670
select * from  information_schema.table_privileges;
 
671
flush privileges;
 
672
show grants for mysqltest_8@'';
 
673
show grants for mysqltest_8;
 
674
 
 
675
--echo "DROP USER" should clear privileges
 
676
grant all privileges on mysqltest.* to mysqltest_8@'';
 
677
grant select on mysqltest.* to mysqltest_8@'';
 
678
grant update on t1 to mysqltest_8@'';
 
679
grant update (a) on t1 to mysqltest_8@'';
 
680
grant all privileges on mysqltest.* to mysqltest_8;
 
681
show grants for mysqltest_8@'';
 
682
show grants for mysqltest_8;
 
683
select * from  information_schema.user_privileges
 
684
where grantee like "'mysqltest_8'%";
 
685
connect (conn5,localhost,mysqltest_8,,);
 
686
select * from t1;
 
687
disconnect conn5;
 
688
connection master;
 
689
flush privileges;
 
690
show grants for mysqltest_8@'';
 
691
show grants for mysqltest_8;
 
692
drop user mysqltest_8@'';
 
693
--error ER_NONEXISTING_GRANT
 
694
show grants for mysqltest_8@'';
 
695
show grants for mysqltest_8;
 
696
select * from  information_schema.user_privileges
 
697
where grantee like "'mysqltest_8'%";
 
698
drop user mysqltest_8;
 
699
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
700
--error ER_ACCESS_DENIED_ERROR
 
701
connect (conn6,localhost,mysqltest_8,,);
 
702
connection master;
 
703
--error ER_NONEXISTING_GRANT
 
704
show grants for mysqltest_8;
 
705
drop user mysqltest_8@host8;
 
706
--error ER_NONEXISTING_GRANT
 
707
show grants for mysqltest_8@host8;
 
708
 
 
709
# Restore the anonymous users.
 
710
insert into mysql.user select * from t2;
 
711
flush privileges;
 
712
drop table t2;
 
713
drop table t1;
 
714
 
 
715
#
 
716
# Bug#20214 Incorrect error when user calls SHOW CREATE VIEW on non
 
717
#           privileged view
 
718
#
 
719
 
 
720
connection master;
 
721
 
 
722
CREATE DATABASE mysqltest3;
 
723
USE mysqltest3;
 
724
 
 
725
CREATE TABLE t_nn (c1 INT);
 
726
CREATE VIEW  v_nn AS SELECT * FROM t_nn;
 
727
 
 
728
CREATE DATABASE mysqltest2;
 
729
USE mysqltest2;
 
730
 
 
731
CREATE TABLE t_nn (c1 INT);
 
732
CREATE VIEW  v_nn AS SELECT * FROM t_nn;
 
733
CREATE VIEW  v_yn AS SELECT * FROM t_nn;
 
734
CREATE VIEW  v_gy AS SELECT * FROM t_nn;
 
735
CREATE VIEW  v_ny AS SELECT * FROM t_nn;
 
736
CREATE VIEW  v_yy AS SELECT * FROM t_nn WHERE c1=55;
 
737
 
 
738
GRANT SHOW VIEW        ON mysqltest2.v_ny TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
 
739
GRANT SELECT           ON mysqltest2.v_yn TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
 
740
GRANT SELECT           ON mysqltest2.*    TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
 
741
GRANT SHOW VIEW,SELECT ON mysqltest2.v_yy TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
 
742
 
 
743
connect (mysqltest_1, localhost, mysqltest_1, mysqltest_1,);
 
744
 
 
745
# fail because of missing SHOW VIEW (have generic SELECT)
 
746
--error ER_TABLEACCESS_DENIED_ERROR
 
747
SHOW CREATE VIEW  mysqltest2.v_nn;
 
748
--error ER_TABLEACCESS_DENIED_ERROR
 
749
SHOW CREATE TABLE mysqltest2.v_nn;
 
750
 
 
751
# fail because of missing SHOW VIEW
 
752
--error ER_TABLEACCESS_DENIED_ERROR
 
753
SHOW CREATE VIEW  mysqltest2.v_yn;
 
754
--error ER_TABLEACCESS_DENIED_ERROR
 
755
SHOW CREATE TABLE mysqltest2.v_yn;
 
756
 
 
757
# succeed (despite of missing SELECT, having SHOW VIEW bails us out)
 
758
SHOW CREATE TABLE mysqltest2.v_ny;
 
759
 
 
760
# succeed (despite of missing SELECT, having SHOW VIEW bails us out)
 
761
SHOW CREATE VIEW  mysqltest2.v_ny;
 
762
 
 
763
# fail because of missing (specific or generic) SELECT
 
764
--error ER_TABLEACCESS_DENIED_ERROR
 
765
SHOW CREATE TABLE mysqltest3.t_nn;
 
766
 
 
767
# fail because of missing (specific or generic) SELECT (not because it's not a view!)
 
768
--error ER_TABLEACCESS_DENIED_ERROR
 
769
SHOW CREATE VIEW  mysqltest3.t_nn;
 
770
 
 
771
# fail because of missing missing (specific or generic) SELECT (and SHOW VIEW)
 
772
--error ER_TABLEACCESS_DENIED_ERROR
 
773
SHOW CREATE VIEW  mysqltest3.v_nn;
 
774
--error ER_TABLEACCESS_DENIED_ERROR
 
775
SHOW CREATE TABLE mysqltest3.v_nn;
 
776
 
 
777
# succeed thanks to generic SELECT
 
778
SHOW CREATE TABLE mysqltest2.t_nn;
 
779
 
 
780
# fail because it's not a view!  (have generic SELECT though)
 
781
--error ER_WRONG_OBJECT
 
782
SHOW CREATE VIEW  mysqltest2.t_nn;
 
783
 
 
784
# succeed, have SELECT and SHOW VIEW
 
785
SHOW CREATE VIEW mysqltest2.v_yy;
 
786
 
 
787
# succeed, have SELECT and SHOW VIEW
 
788
SHOW CREATE TABLE mysqltest2.v_yy;
 
789
 
 
790
# clean-up
 
791
connection master;
 
792
 
 
793
# succeed, we're root
 
794
SHOW CREATE TABLE mysqltest2.v_nn;
 
795
SHOW CREATE VIEW  mysqltest2.v_nn;
 
796
 
 
797
SHOW CREATE TABLE mysqltest2.t_nn;
 
798
 
 
799
# fail because it's not a view!
 
800
--error ER_WRONG_OBJECT
 
801
SHOW CREATE VIEW mysqltest2.t_nn;
 
802
 
 
803
DROP VIEW  mysqltest2.v_nn;
 
804
DROP VIEW  mysqltest2.v_yn;
 
805
DROP VIEW  mysqltest2.v_ny;
 
806
DROP VIEW  mysqltest2.v_yy;
 
807
DROP TABLE mysqltest2.t_nn;
 
808
DROP DATABASE mysqltest2;
 
809
DROP VIEW  mysqltest3.v_nn;
 
810
DROP TABLE mysqltest3.t_nn;
 
811
DROP DATABASE mysqltest3;
 
812
disconnect mysqltest_1;
 
813
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost';
 
814
DROP USER 'mysqltest_1'@'localhost';
 
815
 
 
816
# restore the original database
 
817
USE test;
 
818
connection default;
 
819
disconnect master;
 
820
 
 
821
 
 
822
#
 
823
# Bug#10668 CREATE USER does not enforce username length limit
 
824
#
 
825
--error ER_WRONG_STRING_LENGTH
 
826
create user mysqltest1_thisisreallytoolong;
 
827
 
 
828
#
 
829
# Test for Bug#16899 Possible buffer overflow in handling of DEFINER-clause.
 
830
#
 
831
# These checks are intended to ensure that appropriate errors are risen when
 
832
# illegal user name or hostname is specified in user-clause of GRANT/REVOKE
 
833
# statements.
 
834
#
 
835
 
 
836
#
 
837
# Bug#22369 Alter table rename combined with other alterations causes lost tables
 
838
#
 
839
CREATE DATABASE mysqltest1;
 
840
CREATE TABLE mysqltest1.t1 (
 
841
  int_field INTEGER UNSIGNED NOT NULL,
 
842
  char_field CHAR(10),
 
843
  INDEX(`int_field`)
 
844
);
 
845
CREATE TABLE mysqltest1.t2 (int_field INT);
 
846
 
 
847
--echo "Now check that we require equivalent grants for "
 
848
--echo "RENAME TABLE and ALTER TABLE"
 
849
CREATE USER mysqltest_1@localhost;
 
850
GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
 
851
 
 
852
connect (conn42,localhost,mysqltest_1,,mysqltest1);
 
853
SELECT USER();
 
854
SHOW GRANTS;
 
855
--error ER_TABLEACCESS_DENIED_ERROR
 
856
RENAME TABLE t1 TO t2;
 
857
--error ER_TABLEACCESS_DENIED_ERROR
 
858
ALTER TABLE t1 RENAME TO t2;
 
859
--disconnect conn42
 
860
--connection default
 
861
GRANT DROP ON mysqltest1.t1 TO mysqltest_1@localhost;
 
862
 
 
863
connect (conn42,localhost,mysqltest_1,,mysqltest1);
 
864
--error ER_TABLEACCESS_DENIED_ERROR
 
865
RENAME TABLE t1 TO t2;
 
866
--error ER_TABLEACCESS_DENIED_ERROR
 
867
ALTER TABLE t1 RENAME TO t2;
 
868
--disconnect conn42
 
869
--connection default
 
870
GRANT ALTER ON mysqltest1.t1 TO mysqltest_1@localhost;
 
871
 
 
872
connect (conn42,localhost,mysqltest_1,,mysqltest1);
 
873
SHOW GRANTS;
 
874
--error ER_TABLEACCESS_DENIED_ERROR
 
875
RENAME TABLE t1 TO t2;
 
876
--error ER_TABLEACCESS_DENIED_ERROR
 
877
ALTER TABLE t1 RENAME TO t2;
 
878
--disconnect conn42
 
879
--connection default
 
880
GRANT INSERT, CREATE ON mysqltest1.t1 TO mysqltest_1@localhost;
 
881
connect (conn42,localhost,mysqltest_1,,mysqltest1);
 
882
SHOW GRANTS;
 
883
--error ER_TABLEACCESS_DENIED_ERROR
 
884
--disconnect conn42
 
885
--connection default
 
886
GRANT INSERT, SELECT, CREATE, ALTER, DROP ON mysqltest1.t2 TO mysqltest_1@localhost;
 
887
DROP TABLE mysqltest1.t2;
 
888
 
 
889
connect (conn42,localhost,mysqltest_1,,mysqltest1);
 
890
SHOW GRANTS;
 
891
RENAME TABLE t1 TO t2;
 
892
RENAME TABLE t2 TO t1;
 
893
ALTER TABLE t1 RENAME TO t2;
 
894
ALTER TABLE t2 RENAME TO t1;
 
895
--disconnect conn42
 
896
--connection default
 
897
REVOKE DROP, INSERT ON mysqltest1.t1 FROM mysqltest_1@localhost;
 
898
REVOKE DROP, INSERT ON mysqltest1.t2 FROM mysqltest_1@localhost;
 
899
 
 
900
connect (conn42,localhost,mysqltest_1,,mysqltest1);
 
901
SHOW GRANTS;
 
902
--error ER_TABLEACCESS_DENIED_ERROR
 
903
RENAME TABLE t1 TO t2;
 
904
--error ER_TABLEACCESS_DENIED_ERROR
 
905
ALTER TABLE t1 RENAME TO t2;
 
906
--disconnect conn42
 
907
--connection default
 
908
 
 
909
DROP USER mysqltest_1@localhost;
 
910
DROP DATABASE mysqltest1;
 
911
USE test;
 
912
 
 
913
# Working with database-level privileges.
 
914
 
 
915
--error ER_WRONG_STRING_LENGTH
 
916
GRANT CREATE ON mysqltest.* TO 1234567890abcdefGHIKL@localhost;
 
917
 
 
918
--error ER_WRONG_STRING_LENGTH
 
919
GRANT CREATE ON mysqltest.* TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
 
920
 
 
921
--error ER_WRONG_STRING_LENGTH
 
922
REVOKE CREATE ON mysqltest.* FROM 1234567890abcdefGHIKL@localhost;
 
923
 
 
924
--error ER_WRONG_STRING_LENGTH
 
925
REVOKE CREATE ON mysqltest.* FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
 
926
 
 
927
# Working with table-level privileges.
 
928
 
 
929
--error ER_WRONG_STRING_LENGTH
 
930
GRANT CREATE ON t1 TO 1234567890abcdefGHIKL@localhost;
 
931
 
 
932
--error ER_WRONG_STRING_LENGTH
 
933
GRANT CREATE ON t1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
 
934
 
 
935
--error ER_WRONG_STRING_LENGTH
 
936
REVOKE CREATE ON t1 FROM 1234567890abcdefGHIKL@localhost;
 
937
 
 
938
--error ER_WRONG_STRING_LENGTH
 
939
REVOKE CREATE ON t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
 
940
 
 
941
# Working with routine-level privileges.
 
942
 
 
943
--error ER_WRONG_STRING_LENGTH
 
944
GRANT EXECUTE ON PROCEDURE p1 TO 1234567890abcdefGHIKL@localhost;
 
945
 
 
946
--error ER_WRONG_STRING_LENGTH
 
947
GRANT EXECUTE ON PROCEDURE p1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
 
948
 
 
949
--error ER_WRONG_STRING_LENGTH
 
950
REVOKE EXECUTE ON PROCEDURE p1 FROM 1234567890abcdefGHIKL@localhost;
 
951
 
 
952
--error ER_WRONG_STRING_LENGTH
 
953
REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
 
954
 
 
955
 
 
956
#
 
957
# Bug#23556 TRUNCATE TABLE still maps to DELETE
 
958
#
 
959
CREATE USER bug23556@localhost;
 
960
CREATE DATABASE bug23556;
 
961
GRANT SELECT ON bug23556.* TO bug23556@localhost;
 
962
connect (bug23556,localhost,bug23556,,bug23556);
 
963
 
 
964
connection default;
 
965
USE bug23556;
 
966
CREATE TABLE t1 (a INT PRIMARY KEY); INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
 
967
GRANT DELETE ON t1 TO bug23556@localhost;
 
968
 
 
969
connection bug23556;
 
970
USE bug23556;
 
971
--error ER_TABLEACCESS_DENIED_ERROR
 
972
TRUNCATE t1;
 
973
 
 
974
connection default;
 
975
USE bug23556;
 
976
REVOKE DELETE ON t1 FROM bug23556@localhost;
 
977
GRANT DROP ON t1 TO bug23556@localhost;
 
978
 
 
979
connection bug23556;
 
980
USE bug23556;
 
981
TRUNCATE t1;
 
982
 
 
983
connection default;
 
984
USE bug23556;
 
985
DROP TABLE t1;
 
986
USE test;
 
987
DROP DATABASE bug23556;
 
988
DROP USER bug23556@localhost;
 
989
connection default;
 
990
disconnect bug23556;
 
991
 
 
992
 
 
993
#
 
994
# Bug#6774 Replication fails with Wrong usage of DB GRANT and GLOBAL PRIVILEGES
 
995
#
 
996
# Check if GRANT ... ON * ... fails when no database is selected
 
997
connect (con1, localhost, root,,*NO-ONE*);
 
998
connection con1;
 
999
--error ER_NO_DB_ERROR
 
1000
GRANT PROCESS ON * TO user@localhost;
 
1001
disconnect con1;
 
1002
connection default;
 
1003
 
 
1004
 
 
1005
#
 
1006
# Bug#9504 Stored procedures: execute privilege doesn't make 'use database'
 
1007
# okay.
 
1008
#
 
1009
 
 
1010
# Prepare.
 
1011
 
 
1012
--disable_warnings
 
1013
DROP DATABASE IF EXISTS mysqltest1;
 
1014
DROP DATABASE IF EXISTS mysqltest2;
 
1015
DROP DATABASE IF EXISTS mysqltest3;
 
1016
DROP DATABASE IF EXISTS mysqltest4;
 
1017
--enable_warnings
 
1018
 
 
1019
CREATE DATABASE mysqltest1;
 
1020
CREATE DATABASE mysqltest2;
 
1021
CREATE DATABASE mysqltest3;
 
1022
CREATE DATABASE mysqltest4;
 
1023
 
 
1024
CREATE PROCEDURE mysqltest1.p_def() SQL SECURITY DEFINER
 
1025
  SELECT 1;
 
1026
 
 
1027
CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER
 
1028
  SELECT 1;
 
1029
 
 
1030
CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER
 
1031
  RETURN 1;
 
1032
 
 
1033
CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER
 
1034
  RETURN 1;
 
1035
 
 
1036
GRANT EXECUTE ON PROCEDURE mysqltest1.p_def TO mysqltest_1@localhost;
 
1037
GRANT EXECUTE ON PROCEDURE mysqltest2.p_inv TO mysqltest_1@localhost;
 
1038
GRANT EXECUTE ON FUNCTION mysqltest3.f_def TO mysqltest_1@localhost;
 
1039
GRANT EXECUTE ON FUNCTION mysqltest4.f_inv TO mysqltest_1@localhost;
 
1040
 
 
1041
GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost;
 
1042
 
 
1043
# Test.
 
1044
 
 
1045
--connect (bug9504_con1,localhost,mysqltest_1,,)
 
1046
--echo
 
1047
--echo ---> connection: bug9504_con1
 
1048
 
 
1049
# - Check that we can switch to the db;
 
1050
 
 
1051
use mysqltest1;
 
1052
 
 
1053
use mysqltest2;
 
1054
 
 
1055
use mysqltest3;
 
1056
 
 
1057
use mysqltest4;
 
1058
 
 
1059
# - Check that we can call stored routines;
 
1060
 
 
1061
use test;
 
1062
 
 
1063
CALL mysqltest1.p_def();
 
1064
 
 
1065
CALL mysqltest2.p_inv();
 
1066
 
 
1067
SELECT mysqltest3.f_def();
 
1068
 
 
1069
SELECT mysqltest4.f_inv();
 
1070
 
 
1071
# Cleanup.
 
1072
 
 
1073
--connection default
 
1074
--echo
 
1075
--echo ---> connection: default
 
1076
 
 
1077
--disconnect bug9504_con1
 
1078
 
 
1079
DROP DATABASE mysqltest1;
 
1080
DROP DATABASE mysqltest2;
 
1081
DROP DATABASE mysqltest3;
 
1082
DROP DATABASE mysqltest4;
 
1083
 
 
1084
DROP USER mysqltest_1@localhost;
 
1085
 
 
1086
 
 
1087
#
 
1088
# Bug#27337 Privileges are not restored properly.
 
1089
#
 
1090
# Actually, the patch for this bugs fixes two problems. So, here are two test
 
1091
# cases.
 
1092
 
 
1093
# Test case 1: privileges are not restored properly after calling a stored
 
1094
# routine defined with SQL SECURITY INVOKER clause.
 
1095
 
 
1096
# Prepare.
 
1097
 
 
1098
--disable_warnings
 
1099
DROP DATABASE IF EXISTS mysqltest1;
 
1100
DROP DATABASE IF EXISTS mysqltest2;
 
1101
--enable_warnings
 
1102
 
 
1103
CREATE DATABASE mysqltest1;
 
1104
CREATE DATABASE mysqltest2;
 
1105
 
 
1106
GRANT ALL PRIVILEGES ON mysqltest1.* TO mysqltest_1@localhost;
 
1107
GRANT SELECT ON mysqltest2.* TO mysqltest_1@localhost;
 
1108
 
 
1109
CREATE PROCEDURE mysqltest1.p1() SQL SECURITY INVOKER
 
1110
  SELECT 1;
 
1111
 
 
1112
# Test.
 
1113
 
 
1114
--connect (bug27337_con1,localhost,mysqltest_1,,mysqltest2)
 
1115
--echo
 
1116
--echo ---> connection: bug27337_con1
 
1117
 
 
1118
--error ER_TABLEACCESS_DENIED_ERROR
 
1119
CREATE TABLE t1(c INT);
 
1120
 
 
1121
CALL mysqltest1.p1();
 
1122
 
 
1123
--error ER_TABLEACCESS_DENIED_ERROR
 
1124
CREATE TABLE t1(c INT);
 
1125
 
 
1126
--disconnect bug27337_con1
 
1127
 
 
1128
--connect (bug27337_con2,localhost,mysqltest_1,,mysqltest2)
 
1129
--echo
 
1130
--echo ---> connection: bug27337_con2
 
1131
 
 
1132
--error ER_TABLEACCESS_DENIED_ERROR
 
1133
CREATE TABLE t1(c INT);
 
1134
 
 
1135
SHOW TABLES;
 
1136
 
 
1137
# Cleanup.
 
1138
 
 
1139
--connection default
 
1140
--echo
 
1141
--echo ---> connection: default
 
1142
 
 
1143
--disconnect bug27337_con2
 
1144
 
 
1145
DROP DATABASE mysqltest1;
 
1146
DROP DATABASE mysqltest2;
 
1147
 
 
1148
DROP USER mysqltest_1@localhost;
 
1149
 
 
1150
# Test case 2: privileges are not checked properly for prepared statements.
 
1151
 
 
1152
# Prepare.
 
1153
 
 
1154
--disable_warnings
 
1155
DROP DATABASE IF EXISTS mysqltest1;
 
1156
DROP DATABASE IF EXISTS mysqltest2;
 
1157
--enable_warnings
 
1158
 
 
1159
CREATE DATABASE mysqltest1;
 
1160
CREATE DATABASE mysqltest2;
 
1161
 
 
1162
CREATE TABLE mysqltest1.t1(c INT);
 
1163
CREATE TABLE mysqltest2.t2(c INT);
 
1164
 
 
1165
GRANT SELECT ON mysqltest1.t1 TO mysqltest_1@localhost;
 
1166
GRANT SELECT ON mysqltest2.t2 TO mysqltest_2@localhost;
 
1167
 
 
1168
# Test.
 
1169
 
 
1170
--connect (bug27337_con1,localhost,mysqltest_1,,mysqltest1)
 
1171
--echo
 
1172
--echo ---> connection: bug27337_con1
 
1173
 
 
1174
SHOW TABLES FROM mysqltest1;
 
1175
 
 
1176
PREPARE stmt1 FROM 'SHOW TABLES FROM mysqltest1';
 
1177
 
 
1178
EXECUTE stmt1;
 
1179
 
 
1180
--connect (bug27337_con2,localhost,mysqltest_2,,mysqltest2)
 
1181
--echo
 
1182
--echo ---> connection: bug27337_con2
 
1183
 
 
1184
SHOW COLUMNS FROM mysqltest2.t2;
 
1185
 
 
1186
PREPARE stmt2 FROM 'SHOW COLUMNS FROM mysqltest2.t2';
 
1187
 
 
1188
EXECUTE stmt2;
 
1189
 
 
1190
--connection default
 
1191
--echo
 
1192
--echo ---> connection: default
 
1193
 
 
1194
REVOKE SELECT ON mysqltest1.t1 FROM mysqltest_1@localhost;
 
1195
REVOKE SELECT ON mysqltest2.t2 FROM mysqltest_2@localhost;
 
1196
 
 
1197
--connection bug27337_con1
 
1198
--echo
 
1199
--echo ---> connection: bug27337_con1
 
1200
 
 
1201
--error ER_DBACCESS_DENIED_ERROR
 
1202
SHOW TABLES FROM mysqltest1;
 
1203
 
 
1204
--error ER_DBACCESS_DENIED_ERROR
 
1205
EXECUTE stmt1;
 
1206
 
 
1207
--connection bug27337_con2
 
1208
--echo
 
1209
--echo ---> connection: bug27337_con2
 
1210
 
 
1211
--error ER_TABLEACCESS_DENIED_ERROR
 
1212
SHOW COLUMNS FROM mysqltest2.t2;
 
1213
 
 
1214
--error ER_TABLEACCESS_DENIED_ERROR
 
1215
EXECUTE stmt2;
 
1216
 
 
1217
# Cleanup.
 
1218
 
 
1219
--connection default
 
1220
--echo
 
1221
--echo ---> connection: default
 
1222
 
 
1223
--disconnect bug27337_con1
 
1224
--disconnect bug27337_con2
 
1225
 
 
1226
DROP DATABASE mysqltest1;
 
1227
DROP DATABASE mysqltest2;
 
1228
 
 
1229
DROP USER mysqltest_1@localhost;
 
1230
DROP USER mysqltest_2@localhost;
 
1231
 
 
1232
#
 
1233
# Bug#27878 Unchecked privileges on a view referring to a table from another
 
1234
#           database.
 
1235
#
 
1236
USE test;
 
1237
CREATE TABLE t1 (f1 int, f2 int);
 
1238
INSERT INTO t1 VALUES(1,1), (2,2);
 
1239
CREATE DATABASE db27878;
 
1240
GRANT UPDATE(f1) ON t1 TO 'mysqltest_1'@'localhost';
 
1241
GRANT SELECT ON `test`.* TO 'mysqltest_1'@'localhost';
 
1242
GRANT ALL ON db27878.* TO 'mysqltest_1'@'localhost';
 
1243
USE db27878;
 
1244
CREATE SQL SECURITY INVOKER VIEW db27878.v1 AS SELECT * FROM test.t1;
 
1245
connect (user1,localhost,mysqltest_1,,test);
 
1246
connection user1;
 
1247
USE db27878;
 
1248
--error 1356
 
1249
UPDATE v1 SET f2 = 4;
 
1250
SELECT * FROM test.t1;
 
1251
disconnect user1;
 
1252
connection default;
 
1253
REVOKE UPDATE (f1) ON `test`.`t1` FROM 'mysqltest_1'@'localhost';
 
1254
REVOKE SELECT ON `test`.* FROM 'mysqltest_1'@'localhost';
 
1255
REVOKE ALL ON db27878.* FROM 'mysqltest_1'@'localhost';
 
1256
DROP USER mysqltest_1@localhost;
 
1257
DROP DATABASE db27878;
 
1258
USE test;
 
1259
DROP TABLE t1;
 
1260
 
 
1261
--echo #
 
1262
--echo #  Bug#33275 Server crash when creating temporary table mysql.user
 
1263
--echo #
 
1264
CREATE TEMPORARY TABLE mysql.user (id INT);
 
1265
FLUSH PRIVILEGES;
 
1266
DROP TABLE mysql.user;
 
1267
 
 
1268
 
 
1269
#
 
1270
# Bug#33201 Crash occurs when granting update privilege on one column of a view
 
1271
#
 
1272
drop table if exists test;
 
1273
drop function if exists test_function;
 
1274
drop view if exists v1;
 
1275
create table test (col1 varchar(30));
 
1276
delimiter |;
 
1277
create function test_function() returns varchar(30)
 
1278
begin
 
1279
        declare tmp varchar(30);
 
1280
        select col1 from test limit 1 into tmp;
 
1281
        return '1';
 
1282
end|
 
1283
delimiter ;|
 
1284
create view v1 as select test.* from test where test.col1=test_function();
 
1285
grant update (col1) on v1 to 'greg'@'localhost';
 
1286
drop user 'greg'@'localhost';
 
1287
drop view v1;
 
1288
drop table test;
 
1289
drop function test_function;
 
1290
 
 
1291
#
 
1292
# Bug#41456 SET PASSWORD hates CURRENT_USER()
 
1293
#
 
1294
SELECT CURRENT_USER();
 
1295
SET PASSWORD FOR CURRENT_USER() = PASSWORD("admin");
 
1296
SET PASSWORD FOR CURRENT_USER() = PASSWORD("");
 
1297
 
 
1298
--echo End of 5.0 tests
 
1299
 
 
1300
#
 
1301
# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
 
1302
#
 
1303
set names utf8;
 
1304
grant select on test.* to юзер_юзер@localhost;
 
1305
--exec $MYSQL --default-character-set=utf8 --user=юзер_юзер -e "select user()"
 
1306
revoke all on test.* from юзер_юзер@localhost;
 
1307
drop user юзер_юзер@localhost;
 
1308
--error ER_WRONG_STRING_LENGTH
 
1309
grant select on test.* to очень_длинный_юзер@localhost;
 
1310
set names default;
 
1311
 
 
1312
#
 
1313
# Bug#20901 CREATE privilege is enough to insert into a table
 
1314
#
 
1315
 
 
1316
create database mysqltest;
 
1317
use mysqltest;
 
1318
 
 
1319
grant create on mysqltest.* to mysqltest@localhost;
 
1320
create table t1 (i INT);
 
1321
 
 
1322
connect (user1,localhost,mysqltest,,mysqltest);
 
1323
connection user1;
 
1324
# show we don't have INSERT
 
1325
--error ER_TABLEACCESS_DENIED_ERROR
 
1326
insert into t1 values (1);
 
1327
# show we have CREATE
 
1328
create table t2 (i INT);
 
1329
create table t4 (i INT);
 
1330
 
 
1331
connection default;
 
1332
grant select, insert on mysqltest.t2 to mysqltest@localhost;
 
1333
grant         insert on mysqltest.t4 to mysqltest@localhost;
 
1334
# to specify ACLs for non-existent objects, must explictly |CREATE
 
1335
grant create, insert on mysqltest.t5 to mysqltest@localhost;
 
1336
grant create, insert on mysqltest.t6 to mysqltest@localhost;
 
1337
flush privileges;
 
1338
 
 
1339
connection user1;
 
1340
insert into t2 values (1);
 
1341
 
 
1342
 
 
1343
# CREATE IF NOT EXISTS...SELECT, t1 exists, no INSERT, must fail
 
1344
--error ER_TABLEACCESS_DENIED_ERROR
 
1345
create table if not exists t1 select * from t2;
 
1346
 
 
1347
# CREATE IF NOT EXISTS...SELECT, no t3 yet, no INSERT, must fail
 
1348
--error ER_TABLEACCESS_DENIED_ERROR
 
1349
create table if not exists t3 select * from t2;
 
1350
 
 
1351
# CREATE IF NOT EXISTS...SELECT, t4 exists, have INSERT, must succeed
 
1352
create table if not exists t4 select * from t2;
 
1353
 
 
1354
# CREATE IF NOT EXISTS...SELECT, no t5 yet, have INSERT, must succeed
 
1355
create table if not exists t5 select * from t2;
 
1356
 
 
1357
 
 
1358
# CREATE...SELECT, no t6 yet, have INSERT, must succeed
 
1359
create table t6 select * from t2;
 
1360
 
 
1361
# CREATE...SELECT, no t7 yet, no INSERT, must fail
 
1362
--error ER_TABLEACCESS_DENIED_ERROR
 
1363
create table t7 select * from t2;
 
1364
 
 
1365
# CREATE...SELECT, t4 exists, have INSERT, must still fail (exists)
 
1366
--error 1050
 
1367
create table t4 select * from t2;
 
1368
 
 
1369
# CREATE...SELECT, t1 exists, no INSERT, must fail
 
1370
--error ER_TABLEACCESS_DENIED_ERROR
 
1371
create table t1 select * from t2;
 
1372
 
 
1373
 
 
1374
connection default;
 
1375
drop table t1,t2,t4,t5,t6;
 
1376
 
 
1377
revoke create         on mysqltest.*  from mysqltest@localhost;
 
1378
revoke select, insert on mysqltest.t2 from mysqltest@localhost;
 
1379
revoke insert         on mysqltest.t4 from mysqltest@localhost;
 
1380
revoke create, insert on mysqltest.t5 from mysqltest@localhost;
 
1381
revoke create, insert on mysqltest.t6 from mysqltest@localhost;
 
1382
drop user mysqltest@localhost;
 
1383
 
 
1384
disconnect user1;
 
1385
drop database mysqltest;
 
1386
use test;
 
1387
 
 
1388
 
 
1389
#
 
1390
# Bug#16470 crash on grant if old grant tables
 
1391
#
 
1392
--echo FLUSH PRIVILEGES without procs_priv table.
 
1393
RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
 
1394
--error ER_NO_SUCH_TABLE
 
1395
FLUSH PRIVILEGES;
 
1396
--echo Assigning privileges without procs_priv table.
 
1397
CREATE DATABASE mysqltest1;
 
1398
CREATE PROCEDURE mysqltest1.test() SQL SECURITY DEFINER
 
1399
  SELECT 1;
 
1400
--error ER_NO_SUCH_TABLE
 
1401
GRANT EXECUTE ON FUNCTION mysqltest1.test TO mysqltest_1@localhost;
 
1402
GRANT ALL PRIVILEGES ON test.* TO mysqltest_1@localhost;
 
1403
CALL mysqltest1.test();
 
1404
DROP DATABASE mysqltest1;
 
1405
RENAME TABLE mysql.procs_gone TO mysql.procs_priv;
 
1406
DROP USER mysqltest_1@localhost;
 
1407
FLUSH PRIVILEGES;
 
1408
 
 
1409
 
 
1410
#
 
1411
# Bug#33464 DROP FUNCTION caused a crash.
 
1412
#
 
1413
CREATE DATABASE dbbug33464;
 
1414
CREATE USER 'userbug33464'@'localhost';
 
1415
 
 
1416
GRANT CREATE ROUTINE ON dbbug33464.* TO 'userbug33464'@'localhost';
 
1417
 
 
1418
--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK
 
1419
connect (connbug33464, localhost, userbug33464, , dbbug33464);
 
1420
--source suite/funcs_1/include/show_connection.inc
 
1421
 
 
1422
--disable_warnings
 
1423
DROP PROCEDURE IF EXISTS sp3;
 
1424
DROP FUNCTION IF EXISTS fn1;
 
1425
--enable_warnings
 
1426
 
 
1427
delimiter //;
 
1428
CREATE PROCEDURE sp3(v1 char(20))
 
1429
BEGIN
 
1430
   SELECT * from dbbug33464.t6 where t6.f2= 'xyz';
 
1431
END//
 
1432
delimiter ;//
 
1433
 
 
1434
delimiter //;
 
1435
CREATE FUNCTION fn1() returns char(50) SQL SECURITY INVOKER
 
1436
BEGIN
 
1437
   return 1;
 
1438
END//
 
1439
delimiter ;//
 
1440
 
 
1441
delimiter //;
 
1442
CREATE FUNCTION fn2() returns char(50) SQL SECURITY DEFINER
 
1443
BEGIN
 
1444
   return 2;
 
1445
END//
 
1446
delimiter ;//
 
1447
 
 
1448
disconnect connbug33464;
 
1449
 
 
1450
# cleanup
 
1451
connection default;
 
1452
USE dbbug33464;
 
1453
--source suite/funcs_1/include/show_connection.inc
 
1454
 
 
1455
SELECT fn1();
 
1456
SELECT fn2();
 
1457
 
 
1458
--error 0, ER_CANNOT_USER
 
1459
DROP USER 'userbug33464'@'localhost';
 
1460
 
 
1461
DROP FUNCTION fn1;
 
1462
DROP FUNCTION fn2;
 
1463
DROP PROCEDURE sp3;
 
1464
 
 
1465
--error 0, ER_CANNOT_USER
 
1466
DROP USER 'userbug33464'@'localhost';
 
1467
 
 
1468
USE test;
 
1469
DROP DATABASE dbbug33464;
 
1470
 
 
1471
 
 
1472
SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 
1473
 
 
1474
#
 
1475
# Bug#44658 Create procedure makes server crash when user does not have ALL privilege
 
1476
#
 
1477
CREATE USER user1;
 
1478
CREATE USER user2;
 
1479
GRANT CREATE ON db1.* TO 'user1'@'localhost';
 
1480
GRANT CREATE ROUTINE ON db1.* TO 'user1'@'localhost';
 
1481
GRANT CREATE ON db1.* TO 'user2'@'%';
 
1482
GRANT CREATE ROUTINE ON db1.* TO 'user2'@'%';
 
1483
FLUSH PRIVILEGES;
 
1484
SHOW GRANTS FOR 'user1'@'localhost';
 
1485
connect (con1,localhost,user1,,);
 
1486
--echo ** Connect as user1 and create a procedure.
 
1487
--echo ** The creation will imply implicitly assigned
 
1488
--echo ** EXECUTE and ALTER ROUTINE privileges to
 
1489
--echo ** the current user user1@localhost. 
 
1490
SELECT @@GLOBAL.sql_mode;
 
1491
SELECT @@SESSION.sql_mode;
 
1492
CREATE DATABASE db1;
 
1493
DELIMITER ||;
 
1494
CREATE PROCEDURE db1.proc1(p1 INT)
 
1495
 BEGIN
 
1496
 SET @x = 0;
 
1497
 REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
 
1498
 END ;||
 
1499
DELIMITER ;||
 
1500
 
 
1501
connect (con2,localhost,user2,,);
 
1502
--echo ** Connect as user2 and create a procedure.
 
1503
--echo ** Implicitly assignment of privileges will
 
1504
--echo ** fail because the user2@localhost is an
 
1505
--echo ** unknown user.
 
1506
DELIMITER ||;
 
1507
CREATE PROCEDURE db1.proc2(p1 INT)
 
1508
 BEGIN
 
1509
 SET @x = 0;
 
1510
 REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
 
1511
 END ;||
 
1512
DELIMITER ;||
 
1513
 
 
1514
connection default;
 
1515
SHOW GRANTS FOR 'user1'@'localhost';
 
1516
SHOW GRANTS FOR 'user2';
 
1517
disconnect con1;
 
1518
disconnect con2;
 
1519
DROP PROCEDURE db1.proc1;
 
1520
DROP PROCEDURE db1.proc2;
 
1521
REVOKE ALL ON db1.* FROM 'user1'@'localhost';
 
1522
REVOKE ALL ON db1.* FROM 'user2'@'%';
 
1523
DROP USER 'user1';
 
1524
DROP USER 'user1'@'localhost';
 
1525
DROP USER 'user2';
 
1526
DROP DATABASE db1;
 
1527
 
 
1528
# Wait till we reached the initial number of concurrent sessions
 
1529
--source include/wait_until_count_sessions.inc