Re: bug report: pg_dump does not use CASCADE in DROP - Mailing list pgsql-bugs

From Tom Lane
Subject Re: bug report: pg_dump does not use CASCADE in DROP
Date
Msg-id 2664.1062260752@sss.pgh.pa.us
Whole thread Raw
In response to Re: bug report: pg_dump does not use CASCADE in DROP  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: bug report: pg_dump does not use CASCADE in DROP  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-bugs
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Should we be using CASCADE?  Seems that is going to double-drop some
> tables.

It kinda scares me too.  If you are loading into a database that already
has stuff in it, seems like CASCADE could lead to dropping stuff that is
not part of the dataset being loaded.

If you have no stuff in the database that is not part of the dataset
being loaded, then there's no percentage in individual DROP commands
anyway --- you'd be better off to drop the whole DB, create a new one,
and run the restore without any DROPs.  So AFAICS the use of DROP in
restores is intended for reloading part of an existing database.
As such, automatic DROP CASCADEs seem like an excellent foot-gun.
Much safer to do the required drops manually before running restore.

It might be okay as an option in pg_restore, but not as default
behavior.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: bug report: pg_dump does not use CASCADE in DROP
Next
From: Bruce Momjian
Date:
Subject: Re: bug report: pg_dump does not use CASCADE in DROP