From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Vik Fearing <vik@2ndquadrant.fr>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: denisa.cirstescu@asentinel.com, "pgsql-docs@postgresql.org" <pgsql-docs@postgresql.org>
Subject: Re: Undocumented behavior od DROP SCHEMA ... CASCADE
Date: Fri, 12 Aug 2016 18:58:32 -0400
Message-ID: <29747.1471042712@sss.pgh.pa.us> (raw)
In-Reply-To: <20160812222611.GA721702@alvherre.pgsql>
References: <20160812222611.GA721702@alvherre.pgsql>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-docs>
Alvaro Herrera <alvherre@2ndquadrant.com> 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
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 using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, david.g.johnston@gmail.com, vik@2ndquadrant.fr, peter.eisentraut@2ndquadrant.com
Subject: Re: Undocumented behavior od DROP SCHEMA ... CASCADE
In-Reply-To: <29747.1471042712@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