Re: Unexpected behavior of DROP VIEW/TABLE IF EXISTS

From: Peter Moser <pitiz29a(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unexpected behavior of DROP VIEW/TABLE IF EXISTS
Date: 2018-06-26 15:46:50
Message-ID: a3d63a69-d827-ff77-b934-1271f3f6fb37@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 06/26/2018 05:34 PM, Pavel Stehule wrote:
> 2018-06-26 17:23 GMT+02:00 Peter Moser <pitiz29a(at)gmail(dot)com
> <mailto:pitiz29a(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-06-26 15:48:40 Re: ssl_library parameter
Previous Message Pavel Stehule 2018-06-26 15:34:33 Re: Unexpected behavior of DROP VIEW/TABLE IF EXISTS