diff options
author | Matthias Leich <Matthias.Leich@sun.com> | 2009-02-05 21:47:23 +0100 |
---|---|---|
committer | Matthias Leich <Matthias.Leich@sun.com> | 2009-02-05 21:47:23 +0100 |
commit | 41e6a1f89c943083e46fba9f548333629eefbbd9 (patch) | |
tree | e767d62e647bd5bd95395a64bbef983632f63971 /mysql-test/t/grant.test | |
parent | 6f19c0fc46de7840431e38e7a5e6610124d05179 (diff) | |
download | mariadb-git-41e6a1f89c943083e46fba9f548333629eefbbd9.tar.gz |
2. Slice of fix for Bug#42003 tests missing the disconnect of connections <> default
- If missing: add "disconnect <session>"
- If physical disconnect of non "default" sessions is not finished
at test end: add routine which waits till this happened
+ additional improvements
- remove superfluous files created by the test
- replace error numbers by error names
- remove trailing spaces, replace tabs by spaces
- unify writing of bugs within comments
- correct comments
- minor changes of formatting
Fixed tests:
backup
check
compress
grant
information_schema
multi_update
overflow
packet
query_cache_not_embedded
sp-threads
subselect
synchronization
timezone_grant
Diffstat (limited to 'mysql-test/t/grant.test')
-rw-r--r-- | mysql-test/t/grant.test | 179 |
1 files changed, 84 insertions, 95 deletions
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 14c5879d007..6f6e8753004 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -3,6 +3,9 @@ # Grant tests not performed with embedded server -- source include/not_embedded.inc +# Save the initial number of concurrent sessions +--source include/count_sessions.inc + # Cleanup --disable_warnings drop table if exists t1; @@ -78,7 +81,7 @@ delete from mysql.db where user='mysqltest_1'; delete from mysql.tables_priv where user='mysqltest_1'; delete from mysql.columns_priv where user='mysqltest_1'; flush privileges; ---error 1141 +--error ER_NONEXISTING_GRANT show grants for mysqltest_1@localhost; # @@ -116,15 +119,15 @@ drop table t1; # # Test some error conditions # ---error 1221 +--error ER_WRONG_USAGE GRANT FILE on mysqltest.* to mysqltest_1@localhost; -select 1; # To test that the previous command didn't cause problems +select 1; # To test that the previous command didn't cause problems # -# Bug #4898: User privileges depending on ORDER BY Settings of table db +# Bug#4898 User privileges depending on ORDER BY Settings of table db # insert into mysql.user (host, user) values ('localhost', 'test11'); -insert into mysql.db (host, db, user, select_priv) values +insert into mysql.db (host, db, user, select_priv) values ('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); alter table mysql.db order by db asc; flush privileges; @@ -136,7 +139,7 @@ delete from mysql.user where user='test11'; delete from mysql.db where user='test11'; # -# Bug#6123: GRANT USAGE inserts useless Db row +# Bug#6123 GRANT USAGE inserts useless Db row # create database mysqltest1; grant usage on mysqltest1.* to test6123 identified by 'magic123'; @@ -145,7 +148,7 @@ delete from mysql.user where user='test6123'; drop database mysqltest1; # -# Test for 'drop user', 'revoke privileges, grant' +# Test for 'drop user', 'revoke privileges, grant' # create table t1 (a int); @@ -160,7 +163,7 @@ grant select(a) on test.t1 to drop_user@localhost; show grants for drop_user@localhost; # -# Bug3086 +# Bug#3086 SHOW GRANTS doesn't follow ANSI_QUOTES # set sql_mode=ansi_quotes; show grants for drop_user@localhost; @@ -178,7 +181,7 @@ show grants for drop_user@localhost; revoke all privileges, grant option from drop_user@localhost; show grants for drop_user@localhost; drop user drop_user@localhost; ---error 1269 +--error ER_REVOKE_GRANTS revoke all privileges, grant option from drop_user@localhost; grant select(a) on test.t1 to drop_user1@localhost; @@ -188,10 +191,10 @@ grant select on *.* to drop_user4@localhost; # Drop user now implicitly revokes all privileges. drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, drop_user4@localhost; ---error 1269 +--error ER_REVOKE_GRANTS revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, drop_user4@localhost; ---error 1396 +--error ER_CANNOT_USER drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, drop_user4@localhost; drop table t1; @@ -201,12 +204,12 @@ show grants for mysqltest_1@localhost; drop user mysqltest_1@localhost; # -# Bug #3403 Wrong encodin in SHOW GRANTS output +# Bug#3403 Wrong encoding in SHOW GRANTS, EPLAIN SELECT output # SET NAMES koi8r; CREATE DATABASE ÂÄ; USE ÂÄ; -CREATE TABLE ÔÁÂ (ËÏÌ int); +CREATE TABLE ÔÁÂ (ËÏÌ INT); GRANT SELECT ON ÂÄ.* TO ÀÚÅÒ@localhost; SHOW GRANTS FOR ÀÚÅÒ@localhost; @@ -227,7 +230,7 @@ DROP DATABASE ÂÄ; SET NAMES latin1; # -# Bug #5831: REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke everything +# Bug#5831 REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke everything # USE test; CREATE TABLE t1 (a int ); @@ -296,7 +299,7 @@ DROP DATABASE testdb9; DROP DATABASE testdb10; # -# Bug #6932: a problem with 'revoke ALL PRIVILEGES' +# Bug#6932 a problem with 'revoke ALL PRIVILEGES' # create table t1(a int, b int, c int, d int); @@ -310,7 +313,7 @@ drop user grant_user@localhost; drop table t1; # -# Bug#7391: Cross-database multi-table UPDATE security problem +# Bug#7391 Cross-database multi-table UPDATE security problem # create database mysqltest_1; create database mysqltest_2; @@ -319,36 +322,36 @@ create table mysqltest_1.t2 select 1 b, 2 r; create table mysqltest_2.t1 select 1 c, 2 s; create table mysqltest_2.t2 select 1 d, 2 t; -#test the column privileges +# test the column privileges grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost; grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost; grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost; grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost; connect (conn1,localhost,mysqltest_3,,); connection conn1; -SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES - WHERE GRANTEE = '''mysqltest_3''@''localhost''' +SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES + WHERE GRANTEE = '''mysqltest_3''@''localhost''' ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE; SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES - WHERE GRANTEE = '''mysqltest_3''@''localhost''' + WHERE GRANTEE = '''mysqltest_3''@''localhost''' ORDER BY TABLE_NAME,PRIVILEGE_TYPE; SELECT * from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES - WHERE GRANTEE = '''mysqltest_3''@''localhost''' + WHERE GRANTEE = '''mysqltest_3''@''localhost''' ORDER BY TABLE_SCHEMA,PRIVILEGE_TYPE; SELECT * from INFORMATION_SCHEMA.USER_PRIVILEGES WHERE GRANTEE = '''mysqltest_3''@''localhost''' ORDER BY TABLE_CATALOG,PRIVILEGE_TYPE; ---error 1143 +--error ER_COLUMNACCESS_DENIED_ERROR update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1; ---error 1143 +--error ER_COLUMNACCESS_DENIED_ERROR update mysqltest_1.t2, mysqltest_2.t2 set d=20 where d=1; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1; ---error 1143 +--error ER_COLUMNACCESS_DENIED_ERROR update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2; -#the following two should work +# the following two should work update mysqltest_1.t1, mysqltest_2.t2 set a=10,d=10; update mysqltest_1.t1, mysqltest_2.t1 set a=20 where c=20; connection master; @@ -359,7 +362,7 @@ revoke all on mysqltest_1.t2 from mysqltest_3@localhost; revoke all on mysqltest_2.t1 from mysqltest_3@localhost; revoke all on mysqltest_2.t2 from mysqltest_3@localhost; -#test the db/table level privileges +# test the db/table level privileges grant all on mysqltest_2.* to mysqltest_3@localhost; grant select on *.* to mysqltest_3@localhost; # Next grant is needed to trigger bug#7391. Do not optimize! @@ -371,15 +374,15 @@ connection conn2; use mysqltest_1; update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600; # the following failed before, should fail now. ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200; use mysqltest_2; -#the following used to succeed, it must fail now. ---error 1142 +# the following used to succeed, it must fail now. +--error ER_TABLEACCESS_DENIED_ERROR update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200; #lets see the result connection master; @@ -393,6 +396,7 @@ delete from mysql.columns_priv where user="mysqltest_3"; flush privileges; drop database mysqltest_1; drop database mysqltest_2; +disconnect conn2; # # just SHOW PRIVILEGES test @@ -400,7 +404,7 @@ drop database mysqltest_2; SHOW PRIVILEGES; # -# Rights for renaming test (Bug #3270) +# Rights for renaming test (Bug#3270) # connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); connection root; @@ -411,16 +415,18 @@ create table mysqltest.t1 (a int,b int,c int); grant all on mysqltest.t1 to mysqltest_1@localhost; connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK); connection user1; --- error 1142 +-- error ER_TABLEACCESS_DENIED_ERROR alter table t1 rename t2; disconnect user1; connection root; revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; delete from mysql.user where user=_binary'mysqltest_1'; drop database mysqltest; +connection default; +disconnect root; # -# check all new table priveleges +# check all new table privileges # CREATE USER dummy@localhost; CREATE DATABASE mysqltest; @@ -485,7 +491,7 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost; DROP USER dummy@localhost; DROP DATABASE mysqltest; # -# Bug #11330: Entry in tables_priv with host = '' causes crash +# Bug#11330 Entry in tables_priv with host = '' causes crash # connection default; use mysql; @@ -496,7 +502,7 @@ flush privileges; use test; # -# Bug #10892 user variables not auto cast for comparisons +# Bug#10892 user variables not auto cast for comparisons # Check that we don't get illegal mix of collations # set @user123="non-existent"; @@ -515,18 +521,18 @@ show grants for root@localhost; set names latin1; # -# Bug #15598 Server crashes in specific case during setting new password +# Bug#15598 Server crashes in specific case during setting new password # - Caused by a user with host '' # create user mysqltest_7@; set password for mysqltest_7@ = password('systpass'); show grants for mysqltest_7@; drop user mysqltest_7@; ---error 1141 +--error ER_NONEXISTING_GRANT show grants for mysqltest_7@; # -# Bug#14385: GRANT and mapping to correct user account problems +# Bug#14385 GRANT and mapping to correct user account problems # create database mysqltest; use mysqltest; @@ -542,7 +548,7 @@ flush privileges; drop database mysqltest; # -# Bug #27515: DROP previlege is not required for RENAME TABLE +# Bug#27515 DROP previlege is not required for RENAME TABLE # connection master; create database db27515; @@ -553,7 +559,7 @@ grant insert, create on db27515.t2 to user27515@localhost; connect (conn27515, localhost, user27515, , db27515); connection conn27515; ---error 1142 +--error ER_TABLEACCESS_DENIED_ERROR rename table t1 to t2; disconnect conn27515; @@ -565,7 +571,7 @@ drop database db27515; --echo End of 4.1 tests # -# Bug #16297 In memory grant tables not flushed when users's hostname is "" +# Bug#16297 In memory grant tables not flushed when users's hostname is "" # use test; create table t1 (a int); @@ -582,11 +588,11 @@ create user mysqltest_8; create user mysqltest_8@host8; # Try to create them again ---error 1396 +--error ER_CANNOT_USER create user mysqltest_8@''; ---error 1396 +--error ER_CANNOT_USER create user mysqltest_8; ---error 1396 +--error ER_CANNOT_USER create user mysqltest_8@host8; select user, QUOTE(host) from mysql.user where user="mysqltest_8"; @@ -681,44 +687,43 @@ flush privileges; show grants for mysqltest_8@''; show grants for mysqltest_8; drop user mysqltest_8@''; ---error 1141 +--error ER_NONEXISTING_GRANT show grants for mysqltest_8@''; show grants for mysqltest_8; select * from information_schema.user_privileges where grantee like "'mysqltest_8'%"; drop user mysqltest_8; --replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT ---error 1045 +--error ER_ACCESS_DENIED_ERROR connect (conn6,localhost,mysqltest_8,,); connection master; ---error 1141 +--error ER_NONEXISTING_GRANT show grants for mysqltest_8; drop user mysqltest_8@host8; ---error 1141 +--error ER_NONEXISTING_GRANT show grants for mysqltest_8@host8; # Restore the anonymous users. insert into mysql.user select * from t2; flush privileges; drop table t2; - drop table t1; # -# Bug#20214: Incorrect error when user calls SHOW CREATE VIEW on non -# privileged view +# Bug#20214 Incorrect error when user calls SHOW CREATE VIEW on non +# privileged view # connection master; CREATE DATABASE mysqltest3; -use mysqltest3; +USE mysqltest3; CREATE TABLE t_nn (c1 INT); CREATE VIEW v_nn AS SELECT * FROM t_nn; CREATE DATABASE mysqltest2; -use mysqltest2; +USE mysqltest2; CREATE TABLE t_nn (c1 INT); CREATE VIEW v_nn AS SELECT * FROM t_nn; @@ -740,24 +745,18 @@ SHOW CREATE VIEW mysqltest2.v_nn; --error ER_TABLEACCESS_DENIED_ERROR SHOW CREATE TABLE mysqltest2.v_nn; - - # fail because of missing SHOW VIEW --error ER_TABLEACCESS_DENIED_ERROR SHOW CREATE VIEW mysqltest2.v_yn; --error ER_TABLEACCESS_DENIED_ERROR SHOW CREATE TABLE mysqltest2.v_yn; - - # succeed (despite of missing SELECT, having SHOW VIEW bails us out) SHOW CREATE TABLE mysqltest2.v_ny; # succeed (despite of missing SELECT, having SHOW VIEW bails us out) SHOW CREATE VIEW mysqltest2.v_ny; - - # fail because of missing (specific or generic) SELECT --error ER_TABLEACCESS_DENIED_ERROR SHOW CREATE TABLE mysqltest3.t_nn; @@ -766,16 +765,12 @@ SHOW CREATE TABLE mysqltest3.t_nn; --error ER_TABLEACCESS_DENIED_ERROR SHOW CREATE VIEW mysqltest3.t_nn; - - # fail because of missing missing (specific or generic) SELECT (and SHOW VIEW) --error ER_TABLEACCESS_DENIED_ERROR SHOW CREATE VIEW mysqltest3.v_nn; --error ER_TABLEACCESS_DENIED_ERROR SHOW CREATE TABLE mysqltest3.v_nn; - - # succeed thanks to generic SELECT SHOW CREATE TABLE mysqltest2.t_nn; @@ -783,8 +778,6 @@ SHOW CREATE TABLE mysqltest2.t_nn; --error ER_WRONG_OBJECT SHOW CREATE VIEW mysqltest2.t_nn; - - # succeed, have SELECT and SHOW VIEW SHOW CREATE VIEW mysqltest2.v_yy; @@ -792,8 +785,7 @@ SHOW CREATE VIEW mysqltest2.v_yy; SHOW CREATE TABLE mysqltest2.v_yy; - -#clean-up +# clean-up connection master; # succeed, we're root @@ -806,38 +798,30 @@ SHOW CREATE TABLE mysqltest2.t_nn; --error ER_WRONG_OBJECT SHOW CREATE VIEW mysqltest2.t_nn; - - DROP VIEW mysqltest2.v_nn; DROP VIEW mysqltest2.v_yn; DROP VIEW mysqltest2.v_ny; DROP VIEW mysqltest2.v_yy; - DROP TABLE mysqltest2.t_nn; - DROP DATABASE mysqltest2; - - - DROP VIEW mysqltest3.v_nn; DROP TABLE mysqltest3.t_nn; - DROP DATABASE mysqltest3; - +disconnect mysqltest_1; REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost'; DROP USER 'mysqltest_1'@'localhost'; # restore the original database -use test; +USE test; # -# Bug #10668: CREATE USER does not enforce username length limit +# Bug#10668 CREATE USER does not enforce username length limit # --error ER_WRONG_STRING_LENGTH create user mysqltest1_thisisreallytoolong; # -# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause. +# Test for Bug#16899 Possible buffer overflow in handling of DEFINER-clause. # # These checks are intended to ensure that appropriate errors are risen when # illegal user name or hostname is specified in user-clause of GRANT/REVOKE @@ -887,7 +871,7 @@ REVOKE EXECUTE ON PROCEDURE p1 FROM 1234567890abcdefGHIKL@localhost; REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; # -# Bug #6774: Replication fails with Wrong usage of DB GRANT and GLOBAL PRIVILEGES +# Bug#6774 Replication fails with Wrong usage of DB GRANT and GLOBAL PRIVILEGES # # Check if GRANT ... ON * ... fails when no database is selected connect (con1, localhost, root,,*NO-ONE*); @@ -899,7 +883,7 @@ connection default; # -# BUG#9504: Stored procedures: execute privilege doesn't make 'use database' +# Bug#9504 Stored procedures: execute privilege doesn't make 'use database' # okay. # @@ -924,8 +908,8 @@ CREATE PROCEDURE mysqltest2.p_inv() SQL SECURITY INVOKER SELECT 1; CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER - RETURN 1; - + RETURN 1; + CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER RETURN 1; @@ -981,7 +965,7 @@ DROP USER mysqltest_1@localhost; # -# BUG#27337: Privileges are not restored properly. +# Bug#27337 Privileges are not restored properly. # # Actually, the patch for this bugs fixes two problems. So, here are two test # cases. @@ -1043,7 +1027,7 @@ DROP DATABASE mysqltest2; DROP USER mysqltest_1@localhost; -# Test case 2: priveleges are not checked properly for prepared statements. +# Test case 2: privileges are not checked properly for prepared statements. # Prepare. @@ -1116,6 +1100,7 @@ EXECUTE stmt2; --echo --echo ---> connection: default +--disconnect bug27337_con1 --disconnect bug27337_con2 DROP DATABASE mysqltest1; @@ -1125,21 +1110,21 @@ DROP USER mysqltest_1@localhost; DROP USER mysqltest_2@localhost; # -# Bug#27878: Unchecked privileges on a view referring to a table from another -# database. +# Bug#27878 Unchecked privileges on a view referring to a table from another +# database. # -use test; +USE test; CREATE TABLE t1 (f1 int, f2 int); INSERT INTO t1 VALUES(1,1), (2,2); CREATE DATABASE db27878; GRANT UPDATE(f1) ON t1 TO 'mysqltest_1'@'localhost'; GRANT SELECT ON `test`.* TO 'mysqltest_1'@'localhost'; GRANT ALL ON db27878.* TO 'mysqltest_1'@'localhost'; -use db27878; +USE db27878; CREATE SQL SECURITY INVOKER VIEW db27878.v1 AS SELECT * FROM test.t1; connect (user1,localhost,mysqltest_1,,test); connection user1; -use db27878; +USE db27878; --error 1356 UPDATE v1 SET f2 = 4; SELECT * FROM test.t1; @@ -1150,11 +1135,11 @@ REVOKE SELECT ON `test`.* FROM 'mysqltest_1'@'localhost'; REVOKE ALL ON db27878.* FROM 'mysqltest_1'@'localhost'; DROP USER mysqltest_1@localhost; DROP DATABASE db27878; -use test; +USE test; DROP TABLE t1; # -# Bug #33201 Crash occurs when granting update privilege on one column of a view +# Bug#33201 Crash occurs when granting update privilege on one column of a view # drop table if exists test; drop function if exists test_function; @@ -1183,3 +1168,7 @@ SET PASSWORD FOR CURRENT_USER() = PASSWORD("admin"); SET PASSWORD FOR CURRENT_USER() = PASSWORD(""); --echo End of 5.0 tests + +disconnect master; +# Wait till we reached the initial number of concurrent sessions +--source include/wait_until_count_sessions.inc |