pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
11+ messages / 5 participants
[nested] [flat]

* COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 14:52  Pavel Golub <pavel@microolap.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Pavel Golub @ 2011-07-05 14:52 UTC (permalink / raw)
  To: pgsql-bugs; +Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>

Hello.

System: PostgreSQL v9.0 Windows XP SP3
SQL: COPY "tablename" TO STDOUT WITH (FORMAT binary)
ERROR:  syntax error at or near "binary"
LINE 1: ...OPY "tablename" TO STDOUT WITH (FORMAT binary)
                                                  ^

********** Error **********

ERROR: syntax error at or near "binary"
SQL state: 42601
Character: 55

But if I use 'FORMAT text' or 'FORMAT csv' all is OK.

Suppose this happens because BINARY is not listed in
"unreserved_keyword" neither in "col_name_keyword parser" parser rules, but
listed in "type_func_name_keyword" instead.



-- 
With best wishes,
 Pavel                          mailto:pavel@gf.microolap.com




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [HACKERS] COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 15:06  Alvaro Herrera <alvherre@commandprompt.com>
  parent: Pavel Golub <pavel@microolap.com>
  0 siblings, 2 replies; 11+ messages in thread

From: Alvaro Herrera @ 2011-07-05 15:06 UTC (permalink / raw)
  To: Pavel Golub <pavel@gf.microolap.com>; +Cc: pgsql-bugs; PostgreSQL Hackers <pgsql-hackers@postgresql.org>

Excerpts from Pavel Golub's message of mar jul 05 10:52:06 -0400 2011:
> Hello.
> 
> System: PostgreSQL v9.0 Windows XP SP3
> SQL: COPY "tablename" TO STDOUT WITH (FORMAT binary)
> ERROR:  syntax error at or near "binary"
> LINE 1: ...OPY "tablename" TO STDOUT WITH (FORMAT binary)
>                                                   ^
> 
> ********** Error **********
> 
> ERROR: syntax error at or near "binary"
> SQL state: 42601
> Character: 55
> 
> But if I use 'FORMAT text' or 'FORMAT csv' all is OK.
> 
> Suppose this happens because BINARY is not listed in
> "unreserved_keyword" neither in "col_name_keyword parser" parser rules, but
> listed in "type_func_name_keyword" instead.

That seems pretty unfortunate.  Of course, it works if you quote it:

COPY "tablename" TO STDOUT WITH (FORMAT "binary")

I assume it's not in unreserved_keyword because it would cause a
shift/reduce conflict elsewhere.

-- 
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [HACKERS] COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 15:13  Pavel Golub <pavel@microolap.com>
  parent: Alvaro Herrera <alvherre@commandprompt.com>
  1 sibling, 0 replies; 11+ messages in thread

From: Pavel Golub @ 2011-07-05 15:13 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@commandprompt.com>; +Cc: pgsql-bugs; PostgreSQL Hackers <pgsql-hackers@postgresql.org>

Hello, Alvaro.

You wrote:

AH> Excerpts from Pavel Golub's message of mar jul 05 10:52:06 -0400 2011:
>> Hello.
>> 
>> System: PostgreSQL v9.0 Windows XP SP3
>> SQL: COPY "tablename" TO STDOUT WITH (FORMAT binary)
>> ERROR:  syntax error at or near "binary"
>> LINE 1: ...OPY "tablename" TO STDOUT WITH (FORMAT binary)
>>                                                   ^
>> 
>> ********** Error **********
>> 
>> ERROR: syntax error at or near "binary"
>> SQL state: 42601
>> Character: 55
>> 
>> But if I use 'FORMAT text' or 'FORMAT csv' all is OK.
>> 
>> Suppose this happens because BINARY is not listed in
>> "unreserved_keyword" neither in "col_name_keyword parser" parser rules, but
>> listed in "type_func_name_keyword" instead.

AH> That seems pretty unfortunate.  Of course, it works if you quote it:

AH> COPY "tablename" TO STDOUT WITH (FORMAT "binary")

AH> I assume it's not in unreserved_keyword because it would cause a
AH> shift/reduce conflict elsewhere.


Well, there are two ways:
1. Change documentation, so quoted or double quoted values are
accepted

2. Fix parser

-- 
With best wishes,
 Pavel                          mailto:pavel@gf.microolap.com




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [HACKERS] COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 15:23  Robert Haas <robertmhaas@gmail.com>
  parent: Alvaro Herrera <alvherre@commandprompt.com>
  1 sibling, 3 replies; 11+ messages in thread

From: Robert Haas @ 2011-07-05 15:23 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@commandprompt.com>; +Cc: Pavel Golub <pavel@gf.microolap.com>; pgsql-bugs; PostgreSQL Hackers <pgsql-hackers@postgresql.org>

