Re: [HACKERS] Refactor handling of database attributes betweenpg_dump and pg_dumpall - Mailing list pgsql-hackers

From Haribabu Kommi
Subject Re: [HACKERS] Refactor handling of database attributes betweenpg_dump and pg_dumpall
Date
Msg-id CAJrrPGeijs7bG6pyPwdyaQp2Q32BidnDL0H-tKmS6nZ_B3jSgA@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] Refactor handling of database attributes betweenpg_dump and pg_dumpall  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: [HACKERS] Refactor handling of database attributes betweenpg_dump and pg_dumpall
List pgsql-hackers


On Sun, Oct 22, 2017 at 3:08 AM, Robert Haas <robertmhaas@gmail.com> wrote:
On Sat, Oct 21, 2017 at 1:30 AM, Haribabu Kommi
<kommi.haribabu@gmail.com> wrote:
> Before refactoring, pg_dumpall doesn't print "create database" commands
> for both tempalte1 and postgres database, but on the other hand pg_dump
> dump the create database commands with --create option.
>
> To keep the behavior of all the database attributes in the dump of both
> pg_dump and pg_dumpall, the code is unified and moved into pg_dump.
> But to retain the pg_dumpall behavior of not dumping the "create database"
> commands, a new option is added to pg_dump to skip dumping the
> create database commands.
>
> The new option name is now "--skip-create-default-db", this can be used
> normal user also when try to dump the postgres database to not let create
> the database commands in the dump.

I don't get this at all.  If you don't want to create the database,
just don't pass the -C argument.  It doesn't make sense to have a -C
argument which makes it create the database and then a
--skip-create-default-db argument which makes it sometimes not create
the database after all.

Apologies for not providing much details.

pg_dumpall is used to produce the following statements for database,

"Create database" (other than default database) or
"Alter database set tablespace" for default database (if required)

ACL queries related to database
Alter database config
Alter database role config

whereas, pg_dump used to produce only "create database statement".

With the refactoring, all the pg_dumpall database statements are moved
into pg_dump. -C/--create option of pg_dump produces all the statements
of pg_dumpall. The --skip-default-create-db option is to make sure that 
it doesn't produce "Create database" statement and instead may produce
"Alter database set tablespace" for default databases of (postgres and template1).

-C/--create option is to control the entire database statements.
--skip-create-default-db is option to control the "create" or "Alter" database statement
for default database.

During restore the dump, the -C/--create restores all the Database statements.

comments? or any better approach?

Regards,
Hari Babu
Fujitsu Australia

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] legitimacy of using PG_TRY , PG_CATCH , PG_END_TRY in C function
Next
From: Rajkumar Raghuwanshi
Date:
Subject: Re: [HACKERS] path toward faster partition pruning