From 34a45d8172fb36790523b90a6d7ee238d4adbf8b Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Tue, 30 Aug 2016 12:00:00 -0400
Subject: [PATCH 09/27] Rename some typedefs to avoid name conflicts

C++ does not like that in struct _archiveHandle some of the fields have
the same name as a typedef.  This changes the meaning of the typedef in
the scope of the struct, causing warnings and possibly other problems.

Rename the types so they have names distinct from the struct fields.
---
 src/bin/pg_dump/pg_backup.h          |   4 +-
 src/bin/pg_dump/pg_backup_archiver.c |  10 +--
 src/bin/pg_dump/pg_backup_archiver.h | 114 +++++++++++++++++------------------
 3 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 4afa92f..dac8383 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -221,7 +221,7 @@ typedef int DumpId;
 
 typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
 
-typedef void (*SetupWorkerPtr) (Archive *AH);
+typedef void (*SetupWorkerPtrType) (Archive *AH);
 
 /*
  * Main archiver interface.
@@ -268,7 +268,7 @@ extern Archive *OpenArchive(const char *FileSpec, const ArchiveFormat fmt);
 /* Create a new archive */
 extern Archive *CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
 			  const int compression, ArchiveMode mode,
-			  SetupWorkerPtr setupDumpWorker);
+			  SetupWorkerPtrType setupDumpWorker);
 
 /* The --list option */
 extern void PrintTOCSummary(Archive *AH);
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 05bdbdb..5a0c1fb 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -56,7 +56,7 @@ static const char *modulename = gettext_noop("archiver");
 
 
 static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
-	 const int compression, ArchiveMode mode, SetupWorkerPtr setupWorkerPtr);
+	 const int compression, ArchiveMode mode, SetupWorkerPtrType setupWorkerPtr);
 static void _getObjectDescription(PQExpBuffer buf, TocEntry *te,
 					  ArchiveHandle *AH);
 static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData, bool acl_pass);
@@ -197,7 +197,7 @@ setupRestoreWorker(Archive *AHX)
 /* Public */
 Archive *
 CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
