Re: RLS makes COPY TO process child tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yugo NAGATA <nagata(at)sraoss(dot)co(dot)jp>
Cc: Antonin Houska <ah(at)cybertec(dot)at>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: RLS makes COPY TO process child tables
Date: 2023-02-01 16:47:23
Message-ID: 1379089.1675270043@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Yugo NAGATA <nagata(at)sraoss(dot)co(dot)jp> writes:
> Antonin Houska <ah(at)cybertec(dot)at> wrote:
>> 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:

> I think this is a bug because the current behaviour is different from
> the documentation.

I agree, it shouldn't do that.

> When RLS is enabled on a table in `COPY ... TO ...`, the query is converted
> to `COPY (SELECT * FROM ...) TO ...` to allow the rewriter to add in RLS
> clauses. This causes to dump the rows of child tables.

Do we actually say that in so many words, either in the code or docs?
If so, it ought to read `COPY (SELECT * FROM ONLY ...) TO ...`
instead. (If we say that in the docs, then arguably the code *does*
conform to the docs. But I don't see it in the COPY ref page at least.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sébastien Lardière 2023-02-01 16:54:43 Re: Timeline ID hexadecimal format
Previous Message Matthias van de Meent 2023-02-01 16:27:26 Re: Progress report of CREATE INDEX for nested partitioned tables