Re: "COPY foo FROM STDOUT" and ecpg

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: "COPY foo FROM STDOUT" and ecpg
Date: 2013-02-26 16:34:30
Message-ID: 512CE416.5080503@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 26.02.2013 18:23, Tom Lane wrote:
> Heikki Linnakangas<hlinnakangas(at)vmware(dot)com> writes:
>> While looking at Fujita Etsuro's patch to allow copy to/from a shell
>> command, I noticed that the grammar currently allows these:
>
>> COPY foo FROM STDOUT
>> COPY foo TO STDIN
>
>> In other words, STDIN and STDOUT can be used completely interchangeably.
>> However, the ecpg grammar is more strict about that:
>
>> ERROR: COPY TO STDIN is not possible
>
>> Any particular reason for ecpg to check that, while the backend doesn't
>> care? I think we should just remove those checks from the ecpg grammar.
>
> Agreed, but your draft patch doesn't do that completely. It should only
> make tests that correspond to what the error message says.

Sorry, I don't understand what you're saying. Can you elaborate?

> (I assume
> the backend will bounce the other cases at some post-grammar stage.)

No. All four combinations of FROM/TO and STDIN/STDOUT are accepted:

postgres=# copy foo from stdin;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> foo
>> \.
postgres=# copy foo from stdout;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
>> bar
>> \.
postgres=# copy foo to stdin;
foo
bar
postgres=# copy foo to stdout;
foo
bar

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2013-02-26 16:36:23 Re: pg_xlogdump compile error
Previous Message Tom Lane 2013-02-26 16:33:48 Re: pg_xlogdump