Re: "COPY foo FROM STDOUT" and ecpg - Mailing list pgsql-hackers

From Greg Stark
Subject Re: "COPY foo FROM STDOUT" and ecpg
Date
Msg-id CAM-w4HOimm1PSm0QzLygzV4+Xs=M2_mBFS=dGAMT2XbOjpHrFA@mail.gmail.com
Whole thread Raw
In response to Re: "COPY foo FROM STDOUT" and ecpg  (Heikki Linnakangas <hlinnakangas@vmware.com>)
List pgsql-hackers
On Tue, Feb 26, 2013 at 4:34 PM, Heikki Linnakangas
<hlinnakangas@vmware.com> wrote:
> No. All four combinations of FROM/TO and STDIN/STDOUT are accepted:
...
> postgres=# copy foo to stdin;
> foo
> bar
> postgres=# copy foo to stdout;
> foo
> bar

Hm, so STDIN/STDOUT are just noise words and psql uses stdin for input
and stdout for output regardless of what's specified? That seems a bit
odd. I would have expected to be able to do something like

cat > script.sql
copy foo to stdin;
copy bar to stdout;
^D
psql -f script.sql 0>/tmp/foo.data 1>/tmp/bar.data

But then I haven't heard any clamoring of demand for such a feature.
And if there was it would make sense to implement "copy foo to fd X"
and then make stdin an alias for "fd 0" rather than only support two
file descriptors. It wouldn't make sense to expend all that effort
just to support writing to just stdin.

-- 
greg



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_xlogdump
Next
From: Dimitri Fontaine
Date:
Subject: Re: pg_xlogdump