Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UgdXB-0003P4-To for pgsql-bugs@arkaria.postgresql.org; Sun, 26 May 2013 16:11:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UgdXA-0004TF-JU for pgsql-bugs@arkaria.postgresql.org; Sun, 26 May 2013 16:11:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UgdX9-0004SV-NP for pgsql-bugs@postgresql.org; Sun, 26 May 2013 16:10:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UgdX1-0004Dt-9y for pgsql-bugs@postgresql.org; Sun, 26 May 2013 16:10:59 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r4QGAnxD013863; Sun, 26 May 2013 12:10:49 -0400 (EDT) From: Tom Lane To: Heikki Linnakangas cc: Simon Riggs , pgsql-bugs , PostgreSQL-development Subject: Re: [HACKERS] COPY .... (FORMAT binary) syntax doesn't work In-reply-to: <51A22BD3.4000604@vmware.com> References: <51A22BD3.4000604@vmware.com> Comments: In-reply-to Heikki Linnakangas message dated "Sun, 26 May 2013 11:35:47 -0400" Date: Sun, 26 May 2013 12:10:49 -0400 Message-ID: <13862.1369584649@sss.pgh.pa.us> X-Pg-Spam-Score: -3.0 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Heikki Linnakangas writes: > On 26.05.2013 04:31, Simon Riggs wrote: >> This new format does not [work:] >> COPY pgbench_accounts FROM '/tmp/acc' (FORMAT BINARY); >> ERROR: syntax error at or near "BINARY" at character 47 > 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")); > + } That only fixes things for the specific case of FORMAT BINARY. I think it would be better to generalize ColId_or_Sconst. This one-liner works, but it's pretty ugly: *** gram.y~ Sun May 26 11:58:42 2013 --- gram.y Sun May 26 12:00:03 2013 *************** opt_encoding: *** 1548,1553 **** --- 1548,1554 ---- ColId_or_Sconst: ColId { $$ = $1; } + | type_func_name_keyword { $$ = pstrdup($1); } | Sconst { $$ = $1; } ; More readable would be to invent an intermediate nonterminal falling between ColId and ColLabel, whose expansion would be "IDENT | unreserved_keyword | col_name_keyword | type_func_name_keyword", and then replace ColId_or_Sconst with whatever-we-call-that_or_Sconst. Any thoughts about a name for that new nonterminal? BTW, I tried just replacing ColId with ColLabel here, and that *almost* works, but there are some places where we can see either ColId_or_Sconst or DEFAULT. I don't know of any sane way to express "all reserved keywords except DEFAULT" to bison, so the best we can realistically do is to accept all not-fully-reserved keywords in these places. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs