Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UgczJ-0001e9-Ci for pgsql-hackers@arkaria.postgresql.org; Sun, 26 May 2013 15:36:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UgczI-0007X1-Sg for pgsql-hackers@arkaria.postgresql.org; Sun, 26 May 2013 15:36:00 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UgczH-0007Ws-PX; Sun, 26 May 2013 15:35:59 +0000 Received: from smtp-outbound-1.vmware.com ([208.91.2.12]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UgczA-00010Q-5r; Sun, 26 May 2013 15:35:59 +0000 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 973F628278; Sun, 26 May 2013 08:35:50 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (zcs-prod-ext-mta-1.vmware.com [10.113.62.223]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 9549D40811; Sun, 26 May 2013 08:35:50 -0700 (PDT) Received: from zcs-prod-ext-mta-1.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTP id 9908312002A; Sun, 26 May 2013 08:41:18 -0700 (PDT) Received: from [10.68.0.15] (zimbra-prod-ext-proxy-vip.vmware.com [10.113.63.87]) by zcs-prod-ext-mta-1.vmware.com (Postfix) with ESMTPSA; Sun, 26 May 2013 08:41:17 -0700 (PDT) Message-ID: <51A22BD3.4000604@vmware.com> Date: Sun, 26 May 2013 11:35:47 -0400 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Simon Riggs CC: pgsql-bugs , PostgreSQL-development Subject: Re: [BUGS] COPY .... (FORMAT binary) syntax doesn't work References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -5.3 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 26.05.2013 04:31, Simon Riggs wrote: > This works fine... > COPY pgbench_accounts TO '/tmp/acc' BINARY; > > This new format does not > COPY pgbench_accounts FROM '/tmp/acc' (FORMAT BINARY); > ERROR: syntax error at or near "BINARY" at character 47 > > which looks like I've mistyped something. Until you realise that this > statement gives a completely different error message. > > COPY pgbench_accounts FROM '/tmp/acc' (FORMAT anyname); > ERROR: COPY format "anyname" not recognized > > and we also note that there are no examples in the docs, nor > regression tests to cover this situation. > > So I conclude that this hasn't ever worked since it was introduced in 9.0. > > The cause is that there is an overlap between the old and the new COPY > syntax, relating to the word BINARY. It's the grammar generating the > error, not post parse analysis. Hmm, the problem is that BINARY is a type_func_keyword, so it doesn't match the ColId rule used to capture the format argument. > My attempts to fix that look pretty ugly, so I'm not even going to > post them. I can stop the error on binary by causing errors on csv and > text, obviously not a fix. Any grammar based fix looks like it would > restrict the list of formats, which breaks the orginal intention of > the syntax change. This seems to work: --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -2528,3 +2528,7 @@ copy_generic_opt_elem: { $$ = makeDefElem($1, $2); } + | ColLabel BINARY + { + $$ = makeDefElem($1, (Node *) makeString("binary")); + } Am I missing something? - Heikki -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers