Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gUb2l-0006lY-Cw for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Dec 2018 17:33:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUb2k-0004Hu-1Y for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Dec 2018 17:33:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gUb2j-0004Hn-Nz for pgsql-bugs@lists.postgresql.org; Wed, 05 Dec 2018 17:33:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gUb2g-0001vG-T1 for pgsql-bugs@lists.postgresql.org; Wed, 05 Dec 2018 17:33:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wB5HWtTw006310; Wed, 5 Dec 2018 12:32:55 -0500 From: Tom Lane To: "Daniel Verite" cc: "David G. Johnston" , "Voillequin, Jean-Marc" , "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #15535: psql: \copy: parse error at... In-reply-to: <8116df5b-46d4-4099-b334-bd727e337044@manitou-mail.org> References: <8116df5b-46d4-4099-b334-bd727e337044@manitou-mail.org> Comments: In-reply-to "Daniel Verite" message dated "Wed, 05 Dec 2018 18:23:19 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6308.1544031175.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 05 Dec 2018 12:32:55 -0500 Message-ID: <6309.1544031175@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Daniel Verite" writes: > Tom Lane wrote: >> 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. > That would be the proof-of-concept patch posted a few weeks ago here: > https://www.postgresql.org/message-id/15dadc39-e050-4d46-956b-dcc4ed0987= 53@manitou-mail.org > There didn't seem to be much of community buy-in for this idea, so I've = it > let rest > for the moment. On one hand, it solves actual problems such as the one > mentioned in this bug report, on the other hand I can feel the discomfor= t > of having 3 forms of \copy, in addition to COPY, and that maybe it would > create more confusion than benefits, overall. Yeah, that is an issue all right. It occurs to me that for the COPY TO side, we don't really need any new command: we could just make \g work for that case. (Testing, it seems that plain "\g" works fine already, but "\g foo" fails to redirect the COPY output, which seems to me to be arguably a bug as well as lack of useful functionality.) That approach does nothing for COPY FROM, though. On the other hand, it's not needed nearly as bad for COPY FROM, since you can't put a giant sub-SELECT into that. regards, tom lane