On Tue, Jul 5, 2011 at 11:06 AM, Alvaro Herrera
<alvherre@commandprompt.com> wrote:
> Excerpts from Pavel Golub's message of mar jul 05 10:52:06 -0400 2011:
>> Hello.
>>
>> System: PostgreSQL v9.0 Windows XP SP3
>> SQL: COPY "tablename" TO STDOUT WITH (FORMAT binary)
>> ERROR:  syntax error at or near "binary"
>> LINE 1: ...OPY "tablename" TO STDOUT WITH (FORMAT binary)
>>                                                   ^
>>
>> ********** Error **********
>>
>> ERROR: syntax error at or near "binary"
>> SQL state: 42601
>> Character: 55
>>
>> But if I use 'FORMAT text' or 'FORMAT csv' all is OK.
>>
>> Suppose this happens because BINARY is not listed in
>> "unreserved_keyword" neither in "col_name_keyword parser" parser rules, but
>> listed in "type_func_name_keyword" instead.
>
> That seems pretty unfortunate.  Of course, it works if you quote it:
>
> COPY "tablename" TO STDOUT WITH (FORMAT "binary")
>
> I assume it's not in unreserved_keyword because it would cause a
> shift/reduce conflict elsewhere.

Yeah.  In particular, it conflicts with the ancient copy syntax which
we still support for backwards compatibility with versions < 7.3.  We
can fix the immediate problem with something like the attached.

(a) Should we do that?

(b) Should we back-patch it to 9.1 and 9.0?

(c) Should we consider removing compatibility with the ancient copy
syntax in 9.2, and de-reserving that keyword?  (Given that the
workaround is this simple, I'm inclined to say "no", but could be
persuaded otherwise.)

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachments:

allow-copy-format-binary.patch (application/octet-stream, 862B) download *** a/src/backend/parser/gram.y --- b/src/backend/parser/gram.y *************** *** 2341,2351 **** copy_generic_opt_elem: ; copy_generic_opt_arg: ! opt_boolean_or_string { $$ = (Node *) makeString($1); } ! | NumericOnly { $$ = (Node *) $1; } ! | '*' { $$ = (Node *) makeNode(A_Star); } | '(' copy_generic_opt_arg_list ')' { $$ = (Node *) $2; } ! | /* EMPTY */ { $$ = NULL; } ; copy_generic_opt_arg_list: --- 2341,2352 ---- ; copy_generic_opt_arg: ! opt_boolean_or_string { $$ = (Node *) makeString($1); } ! | BINARY { $$ = (Node *) makeString("binary") } ! | NumericOnly { $$ = (Node *) $1; } ! | '*' { $$ = (Node *) makeNode(A_Star); } | '(' copy_generic_opt_arg_list ')' { $$ = (Node *) $2; } ! | /* EMPTY */ { $$ = NULL; } ; copy_generic_opt_arg_list:
^ permalink raw reply [nested|flat] 11+ messages in thread

* Re: [HACKERS] COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 15:30  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Robert Haas <robertmhaas@gmail.com>
  2 siblings, 1 reply; 11+ messages in thread

From: Tom Lane @ 2011-07-05 15:30 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@commandprompt.com>; Pavel Golub <pavel@gf.microolap.com>; pgsql-bugs; PostgreSQL Hackers <pgsql-hackers@postgresql.org>

Robert Haas <robertmhaas@gmail.com> writes:
> On Tue, Jul 5, 2011 at 11:06 AM, Alvaro Herrera
> <alvherre@commandprompt.com> wrote:
>> I assume it's not in unreserved_keyword because it would cause a
>> shift/reduce conflict elsewhere.

> Yeah.  In particular, it conflicts with the ancient copy syntax which
> we still support for backwards compatibility with versions < 7.3.  We
> can fix the immediate problem with something like the attached.

> (a) Should we do that?

That seems like a horrid crock ...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [HACKERS] COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 15:34  Andrew Dunstan <andrew@dunslane.net>
  parent: Robert Haas <robertmhaas@gmail.com>
  2 siblings, 0 replies; 11+ messages in thread

From: Andrew Dunstan @ 2011-07-05 15:34 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@commandprompt.com>; Pavel Golub <pavel@gf.microolap.com>; pgsql-bugs; PostgreSQL Hackers <pgsql-hackers@postgresql.org>



On 07/05/2011 11:23 AM, Robert Haas wrote:
>
> Yeah.  In particular, it conflicts with the ancient copy syntax which
> we still support for backwards compatibility with versions<  7.3.  We
> can fix the immediate problem with something like the attached.
>
> (a) Should we do that?

yes.

> (b) Should we back-patch it to 9.1 and 9.0?

yes.

> (c) Should we consider removing compatibility with the ancient copy
> syntax in 9.2, and de-reserving that keyword?  (Given that the
> workaround is this simple, I'm inclined to say "no", but could be
> persuaded otherwise.)
>



