DROP VIEW name WITHOUT TYPE

Started by Przemysław Sztochabout 1 year ago3 messages
#1Przemysław Sztoch
przemyslaw@sztoch.pl

Is it possible to extend DROP VIEW command:

DROP VIEW [ IF EXISTS ]/|name|/ [, ...] [ CASCADE | RESTRICT | WITHOUT TYPE]

I want to allow to DROP VIEW if any objects depend on it.

Am I right, If we leave (or convert) TYPE linked to VIEW, then DROP will be possible?

--
Przemysław Sztoch | Mobile +48 509 99 00 66

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Przemysław Sztoch (#1)
Re: DROP VIEW name WITHOUT TYPE

On Fri, Nov 8, 2024 at 7:51 AM Przemysław Sztoch <przemyslaw@sztoch.pl>
wrote:

Is it possible to extend DROP VIEW command:

DROP VIEW [ IF EXISTS ] *name* [, ...] [ CASCADE | RESTRICT | WITHOUT TYPE]

I want to allow to DROP VIEW if any objects depend on it.

Am I right, If we leave (or convert) TYPE linked to VIEW, then DROP will be possible?

No...you can't write "select * from type_name" and that is going to be the
most common kind of dependency you have to deal with.

David J.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Przemysław Sztoch (#1)
Re: DROP VIEW name WITHOUT TYPE

=?UTF-8?Q?Przemys=C5=82aw_Sztoch?= <przemyslaw@sztoch.pl> writes:

Am I right, If we leave (or convert) TYPE linked to VIEW, then DROP will be possible?

No ...

CREATE VIEW level1 AS SELECT * FROM base_table;
CREATE VIEW level2 AS SELECT * FROM level1;

You can't drop level1 without dropping level2; the composite type
associated with level1 doesn't enter into that. I'd actually
find it rather surprising if there are many real-world cases where
other objects have a dependency on a view's composite type but not
on the view itself.

regards, tom lane