Skip to content

Commit e64d3c5

Browse files
committed
Minimize calls of pg_class_aclcheck to minimum necessary
In a couple of code paths, pg_class_aclcheck is called in succession with multiple different modes set. This patch combines those modes to have a single call of this function and reduce a bit process overhead for permission checking. Author: Michael Paquier <michael@otacoo.com> Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>
1 parent a5f7d58 commit e64d3c5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/backend/commands/sequence.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,8 @@ nextval_internal(Oid relid)
546546
/* open and AccessShareLock sequence */
547547
init_sequence(relid, &elm, &seqrel);
548548

549-
if (pg_class_aclcheck(elm->relid, GetUserId(), ACL_USAGE) != ACLCHECK_OK &&
550-
pg_class_aclcheck(elm->relid, GetUserId(), ACL_UPDATE) != ACLCHECK_OK)
549+
if (pg_class_aclcheck(elm->relid, GetUserId(),
550+
ACL_USAGE | ACL_UPDATE) != ACLCHECK_OK)
551551
ereport(ERROR,
552552
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
553553
errmsg("permission denied for sequence %s",
@@ -759,8 +759,8 @@ currval_oid(PG_FUNCTION_ARGS)
759759
/* open and AccessShareLock sequence */
760760
init_sequence(relid, &elm, &seqrel);
761761

762-
if (pg_class_aclcheck(elm->relid, GetUserId(), ACL_SELECT) != ACLCHECK_OK &&
763-
pg_class_aclcheck(elm->relid, GetUserId(), ACL_USAGE) != ACLCHECK_OK)
762+
if (pg_class_aclcheck(elm->relid, GetUserId(),
763+
ACL_SELECT | ACL_USAGE) != ACLCHECK_OK)
764764
ereport(ERROR,
765765
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
766766
errmsg("permission denied for sequence %s",
@@ -801,8 +801,8 @@ lastval(PG_FUNCTION_ARGS)
801801
/* nextval() must have already been called for this sequence */
802802
Assert(last_used_seq->last_valid);
803803

804-
if (pg_class_aclcheck(last_used_seq->relid, GetUserId(), ACL_SELECT) != ACLCHECK_OK &&
805-
pg_class_aclcheck(last_used_seq->relid, GetUserId(), ACL_USAGE) != ACLCHECK_OK)
804+
if (pg_class_aclcheck(last_used_seq->relid, GetUserId(),
805+
ACL_SELECT | ACL_USAGE) != ACLCHECK_OK)
806806
ereport(ERROR,
807807
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
808808
errmsg("permission denied for sequence %s",

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