Re: R: feature proposal ...

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: R: feature proposal ...
Дата
Msg-id 200509222153.j8MLrif15655@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: R: feature proposal ...  (AgentM <agentm@themactionfaction.com>)
Список 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@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Jonah H. Harris"
Дата:
Сообщение: Re: Hierarchical Queries--Stalled No Longer...
Следующее
От: "Jonah H. Harris"
Дата:
Сообщение: Re: PCTFree Results