v16_misc.nocfbot

application/octet-stream

Filename: v16_misc.nocfbot
Type: application/octet-stream
Part: 0
Message: Re: Non-text mode for pg_dumpall
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 32d645728a..1dfa0420ea 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -2934,13 +2934,13 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
 
 	/*
 	 * DATABASE and DATABASE PROPERTIES also have a special rule: they are
-	 * restored in createDB mode or restored format is not plain file, and not
-	 * restored otherwise, independently of all else.
+	 * restored in createDB mode, and not restored otherwise, independently of
+	 * all else.
 	 */
 	if (strcmp(te->desc, "DATABASE") == 0 ||
 		strcmp(te->desc, "DATABASE PROPERTIES") == 0)
 	{
-		if (ropt->createDB || AH->format != archNull)
+		if (ropt->createDB)
 			return REQ_SCHEMA;
 		else
 			return 0;
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index af7d815a77..2d3ae14f75 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -1090,8 +1090,11 @@ restoreAllDatabases(PGconn *conn, const char *dumpdirpath,
 	 * To restore multiple databases, -C (create database) option should be specified
 	 * or all databases should be created before pg_restore.
 	 */
-	if (opts->createDB != 1)
-		pg_log_info("restoring dump of pg_dumpall without -C option, there might be multiple databases in directory.");
+	if (num_db_restore > 1 && opts->createDB != 1)
+	{
+		pg_log_info("restoring multiple databases without -C option, implicit -C is assumed");
+		opts->createDB = 1;
+	}
 
 	/* TODO: MAX_ON_EXIT_NICELY is 100 now... max AH handle register on exit .*/
 	if (num_db_restore > MAX_ON_EXIT_NICELY)
@@ -1144,7 +1147,10 @@ restoreAllDatabases(PGconn *conn, const char *dumpdirpath,
 
 		pg_log_info("restoring database \"%s\"", dboid_cell->db_name);
 
-		dbexit_code = restoreOneDatabase(subdirpath, opts, numWorkers, true, dboid_cell->db_name);
+		if (num_db_restore == 1)
+			dbexit_code = restoreOneDatabase(subdirpath, opts, numWorkers, false, dboid_cell->db_name);
+		else
+			dbexit_code = restoreOneDatabase(subdirpath, opts, numWorkers, true, dboid_cell->db_name);
 
 		/* Store exit_code to report it back. */
 		if (exit_code == 0 && dbexit_code != 0)