From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Simon Riggs <simon@2ndQuadrant.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: [BUGS] COPY .... (FORMAT binary) syntax doesn't work
Date: Sun, 26 May 2013 11:35:47 -0400
Message-ID: <51A22BD3.4000604@vmware.com> (raw)
In-Reply-To: <CA+U5nML5zj43Mxk2FND-F+JH_tjxNs=_qePSV1aPOBJmsONYgg@mail.gmail.com>
References: <CA+U5nML5zj43Mxk2FND-F+JH_tjxNs=_qePSV1aPOBJmsONYgg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
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:
inline patch 1: src/backend/parser/gram.y (+4/-0 lines) download inline-1.patch--- 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
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: hlinnakangas@vmware.com, simon@2ndQuadrant.com, pgsql-hackers@postgresql.org
Subject: Re: [BUGS] COPY .... (FORMAT binary) syntax doesn't work
In-Reply-To: <51A22BD3.4000604@vmware.com>
References: <CA+U5nML5zj43Mxk2FND-F+JH_tjxNs=_qePSV1aPOBJmsONYgg@mail.gmail.com> <51A22BD3.4000604@vmware.com>
* 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