]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Remove unnecessary failure cases in RemoveRoleFromObjectPolicy().
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 25 Jun 2021 17:59:38 +0000 (13:59 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 25 Jun 2021 17:59:38 +0000 (13:59 -0400)
commitf5b780c45ca6d8d4cd4d325ae4b3b60f75179472
tree3a636ac01be48e147848775a8aa890b4fdb51d68
parent4040139f22b4d3a4c67a7517a01ffd03ff0c59f4
Remove unnecessary failure cases in RemoveRoleFromObjectPolicy().

It's not really necessary for this function to open or lock the
relation associated with the pg_policy entry it's modifying.  The
error checks it's making on the rel are if anything counterproductive
(e.g., if we don't want to allow installation of policies on system
catalogs, here is not the place to prevent that).  In particular, it
seems just wrong to insist on an ownership check.  That has the net
effect of forcing people to use superuser for DROP OWNED BY, which
surely is not an effect we want.  Also there is no point in rebuilding
the dependencies of the policy expressions, which aren't being
changed.  Lastly, locking the table also seems counterproductive; it's
not helping to prevent race conditions, since we failed to re-read the
pg_policy row after acquiring the lock.  That means that concurrent
DDL would likely result in "tuple concurrently updated/deleted"
errors; which is the same behavior this code will produce, with less
overhead.

Per discussion of bug #17062.  Back-patch to all supported versions,
as the failure cases this eliminates seem just as undesirable in 9.6
as in HEAD.

Discussion: https://postgr.es/m/1573181.1624220108@sss.pgh.pa.us
src/backend/commands/policy.c