Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bYLPX-0007ZU-0o for pgsql-docs@arkaria.postgresql.org; Fri, 12 Aug 2016 22:58:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bYLPW-0000ZZ-BY for pgsql-docs@arkaria.postgresql.org; Fri, 12 Aug 2016 22:58:42 +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 1bYLPV-0000ZS-UZ for pgsql-docs@postgresql.org; Fri, 12 Aug 2016 22:58:41 +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 1bYLPS-0006kF-Rb for pgsql-docs@postgresql.org; Fri, 12 Aug 2016 22:58:41 +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 u7CMwWs6029748; Fri, 12 Aug 2016 18:58:32 -0400 From: Tom Lane To: Alvaro Herrera cc: "David G. Johnston" , Vik Fearing , Peter Eisentraut , denisa.cirstescu@asentinel.com, "pgsql-docs@postgresql.org" Subject: Re: Undocumented behavior od DROP SCHEMA ... CASCADE In-reply-to: <20160812222611.GA721702@alvherre.pgsql> References: <20160812222611.GA721702@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Fri, 12 Aug 2016 18:26:11 -0400" Date: Fri, 12 Aug 2016 18:58:32 -0400 Message-ID: <29747.1471042712@sss.pgh.pa.us> X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org Alvaro Herrera writes: > Tom Lane wrote: >> You'd need the object locks in any case, to be sure things hold still long >> enough for their dependencies to be examined. It's possible a weaker lock >> type would suffice, but I'm not sure; we generally don't require exclusive >> lock on an object to add or remove dependencies on it. > Of course, using a weak lock could run afoul of somebody changing the > dependencies underneath. But even using a stronger lock is unlikely to > give any actual protection: in UI programs (be it GUI admin programs or > psql), more likely than not many users are going to run a check in one > transaction, then run the actual drop in a different transaction. Well, obviously the output would not be authoritative about what might get dropped in a later drop attempt. But I'm thinking just about not getting "cache lookup failed" or similar failures in the function itself. Also, assuming that we did acquire full-strength locks, that would mean that if you do begin; select pg_drop_cascades_to(foo); drop foo cascade; commit; then in fact the function output WOULD be authoritative about what would get dropped in the second step. That seems like a useful property to have, even if there are lots of production scenarios where you'd not want to hold the locks long enough for a human to eyeball the list. You could imagine for instance an application quickly verifying that the SELECT result matches a previously vetted list before barging ahead with the DROP. (Right now, you can approximate that sort of "safe drop" by looking at the NOTICE output before committing --- but as you noted, that only works up to 100 dependencies.) regards, tom lane -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs