Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0pIf-0007FJ-Uv for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Sep 2018 14:42:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g0pId-0001M7-5u for pgsql-bugs@arkaria.postgresql.org; Fri, 14 Sep 2018 14:42:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0pIT-0000YM-0T for pgsql-bugs@lists.postgresql.org; Fri, 14 Sep 2018 14:42:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0pIP-0002jc-HN for pgsql-bugs@lists.postgresql.org; Fri, 14 Sep 2018 14:42:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w8EEfuhR019412; Fri, 14 Sep 2018 10:41:56 -0400 From: Tom Lane To: Terence Zekveld cc: Merlin Moncure , "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #15384: dropping views and materialized views In-reply-to: References: <153691803945.22350.17400062274182452899@wrigleys.postgresql.org> Comments: In-reply-to Terence Zekveld message dated "Fri, 14 Sep 2018 14:07:15 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19410.1536936116.1@sss.pgh.pa.us> Date: Fri, 14 Sep 2018 10:41:56 -0400 Message-ID: <19411.1536936116@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Terence Zekveld 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