-	 const int compression, ArchiveMode mode, SetupWorkerPtr setupDumpWorker)
+	 const int compression, ArchiveMode mode, SetupWorkerPtrType setupDumpWorker)
 
 {
 	ArchiveHandle *AH = _allocAH(FileSpec, fmt, compression, mode, setupDumpWorker);
@@ -2217,7 +2217,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
  */
 static ArchiveHandle *
 _allocAH(const char *FileSpec, const ArchiveFormat fmt,
-	  const int compression, ArchiveMode mode, SetupWorkerPtr setupWorkerPtr)
+	  const int compression, ArchiveMode mode, SetupWorkerPtrType setupWorkerPtr)
 {
 	ArchiveHandle *AH;
 
@@ -2371,8 +2371,8 @@ WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
 void
 WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
 {
-	StartDataPtr startPtr;
-	EndDataPtr	endPtr;
+	StartDataPtrType startPtr;
+	EndDataPtrType	endPtr;
 
 	AH->currToc = te;
 
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index 0376f2b..b33793f 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -136,40 +136,40 @@ typedef enum T_Action
 	ACT_RESTORE
 } T_Action;
 
-typedef void (*ClosePtr) (ArchiveHandle *AH);
-typedef void (*ReopenPtr) (ArchiveHandle *AH);
-typedef void (*ArchiveEntryPtr) (ArchiveHandle *AH, TocEntry *te);
-
-typedef void (*StartDataPtr) (ArchiveHandle *AH, TocEntry *te);
-typedef void (*WriteDataPtr) (ArchiveHandle *AH, const void *data, size_t dLen);
-typedef void (*EndDataPtr) (ArchiveHandle *AH, TocEntry *te);
-
-typedef void (*StartBlobsPtr) (ArchiveHandle *AH, TocEntry *te);
-typedef void (*StartBlobPtr) (ArchiveHandle *AH, TocEntry *te, Oid oid);
-typedef void (*EndBlobPtr) (ArchiveHandle *AH, TocEntry *te, Oid oid);
-typedef void (*EndBlobsPtr) (ArchiveHandle *AH, TocEntry *te);
-
-typedef int (*WriteBytePtr) (ArchiveHandle *AH, const int i);
-typedef int (*ReadBytePtr) (ArchiveHandle *AH);
-typedef void (*WriteBufPtr) (ArchiveHandle *AH, const void *c, size_t len);
-typedef void (*ReadBufPtr) (ArchiveHandle *AH, void *buf, size_t len);
-typedef void (*SaveArchivePtr) (ArchiveHandle *AH);
-typedef void (*WriteExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
-typedef void (*ReadExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
-typedef void (*PrintExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
-typedef void (*PrintTocDataPtr) (ArchiveHandle *AH, TocEntry *te);
-
-typedef void (*ClonePtr) (ArchiveHandle *AH);
-typedef void (*DeClonePtr) (ArchiveHandle *AH);
-
-typedef char *(*WorkerJobRestorePtr) (ArchiveHandle *AH, TocEntry *te);
-typedef char *(*WorkerJobDumpPtr) (ArchiveHandle *AH, TocEntry *te);
-typedef char *(*MasterStartParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
+typedef void (*ClosePtrType) (ArchiveHandle *AH);
+typedef void (*ReopenPtrType) (ArchiveHandle *AH);
+typedef void (*ArchiveEntryPtrType) (ArchiveHandle *AH, TocEntry *te);
+
+typedef void (*StartDataPtrType) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*WriteDataPtrType) (ArchiveHandle *AH, const void *data, size_t dLen);
+typedef void (*EndDataPtrType) (ArchiveHandle *AH, TocEntry *te);
+
+typedef void (*StartBlobsPtrType) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*StartBlobPtrType) (ArchiveHandle *AH, TocEntry *te, Oid oid);
+typedef void (*EndBlobPtrType) (ArchiveHandle *AH, TocEntry *te, Oid oid);
+typedef void (*EndBlobsPtrType) (ArchiveHandle *AH, TocEntry *te);
+
+typedef int (*WriteBytePtrType) (ArchiveHandle *AH, const int i);
+typedef int (*ReadBytePtrType) (ArchiveHandle *AH);
+typedef void (*WriteBufPtrType) (ArchiveHandle *AH, const void *c, size_t len);
+typedef void (*ReadBufPtrType) (ArchiveHandle *AH, void *buf, size_t len);
+typedef void (*SaveArchivePtrType) (ArchiveHandle *AH);
+typedef void (*WriteExtraTocPtrType) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*ReadExtraTocPtrType) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*PrintExtraTocPtrType) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*PrintTocDataPtrType) (ArchiveHandle *AH, TocEntry *te);
+
+typedef void (*ClonePtrType) (ArchiveHandle *AH);
+typedef void (*DeClonePtrType) (ArchiveHandle *AH);
+
+typedef char *(*WorkerJobRestorePtrType) (ArchiveHandle *AH, TocEntry *te);
+typedef char *(*WorkerJobDumpPtrType) (ArchiveHandle *AH, TocEntry *te);
+typedef char *(*MasterStartParallelItemPtrType) (ArchiveHandle *AH, TocEntry *te,
 														 T_Action act);
