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 1gUbfA-0000CX-Lh for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Dec 2018 18:12:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUbf9-000752-94 for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Dec 2018 18:12:43 +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 1gUbf8-000740-VY for pgsql-bugs@lists.postgresql.org; Wed, 05 Dec 2018 18:12:43 +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 1gUbf5-0002q0-Oq for pgsql-bugs@lists.postgresql.org; Wed, 05 Dec 2018 18:12:41 +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 wB5ICbvh007733; Wed, 5 Dec 2018 13:12:37 -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: <05a4c411-66fa-4bd0-bf80-98041a87c8de@manitou-mail.org> References: <05a4c411-66fa-4bd0-bf80-98041a87c8de@manitou-mail.org> Comments: In-reply-to "Daniel Verite" message dated "Wed, 05 Dec 2018 19:01:19 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7731.1544033557.1@sss.pgh.pa.us> Date: Wed, 05 Dec 2018 13:12:37 -0500 Message-ID: <7732.1544033557@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Daniel Verite" writes: > Tom Lane wrote: >> 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. > Agreed. I will look into the problem of COPY OUT with \g filename > if you don't beat me to it. I wasn't volunteering to work on that, so have at it. > Concerning \copyfrom, the most obvious use case is when the filename > has to be a variable, which \copy doesn't allow for. > But this one might be better solved by just improving \copy. I wonder ... would it be outrageous for "\g foo" to be interpreted as reading foo, not writing it, if what comes back from the server is a CopyInResponse message rather than a query result or CopyOutResponse? No new commands that way, but maybe more potential for user confusion, so I'm not sure if this is a good idea or not. regards, tom lane