BUG #16492: DROP VIEW IF EXISTS error

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: postgresql(dot)2020(at)t-net(dot)ruhr
Subject: BUG #16492: DROP VIEW IF EXISTS error
Date: 2020-06-12 17:47:12
Message-ID: 16492-2f002961054fd4a8@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16492
Logged by: Nina Marlow
Email address: postgresql(dot)2020(at)t-net(dot)ruhr
PostgreSQL version: 12.3
Operating system: Linux/Docker
Description:

When trying to use "DROP VIEW IF EXISTS x" while a table named "x" exists,
the DROP statement raises an "Error: x is not a view".

The documentation says about the "IF EXISTS" clause:

> Do not throw an error if the view does not exist. A notice is issued in
this case.

Imho, there shouldn't be an error if the view does not exist regardless of
whether or not a table with this name exists. The observed behavior is
contrary to the sense of the "IF EXISTS" clause as one would have to check
whether a table with the desired name exists before using "DROP VIEW IF
EXISTS". But then you could directly check whether or not the view itself
exists.

The error is, of course, absolutely correct for the "DROP VIEW" (without "IF
EXISTS") statement.

But when using "IF EXISTS", it can be a big problem if the statement is part
of a longer batch of statements because the batch operation stops on the
error.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Haas 2020-06-12 18:13:11 Re: BUG #16040: PL/PGSQL RETURN QUERY statement never uses a parallel plan
Previous Message PG Bug reporting form 2020-06-12 17:07:09 BUG #16491: PostgreSQL will not install unless a local account is used