Hi Ayoub On 04/11/2026 13:58, Ayoub Kazar wrote: > > The attached patch uses the existing attnums to build targetlist based > on it, in the case of RLS.
I tested the patch and it solves the reported issue. It also changes how COPY TO handles columns that the user has no select privileges on,but I'd argue this is an improvement: create user u login; create table t(a int, b int generated always as (a+40) stored, c text); insert into t (a,c) values (2,'foo'); grant select (a,c) on t to u; alter table t enable row level security; create policy p on t using (true); == master == postgres=# set role u; SET postgres=> copy t to stdout; ERROR: permission denied for table t == patched == postgres=# set role u; SET postgres=> copy t to stdout; 2 foo postgres=> I guess this test could also be added to the regression tests. BTW, is there another reason to not allow generated columns in COPY TO other than being consistent with COPY FROM? Thanks! Best, Jim
