Re: Alternative to \copy in psql modelled after \g

Daniel Verite <daniel@manitou-mail.org>

From: "Daniel Verite" <daniel@manitou-mail.org>
To: "Fabien COELHO" <coelho@cri.ensmp.fr>
Cc: "PostgreSQL Hackers" <pgsql-hackers@lists.postgresql.org>,"David G. Johnston" <david.g.johnston@gmail.com>
Date: 2018-12-27T16:24:50Z
Lists: pgsql-hackers
	Fabien COELHO wrote:

> > It does not add "unless the query is a COPY", so it seems right
> > to make that just work, and call it a bug fix.
> 
> Does this suggest backpatching?

Yes, I think it's a candidate for back-patching.

> > There is a precedent in regress/sql/hs_standby_allowed.sql doing:
> >
> >  COPY hs1 TO '/tmp/copy_test'
> >  \! cat /tmp/copy_test
> 
> Indeed. I'm unsure windows has cat or /tmp, so I do not understand how it 
> works on such platform. Maybe I'm missing something.

It's exercised only on a standby. Possibly few machines run this test,
among which none powered by Windows? And maybe it even works
on Windows in some cases: the reference to /tmp would work
in an MSYS/MingW environment and "cat" might too if \! gets
to the /bin/sh of that environment.

> However TAP tests do that, and I have used this extensively with pgbench, 
> so a psql TAP test could do that and other things, such as importing a csv 
> file or whatever.

It looks a significant step forward, to be brought by a patch on its own
without prospect of being back-patched.


Best regards,
-- 
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite


Commits

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