pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
Date: Fri, 18 Jun 2021 22:00:33 +0000
Message-ID: <E1luMXR-00054E-8H@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d21fca084356946664bfce19d66d2df2bb873cbd

Modified Files
--------------
src/backend/commands/policy.c             | 50 +++++++++++++++++--------------
src/test/regress/expected/rowsecurity.out |  9 ++++++
src/test/regress/sql/rowsecurity.sql      | 10 +++++++
3 files changed, 46 insertions(+), 23 deletions(-)



view thread (8+ messages)  latest in thread

Message-ID: <E1luMXR-00054E-8H@gemulon.postgresql.org>
Permalink:  ../E1luMXR-00054E-8H@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1luMXR-00054E-8H@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
  In-Reply-To: <E1luMXR-00054E-8H@gemulon.postgresql.org>
  References: <E1luMXR-00054E-8H@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox