Skip to content

Commit bd823e1

Browse files
committed
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".
1 parent ea9968c commit bd823e1

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

src/bin/pg_dump/pg_backup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.52 2009/06/11 14:49:07 momjian Exp $
18+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup.h,v 1.53 2010/05/15 21:41:16 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -96,7 +96,7 @@ typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
9696

9797
typedef struct _restoreOptions
9898
{
99-
int create; /* Issue commands to create the database */
99+
int createDB; /* Issue commands to create the database */
100100
int noOwner; /* Don't try to match original object owner */
101101
int noTablespace; /* Don't issue tablespace-related commands */
102102
int disable_triggers; /* disable triggers during data-only

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.184 2010/04/23 23:21:44 rhaas Exp $
18+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.185 2010/05/15 21:41:16 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -211,19 +211,19 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
211211
/*
212212
* Check for nonsensical option combinations.
213213
*
214-
* NB: create+dropSchema is useless because if you're creating the DB,
214+
* NB: createDB+dropSchema is useless because if you're creating the DB,
215215
* there's no need to drop individual items in it. Moreover, if we tried
216216
* to do that then we'd issue the drops in the database initially
217217
* connected to, not the one we will create, which is very bad...
218218
*/
219-
if (ropt->create && ropt->dropSchema)
219+
if (ropt->createDB && ropt->dropSchema)
220220
die_horribly(AH, modulename, "-C and -c are incompatible options\n");
221221

222222
/*
223-
* -1 is not compatible with -C, because we can't create a database inside
223+
* -C is not compatible with -1, because we can't create a database inside
224224
* a transaction block.
225225
*/
226-
if (ropt->create && ropt->single_txn)
226+
if (ropt->createDB && ropt->single_txn)
227227
die_horribly(AH, modulename, "-C and -1 are incompatible options\n");
228228

229229
/*
@@ -815,6 +815,9 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
815815

816816
ahprintf(AH, ";\n;\n; Selected TOC Entries:\n;\n");
817817

818+
/* We should print DATABASE entries whether or not -C was specified */
819+
ropt->createDB = 1;
820+
818821
for (te = AH->toc->next; te != AH->toc; te = te->next)
819822
{
820823
if (ropt->verbose || _tocEntryRequired(te, ropt, true) != 0)
@@ -2257,7 +2260,7 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt, bool include_acls)
22572260
return 0;
22582261

22592262
/* Ignore DATABASE entry unless we should create it */
2260-
if (!ropt->create && strcmp(te->desc, "DATABASE") == 0)
2263+
if (!ropt->createDB && strcmp(te->desc, "DATABASE") == 0)
22612264
return 0;
22622265

22632266
/* Check options for selective dump/restore */

src/bin/pg_dump/pg_dump.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* http://archives.postgresql.org/pgsql-bugs/2010-02/msg00187.php
2626
*
2727
* IDENTIFICATION
28-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.579 2010/03/18 20:00:51 petere Exp $
28+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.580 2010/05/15 21:41:16 tgl Exp $
2929
*
3030
*-------------------------------------------------------------------------
3131
*/
@@ -243,7 +243,7 @@ main(int argc, char **argv)
243243
int compressLevel = -1;
244244
int plainText = 0;
245245
int outputClean = 0;
246-
int outputCreate = 0;
246+
int outputCreateDB = 0;
247247
bool outputBlobs = false;
248248
int outputNoOwner = 0;
249249
char *outputSuperuser = NULL;
@@ -352,7 +352,7 @@ main(int argc, char **argv)
352352
break;
353353

354354
case 'C': /* Create DB */
355-
outputCreate = 1;
355+
outputCreateDB = 1;
356356
break;
357357

358358
case 'E': /* Dump encoding */
@@ -766,7 +766,7 @@ main(int argc, char **argv)
766766
ropt->dropSchema = outputClean;
767767
ropt->aclsSkip = aclsSkip;
768768
ropt->superuser = outputSuperuser;
769-
ropt->create = outputCreate;
769+
ropt->createDB = outputCreateDB;
770770
ropt->noOwner = outputNoOwner;
771771
ropt->noTablespace = outputNoTablespaces;
772772
ropt->disable_triggers = disable_triggers;

src/bin/pg_dump/pg_restore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*
3636
* IDENTIFICATION
37-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.101 2009/11/19 22:05:48 petere Exp $
37+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_restore.c,v 1.102 2010/05/15 21:41:16 tgl Exp $
3838
*
3939
*-------------------------------------------------------------------------
4040
*/
@@ -154,7 +154,7 @@ main(int argc, char **argv)
154154
opts->dropSchema = 1;
155155
break;
156156
case 'C':
157-
opts->create = 1;
157+
opts->createDB = 1;
158158
break;
159159
case 'd':
160160
opts->dbname = strdup(optarg);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy