Re: DROP CASCADE transitive dependencies

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: C GG <cgg0007(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: DROP CASCADE transitive dependencies
Date: 2018-12-03 18:26:26
Message-ID: 2493.1543861586@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

C GG <cgg0007(at)gmail(dot)com> writes:
> ...PostgreSQL 9.5...
> `DROP SCHEMA blah;` reports all the dependent objects and advises to `DROP
> SCHEMA blah CASCADE;` ...

> Will DROP ... CASCADE traverse the entire dependency tree for each of the
> dependent objects (potentially dropping something unintended), or will it
> stop at the first level and balk at any new transitive dependencies?

The former. However, the list of dependencies it's showing you as
potentially dropped already includes transitive dependencies; there
aren't going to be "new" ones unless somebody is adding things
concurrently.

If you're feeling paranoid, you could always do

begin;
drop ... cascade;

and then look at the reported list of objects before deciding whether
to commit or roll back.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message C GG 2018-12-03 19:07:31 Re: DROP CASCADE transitive dependencies
Previous Message Stephen Frost 2018-12-03 18:15:49 Re: Query never completes with an OR condition