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: Ensure COPY TO on an RLS-enabled table copies no more than it sh
Date: Fri, 10 Mar 2023 18:52:57 +0000
Message-ID: <E1pahrM-002t75-VE@gemulon.postgresql.org> (raw)

Ensure COPY TO on an RLS-enabled table copies no more than it should.

The COPY documentation is quite clear that "COPY relation TO" copies
rows from only the named table, not any inheritance children it may
have.  However, if you enabled row-level security on the table then
this stopped being true, because the code forgot to apply the ONLY
modifier in the "SELECT ... FROM relation" query that it constructs
in order to allow RLS predicates to be attached.  Fix that.

Report and patch by Antonin Houska (comment adjustments and test case
by me).  Back-patch to all supported branches.

Discussion: https://postgr.es/m/3472.1675251957@antos

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/53a53ea332131b3d29d8d69e1dc2823f4d6ff21a

Modified Files
--------------
src/backend/commands/copy.c               |  5 ++++-
src/backend/commands/copyto.c             |  4 ++--
src/test/regress/expected/rowsecurity.out | 37 +++++++++++++++++++++++++++++++
src/test/regress/sql/rowsecurity.sql      | 34 ++++++++++++++++++++++++++++
4 files changed, 77 insertions(+), 3 deletions(-)



view thread (8+ messages)  latest in thread

Message-ID: <E1pahrM-002t75-VE@gemulon.postgresql.org>
Permalink:  ../E1pahrM-002t75-VE@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pahrM-002t75-VE@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Ensure COPY TO on an RLS-enabled table copies no more than it sh
  In-Reply-To: <E1pahrM-002t75-VE@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