Re: bug report: pg_dump does not use CASCADE in DROP

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Preston Landers <planders(at)journyx(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: bug report: pg_dump does not use CASCADE in DROP
Date: 2003-08-30 16:41:26
Message-ID: 200308301641.h7UGfQ412819@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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.

Once pg_dump starts using the dependency information, it seems it could
do the drops in the proper order, and when it detects
mutually-dependent tables, it can use a single DROP CASCADE to remove
them all --- seems like that is a TODO.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2003-08-30 16:51:43 Re: True64 Unix v5.1 - postgresql-7.2.4 compilation problem
Previous Message Tom Lane 2003-08-30 16:25:52 Re: bug report: pg_dump does not use CASCADE in DROP