1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-20 05:03:10 +03:00

Ensure that pg_restore -l will output DATABASE entries whether or not -C

is specified.  Per bug report from Russell Smith and ensuing discussion.
Since this is a corner case behavioral change, I'm going to be conservative
and not back-patch it.

In passing, also rename the RestoreOptions field for the -C switch to
something less generic than "create".
This commit is contained in:
Tom Lane
2010-05-15 21:41:16 +00:00
parent ea9968c331
commit bd823e11fa
4 changed files with 17 additions and 14 deletions

View File

@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.184 2010/04/23 23:21:44 rhaas Exp $
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.185 2010/05/15 21:41:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -211,19 +211,19 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
/*
* Check for nonsensical option combinations.
*
* NB: create+dropSchema is useless because if you're creating the DB,
* NB: createDB+dropSchema is useless because if you're creating the DB,
* there's no need to drop individual items in it. Moreover, if we tried
* to do that then we'd issue the drops in the database initially
* connected to, not the one we will create, which is very bad...
*/
if (ropt->create && ropt->dropSchema)
if (ropt->createDB && ropt->dropSchema)
die_horribly(AH, modulename, "-C and -c are incompatible options\n");
/*
* -1 is not compatible with -C, because we can't create a database inside
* -C is not compatible with -1, because we can't create a database inside
* a transaction block.
*/
if (ropt->create && ropt->single_txn)
if (ropt->createDB && ropt->single_txn)
die_horribly(AH, modulename, "-C and -1 are incompatible options\n");
/*
@ -815,6 +815,9 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
ahprintf(AH, ";\n;\n; Selected TOC Entries:\n;\n");
/* We should print DATABASE entries whether or not -C was specified */
ropt->createDB = 1;
for (te = AH->toc->next; te != AH->toc; te = te->next)
{
if (ropt->verbose || _tocEntryRequired(te, ropt, true) != 0)
@ -2257,7 +2260,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
return 0;
/* Ignore DATABASE entry unless we should create it */
if (!ropt->create && strcmp(te->desc, "DATABASE") == 0)
if (!ropt->createDB && strcmp(te->desc, "DATABASE") == 0)
return 0;
/* Check options for selective dump/restore */