Re: BUG #18287: pg_restore with -C and -c options does not do what is said in the documentation

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: loic(dot)seguin(at)hotmail(dot)fr, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18287: pg_restore with -C and -c options does not do what is said in the documentation
Date: 2024-01-12 15:31:06
Message-ID: CAKFQuwaiTpUq4LL+yQgqmjs5orRLa84-XRXDQSH8H=Jfm5Pd=w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Jan 12, 2024 at 7:44 AM PG Bug reporting form <
noreply(at)postgresql(dot)org> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 18287
> Logged by: Loic Seguin
> Email address: loic(dot)seguin(at)hotmail(dot)fr
> PostgreSQL version: 14.0
> Operating system: Ubuntu
> Description:
>

> When this option is used, the database named with -d is used only to issue
> the initial DROP DATABASE and CREATE DATABASE commands. All data is
> restored
> into the database name that appears in the archive."
>
> If you analyze the log above you can see that the database that is dropped
> is not the one used after the -d option but the one in the dump file.
>
> So I think it is an error in the description of the option -C no ?
>
> Or maybe I don't understand maybe the description but it also says above
> "If --clean is also specified, drop and recreate the target database before
> connecting to it."
>
> It is clearly stated "target" here not the source database.
>
>
"used to issue" means that it is the database being connected to in order
to execute SQL. Per the final sentence, the database name that appears in
those SQL commands is the one in the source file. Which furthermore makes
sense as you cannot drop a database to which you are connected.

If you don't want the name of the restored database to match the name of
the source database you don't specify --create .

I can see an argument for -d mentioning the different usage of the database
name when --create is specified. I can kinda see not requiring the mental
leap that because the data is restored into the database named in the
source that the cleaned and created database name must likewise be the one
in the source. IOW, there is no bug here but I can appreciate that the
existing wording could be a challenge to interpret. Now that you know how
it works do you have a suggestion for improving the wording?

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Jonathan S. Katz 2024-01-12 16:19:08 Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends
Previous Message Tom Lane 2024-01-12 14:59:39 Re: BUG #18284: Filter in left lateral join not respected