From: Tom Lane <tgl@sss.pgh.pa.us>
To: Heikki Linnakangas <hlinnakangas@vmware.com>
Cc: Simon Riggs <simon@2ndQuadrant.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] COPY .... (FORMAT binary) syntax doesn't work
Date: Sun, 26 May 2013 12:10:49 -0400
Message-ID: <13862.1369584649@sss.pgh.pa.us> (raw)
In-Reply-To: <51A22BD3.4000604@vmware.com>
References: <CA+U5nML5zj43Mxk2FND-F+JH_tjxNs=_qePSV1aPOBJmsONYgg@mail.gmail.com>
<51A22BD3.4000604@vmware.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Heikki Linnakangas <hlinnakangas@vmware.com> 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:
inline patch 1: gram.y (+1/-0 lines) download inline-1.patch*** 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, hlinnakangas@vmware.com, simon@2ndQuadrant.com, pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] COPY .... (FORMAT binary) syntax doesn't work
In-Reply-To: <13862.1369584649@sss.pgh.pa.us>
References: <CA+U5nML5zj43Mxk2FND-F+JH_tjxNs=_qePSV1aPOBJmsONYgg@mail.gmail.com> <51A22BD3.4000604@vmware.com> <13862.1369584649@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox