diff -urNad mysql-dfsg-4.0.24/sql/sql_acl.cc /home/seanius/tmp/dpep.p65N7m/mysql-dfsg-4.0.24/sql/sql_acl.cc --- mysql-dfsg-4.0.24/sql/sql_acl.cc 2005-03-04 19:38:15.000000000 -0500 +++ /home/seanius/tmp/dpep.p65N7m/mysql-dfsg-4.0.24/sql/sql_acl.cc 2005-03-30 19:33:43.456668031 -0500 @@ -855,6 +855,9 @@ /* Get privilege for a host, user and db combination + + as db_is_pattern changes the semantics of comparison, + acl_cache is not used if db_is_pattern is set. */ ulong acl_get(const char *host, const char *ip, const char *bin_ip, @@ -875,7 +878,7 @@ db=tmp_db; } key_length=(uint) (end-key); - if ((entry=(acl_entry*) acl_cache->search(key,key_length))) + if (!db_is_pattern && (entry=(acl_entry*) acl_cache->search(key,key_length))) { db_access=entry->access; VOID(pthread_mutex_unlock(&acl_cache->lock)); @@ -923,7 +926,8 @@ } exit: /* Save entry in cache for quick retrieval */ - if ((entry= (acl_entry*) malloc(sizeof(acl_entry)+key_length))) + if (!db_is_pattern && + (entry= (acl_entry*) malloc(sizeof(acl_entry)+key_length))) { entry->access=(db_access & host_access); entry->length=key_length; diff -urNad mysql-dfsg-4.0.24/sql/sql_parse.cc /home/seanius/tmp/dpep.p65N7m/mysql-dfsg-4.0.24/sql/sql_parse.cc --- mysql-dfsg-4.0.24/sql/sql_parse.cc 2005-03-04 19:38:14.000000000 -0500 +++ /home/seanius/tmp/dpep.p65N7m/mysql-dfsg-4.0.24/sql/sql_parse.cc 2005-03-30 19:34:41.802999951 -0500 @@ -2704,6 +2704,7 @@ DBUG_PRINT("enter",("want_access: %lu master_access: %lu", want_access, thd->master_access)); ulong db_access,dummy; + bool db_is_pattern= test(want_access & GRANT_ACL); if (save_priv) *save_priv=0; else @@ -2725,9 +2726,9 @@ */ db_access= thd->db_access; if (!(thd->master_access & SELECT_ACL) && - (db && (!thd->db || strcmp(db,thd->db)))) + (db && (!thd->db || db_is_pattern || strcmp(db,thd->db)))) db_access=acl_get(thd->host, thd->ip, (char*) &thd->remote.sin_addr, - thd->priv_user, db, 0); /* purecov: inspected */ + thd->priv_user, db, db_is_pattern); *save_priv=thd->master_access | db_access; DBUG_RETURN(FALSE); } @@ -2745,9 +2746,9 @@ if (db == any_db) DBUG_RETURN(FALSE); // Allow select on anything - if (db && (!thd->db || strcmp(db,thd->db))) + if (db && (!thd->db || db_is_pattern || strcmp(db,thd->db))) db_access=acl_get(thd->host, thd->ip, (char*) &thd->remote.sin_addr, - thd->priv_user, db, 0); /* purecov: inspected */ + thd->priv_user, db, db_is_pattern); else db_access=thd->db_access; // Remove SHOW attribute and access rights we already have