Re: Undocumented behavior od DROP SCHEMA ... CASCADE

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Vik Fearing <vik(at)2ndquadrant(dot)fr>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, denisa(dot)cirstescu(at)asentinel(dot)com, "pgsql-docs(at)postgresql(dot)org" <pgsql-docs(at)postgresql(dot)org>
Subject: Re: Undocumented behavior od DROP SCHEMA ... CASCADE
Date: 2016-08-12 13:16:22
Message-ID: CAKFQuwZNS9YHs4xxgY3TEfHYP9fZjgsmuDn0+dLvD29k76=-sA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Fri, Aug 12, 2016 at 8:54 AM, Vik Fearing <vik(at)2ndquadrant(dot)fr> wrote:

> On 12/08/16 14:47, Peter Eisentraut wrote:
> > On 8/5/16 6:48 AM, denisa(dot)cirstescu(at)asentinel(dot)com wrote:
> >> Page: https://www.postgresql.org/docs/9.5/static/sql-dropschema.html
> >> Description:
> >>
> >> DROP SCHEMA ... CASCADE has a behavior that has not been documented.
> >> According to the documentation: &quot;CASCADE - Automatically drop
> objects
> >> (tables, functions, etc.) that are contained in the schema.&quot;.
> >> Well, besides this, DROP SCHEMA ... CASCADE also drops all the views
> which
> >> depends on the schema that is being dropped. It does not matter if the
> views
> >> are in the public schema or another schema than the one being dropped,
> they
> >> are deleted.
> >
> > Can you give an example?
>
> vik=# create schema a create table t (id int);
> CREATE SCHEMA
> vik=# create schema b create view v as select * from a.t;
> CREATE SCHEMA
> vik=# drop schema a cascade;
> NOTICE: drop cascades to 2 other objects
> DETAIL: drop cascades to table a.t
> drop cascades to view b.v
> DROP SCHEMA
>
> I think the OP is complaining that cascading to b.v is not sufficiently
> documented. It seems logical to me that this would be the correct
> behavior, but since at least one person got confused enough about it to
> come and tell us, we should probably add some kind of warning or something.
>

​Yeah, it should probably be modified to something like:

Automatically drop objects (tables, functions, etc...) that are contained
in the schema. Each object dropped is also done with the CASCADE option.
This means that others schemas will be affected if they depend on objects
in the named schema.

David J.​

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2016-08-12 14:01:44 Re: Undocumented behavior od DROP SCHEMA ... CASCADE
Previous Message Vik Fearing 2016-08-12 12:54:44 Re: Undocumented behavior od DROP SCHEMA ... CASCADE