pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Terence Zekveld <Terence.Zekveld@eoh.com>
Cc: Merlin Moncure <mmoncure@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #15384: dropping views and materialized views
Date: Fri, 14 Sep 2018 10:41:56 -0400
Message-ID: <19411.1536936116@sss.pgh.pa.us> (raw)
In-Reply-To: <VI1PR05MB5005A0FE1292B4C026A56C77F8190@VI1PR05MB5005.eurprd05.prod.outlook.com>
References: <153691803945.22350.17400062274182452899@wrigleys.postgresql.org>
	<CAHyXU0x_eAZU3wV-5AmxYYbyxXzzKYAyGF05GtcwSjUsdWgNyA@mail.gmail.com>
	<VI1PR05MB5005A0FE1292B4C026A56C77F8190@VI1PR05MB5005.eurprd05.prod.outlook.com>

Terence Zekveld <Terence.Zekveld@eoh.com> writes:
>> But either the 1st or the 2nd DROP functions throw an error, either
>> "theschema.theviewname is not a view" or "theschema.theviewname is not a
>> materialized view".
>> I would think these errors are not relevant when using the "IF EXISTS"
>> option, i.e. it should execute both, 'skipping' the one that refers to the
>> incorrect type of view...

We've discussed this before, but the current policy is that IF [NOT]
EXISTS are narrowly read as applying only to object-does-not-exist
or object-already-exists errors.  They're not "get out of jail free"
cards.  If you start opening that up, you get into all sorts of
squishy questions; for instance, should a permissions failure become
a non-error?

In the particular case of DROP IF EXISTS, there's a good rationale for
treating doesn't-exist specially: the state after the command is the same
whether the object was there or not, so it's reasonable to consider
doesn't-exist as success rather than an error condition.  This does not
hold when the problem is there's-an-object-but-it's-the-wrong-type; then,
that object is still blocking creation of a new object by that name.

I think a more reasonable way to attack this would be, not to make IF
EXISTS more permissive, but to have a distinct command type that's
specifically defined as not caring about the relkind, perhaps
DROP RELATION.  v11's DROP ROUTINE is a precedent ...

			regards, tom lane




view thread (5+ messages)  latest in thread

Message-ID: <19411.1536936116@sss.pgh.pa.us>
Permalink:  ../19411.1536936116@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/19411.1536936116@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Terence.Zekveld@eoh.com, mmoncure@gmail.com
  Subject: Re: BUG #15384: dropping views and materialized views
  In-Reply-To: <19411.1536936116@sss.pgh.pa.us>
  References: <153691803945.22350.17400062274182452899@wrigleys.postgresql.org> <CAHyXU0x_eAZU3wV-5AmxYYbyxXzzKYAyGF05GtcwSjUsdWgNyA@mail.gmail.com> <VI1PR05MB5005A0FE1292B4C026A56C77F8190@VI1PR05MB5005.eurprd05.prod.outlook.com> <19411.1536936116@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox