pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
8+ messages / 2 participants
[nested] [flat]

* pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
@ 2021-06-18 22:00 Tom Lane <tgl@sss.pgh.pa.us>
  2021-06-18 23:18 ` Re: pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2021-06-18 22:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
  2021-06-18 22:00 pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Tom Lane <tgl@sss.pgh.pa.us>
@ 2021-06-18 23:18 ` Michael Paquier <michael@paquier.xyz>
  2021-06-19 02:42   ` Re: pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Michael Paquier @ 2021-06-18 23:18 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers@lists.postgresql.org

On Fri, Jun 18, 2021 at 10:00:33PM +0000, Tom Lane wrote:
> 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.

A nit here.
+       /* If any roles remain, update the policy entry. */
+       if (num_roles > 0)
+       {
        /* This is the array for the new tuple */
This indentation is incorrect.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
  2021-06-18 22:00 pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Tom Lane <tgl@sss.pgh.pa.us>
  2021-06-18 23:18 ` Re: pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Michael Paquier <michael@paquier.xyz>
@ 2021-06-19 02:42   ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Tom Lane @ 2021-06-19 02:42 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-committers@lists.postgresql.org

Michael Paquier <michael@paquier.xyz> writes:
> This indentation is incorrect.

Yeah, I intentionally didn't reindent the code that's now inside
the inner if-block.  It would have made back-patching more painful
(because that chunk isn't identical across branches).  And I think
we're going to be rewriting that whole function in a little bit,
so I see no need to be very fussy about how pretty the intermediate
state is.  I just pushed that because I didn't want to ship beta2
with a known crasher bug.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
@ 2021-06-18 22:00 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Tom Lane @ 2021-06-18 22:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/33af10c598e2bff55be46eb79f7c785440aa13c5

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(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
@ 2021-06-18 22:00 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Tom Lane @ 2021-06-18 22:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_12_STABLE

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

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(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
@ 2021-06-18 22:00 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Tom Lane @ 2021-06-18 22:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_11_STABLE

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

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(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
@ 2021-06-18 22:00 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Tom Lane @ 2021-06-18 22:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL_10_STABLE

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

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(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries
@ 2021-06-18 22:00 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Tom Lane @ 2021-06-18 22:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0b29b41e5b9614397ba839552f35b4485ca49e0f

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



^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2021-06-19 02:42 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 22:00 pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Tom Lane <tgl@sss.pgh.pa.us>
2021-06-18 23:18 ` Michael Paquier <michael@paquier.xyz>
2021-06-19 02:42   ` Tom Lane <tgl@sss.pgh.pa.us>
2021-06-18 22:00 pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Tom Lane <tgl@sss.pgh.pa.us>
2021-06-18 22:00 pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Tom Lane <tgl@sss.pgh.pa.us>
2021-06-18 22:00 pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Tom Lane <tgl@sss.pgh.pa.us>
2021-06-18 22:00 pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Tom Lane <tgl@sss.pgh.pa.us>
2021-06-18 22:00 pgsql: Fix misbehavior of DROP OWNED BY with duplicate polroles entries Tom Lane <tgl@sss.pgh.pa.us>

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