-typedef int (*MasterEndParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
+typedef int (*MasterEndParallelItemPtrType) (ArchiveHandle *AH, TocEntry *te,
 											  const char *str, T_Action act);
 
-typedef size_t (*CustomOutPtr) (ArchiveHandle *AH, const void *buf, size_t len);
+typedef size_t (*CustomOutPtrType) (ArchiveHandle *AH, const void *buf, size_t len);
 
 typedef enum
 {
@@ -242,42 +242,42 @@ struct _archiveHandle
 	size_t		lookaheadLen;	/* Length of data in lookahead */
 	pgoff_t		lookaheadPos;	/* Current read position in lookahead buffer */
 
-	ArchiveEntryPtr ArchiveEntryPtr;	/* Called for each metadata object */
-	StartDataPtr StartDataPtr;	/* Called when table data is about to be
+	ArchiveEntryPtrType ArchiveEntryPtr;	/* Called for each metadata object */
+	StartDataPtrType StartDataPtr;	/* Called when table data is about to be
 								 * dumped */
-	WriteDataPtr WriteDataPtr;	/* Called to send some table data to the
+	WriteDataPtrType WriteDataPtr;	/* Called to send some table data to the
 								 * archive */
-	EndDataPtr EndDataPtr;		/* Called when table data dump is finished */
-	WriteBytePtr WriteBytePtr;	/* Write a byte to output */
-	ReadBytePtr ReadBytePtr;	/* Read a byte from an archive */
-	WriteBufPtr WriteBufPtr;	/* Write a buffer of output to the archive */
-	ReadBufPtr ReadBufPtr;		/* Read a buffer of input from the archive */
-	ClosePtr ClosePtr;			/* Close the archive */
-	ReopenPtr ReopenPtr;		/* Reopen the archive */
-	WriteExtraTocPtr WriteExtraTocPtr;	/* Write extra TOC entry data
+	EndDataPtrType EndDataPtr;		/* Called when table data dump is finished */
+	WriteBytePtrType WriteBytePtr;	/* Write a byte to output */
+	ReadBytePtrType ReadBytePtr;	/* Read a byte from an archive */
+	WriteBufPtrType WriteBufPtr;	/* Write a buffer of output to the archive */
+	ReadBufPtrType ReadBufPtr;		/* Read a buffer of input from the archive */
+	ClosePtrType ClosePtr;			/* Close the archive */
+	ReopenPtrType ReopenPtr;		/* Reopen the archive */
+	WriteExtraTocPtrType WriteExtraTocPtr;	/* Write extra TOC entry data
 										 * associated with the current archive
 										 * format */
-	ReadExtraTocPtr ReadExtraTocPtr;	/* Read extr info associated with
+	ReadExtraTocPtrType ReadExtraTocPtr;	/* Read extr info associated with
 										 * archie format */
-	PrintExtraTocPtr PrintExtraTocPtr;	/* Extra TOC info for format */
-	PrintTocDataPtr PrintTocDataPtr;
+	PrintExtraTocPtrType PrintExtraTocPtr;	/* Extra TOC info for format */
+	PrintTocDataPtrType PrintTocDataPtr;
 
-	StartBlobsPtr StartBlobsPtr;
-	EndBlobsPtr EndBlobsPtr;
-	StartBlobPtr StartBlobPtr;
-	EndBlobPtr EndBlobPtr;
+	StartBlobsPtrType StartBlobsPtr;
+	EndBlobsPtrType EndBlobsPtr;
+	StartBlobPtrType StartBlobPtr;
+	EndBlobPtrType EndBlobPtr;
 
-	MasterStartParallelItemPtr MasterStartParallelItemPtr;
-	MasterEndParallelItemPtr MasterEndParallelItemPtr;
+	MasterStartParallelItemPtrType MasterStartParallelItemPtr;
+	MasterEndParallelItemPtrType MasterEndParallelItemPtr;
 
-	SetupWorkerPtr SetupWorkerPtr;
-	WorkerJobDumpPtr WorkerJobDumpPtr;
-	WorkerJobRestorePtr WorkerJobRestorePtr;
+	SetupWorkerPtrType SetupWorkerPtr;
+	WorkerJobDumpPtrType WorkerJobDumpPtr;
+	WorkerJobRestorePtrType WorkerJobRestorePtr;
 
-	ClonePtr ClonePtr;			/* Clone format-specific fields */
-	DeClonePtr DeClonePtr;		/* Clean up cloned fields */
+	ClonePtrType ClonePtr;			/* Clone format-specific fields */
+	DeClonePtrType DeClonePtr;		/* Clean up cloned fields */
 
-	CustomOutPtr CustomOutPtr;	/* Alternative script output routine */
+	CustomOutPtrType CustomOutPtr;	/* Alternative script output routine */
 
 	/* Stuff for direct DB connection */
 	char	   *archdbname;		/* DB name *read* from archive */
-- 
2.9.3

