Re: Unexpected behavior of DROP VIEW/TABLE IF EXISTS - Mailing list pgsql-hackers

From Peter Moser
Subject Re: Unexpected behavior of DROP VIEW/TABLE IF EXISTS
Date
Msg-id a3d63a69-d827-ff77-b934-1271f3f6fb37@gmail.com
Whole thread Raw
In response to Re: Unexpected behavior of DROP VIEW/TABLE IF EXISTS  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
On 06/26/2018 05:34 PM, Pavel Stehule wrote:
> 2018-06-26 17:23 GMT+02:00 Peter Moser <pitiz29a@gmail.com 
> <mailto:pitiz29a@gmail.com>>:
>     What do you think, is it worth to create a patch to solve this
>     issue, where a DROP TABLE does not fail, if the given name is
>     actually a VIEW or vice-versa?
> 
> 
> DROP TABLE should to remove table and nothing else, like DROP VIEW 
> should to drop just view and nothing else. It is safeguard.

My last sentence is misleading. What I thought is:

DROP TABLE X;

Should not delete a view X, and result in an error only if table X does 
not exist. It should not look at views for error handling, maybe just as 
hint that there is a view X and we might use DROP VIEW X instead.

DROP TABLE IF EXISTS X;

Should also not delete a view X, and not result in any error if X is a 
view and not a table.

Hopefully I explained things better now.

Cheers,
Peter


pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Unexpected behavior of DROP VIEW/TABLE IF EXISTS
Next
From: Tom Lane
Date:
Subject: Re: ssl_library parameter