Re: [PATCHES] Current-stream read for psql's \copy - Mailing list pgsql-hackers

From Richard Huxton
Subject Re: [PATCHES] Current-stream read for psql's \copy
Date
Msg-id 40A9D2B8.2060403@archonet.com
Whole thread Raw
In response to Re: [PATCHES] Current-stream read for psql's \copy  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian wrote:
> Also, I came upon this gem:
> 
>     $ echo '\\copy test to stdout' | psql -o /tmp/z test
>     444
>     444
>     444
>     444
>     444
> 
> Seems 'copy to stdout' also has this split idea of sending \copy output
> to a different place from other output.
> 
> I guess my big question now is why someone would use \copy stdin/stdout
> for reading input from the command stream when they can use COPY?

I think the idea was that you could have a program that does something 
like (Perl):

my $fh = open('| psql -f commands.sql');
print $fh "1\ta\n";

Where commands.sql contains the \copy.

I'm not saying that was the original intention, but someone pointed out 
you could do things that way, and I can see it might (rarely) be useful.

--   Richard Huxton  Archonet Ltd


pgsql-hackers by date:

Previous
From: Marko Karppinen
Date:
Subject: Re: Call for 7.5 feature completion
Next
From: Richard Huxton
Date:
Subject: Re: Call for 7.5 feature completion