From 0a85c102254b72ec7ce16bc504206a1a5c84bd76 Mon Sep 17 00:00:00 2001 From: Joe Conway Date: Thu, 22 Dec 2016 17:56:50 -0800 Subject: [PATCH] Improve RLS documentation with respect to COPY Documentation for pg_restore said COPY TO does not support row security when in fact it should say COPY FROM. Fix that. While at it, make it clear that "COPY FROM" does not allow RLS to be enabled and INSERT should be used instead. Also that SELECT policies will apply to COPY TO statements. Back-patch to 9.5 where RLS first appeared. Author: Joe Conway Reviewed-By: Dean Rasheed and Robert Haas Discussion: https://postgr.es/m/5744FA24.3030008%40joeconway.com --- doc/src/sgml/ref/copy.sgml | 9 +++++++++ doc/src/sgml/ref/pg_dump.sgml | 5 +++++ doc/src/sgml/ref/pg_restore.sgml | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml index 2477a872e8..7ff62f2a82 100644 --- a/doc/src/sgml/ref/copy.sgml +++ b/doc/src/sgml/ref/copy.sgml @@ -424,6 +424,15 @@ COPY count to have column privileges on the column(s) listed in the command. + + If row-level security is enabled for the table, the relevant + SELECT policies will apply to COPY + table TO statements. + Currently, COPY FROM is not supported for tables + with row-level security. Use equivalent INSERT + statements instead. + + Files named in a COPY command are read or written directly by the server, not by the client application. Therefore, diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index f6225d23c8..b70e7d57e9 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -718,6 +718,11 @@ PostgreSQL documentation to dump the parts of the contents of the table that they have access to. + + Note that if you use this option currently, you probably also want + the dump be in INSERT format, as the + COPY FROM during restore does not support row security. + diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml index bd5b405314..44f0515066 100644 --- a/doc/src/sgml/ref/pg_restore.sgml +++ b/doc/src/sgml/ref/pg_restore.sgml @@ -543,7 +543,7 @@ Note that this option currently also requires the dump be in INSERT - format, as COPY TO does not support row security. + format, as COPY FROM does not support row security. -- 2.40.0