From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Voillequin, Jean-Marc <Jean-Marc.Voillequin@moodys.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #15535: psql: \copy: parse error at...
Date: Wed, 05 Dec 2018 10:04:30 -0500
Message-ID: <18991.1544022270@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwZpKkN3E_FC+Z=J11ncdVBzCWVX24c4KPhrMt+xz1Ed+w@mail.gmail.com>
References: <15535-4358642c2d1edb9d@postgresql.org>
<CAKFQuwa7J0=r72VJks7+RV0YiwQ+_8YX5EQ_u-_cmc2Q0N9Z3Q@mail.gmail.com>
<1EC8157EB499BF459A516ADCF135ADCE3A006FE3@LON-WGMSX712.ad.moodys.net>
<CAKFQuwZpKkN3E_FC+Z=J11ncdVBzCWVX24c4KPhrMt+xz1Ed+w@mail.gmail.com>
"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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, Jean-Marc.Voillequin@moodys.com
Subject: Re: BUG #15535: psql: \copy: parse error at...
In-Reply-To: <18991.1544022270@sss.pgh.pa.us>
References: <15535-4358642c2d1edb9d@postgresql.org> <CAKFQuwa7J0=r72VJks7+RV0YiwQ+_8YX5EQ_u-_cmc2Q0N9Z3Q@mail.gmail.com> <1EC8157EB499BF459A516ADCF135ADCE3A006FE3@LON-WGMSX712.ad.moodys.net> <CAKFQuwZpKkN3E_FC+Z=J11ncdVBzCWVX24c4KPhrMt+xz1Ed+w@mail.gmail.com> <18991.1544022270@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox