]> granicus.if.org Git - postgresql/commitdiff
Fix AclResult vs bool type mix-up
authorPeter Eisentraut <peter_e@gmx.net>
Thu, 6 Apr 2017 15:31:18 +0000 (11:31 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Thu, 6 Apr 2017 15:32:07 +0000 (11:32 -0400)
Using AclResult as a bool or vice versa works by accident, but it's
unusual and possibly confusing style, so write it out more explicitly.

contrib/pgrowlocks/pgrowlocks.c

index 120d0eb8dbfb9cf311350943d662813645c4fdd4..8dd561c02ad437692e720efdbb093e936148999e 100644 (file)
@@ -101,8 +101,9 @@ pgrowlocks(PG_FUNCTION_ARGS)
 
                /* check permissions: must have SELECT on table or be in pg_stat_scan_tables */
                aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
-                                                                         ACL_SELECT) ||
-                       is_member_of_role(GetUserId(), DEFAULT_ROLE_STAT_SCAN_TABLES);
+                                                                         ACL_SELECT);
+               if (aclresult != ACLCHECK_OK)
+                       aclresult = is_member_of_role(GetUserId(), DEFAULT_ROLE_STAT_SCAN_TABLES) ? ACLCHECK_OK : ACLCHECK_NO_PRIV;
 
                if (aclresult != ACLCHECK_OK)
                        aclcheck_error(aclresult, ACL_KIND_CLASS,