diff options
author | unknown <lenz@mysql.com> | 2004-08-12 13:52:43 +0200 |
---|---|---|
committer | unknown <lenz@mysql.com> | 2004-08-12 13:52:43 +0200 |
commit | d734bb9e55e9ec4be4de02301b7257db303f9b25 (patch) | |
tree | a19192efe3c137c669aedcec58ed44f240f2fa74 | |
parent | dd618e8f19072854259ca052b7fb9d3100d25689 (diff) | |
parent | aa5a473b5001d68566c9e66043ab3389114015c0 (diff) | |
download | mariadb-git-d734bb9e55e9ec4be4de02301b7257db303f9b25.tar.gz |
Merge lgrimmer@build.mysql.com:/home/bk/mysql-4.0
into mysql.com:/space/my/mysql-4.0
-rw-r--r-- | mysql-test/r/grant.result | 19 | ||||
-rw-r--r-- | mysql-test/t/grant.test | 16 | ||||
-rw-r--r-- | sql/sql_acl.cc | 18 |
3 files changed, 48 insertions, 5 deletions
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 1a968fa4f2f..d4d8dd1f026 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -131,3 +131,22 @@ Wrong usage of DB GRANT and GLOBAL PRIVILEGES select 1; 1 1 +insert into mysql.user (host, user) values ('localhost', 'test11'); +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; +show grants for test11@localhost; +Grants for test11@localhost +GRANT USAGE ON *.* TO 'test11'@'localhost' +GRANT SELECT ON `ab%`.* TO 'test11'@'localhost' +GRANT SELECT ON `a%`.* TO 'test11'@'localhost' +alter table mysql.db order by db desc; +flush privileges; +show grants for test11@localhost; +Grants for test11@localhost +GRANT USAGE ON *.* TO 'test11'@'localhost' +GRANT SELECT ON `ab%`.* TO 'test11'@'localhost' +GRANT SELECT ON `a%`.* TO 'test11'@'localhost' +delete from mysql.user where user='test11'; +delete from mysql.db where user='test11'; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 598a7186a6e..a278b9d5928 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -89,3 +89,19 @@ drop table t1; --error 1221 GRANT FILE on mysqltest.* to mysqltest_1@localhost; select 1; -- To test that the previous command didn't cause problems + + +# +# 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 +('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y'); +alter table mysql.db order by db asc; +flush privileges; +show grants for test11@localhost; +alter table mysql.db order by db desc; +flush privileges; +show grants for test11@localhost; +delete from mysql.user where user='test11'; +delete from mysql.db where user='test11'; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 4af6f407b57..58d0fe9a7fa 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -460,22 +460,30 @@ static ulong get_sort(uint count,...) va_start(args,count); ulong sort=0; + /* Should not use this function with more than 4 arguments for compare. */ + DBUG_ASSERT(count <= 4); + while (count--) { - char *str=va_arg(args,char*); - uint chars=0,wild=0; + char *start, *str= va_arg(args,char*); + uint chars= 0; + uint wild_pos= 0; /* first wildcard position */ - if (str) + if (start= str) { for (; *str ; str++) { if (*str == wild_many || *str == wild_one || *str == wild_prefix) - wild++; + { + wild_pos= str - start + 1; + break; + } else chars++; } } - sort= (sort << 8) + (wild ? 1 : chars ? 2 : 0); + sort= (sort << 8) + (wild_pos ? (wild_pos > 127 ? 127 : wild_pos) : + (chars ? 128 : 0)); } va_end(args); return sort; |