summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane2019-01-26 19:15:42 +0000
committerTom Lane2019-01-26 19:15:42 +0000
commitae4c7d5ab88668275ab69913169564ce9bcbf27d (patch)
treef2a1fb920937444e3550820c0db02f4daa488081 /doc/src
parent0d5b2735122557417e24a73f92a518638d2a5a32 (diff)
Fix psql's "\g target" meta-command to work with COPY TO STDOUT.
Previously, \g would successfully execute the COPY command, but the target specification if any was ignored, so that the data was always dumped to the regular query output target. This seems like a clear bug, so let's not just fix it but back-patch it. While at it, adjust the documentation for \copy to recommend "COPY ... TO STDOUT \g foo" as a plausible alternative. Back-patch to 9.5. The problem exists much further back, but the code associated with \g was refactored enough in 9.5 that we'd need a significantly different patch for 9.4, and it doesn't seem worth the trouble. Daniel Vérité, reviewed by Fabien Coelho Discussion: https://postgr.es/m/15dadc39-e050-4d46-956b-dcc4ed098753@manitou-mail.org
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/ref/psql-ref.sgml22
1 files changed, 18 insertions, 4 deletions
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 95e331884a1..e217898fb89 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -984,10 +984,24 @@ testdb=>
<tip>
<para>
- This operation is not as efficient as the <acronym>SQL</acronym>
- <command>COPY</command> command because all data must pass
- through the client/server connection. For large
- amounts of data the <acronym>SQL</acronym> command might be preferable.
+ Another way to obtain the same result as <literal>\copy
+ ... to</literal> is to use the <acronym>SQL</acronym> <literal>COPY
+ ... TO STDOUT</literal> command and terminate it
+ with <literal>\g <replaceable>filename</replaceable></literal>
+ or <literal>\g |<replaceable>program</replaceable></literal>.
+ Unlike <literal>\copy</literal>, this method allows the command to
+ span multiple lines; also, variable interpolation and backquote
+ expansion can be used.
+ </para>
+ </tip>
+
+ <tip>
+ <para>
+ These operations are not as efficient as the <acronym>SQL</acronym>
+ <command>COPY</command> command with a file or program data source or
+ destination, because all data must pass through the client/server
+ connection. For large amounts of data the <acronym>SQL</acronym>
+ command might be preferable.
</para>
</tip>