Re: "COPY foo FROM STDOUT" and ecpg

From: Greg Stark <stark(at)mit(dot)edu>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: "COPY foo FROM STDOUT" and ecpg
Date: 2013-02-26 16:45:50
Message-ID: CAM-w4HOimm1PSm0QzLygzV4+Xs=M2_mBFS=dGAMT2XbOjpHrFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 26, 2013 at 4:34 PM, Heikki Linnakangas
<hlinnakangas(at)vmware(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2013-02-26 16:50:08 Re: pg_xlogdump
Previous Message Tom Lane 2013-02-26 16:45:38 Re: pg_xlogdump