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

From David G. Johnston
Subject Re: BUG #18287: pg_restore with -C and -c options does not do what is said in the documentation
Date
Msg-id CAKFQuwaiTpUq4LL+yQgqmjs5orRLa84-XRXDQSH8H=Jfm5Pd=w@mail.gmail.com
Whole thread Raw
In response to BUG #18287: pg_restore with -C and -c options does not do what is said in the documentation  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
On Fri, Jan 12, 2024 at 7:44 AM PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:

Bug reference:      18287
Logged by:          Loic Seguin
Email address:      loic.seguin@hotmail.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.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18284: Filter in left lateral join not respected
Next
From: "Jonathan S. Katz"
Date:
Subject: Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends