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 1gUYjA-0007lw-TE for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Dec 2018 15:04:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUYj9-0006Pn-Ib for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Dec 2018 15:04:39 +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 1gUYj9-0006Pg-9A for pgsql-bugs@lists.postgresql.org; Wed, 05 Dec 2018 15:04:39 +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 1gUYj2-0006xz-Lt for pgsql-bugs@lists.postgresql.org; Wed, 05 Dec 2018 15:04:38 +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 wB5F4UOu018992; Wed, 5 Dec 2018 10:04:30 -0500 From: Tom Lane To: "David G. Johnston" cc: "Voillequin, Jean-Marc" , "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #15535: psql: \copy: parse error at... In-reply-to: References: <15535-4358642c2d1edb9d@postgresql.org> <1EC8157EB499BF459A516ADCF135ADCE3A006FE3@LON-WGMSX712.ad.moodys.net> Comments: In-reply-to "David G. Johnston" message dated "Wed, 05 Dec 2018 07:23:13 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18990.1544022270.1@sss.pgh.pa.us> Date: Wed, 05 Dec 2018 10:04:30 -0500 Message-ID: <18991.1544022270@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "David G. Johnston" 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