Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cAfn3-0002li-Is for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Nov 2016 16:25:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cAfn2-0002QI-Sy for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Nov 2016 16:25:24 +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.84_2) (envelope-from ) id 1cAfn1-0002Pg-KH for pgsql-hackers@postgreSQL.org; Sat, 26 Nov 2016 16:25:23 +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.84_2) (envelope-from ) id 1cAfmt-0004rV-RK for pgsql-hackers@postgreSQL.org; Sat, 26 Nov 2016 16:25:23 +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 uAQGPEjb013225 for ; Sat, 26 Nov 2016 11:25:14 -0500 From: Tom Lane To: pgsql-hackers@postgreSQL.org Subject: Wrong order of tests in findDependentObjects() MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13223.1480177514.1@sss.pgh.pa.us> Date: Sat, 26 Nov 2016 11:25:14 -0500 Message-ID: <13224.1480177514@sss.pgh.pa.us> X-Pg-Spam-Score: -4.9 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org It suddenly struck me that the problem being complained of in bug #14434 is that dependency.c's findDependentObjects() is handling extension dependencies incorrectly. It has this logic: /* * This object is part of the internal implementation of * another object, or is part of the extension that is the * other object. We have three cases: * * 1. At the outermost recursion level, we normally disallow * the DROP. (We just ereport here, rather than proceeding, * since no other dependencies are likely to be interesting.) * However, there are exceptions. */ if (stack == NULL) { /* * Exception 1a: if the owning object is listed in * pendingObjects, just release the caller's lock and * return. We'll eventually complete the DROP when we * reach that entry in the pending list. */ ... /* * Exception 1b: if the owning object is the extension * currently being created/altered, it's okay to continue * with the deletion. This allows dropping of an * extension's objects within the extension's scripts, as * well as corner cases such as dropping a transient * object created within such a script. */ ... /* No exception applies, so throw the error */ ... The bug report occurs because the sequence's extension membership pg_depend record is hit one recursion level down, so that stack!=NULL. Instead, we should rearrange this so that "exception 1b" is allowed whether or not we are at the outermost recursion level. The assumption is that the sequence creation/upgrade script knows what it's doing and should not be forced to issue manual ALTER EXTENSION DROP commands before it can do it. While looking at that, I wonder if "exception 1a" isn't wrongly placed as well. Why shouldn't we let that case occur below top level? regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers