diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 1c3f6c8b4ef..ee6a96b64a5 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -945,8 +945,9 @@ DROP TABLE mysqltest3.t_nn; DROP DATABASE mysqltest3; REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost'; DROP USER 'mysqltest_1'@'localhost'; +use test; create user mysqltest1_thisisreallytoolong; -ERROR HY000: Operation CREATE USER failed for 'mysqltest1_thisisreallytoolong'@'%' +ERROR HY000: String 'mysqltest1_thisisreallytoolong' is too long for user name (should be no longer than 16) GRANT CREATE ON mysqltest.* TO 1234567890abcdefGHIKL@localhost; ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) GRANT CREATE ON mysqltest.* TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY; diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index e65be9a9a57..dddfc6be162 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2860,17 +2860,6 @@ SHOW TABLES; Tables_in_test t1 DROP TABLE t1; -DROP TABLE IF EXISTS t1; -DROP VIEW IF EXISTS v1; -DROP VIEW IF EXISTS v2; -CREATE TABLE t1(a INT, b INT); -CREATE DEFINER=1234567890abcdefGHIKL@localhost -VIEW v1 AS SELECT a FROM t1; -ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) -CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY -VIEW v2 AS SELECT b FROM t1; -ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) -DROP TABLE t1; DROP VIEW IF EXISTS v1; CREATE DATABASE bug21261DB; USE bug21261DB; @@ -2901,6 +2890,17 @@ View Create View v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` where (`t1`.`f1` between now() and (now() + interval 1 minute)) drop view v1; drop table t1; +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +DROP VIEW IF EXISTS v2; +CREATE TABLE t1(a INT, b INT); +CREATE DEFINER=1234567890abcdefGHIKL@localhost +VIEW v1 AS SELECT a FROM t1; +ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16) +CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY +VIEW v2 AS SELECT b FROM t1; +ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60) +DROP TABLE t1; DROP FUNCTION IF EXISTS f1; DROP FUNCTION IF EXISTS f2; DROP VIEW IF EXISTS v1, v2; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 92bedd8cb6b..5e419ec003c 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2747,8 +2747,51 @@ DROP VIEW t1,v1; SHOW TABLES; DROP TABLE t1; +--disable_warnings +DROP VIEW IF EXISTS v1; +--enable_warnings +# +# Bug #21261: Wrong access rights was required for an insert to a view +# +CREATE DATABASE bug21261DB; +USE bug21261DB; +CONNECT (root,localhost,root,,bug21261DB); +CONNECTION root; +CREATE TABLE t1 (x INT); +CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1; +GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost'; +GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost'; +CREATE TABLE t2 (y INT); +GRANT SELECT ON t2 TO 'user21261'@'localhost'; + +CONNECT (user21261, localhost, user21261,, bug21261DB); +CONNECTION user21261; +INSERT INTO v1 (x) VALUES (5); +UPDATE v1 SET x=1; +CONNECTION root; +GRANT SELECT ON v1 TO 'user21261'@'localhost'; +GRANT SELECT ON t1 TO 'user21261'@'localhost'; +CONNECTION user21261; +UPDATE v1,t2 SET x=1 WHERE x=y; +CONNECTION root; +SELECT * FROM t1; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost'; +DROP USER 'user21261'@'localhost'; +DROP VIEW v1; +DROP TABLE t1; +DROP DATABASE bug21261DB; +USE test; + +# +# Bug #15950: NOW() optimized away in VIEWs +# +create table t1 (f1 datetime); +create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute; +show create view v1; +drop view v1; +drop table t1; # # Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause. # @@ -2822,45 +2865,5 @@ DROP FUNCTION f2; DROP VIEW v1, v2; DROP TABLE t1; -# -# Bug #21261: Wrong access rights was required for an insert to a view -# -CREATE DATABASE bug21261DB; -USE bug21261DB; -CONNECT (root,localhost,root,,bug21261DB); -CONNECTION root; -CREATE TABLE t1 (x INT); -CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1; -GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost'; -GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost'; -CREATE TABLE t2 (y INT); -GRANT SELECT ON t2 TO 'user21261'@'localhost'; - -CONNECT (user21261, localhost, user21261,, bug21261DB); -CONNECTION user21261; -INSERT INTO v1 (x) VALUES (5); -UPDATE v1 SET x=1; -CONNECTION root; -GRANT SELECT ON v1 TO 'user21261'@'localhost'; -GRANT SELECT ON t1 TO 'user21261'@'localhost'; -CONNECTION user21261; -UPDATE v1,t2 SET x=1 WHERE x=y; -CONNECTION root; -SELECT * FROM t1; -REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost'; -DROP USER 'user21261'@'localhost'; -DROP VIEW v1; -DROP TABLE t1; -DROP DATABASE bug21261DB; -USE test; - -# -# Bug #15950: NOW() optimized away in VIEWs -# -create table t1 (f1 datetime); -create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute; -show create view v1; -drop view v1; -drop table t1; --echo End of 5.0 tests. diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 2259794d44d..70b2c7a3bfe 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5379,14 +5379,6 @@ bool mysql_create_user(THD *thd, List &list) continue; } - if (user_name->host.length > HOSTNAME_LENGTH || - user_name->user.length > USERNAME_LENGTH) - { - append_user(&wrong_users, user_name); - result= TRUE; - continue; - } - /* Search all in-memory structures and grant tables for a mention of the new user name.