COPY and views

Started by Neil Conwayover 23 years ago2 messages
#1Neil Conway
nconway@klamath.dyndns.org

Is there a reason for the following behavior?

nconway=# create table a (col1 int);
CREATE TABLE
nconway=# insert into a default values;
INSERT 1883513 1
nconway=# copy a to '/tmp/output';
COPY
nconway=# create view myview as select * from a;
CREATE VIEW
nconway=# copy myview to '/tmp/output';
ERROR: You cannot copy view myview

I can understand not allowing COPY FROM to target a view
(or at least, a view without an insertion rule defined) --
but is there a similar reason for disallowing copying data
out of a view?

Cheers,

Neil

--
Neil Conway <neilconway@rogers.com>
PGP Key ID: DB3C29FC

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Neil Conway (#1)
Re: COPY and views

Neil Conway <nconway@klamath.dyndns.org> writes:

I can understand not allowing COPY FROM to target a view
(or at least, a view without an insertion rule defined) --
but is there a similar reason for disallowing copying data
out of a view?

Allowing either would take COPY out of the realm of utility statements
and into the realm of plannable queries --- in particular, COPY from a
view would have to have full SELECT capability, with only a slightly
different user interface for delivering the tuples.

This would not necessarily be a bad idea ... but it would be a major
rewrite of COPY.

regards, tom lane