RLS makes COPY TO process child tables

From: Antonin Houska <ah(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: RLS makes COPY TO process child tables
Date: 2023-02-01 11:45:57
Message-ID: 3472.1675251957@antos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While working on [1] I noticed that if RLS gets enabled, the COPY TO command
includes the contents of child table into the result, although the
documentation says it should not:

"COPY TO can be used only with plain tables, not views, and does not
copy rows from child tables or child partitions. For example, COPY
table TO copies the same rows as SELECT * FROM ONLY table. The syntax
COPY (SELECT * FROM table) TO ... can be used to dump all of the rows
in an inheritance hierarchy, partitioned table, or view."

A test case is attached (rls.sql) as well as fix proposal
(copy_rls_no_inh.diff).

[1] https://commitfest.postgresql.org/41/3641/

--
Antonin Houska
Web: https://www.cybertec-postgresql.com

Attachment Content-Type Size
unknown_filename text/plain 426 bytes
copy_rls_no_inh.diff text/x-diff 459 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-02-01 11:54:26 Re: recovery modules
Previous Message Melih Mutlu 2023-02-01 11:44:22 Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication