From c7040429e7ab19490c2e292e6b6ca01ef551b909 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Mon, 30 Aug 2004 19:44:14 +0000
Subject: [PATCH] Fix obviously-utterly-untested noTocComments code.

---
 src/bin/pg_dump/pg_backup_archiver.c | 56 ++++++++++++++--------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index a4786e4b62c..64603b6a324 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *		$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.95 2004/08/29 05:06:53 momjian Exp $
+ *		$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.96 2004/08/30 19:44:14 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2357,8 +2357,6 @@ _getObjectFromDropStmt(const char *dropStmt, const char *type)
 static void
 _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass)
 {
-	const char *pfx;
-
 	/* ACLs are dumped only during acl pass */
 	if (acl_pass)
 	{
@@ -2371,9 +2369,6 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
 			return;
 	}
 
-	if (AH->noTocComments)
-		return;
-
 	/*
 	 * Avoid dumping the public schema, as it will already be created ...
 	 * unless we are using --clean mode, in which case it's been deleted
@@ -2392,33 +2387,38 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
 		_setWithOids(AH, te);
 
 	/* Emit header comment for item */
-	if (isData)
-		pfx = "Data for ";
-	else
-		pfx = "";
-
-	ahprintf(AH, "--\n");
-	if (AH->public.verbose)
+	if (!AH->noTocComments)
 	{
-		ahprintf(AH, "-- TOC entry %d (class %u OID %u)\n",
-				 te->dumpId, te->catalogId.tableoid, te->catalogId.oid);
-		if (te->nDeps > 0)
+		const char *pfx;
+
+		if (isData)
+			pfx = "Data for ";
+		else
+			pfx = "";
+
+		ahprintf(AH, "--\n");
+		if (AH->public.verbose)
 		{
-			int			i;
+			ahprintf(AH, "-- TOC entry %d (class %u OID %u)\n",
+					 te->dumpId, te->catalogId.tableoid, te->catalogId.oid);
+			if (te->nDeps > 0)
+			{
+				int			i;
 
-			ahprintf(AH, "-- Dependencies:");
-			for (i = 0; i < te->nDeps; i++)
-				ahprintf(AH, " %d", te->dependencies[i]);
-			ahprintf(AH, "\n");
+				ahprintf(AH, "-- Dependencies:");
+				for (i = 0; i < te->nDeps; i++)
+					ahprintf(AH, " %d", te->dependencies[i]);
+				ahprintf(AH, "\n");
+			}
 		}
+		ahprintf(AH, "-- %sName: %s; Type: %s; Schema: %s; Owner: %s\n",
+				 pfx, te->tag, te->desc,
+				 te->namespace ? te->namespace : "-",
+				 te->owner);
+		if (AH->PrintExtraTocPtr != NULL)
+			(*AH->PrintExtraTocPtr) (AH, te);
+		ahprintf(AH, "--\n\n");
 	}
-	ahprintf(AH, "-- %sName: %s; Type: %s; Schema: %s; Owner: %s\n",
-			 pfx, te->tag, te->desc,
-			 te->namespace ? te->namespace : "-",
-			 te->owner);
-	if (AH->PrintExtraTocPtr !=NULL)
-		(*AH->PrintExtraTocPtr) (AH, te);
-	ahprintf(AH, "--\n\n");
 
 	/*
 	 * Actually print the definition.
-- 
GitLab