Re: BUG #15535: psql: \copy: parse error at... - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #15535: psql: \copy: parse error at...
Date
Msg-id 18991.1544022270@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #15535: psql: \copy: parse error at...  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses RE: BUG #15535: psql: \copy: parse error at...  ("Voillequin, Jean-Marc" <Jean-Marc.Voillequin@moodys.com>)
Re: BUG #15535: psql: \copy: parse error at...  ("Daniel Verite" <daniel@manitou-mail.org>)
List pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wednesday, December 5, 2018, Voillequin, Jean-Marc <
> Jean-Marc.Voillequin@moodys.com> wrote:
>> SIMPLE=> \copy (select * from /*comment with a closing parenthesis)*/
>> pg_tables) to 'test';
>> \copy: parse error at "*/"

> psql \copy doesn't understand comments.

More precisely, psql backslash commands in general have no provision
for comments.  Everything from the backslash to the end of the line
(or the next backslash command) is live command text.  If \copy had
a smarter parser for the embedded SELECT command, maybe that would
recognize SQL comments ... but it doesn't.

There was a proposal awhile back to provide a variant of \copy
that works more like \g, so you'd enter something like

COPY (SELECT ...) TO STDOUT
\copyto somefile

which'd be way more flexible --- the COPY command wouldn't have to
fit on one line, for one thing.  But I don't think that's gone
anywhere yet.

            regards, tom lane


pgsql-bugs by date:

Previous
From: Pavlo Golub
Date:
Subject: Re: BUG #15505: pgadmin 4
Next
From: "Voillequin, Jean-Marc"
Date:
Subject: RE: BUG #15535: psql: \copy: parse error at...