pgsql: Fix psql's "\g target" meta-command to work with COPY TO STDOUT.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix psql's "\g target" meta-command to work with COPY TO STDOUT.
Date: 2019-01-26 19:15:59
Message-ID: E1gnTQt-0007lf-GZ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2c50c9f23d1dbb36b4fed50409ec590a0e9adaa2

Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml | 22 +++++++++++++---
src/bin/psql/common.c | 57 ++++++++++++++++++++++++++++++++++++------
src/bin/psql/copy.c | 7 ++++--
3 files changed, 73 insertions(+), 13 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2019-01-26 22:34:02 pgsql: Change function call information to be variable length.
Previous Message Peter Eisentraut 2019-01-26 08:25:21 pgsql: Make regression test output locale-independent