Re: RLS makes COPY TO process child tables

Поиск
Список
Период
Сортировка
От Stephen Frost
Тема Re: RLS makes COPY TO process child tables
Дата
Msg-id Y+L0jZJkHvgdOZRA@tamriel.snowman.net
обсуждение исходный текст
Ответ на Re: RLS makes COPY TO process child tables  (Yugo NAGATA <nagata@sraoss.co.jp>)
Ответы Re: RLS makes COPY TO process child tables  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: RLS makes COPY TO process child tables  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Greetings,

* Yugo NAGATA (nagata@sraoss.co.jp) wrote:
> On Wed, 01 Feb 2023 11:47:23 -0500
> Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> > Yugo NAGATA <nagata@sraoss.co.jp> writes:
> > > Antonin Houska <ah@cybertec.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.

Yeah, I agree based on what the COPY table TO docs say should be
happening.

> > > 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.)
>
> The documentation do not say that, but the current code actually do that.
> Also, there is the following comment in BeginCopyTo().
>
>          * With row-level security and a user using "COPY relation TO", we
>          * have to convert the "COPY relation TO" to a query-based COPY (eg:
>          * "COPY (SELECT * FROM relation) TO"), to allow the rewriter to add
>          * in any RLS clauses.
>
> Maybe, it is be better to change the description in the comment to
> "COPY (SELECT * FROM ONLY relation) TO" when fixing the bug.

Yeah, that should also be updated.  Perhaps you'd send an updated patch
which includes fixing that too and maybe adds clarifying documentation
to COPY which mentions what happens when RLS is enabled on the relation?

I'm not sure if this makes good sense to back-patch.

Thanks,

Stephen

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tatsuo Ishii
Дата:
Сообщение: Re: make_ctags: use -I option to ignore pg_node_attr macro
Следующее
От: Andres Freund
Дата:
Сообщение: deadlock-hard flakiness