Skip to content

Commit 426d015

Browse files
committed
Marginal performance improvement in aclmask(): don't bother with
testing ownership if the caller isn't interested in any GOPTION bits (which is the common case). It did not matter in 8.0 where the ownership test was just a trivial equality test, but it matters now.
1 parent b888ab8 commit 426d015

File tree

1 file changed

+7
-6
lines changed
  • src/backend/utils/adt

1 file changed

+7
-6
lines changed

src/backend/utils/adt/acl.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.123 2005/07/28 22:27:02 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/acl.c,v 1.124 2005/10/07 19:59:34 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1013,18 +1013,19 @@ aclmask(const Acl *acl, Oid roleid, Oid ownerId,
10131013
result = 0;
10141014

10151015
/* Owner always implicitly has all grant options */
1016-
if (has_privs_of_role(roleid, ownerId))
1016+
if ((mask & ACLITEM_ALL_GOPTION_BITS) &&
1017+
has_privs_of_role(roleid, ownerId))
10171018
{
10181019
result = mask & ACLITEM_ALL_GOPTION_BITS;
1019-
if (result == mask)
1020+
if ((how == ACLMASK_ALL) ? (result == mask) : (result != 0))
10201021
return result;
10211022
}
10221023

10231024
num = ACL_NUM(acl);
10241025
aidat = ACL_DAT(acl);
10251026

10261027
/*
1027-
* Check privileges granted directly to user or to public
1028+
* Check privileges granted directly to roleid or to public
10281029
*/
10291030
for (i = 0; i < num; i++)
10301031
{
@@ -1040,11 +1041,11 @@ aclmask(const Acl *acl, Oid roleid, Oid ownerId,
10401041
}
10411042

10421043
/*
1043-
* Check privileges granted indirectly via roles.
1044+
* Check privileges granted indirectly via role memberships.
10441045
* We do this in a separate pass to minimize expensive indirect
10451046
* membership tests. In particular, it's worth testing whether
10461047
* a given ACL entry grants any privileges still of interest before
1047-
* we perform the is_member test.
1048+
* we perform the has_privs_of_role test.
10481049
*/
10491050
remaining = mask & ~result;
10501051
for (i = 0; i < num; i++)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy