Re: R: feature proposal ...

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: AgentM <agentm(at)themactionfaction(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: R: feature proposal ...
Date: 2005-09-22 21:53:44
Message-ID: 200509222153.j8MLrif15655@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

AgentM wrote:
> >
> > While I'm all for COPY from views, I think I'd rather have the
> > syntactic
> > warts than code warts. ISTM that
> >
> > CREATE TEMP VIEW some_name AS SELECT * FROM table WHERE ...;
> > COPY some_name TO stdout;
> >
> > is much uglier than
> >
> > COPY SELECT * FROM table WHERE ... TO stdout;
>
> Or, you could just allow subqueries in COPY to disambiguate the syntax:
>
> COPY (SELECT * FROM table WHERE i=1) TO stdout;

This is one area where I think Informix did a better job than us, though
we inherited COPY so I don't think we can fault the community.

In Informix, LOAD is linked to INSERT, and UNLOAD to SELECT, so you do:

LOAD FROM '/datafile' [optional flags]
INSERT INTO tab [optional columns]

and UNLOAD is:

UNLOAD TO '/datafile' [optional flags]
SELECT * FROM tab

where the SELECT can use a column list, where clause, joins, etc.

We could adopt something similar with COPY

COPY FROM '/datafile' [optional flags]
INSERT INTO tab [optional columns]

COPY TO '/datafile' [optional flags]
SELECT * FROM tab

and internally use the non-executor COPY code for a simple
INSERT/SELECT, and use the view/executor for more complex cases.

--
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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonah H. Harris 2005-09-22 22:03:31 Re: PCTFree Results
Previous Message Jonah H. Harris 2005-09-22 21:37:51 Re: Hierarchical Queries--Stalled No Longer...