"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