On Tue, Aug 10, 2021 at 10:57 PM Greg Sabino Mullane <htamfids@gmail.com> wrote:
>
> On Fri, Jul 16, 2021 at 9:40 AM Tom Lane <tgl@sss.pgh.pa.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.