]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix misbehavior of DROP OWNED BY with duplicate polroles entries.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 18 Jun 2021 22:00:09 +0000 (18:00 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 18 Jun 2021 22:00:09 +0000 (18:00 -0400)
commit33af10c598e2bff55be46eb79f7c785440aa13c5
tree81ee253749c3d05ff5b06faa1cfc7a6288161134
parent102f31a208b85aec542fc93f73a222d98d551694
Fix misbehavior of DROP OWNED BY with duplicate polroles entries.

Ordinarily, a pg_policy.polroles array wouldn't list the same role
more than once; but CREATE POLICY does not prevent that.  If we
perform DROP OWNED BY on a role that is listed more than once,
RemoveRoleFromObjectPolicy either suffered an assertion failure
or encountered a tuple-updated-by-self error.  Rewrite it to cope
correctly with duplicate entries, and add a CommandCounterIncrement
call to prevent the other problem.

Per discussion, there's other cleanup that ought to happen here,
but this seems like the minimum essential fix.

Per bug #17062 from Alexander Lakhin.  It's been broken all along,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/17062-11f471ae3199ca23@postgresql.org
src/backend/commands/policy.c
src/test/regress/expected/rowsecurity.out
src/test/regress/sql/rowsecurity.sql