I'm inclined to say yes, but mainly because it's just old cruft. I don't 
expect to be able,say, to load a pre-7.3 dump into a modern Postgres.

cheers

andrew



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [HACKERS] COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 15:34  Robert Haas <robertmhaas@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 11+ messages in thread

From: Robert Haas @ 2011-07-05 15:34 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alvaro Herrera <alvherre@commandprompt.com>; Pavel Golub <pavel@gf.microolap.com>; pgsql-bugs; PostgreSQL Hackers <pgsql-hackers@postgresql.org>

On Tue, Jul 5, 2011 at 11:30 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
>> On Tue, Jul 5, 2011 at 11:06 AM, Alvaro Herrera
>> <alvherre@commandprompt.com> wrote:
>>> I assume it's not in unreserved_keyword because it would cause a
>>> shift/reduce conflict elsewhere.
>
>> Yeah.  In particular, it conflicts with the ancient copy syntax which
>> we still support for backwards compatibility with versions < 7.3.  We
>> can fix the immediate problem with something like the attached.
>
>> (a) Should we do that?
>
> That seems like a horrid crock ...

Do you have something else to propose?

It's a crock we have used elsewhere, so there is some precedent.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [HACKERS] COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 15:37  Pavel Golub <pavel@microolap.com>
  parent: Robert Haas <robertmhaas@gmail.com>
  2 siblings, 1 reply; 11+ messages in thread

From: Pavel Golub @ 2011-07-05 15:37 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@commandprompt.com>; pgsql-bugs; PostgreSQL Hackers <pgsql-hackers@postgresql.org>

Hello, Robert.

You wrote:

RH> On Tue, Jul 5, 2011 at 11:06 AM, Alvaro Herrera
RH> <alvherre@commandprompt.com> wrote:
>> Excerpts from Pavel Golub's message of mar jul 05 10:52:06 -0400 2011:
>>> Hello.
>>>
>>> System: PostgreSQL v9.0 Windows XP SP3
>>> SQL: COPY "tablename" TO STDOUT WITH (FORMAT binary)
>>> ERROR:  syntax error at or near "binary"
>>> LINE 1: ...OPY "tablename" TO STDOUT WITH (FORMAT binary)
>>>                                                   ^
>>>
>>> ********** Error **********
>>>
>>> ERROR: syntax error at or near "binary"
>>> SQL state: 42601
>>> Character: 55
>>>
>>> But if I use 'FORMAT text' or 'FORMAT csv' all is OK.
>>>
>>> Suppose this happens because BINARY is not listed in
>>> "unreserved_keyword" neither in "col_name_keyword parser" parser rules, but
>>> listed in "type_func_name_keyword" instead.
>>
>> That seems pretty unfortunate.  Of course, it works if you quote it:
>>
>> COPY "tablename" TO STDOUT WITH (FORMAT "binary")
>>
>> I assume it's not in unreserved_keyword because it would cause a
>> shift/reduce conflict elsewhere.

RH> Yeah.  In particular, it conflicts with the ancient copy syntax which
RH> we still support for backwards compatibility with versions < 7.3.  We
RH> can fix the immediate problem with something like the attached.

This patch is ugly. Sorry, Robert, but it's true.

RH> (a) Should we do that?

RH> (b) Should we back-patch it to 9.1 and 9.0?

RH> (c) Should we consider removing compatibility with the ancient copy
RH> syntax in 9.2, and de-reserving that keyword?  (Given that the
RH> workaround is this simple, I'm inclined to say "no", but could be
RH> persuaded otherwise.)

+1 for this. Pre-7.3 syntax is dead in fact for many years.




-- 
With best wishes,
 Pavel                          mailto:pavel@gf.microolap.com




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [HACKERS] COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 15:40  Robert Haas <robertmhaas@gmail.com>
  parent: Pavel Golub <pavel@microolap.com>
  0 siblings, 2 replies; 11+ messages in thread

From: Robert Haas @ 2011-07-05 15:40 UTC (permalink / raw)
  To: Pavel Golub <pavel@gf.microolap.com>; +Cc: Alvaro Herrera <alvherre@commandprompt.com>; pgsql-bugs; PostgreSQL Hackers <pgsql-hackers@postgresql.org>

On Tue, Jul 5, 2011 at 11:37 AM, Pavel Golub <pavel@microolap.com> wrote:
> RH> Yeah.  In particular, it conflicts with the ancient copy syntax which
> RH> we still support for backwards compatibility with versions < 7.3.  We
> RH> can fix the immediate problem with something like the attached.
>
> This patch is ugly. Sorry, Robert, but it's true.

No hard feelings here.  If you, as the reporter of the problem, don't
feel that it's serious enough to warrant back-patching a fix, then I'm
not going to insist.  However, if we don't do what I've proposed here,
then I think 8.4 and 9.0 and probably 9.1 are going to need to stay as
they are, because...

> RH> (c) Should we consider removing compatibility with the ancient copy
> RH> syntax in 9.2, and de-reserving that keyword?  (Given that the
> RH> workaround is this simple, I'm inclined to say "no", but could be
> RH> persuaded otherwise.)
>
> +1 for this. Pre-7.3 syntax is dead in fact for many years.

...this is not something we're going to back-patch.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [HACKERS] COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 15:50  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Robert Haas <robertmhaas@gmail.com>
  1 sibling, 0 replies; 11+ messages in thread

From: Tom Lane @ 2011-07-05 15:50 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Pavel Golub <pavel@gf.microolap.com>; Alvaro Herrera <alvherre@commandprompt.com>; pgsql-bugs; PostgreSQL Hackers <pgsql-hackers@postgresql.org>

Robert Haas <robertmhaas@gmail.com> writes:
> ... However, if we don't do what I've proposed here,
> then I think 8.4 and 9.0 and probably 9.1 are going to need to stay as
> they are, because...

>> RH> (c) Should we consider removing compatibility with the ancient copy
>> RH> syntax in 9.2, and de-reserving that keyword?  (Given that the
>> RH> workaround is this simple, I'm inclined to say "no", but could be
>> RH> persuaded otherwise.)
>> 
>> +1 for this. Pre-7.3 syntax is dead in fact for many years.

> ...this is not something we're going to back-patch.

Given the lack of prior complaints, and the simplicity of the
double-quote workaround, I feel little need to have a back-patchable
fix.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: [HACKERS] COPY .... WITH (FORMAT binary) causes syntax error at or near "binary"
@ 2011-07-05 16:02  Pavel Golub <pavel@microolap.com>
  parent: Robert Haas <robertmhaas@gmail.com>
  1 sibling, 0 replies; 11+ messages in thread

From: Pavel Golub @ 2011-07-05 16:02 UTC (permalink / raw)
  To: Robert Haas <robertmhaas@gmail.com>; +Cc: Alvaro Herrera <alvherre@commandprompt.com>; pgsql-bugs; PostgreSQL Hackers <pgsql-hackers@postgresql.org>

Hello, Robert.

You wrote:

RH> On Tue, Jul 5, 2011 at 11:37 AM, Pavel Golub <pavel@microolap.com> wrote:
>> RH> Yeah.  In particular, it conflicts with the ancient copy syntax which
>> RH> we still support for backwards compatibility with versions < 7.3.  We
>> RH> can fix the immediate problem with something like the attached.
>>
>> This patch is ugly. Sorry, Robert, but it's true.

RH> No hard feelings here.  If you, as the reporter of the problem, don't
RH> feel that it's serious enough to warrant back-patching a fix, then I'm
RH> not going to insist.  However, if we don't do what I've proposed here,
RH> then I think 8.4 and 9.0 and probably 9.1 are going to need to stay as
RH> they are, because...

>> RH> (c) Should we consider removing compatibility with the ancient copy
>> RH> syntax in 9.2, and de-reserving that keyword?  (Given that the
>> RH> workaround is this simple, I'm inclined to say "no", but could be
>> RH> persuaded otherwise.)
>>
>> +1 for this. Pre-7.3 syntax is dead in fact for many years.

RH> ...this is not something we're going to back-patch.


Patches needed for 9.0 and 9.1 only, because this is new format
comparing with 8.x

-- 
With best wishes,
 Pavel                          mailto:pavel@gf.microolap.com




^ permalink  raw  reply  [nested|flat] 11+ messages in thread


end of thread, other threads:[~2011-07-05 16:02 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-07-05 14:52 COPY .... WITH (FORMAT binary) causes syntax error at or near "binary" Pavel Golub <pavel@microolap.com>
2011-07-05 15:06 ` Alvaro Herrera <alvherre@commandprompt.com>
2011-07-05 15:13   ` Pavel Golub <pavel@microolap.com>
2011-07-05 15:23   ` Robert Haas <robertmhaas@gmail.com>
2011-07-05 15:30     ` Tom Lane <tgl@sss.pgh.pa.us>
2011-07-05 15:34       ` Robert Haas <robertmhaas@gmail.com>
2011-07-05 15:34     ` Andrew Dunstan <andrew@dunslane.net>
2011-07-05 15:37     ` Pavel Golub <pavel@microolap.com>
2011-07-05 15:40       ` Robert Haas <robertmhaas@gmail.com>
2011-07-05 15:50         ` Tom Lane <tgl@sss.pgh.pa.us>
2011-07-05 16:02         ` Pavel Golub <pavel@microolap.com>

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