]> granicus.if.org Git - postgresql/commit
Fix RLS with COPY (col1, col2) FROM tab
authorStephen Frost <sfrost@snowman.net>
Mon, 3 Oct 2016 20:22:57 +0000 (16:22 -0400)
committerStephen Frost <sfrost@snowman.net>
Mon, 3 Oct 2016 20:22:57 +0000 (16:22 -0400)
commit814b9e9b8edf36cac65e0d8fcef17e50a04b1617
treef2c2b35fadda3bee09f821cba5efe826f2da3cf7
parent83c2492002162bf79d2a0811bff5724e395909d7
Fix RLS with COPY (col1, col2) FROM tab

Attempting to COPY a subset of columns from a table with RLS enabled
would fail due to an invalid query being constructed (using a single
ColumnRef with the list of fields to exact in 'fields', but that's for
the different levels of an indirection for a single column, not for
specifying multiple columns).

Correct by building a ColumnRef and then RestTarget for each column
being requested and then adding those to the targetList for the select
query.  Include regression tests to hopefully catch if this is broken
again in the future.

Patch-By: Adam Brightwell
Reviewed-By: Michael Paquier
src/backend/commands/copy.c
src/test/regress/expected/copy2.out
src/test/regress/sql/copy2.sql