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

Sun, 26 May 2002 02:32:01 -0400
Neil Conway <nconway@klamath.dyndns.org>
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

Sun, 26 May 2002 11:37:37 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: COPY and views 