Improve RLS documentation with respect to COPY
authorJoe Conway <[email protected]>
Fri, 23 Dec 2016 01:57:14 +0000 (17:57 -0800)
committerJoe Conway <[email protected]>
Fri, 23 Dec 2016 01:57:14 +0000 (17:57 -0800)
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
doc/src/sgml/ref/pg_dump.sgml
doc/src/sgml/ref/pg_restore.sgml

index 2850b4763f26050d136ecd441198a1530392ae2a..808355a3fbea424537f5ea96d5352db0d0e0d10d 100644 (file)
@@ -411,6 +411,15 @@ COPY <replaceable class="parameter">count</replaceable>
     to have column privileges on the column(s) listed in the command.
    </para>
 
+   <para>
+    If row-level security is enabled for the table, the relevant 
+    <command>SELECT</command> policies will apply to <literal>COPY
+    <replaceable class="parameter">table</> TO</literal> statements.
+    Currently, <command>COPY FROM</command> is not supported for tables
+    with row-level security. Use equivalent <command>INSERT</command>
+    statements instead.
+   </para>
+
    <para>
     Files named in a <command>COPY</command> command are read or written
     directly by the server, not by the client application. Therefore,
index 0ca4ad40a43cedf7d1c2107dabd913d90bc7a5e3..ab8ec3f47ed9fa38512abf37c07b5f3bfb201f8c 100644 (file)
@@ -700,6 +700,11 @@ PostgreSQL documentation
         to dump the parts of the contents of the table that they have access to.
        </para>
 
+       <para>
+        Note that if you use this option currently, you probably also want
+        the dump be in <command>INSERT</command> format, as the
+        <command>COPY FROM</command> during restore does not support row security.
+       </para>
       </listitem>
      </varlistentry>
 
index 66a3aa5455ad5e225939013eff8acda38e54bc2f..f357c5731491a4fc4afcbb50300ac665b7dcbedb 100644 (file)
 
        <para>
         Note that this option currently also requires the dump be in <command>INSERT</command>
-        format, as <command>COPY TO</command> does not support row security.
+        format, as <command>COPY FROM</command> does not support row security.
        </para>
       </listitem>
      </varlistentry>