Re: Add option --drop-cascade for pg_dump/restore

From: Wu Haotian <whtsky(at)gmail(dot)com>
To: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, vignesh C <vignesh21(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add option --drop-cascade for pg_dump/restore
Date: 2021-08-11 03:15:00
Message-ID: CADHB_-BURg8XXZ_XvO5UzN2WMBPpDcQ0QdJaMaXb_Mx8DO3Xag@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 10, 2021 at 10:57 PM Greg Sabino Mullane <htamfids(at)gmail(dot)com> wrote:
>
> On Fri, Jul 16, 2021 at 9:40 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>
>> That would require pg_restore to try to edit the DROP commands during
>> restore, which sounds horribly fragile. I'm inclined to think that
>> supporting this option only during initial dump is safer.
>
>
> Safer, but not nearly as useful. Maybe see what the OP (Wu Haotian) can come up with as a first implementation?
>
> Cheers,
> Greg
>

pg_restore already tries to edit the DROP commands during restore in
order to support `--if-exists`.

> supporting this option only during initial dump is safer.

pg_dump & pg_restores use the same function to inject `IF EXISTS` (
and `DROP .. CASCADE` in this patch`).
Supporting this option only during pg_dump may not make it safer, as
the logic is the same.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message 孙诗浩 (思才) 2021-08-11 03:27:23 use-regular-expressions-to-simplify-less_greater-and-not_equals.patch
Previous Message Andrew Dunstan 2021-08-11 02:33:50 Re: Postgres perl module namespace