From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | Peter Moser <pitiz29a(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Unexpected behavior of DROP VIEW/TABLE IF EXISTS |
Date: | 2018-06-26 15:48:43 |
Message-ID: | CAKFQuwbzQ9u_pkuvgBJqLrH8LkM_NDRV6Exaxmhx6H9qZtmwjQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tuesday, June 26, 2018, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> 2018-06-26 17:23 GMT+02:00 Peter Moser <pitiz29a(at)gmail(dot)com>:
>
>> Hi,
>> I want to delete a table X, that may not exist, hence I execute
>>
>> DROP TABLE IF EXISTS X;
>>
>> However, if X is a view, I get an error
>>
>> ERROR: "X" is not a table
>>
> HINT: Use DROP VIEW to remove a view.
>> SQL state: 42809
>>
>> That is unexpected and also difficult to handle
>>
>
> DROP TABLE should to remove table and nothing else, like DROP VIEW should
> to drop just view and nothing else. It is safeguard.
>
Peter isn't asking for drop table to drop a view though, he's asking for
the documented behavior:
"Do not throw an error if the table does not exist. A notice is issued in
this case."
There is no Table named X in the database so the command should be a noop
with a notice. I would concur, though I'm open to just fixing it in v12
and back patching a documentation bug fix stating the exception due to
relations sharing a namespace but there be lacking a corresponding shared
namespace "drop relation" command.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2018-06-26 15:53:53 | Re: "wal receiver" process hang in syslog() while exiting after receiving SIGTERM while the postgres has been promoted. |
Previous Message | Tom Lane | 2018-06-26 15:48:40 | Re: ssl_library parameter |