Re: There should be a way to use the force flag when restoring databases

From: Ahmed Ibrahim <ahmed(dot)ibr(dot)hashim(at)gmail(dot)com>
To: Gurjeet Singh <gurjeet(at)singh(dot)im>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, Joan <aseques(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: There should be a way to use the force flag when restoring databases
Date: 2023-07-23 13:08:53
Message-ID: CAHiW8tzg0cZ2Y8mp+nHLnF4_cmNOLCwt+wajFBFBZZx0KW6ZxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi everyone,

I have been working on this. This is a proposed patch for it so we have a
force option for DROPping the database.

I'd appreciate it if anyone can review.

On Thu, Jul 20, 2023 at 9:36 PM Gurjeet Singh <gurjeet(at)singh(dot)im> wrote:

> On Thu, Jul 20, 2023 at 2:10 AM Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
> >
> > > On 19 Jul 2023, at 19:28, Gurjeet Singh <gurjeet(at)singh(dot)im> wrote:
> > >
> > > The docs for 'pg_restore --create` say "Create the database before
> > > restoring into it. If --clean is also specified, drop and recreate the
> > > target database before connecting to it."
> > >
> > > If we provided a force option, it may then additionally say: "If the
> > > --clean and --force options are specified, DROP DATABASE ... WITH
> > > FORCE command will be used to drop the database."
> >
> > pg_restore --clean refers to dropping any pre-existing database objects
> and not
> > just databases, but --force would only apply to databases.
> >
> > I wonder if it's worth complicating pg_restore with that when running
> dropdb
> > --force before pg_restore is an option for those wanting to use WITH
> FORCE.
>
> Fair point. But the same argument could've been applied to --clean
> option, as well; why overload the meaning of --clean and make it drop
> database, when a dropdb before pg_restore was an option.
>
> IMHO, if pg_restore offers to drop database, providing an option to
> the user to do it forcibly is not that much of a stretch, and within
> reason for the user to expect it to be there, like Joan did.
>
> Best regards,
> Gurjeet
> http://Gurje.et
>
>
>

Attachment Content-Type Size
force.patch text/x-patch 2.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Luzanov 2023-07-23 18:28:46 multiple membership grants and information_schema.applicable_roles
Previous Message Anton A. Melnikov 2023-07-23 12:20:21 Re: Making Vars outer-join aware