Unexpected behavior of DROP VIEW/TABLE IF EXISTS

Поиск
Список
Период
Сортировка
От Peter Moser
Тема Unexpected behavior of DROP VIEW/TABLE IF EXISTS
Дата
Msg-id c4877222-f329-0b6e-e15a-65a41d177bc7@gmail.com
обсуждение исходный текст
Ответы Re: Unexpected behavior of DROP VIEW/TABLE IF EXISTS  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers
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, if I want to be sure 
that I can delete all old tables *and* views called X, and create a new
view for instance with

    CREATE VIEW X AS ....

I cannot do that safely, because having both DROP commands would for 
sure cause an error and therefore a rollback.

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?

Best regards,
Peter


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Thinko/typo in ExecSimpleRelationInsert
Следующее
От: Charles Cui
Дата:
Сообщение: Re: [GSoC] working status