PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16492
PG Version12.3
OSLinux/Docker
Opened2020-06-12 17:47:12+00
Reported byNina Marlow
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16492
Logged by:          Nina Marlow
Email address:      (redacted)
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.

Messages

DateAuthorSubject
2020-06-12 17:47:12+00PG Bug reporting formBUG #16492: DROP VIEW IF EXISTS error
2020-06-12 19:43:19+00"David G(dot) Johnston"Re: BUG #16492: DROP VIEW IF EXISTS error
2020-06-12 20:19:29+00Pavel StehuleRe: BUG #16492: DROP VIEW IF EXISTS error
2020-06-12 20:34:40+00"David G(dot) Johnston"Re: BUG #16492: DROP VIEW IF EXISTS error
2020-06-12 21:15:55+00Pavel StehuleRe: BUG #16492: DROP VIEW IF EXISTS error
2020-06-12 21:41:33+00"David G(dot) Johnston"Re: BUG #16492: DROP VIEW IF EXISTS error
2020-06-13 11:06:33+00Nina MarlowRe: BUG #16492: DROP VIEW IF EXISTS error
2020-06-14 10:51:58+00Pavel StehuleRe: BUG #16492: DROP VIEW IF EXISTS error
2020-06-14 16:19:36+00"David G(dot) Johnston"Re: BUG #16492: DROP VIEW IF EXISTS error
2020-06-14 17:12:15+00Tom LaneRe: BUG #16492: DROP VIEW IF EXISTS error
2020-06-14 18:12:05+00"David G(dot) Johnston"Re: BUG #16492: DROP VIEW IF EXISTS error
2020-06-14 19:04:07+00"David G(dot) Johnston"BUG #16492: DROP VIEW IF EXISTS error
2020-06-15 01:45:28+00Nina MarlowRe: BUG #16492: DROP VIEW IF EXISTS error
2020-06-15 07:16:50+00Pavel StehuleRe: BUG #16492: DROP VIEW IF EXISTS error
2020-06-15 14:45:19+00"David G(dot) Johnston"Re: BUG #16492: DROP VIEW IF EXISTS error
2020-06-15 15:05:35+00Pavel StehuleRe: BUG #16492: DROP VIEW IF EXISTS error
2020-06-15 16:18:00+00"David G(dot) Johnston"Re: BUG #16492: DROP VIEW IF EXISTS error