Re: stdin/stdout mismatch for COPY and \copy

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: mfeit+postgresql(at)notonthe(dot)net, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: stdin/stdout mismatch for COPY and \copy
Date: 2004-04-10 15:30:13
Message-ID: 200404101530.i3AFUDs09700@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Tom Lane wrote:
> >> What is "command output" and how does that differ from stdout?
>
> > In this case, stdout is going to psql's stdout, not to the command
> > stdout.
>
> Hm, I didn't realize it worked like that. So "command output" means
> "where SELECT output would go"? Is that what happens to COPY TO STDOUT?
> (experiments ... I guess so.)
>
> > I thought pstdin/pstdout were very clear in helping folks remember how
> > it is different from stdin/stdout.
>
> Fair enough. If we need two flavors of stdout too, then I agree that
> names are better than "-".

OK, the attached patch implements pstdin and pstdout, and change stdin
and stdout for \copy to be the same as COPY. Using this file:

drop table test;
create table test (x int);
insert into test values (1);
\copy test from stdin

I get for stdin:

$ psql -f /tmp/x -o /dev/null test

for pstdin:

$ psql -f /tmp/x -o /dev/null test
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
test> 33
test> \.

for stdout:

$ psql -f /tmp/x -o /dev/null test

for pstdout:

$ psql -f /tmp/x -o /dev/null test
1

This breaks backward compatibility and has to be mentioned in the
release notes.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 5.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-04-10 17:59:31 Re: PostgreSQL configuration
Previous Message pgsql 2004-04-10 14:40:53 Re: PostgreSQL configuration

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2004-04-10 16:24:23 COPY for CSV documentation
Previous Message Andrew Dunstan 2004-04-10 12:43:25 Re: pg_restore ignore error patch