mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / t / grant2.test
blob447848013f9b54ccc7e20bd9731bbf7392774e51
1 # Grant tests not performed with embedded server
2 -- source include/not_embedded.inc
4 # Save the initial number of concurrent sessions
5 --source include/count_sessions.inc
8 SET NAMES binary;
11 # GRANT tests that require several connections
12 # (usually it's GRANT, reconnect as another user, try something)
16 # prepare playground before tests
17 --disable_warnings
18 drop database if exists mysqltest;
19 drop database if exists mysqltest_1;
20 --enable_warnings
21 delete from mysql.user where user like 'mysqltest\_%';
22 delete from mysql.db where user like 'mysqltest\_%';
23 delete from mysql.tables_priv where user like 'mysqltest\_%';
24 delete from mysql.columns_priv where user like 'mysqltest\_%';
25 flush privileges;
28 grant all privileges on `my\_1`.* to mysqltest_1@localhost with grant option;
29 grant create user on *.* to mysqltest_1@localhost;
30 create user mysqltest_2@localhost;
31 connect (user_a,localhost,mysqltest_1,,);
32 connection user_a;
33 grant select on `my\_1`.* to mysqltest_2@localhost;
34 --error ER_PASSWORD_NOT_ALLOWED
35 grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';
36 disconnect user_a;
37 connection default;
38 grant update on mysql.* to mysqltest_1@localhost;
39 connect (user_b,localhost,mysqltest_1,,);
40 connection user_b;
41 grant select on `my\_1`.* to mysqltest_2@localhost identified by 'pass';
42 grant select on `my\_1`.* to mysqltest_3@localhost;
43 disconnect user_b;
44 connection default;
45 grant insert on mysql.* to mysqltest_1@localhost;
46 connect (user_c,localhost,mysqltest_1,,);
47 connection user_c;
48 grant select on `my\_1`.* to mysqltest_3@localhost;
49 grant select on `my\_1`.* to mysqltest_4@localhost identified by 'pass';
50 disconnect user_c;
51 connection default;
52 delete from mysql.user where user like 'mysqltest\_%';
53 delete from mysql.db where user like 'mysqltest\_%';
54 delete from mysql.tables_priv where user like 'mysqltest\_%';
55 delete from mysql.columns_priv where user like 'mysqltest\_%';
56 flush privileges;
59 # wild_compare fun
62 grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option;
63 grant create user on *.* to mysqltest_1@localhost;
64 connect (user1,localhost,mysqltest_1,,);
65 connection user1;
66 select current_user();
67 grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
68 --error ER_DBACCESS_DENIED_ERROR
69 grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
72 # NO_AUTO_CREATE_USER mode
74 set @@sql_mode='NO_AUTO_CREATE_USER';
75 select @@sql_mode;
77 # GRANT without IDENTIFIED BY does not create new users
79 --error ER_PASSWORD_NO_MATCH
80 grant select on `my\_1`.* to mysqltest_4@localhost with grant option;
81 grant select on `my\_1`.* to mysqltest_4@localhost identified by 'mypass'
82 with grant option;
83 disconnect user1;
84 connection default;
85 show grants for mysqltest_1@localhost;
86 show grants for mysqltest_2@localhost;
87 --error ER_NONEXISTING_GRANT
88 show grants for mysqltest_3@localhost;
89 delete from mysql.user where user like 'mysqltest\_%';
90 delete from mysql.db where user like 'mysqltest\_%';
91 flush privileges;
94 # wild_compare part two - acl_cache
96 create database mysqltest_1;
97 grant all privileges on `mysqltest\_1`.* to mysqltest_1@localhost with grant option;
98 connect (user2,localhost,mysqltest_1,,);
99 connection user2;
100 select current_user();
101 show databases;
102 --error ER_DBACCESS_DENIED_ERROR
103 grant all privileges on `mysqltest_1`.* to mysqltest_1@localhost with grant option;
104 disconnect user2;
105 connection default;
106 show grants for mysqltest_1@localhost;
107 delete from mysql.user where user like 'mysqltest\_%';
108 delete from mysql.db where user like 'mysqltest\_%';
109 drop database mysqltest_1;
110 flush privileges;
113 # Bug#6173 One can circumvent missing UPDATE privilege if he has SELECT and
114 #          INSERT privilege for table with primary key
116 create database mysqltest;
117 grant INSERT, SELECT on mysqltest.* to mysqltest_1@localhost;
118 flush privileges;
119 use mysqltest;
120 create table t1 (id int primary key, data varchar(255));
122 connect (mrbad, localhost, mysqltest_1,,mysqltest);
123 connection mrbad;
124 show grants for current_user();
125 insert into t1 values (1, 'I can''t change it!');
126 --error ER_TABLEACCESS_DENIED_ERROR
127 update t1 set data='I can change it!' where id = 1;
128 # This should not be allowed since it too require UPDATE privilege.
129 --error ER_TABLEACCESS_DENIED_ERROR
130 insert into t1 values (1, 'XXX') on duplicate key update data= 'I can change it!';
131 select * from t1;
132 disconnect mrbad;
134 connection default;
135 drop table t1;
136 delete from mysql.user where user like 'mysqltest\_%';
137 delete from mysql.db where user like 'mysqltest\_%';
138 flush privileges;
141 create table t1 (a int, b int);
142 grant select (a) on t1 to mysqltest_1@localhost with grant option;
143 connect (mrugly, localhost, mysqltest_1,,mysqltest);
144 connection mrugly;
145 --error ER_COLUMNACCESS_DENIED_ERROR
146 grant select (a,b) on t1 to mysqltest_2@localhost;
147 --error ER_TABLEACCESS_DENIED_ERROR
148 grant select on t1 to mysqltest_3@localhost;
149 disconnect mrugly;
151 connection default;
152 drop table t1;
153 delete from mysql.user where user like 'mysqltest\_%';
154 delete from mysql.db where user like 'mysqltest\_%';
155 delete from mysql.tables_priv where user like 'mysqltest\_%';
156 delete from mysql.columns_priv where user like 'mysqltest\_%';
157 flush privileges;
159 drop database mysqltest;
160 use test;
164 # Bug#15775 "drop user" command does not refresh acl_check_hosts
167 # Create some test users
168 create user mysqltest_1@host1;
169 create user mysqltest_2@host2;
170 create user mysqltest_3@host3;
171 create user mysqltest_4@host4;
172 create user mysqltest_5@host5;
173 create user mysqltest_6@host6;
174 create user mysqltest_7@host7;
175 flush privileges;
177 # Drop one user
178 drop user mysqltest_3@host3;
180 # This connect failed before fix since the acl_check_hosts list was corrupted by the "drop user"
181 connect (con8,127.0.0.1,root,,test,$MASTER_MYPORT,);
182 disconnect con8;
183 connection default;
185 # Clean up - Drop all of the remaining users at once
186 drop user mysqltest_1@host1, mysqltest_2@host2, mysqltest_4@host4,
187   mysqltest_5@host5, mysqltest_6@host6, mysqltest_7@host7;
189 # Check that it's still possible to connect
190 connect (con9,127.0.0.1,root,,test,$MASTER_MYPORT,);
191 disconnect con9;
192 connection default;
195 # Bug#16180 Setting SQL_LOG_OFF without SUPER privilege is silently ignored
197 create database mysqltest_1;
198 grant select, insert, update on `mysqltest\_1`.* to mysqltest_1@localhost;
199 connect (con10,localhost,mysqltest_1,,);
200 connection con10;
201 --error ER_SPECIFIC_ACCESS_DENIED_ERROR
202 set sql_log_off = 1;
203 --error ER_SPECIFIC_ACCESS_DENIED_ERROR
204 set sql_log_bin = 0;
205 disconnect con10;
206 connection default;
207 delete from mysql.user where user like 'mysqltest\_1';
208 delete from mysql.db where user like 'mysqltest\_1';
209 drop database mysqltest_1;
210 flush privileges;
212 # End of 4.1 tests
213 # Create and drop user
215 set sql_mode='maxdb';
216 --disable_warnings
217 drop table if exists t1, t2;
218 --enable_warnings
219 create table t1(c1 int);
220 create table t2(c1 int, c2 int);
222 # Three forms of CREATE USER
223 create user 'mysqltest_1';
224 --error ER_CANNOT_USER
225 create user 'mysqltest_1';
226 create user 'mysqltest_2' identified by 'Mysqltest-2';
227 create user 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';
228 grant select on *.* to 'mysqltest_2';
229 grant insert on test.* to 'mysqltest_2';
230 grant update on test.t1 to 'mysqltest_2';
231 grant update (c2) on test.t2 to 'mysqltest_2';
232 select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
233 select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
234 select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
235 select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
236 show grants for 'mysqltest_1';
237 show grants for 'mysqltest_2';
239 # Drop
240 drop user 'mysqltest_1';
241 select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
242 select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
243 select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
244 select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
245 --error ER_NONEXISTING_GRANT
246 show grants for 'mysqltest_1';
248 # Rename
249 rename user 'mysqltest_2' to 'mysqltest_1';
250 select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
251 select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
252 select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
253 select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
254 show grants for 'mysqltest_1';
255 drop user 'mysqltest_1', 'mysqltest_3';
256 --error ER_CANNOT_USER
257 drop user 'mysqltest_1';
259 # Cleanup
260 drop table t1, t2;
262 # Add a stray record
263 insert into mysql.db set user='mysqltest_1', db='%', host='%';
264 flush privileges;
265 --error ER_NONEXISTING_GRANT
266 show grants for 'mysqltest_1';
267 --error ER_REVOKE_GRANTS
268 revoke all privileges, grant option from 'mysqltest_1';
269 drop user 'mysqltest_1';
270 select host,db,user from mysql.db where user = 'mysqltest_1' order by host,db,user;
272 # Add a stray record
273 insert into mysql.tables_priv set host='%', db='test', user='mysqltest_1', table_name='t1';
274 flush privileges;
275 --error ER_NONEXISTING_GRANT
276 show grants for 'mysqltest_1';
277 drop user 'mysqltest_1';
278 select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1' order by host,db,user,table_name;
280 # Add a stray record
281 insert into mysql.columns_priv set host='%', db='test', user='mysqltest_1', table_name='t1', column_name='c1';
282 flush privileges;
283 --error ER_NONEXISTING_GRANT
284 show grants for 'mysqltest_1';
285 drop user 'mysqltest_1';
286 select host,db,user,table_name,column_name from mysql.columns_priv where user = 'mysqltest_1' order by host,db,user,table_name,column_name;
288 # Handle multi user lists
289 create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
290 drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
291 create user 'mysqltest_1', 'mysqltest_2' identified by 'Mysqltest-2', 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';
292 rename user 'mysqltest_1' to 'mysqltest_1a', 'mysqltest_2' TO 'mysqltest_2a', 'mysqltest_3' TO 'mysqltest_3a';
293 --error ER_CANNOT_USER
294 drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
295 drop user 'mysqltest_1a', 'mysqltest_2a', 'mysqltest_3a';
297 # Let one of multiple users fail
298 create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
299 --error ER_CANNOT_USER
300 create user 'mysqltest_1a', 'mysqltest_2', 'mysqltest_3a';
301 --error ER_CANNOT_USER
302 rename user 'mysqltest_1a' to 'mysqltest_1b', 'mysqltest_2a' TO 'mysqltest_2b', 'mysqltest_3a' TO 'mysqltest_3b';
303 drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
304 --error ER_CANNOT_USER
305 drop user 'mysqltest_1b', 'mysqltest_2b', 'mysqltest_3b';
307 # Obsolete syntax has been dropped
308 create user 'mysqltest_2' identified by 'Mysqltest-2';
309 --error ER_PARSE_ERROR
310 drop user 'mysqltest_2' identified by 'Mysqltest-2';
311 drop user 'mysqltest_2';
313 # Strange user names
314 create user '%@b'@'b';
315 show grants for '%@b'@'b';
316 grant select on mysql.* to '%@b'@'b';
317 show grants for '%@b'@'b';
318 rename user '%@b'@'b' to '%@a'@'a';
319 --error ER_NONEXISTING_GRANT
320 show grants for '%@b'@'b';
321 show grants for '%@a'@'a';
322 drop user '%@a'@'a';
324 # CREATE USER privilege is enough
326 create user mysqltest_2@localhost;
327 grant create user on *.* to mysqltest_2@localhost;
328 connect (user3,localhost,mysqltest_2,,);
329 connection user3;
330 --error ER_TABLEACCESS_DENIED_ERROR
331 select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
332 create user mysqltest_A@'%';
333 rename user mysqltest_A@'%' to mysqltest_B@'%';
334 drop user mysqltest_B@'%';
335 disconnect user3;
336 connection default;
337 drop user mysqltest_2@localhost;
339 # INSERT/UPDATE/DELETE is ok too
340 create user mysqltest_3@localhost;
341 grant INSERT,DELETE,UPDATE on mysql.* to mysqltest_3@localhost;
342 connect (user4,localhost,mysqltest_3,,);
343 connection user4;
344 show grants;
345 --error ER_TABLEACCESS_DENIED_ERROR
346 select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
347 insert into mysql.user set host='%', user='mysqltest_B';
348 create user mysqltest_A@'%';
349 rename user mysqltest_B@'%' to mysqltest_C@'%';
350 drop user mysqltest_C@'%';
351 drop user mysqltest_A@'%';
352 disconnect user4;
353 connection default;
354 drop user mysqltest_3@localhost;
356 # Bug#3309 Test IP addresses with netmask
357 set @@sql_mode='';
358 create database mysqltest_1;
359 create table mysqltest_1.t1 (i int);
360 insert into mysqltest_1.t1 values (1),(2),(3);
361 GRANT ALL ON mysqltest_1.t1 TO mysqltest_1@'127.0.0.0/255.0.0.0';
362 connect (n1,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,$MASTER_MYSOCK);
363 connection n1;
364 show grants for current_user();
365 select * from t1;
366 disconnect n1;
367 connection default;
368 REVOKE ALL ON mysqltest_1.t1 FROM mysqltest_1@'127.0.0.0/255.0.0.0';
369 delete from mysql.user where user like 'mysqltest\_1';
370 flush privileges;
371 drop table mysqltest_1.t1;
374 # Bug#12302 Hostname resolution preventing password changes
375 # 'SET PASSWORD = ...' didn't work if connecting hostname !=
376 # hostname the current user is authenticated as. Note that a test for this
377 # was also added to the test above.
379 grant all on mysqltest_1.* to mysqltest_1@'127.0.0.1';
380 connect (b12302,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,);
381 connection b12302;
382 select current_user();
383 set password = password('changed');
384 disconnect b12302;
385 connection default;
386 select host, length(password) from mysql.user where user like 'mysqltest\_1';
387 revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.1';
388 delete from mysql.user where user like 'mysqltest\_1';
389 flush privileges;
390 grant all on mysqltest_1.* to mysqltest_1@'127.0.0.0/255.0.0.0';
391 connect (b12302_2,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,);
392 connection b12302_2;
393 select current_user();
394 set password = password('changed');
395 disconnect b12302_2;
396 connection default;
397 select host, length(password) from mysql.user where user like 'mysqltest\_1';
398 revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.0/255.0.0.0';
399 delete from mysql.user where user like 'mysqltest\_1';
400 flush privileges;
401 drop database mysqltest_1;
403 --source include/add_anonymous_users.inc
405 # But anonymous users can't change their password
406 connect (n5,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
407 connection n5;
408 --error ER_DBACCESS_DENIED_ERROR
409 set password = password("changed");
410 disconnect n5;
411 connection default;
413 --source include/delete_anonymous_users.inc
416 # Bug#12423 "Deadlock when doing FLUSH PRIVILEGES and GRANT in
417 # multi-threaded environment". We should be able to execute FLUSH
418 # PRIVILEGES and SET PASSWORD simultaneously with other account
419 # management commands (such as GRANT and REVOKE) without causing
420 # deadlocks. To achieve this we should ensure that all account
421 # management commands take table and internal locks in the same order.
422 connect (con2root,localhost,root,,);
423 connect (con3root,localhost,root,,);
424 # Check that we can execute FLUSH PRIVILEGES and GRANT simultaneously
425 # This will check that locks are taken in proper order during both
426 # user/db-level and table/column-level privileges reloading.
427 connection default;
428 lock table mysql.user write;
429 connection con2root;
430 send flush privileges;
431 connection con3root;
432 send grant all on *.* to 'mysqltest_1'@'localhost';
433 connection default;
434 unlock tables;
435 connection con2root;
436 reap;
437 connection con3root;
438 reap;
439 # Check for simultaneous SET PASSWORD and REVOKE.
440 connection default;
441 lock table mysql.user write;
442 connection con2root;
443 send set password for 'mysqltest_1'@'localhost' = password('');
444 connection con3root;
445 send revoke all on *.* from 'mysqltest_1'@'localhost';
446 connection default;
447 unlock tables;
448 connection con2root;
449 reap;
450 connection con3root;
451 reap;
452 connection default;
453 # Clean-up
454 drop user 'mysqltest_1'@'localhost';
455 disconnect con2root;
456 disconnect con3root;
458 # End of 4.1 tests
461 # Bug#17279 user with no global privs and with create
462 #           priv in db can create databases
465 create database TESTDB;
466 create table t2(a int);
467 create temporary table t1 as select * from mysql.user;
468 delete from mysql.user where host='localhost';
469 INSERT INTO mysql.user (host, user, password) VALUES
470 ('%','mysqltest_1',password('password'));
471 INSERT INTO mysql.db (host, db, user, select_priv) VALUES
472 ('%','TESTDB','mysqltest_1','Y');
473 FLUSH PRIVILEGES;
475 connect (con1,localhost,mysqltest_1,password,TESTDB);
477 # The user mysqltest_1 should only be allowed access to
478 # database TESTDB, not TEStdb
479 # On system with "lowercase names" we get error "ER_DB_CREATE_EXISTS: Can't create db..."
480 --error ER_DBACCESS_DENIED_ERROR, ER_DB_CREATE_EXISTS
481 create database TEStdb;
483 # Clean-up
484 connection default;
485 disconnect con1;
486 delete from mysql.user;
487 delete from mysql.db where host='%' and user='mysqltest_1' and db='TESTDB';
488 insert into mysql.user select * from t1;
489 drop table t1, t2;
490 drop database TESTDB;
491 flush privileges;
494 # Bug#13310 incorrect user parsing by SP
497 SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
498 SET GLOBAL log_bin_trust_function_creators = 1;
500 GRANT ALL PRIVILEGES ON test.* TO `a@`@localhost;
501 GRANT EXECUTE ON * TO `a@`@localhost;
502 connect (bug13310,localhost,'a@',,test);
503 connection bug13310;
504 CREATE TABLE t2 (s1 INT);
505 INSERT INTO t2 VALUES (1);
506 --disable_warnings
507 DROP FUNCTION IF EXISTS f2;
508 --enable_warnings
509 delimiter //;
510 CREATE FUNCTION f2 () RETURNS INT
511 BEGIN DECLARE v INT; SELECT s1 FROM t2 INTO v; RETURN v; END//
512 delimiter ;//
513 SELECT f2();
515 DROP FUNCTION f2;
516 DROP TABLE t2;
517 disconnect bug13310;
518 connection default;
519 REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost;
520 DROP USER `a@`@localhost;
522 SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
526 # Bug#25578 CREATE TABLE LIKE does not require any privileges on source table
528 --disable_warnings
529 drop database if exists mysqltest_1;
530 drop database if exists mysqltest_2;
531 --enable_warnings
532 --error 0,ER_CANNOT_USER
533 drop user mysqltest_u1@localhost;
535 create database mysqltest_1;
536 create database mysqltest_2;
537 grant all on mysqltest_1.* to mysqltest_u1@localhost;
538 use mysqltest_2;
539 create table t1 (i int);
541 # Connect as user with all rights on mysqltest_1 but with no rights on mysqltest_2.
542 connect (user1,localhost,mysqltest_u1,,mysqltest_1);
543 connection user1;
544 # As expected error is emitted
545 --error ER_TABLEACCESS_DENIED_ERROR
546 show create table mysqltest_2.t1;
547 # This should emit error as well
548 --error ER_TABLEACCESS_DENIED_ERROR
549 create table t1 like mysqltest_2.t1;
551 # Now let us check that SELECT privilege on the source is enough
552 connection default;
553 grant select on mysqltest_2.t1 to mysqltest_u1@localhost;
554 connection user1;
555 show create table mysqltest_2.t1;
556 create table t1 like mysqltest_2.t1;
558 # Clean-up
559 connection default;
560 disconnect user1;
561 use test;
562 drop database mysqltest_1;
563 drop database mysqltest_2;
564 drop user mysqltest_u1@localhost;
568 # Bug#18660 Can't grant any privileges on single table in database
569 #           with underscore char
571 grant all on `mysqltest\_%`.* to mysqltest_1@localhost with grant option;
572 grant usage on *.* to mysqltest_2@localhost;
573 connect (con18600_1,localhost,mysqltest_1,,);
575 create database mysqltest_1;
576 use mysqltest_1;
577 create table t1 (f1 int);
579 grant create on `mysqltest\_1`.* to mysqltest_2@localhost;
580 grant select on mysqltest_1.t1 to mysqltest_2@localhost;
581 connect (con3,localhost,mysqltest_2,,);
582 connection con3;
583 --error ER_DBACCESS_DENIED_ERROR
584 create database mysqltest_3;
585 use mysqltest_1;
586 create table t2(f1 int);
587 select * from t1;
588 connection default;
589 drop database mysqltest_1;
591 connection default;
592 disconnect con3;
593 disconnect con18600_1;
594 revoke all privileges, grant option from mysqltest_1@localhost;
595 revoke all privileges, grant option from mysqltest_2@localhost;
596 drop user mysqltest_1@localhost;
597 drop user mysqltest_2@localhost;
601 # Bug#30468 column level privileges not respected when joining tables
603 CREATE DATABASE db1;
605 USE db1;
606 CREATE TABLE t1 (a INT, b INT);
607 INSERT INTO t1 VALUES (1,1),(2,2);
609 CREATE TABLE t2 (b INT, c INT);
610 INSERT INTO t2 VALUES (1,100),(2,200);
612 GRANT SELECT ON t1 TO mysqltest1@localhost;
613 GRANT SELECT (b) ON t2 TO mysqltest1@localhost;
615 connect (conn1,localhost,mysqltest1,,);
616 connection conn1;
617 USE db1;
618 --error ER_COLUMNACCESS_DENIED_ERROR
619 SELECT c FROM t2;
620 --error ER_TABLEACCESS_DENIED_ERROR
621 SELECT * FROM t2;
622 --error ER_COLUMNACCESS_DENIED_ERROR
623 SELECT * FROM t1 JOIN t2 USING (b);
625 connection default;
626 disconnect conn1;
627 USE test;
628 DROP TABLE db1.t1, db1.t2;
629 DROP USER mysqltest1@localhost;
630 DROP DATABASE db1;
633 --echo End of 5.0 tests
636 # Bug #48319: Server crashes on "GRANT/REVOKE ... TO CURRENT_USER"
639 # work out who we are.
640 USE mysql;
641 SELECT LEFT(CURRENT_USER(),INSTR(CURRENT_USER(),'@')-1) INTO @u;
642 SELECT MID(CURRENT_USER(),INSTR(CURRENT_USER(),'@')+1)  INTO @h;
643 SELECT password FROM user WHERE user=@u AND host=@h INTO @pwd;
645 # show current privs.
646 SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
648 # toggle INSERT
649 UPDATE user SET insert_priv='N' WHERE user=@u AND host=@h;
650 SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
652 # show that GRANT ... TO CURRENT_USER() no longer crashes
653 GRANT INSERT ON *.* TO CURRENT_USER();
654 SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
655 UPDATE user SET insert_priv='N' WHERE user=@u AND host=@h;
657 # show that GRANT ... TO CURRENT_USER() IDENTIFIED BY ... works now
658 GRANT INSERT ON *.* TO CURRENT_USER() IDENTIFIED BY 'keksdose';
659 SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
661 UPDATE user SET password=@pwd WHERE user=@u AND host=@h;
662 SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
664 FLUSH PRIVILEGES;
666 USE test;
668 --echo End of 5.1 tests
670 # Wait till we reached the initial number of concurrent sessions
671 --source include/wait_until_count_sessions.inc