Re: Cascade delete views? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Cascade delete views?
Date
Msg-id 6521.969378938@sss.pgh.pa.us
Whole thread Raw
In response to Cascade delete views?  (Philip Warner <pjw@rhyme.com.au>)
Responses Re: Re: Cascade delete views?
List pgsql-hackers
Philip Warner <pjw@rhyme.com.au> writes:
>     create table test (f1 int);
>     create view v_test as select f1+1 as f11 from test;
>     drop table test;
>     create table test (f1 int);
>     select * from v_test;
>     ERROR:  has_subclass: Relation 19417 not found

> which not very helpful for the person who does not know the history, and
> leads me to believe that there may be a few issues here. 

Yes, this mistake needs to be detected earlier.  The stored view
contains both the name and the OID of the referenced table.  It should
*not* accept a new table with same name and different OID, since there's
no guarantee that the new table has anything like the same column set.
(ALTER TABLE has some issues here too...)

> Should a 'DROP TABLE' drop the views, fail, or be recoverable from by
> recreating the table?

Yes ;-).

Any of those behaviors would be better than what we have now.  However,
none of them is going to be easy to implement.  There will need to be
more info stored about views than there is now.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: odbc (was: Re: ascii to character conversion in postgres)
Next
From: Tom Lane
Date:
Subject: Re: Re: pg_dump tries to do too much per query