commit b044ed612c51be47124974d0d2d5cab7f41cdab3
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date:   Wed Oct 8 14:57:38 2014 -0300

    pg_dump_structs.h

diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h
index b387aa1..a6a2d65 100644
--- a/src/bin/pg_dump/dumputils.h
+++ b/src/bin/pg_dump/dumputils.h
@@ -19,17 +19,7 @@
 #include "libpq-fe.h"
 #include "pqexpbuffer.h"
 
-typedef struct SimpleStringListCell
-{
-	struct SimpleStringListCell *next;
-	char		val[1];			/* VARIABLE LENGTH FIELD */
-} SimpleStringListCell;
-
-typedef struct SimpleStringList
-{
-	SimpleStringListCell *head;
-	SimpleStringListCell *tail;
-} SimpleStringList;
+#include "pg_dump_structs.h"
 
 
 extern int	quote_all_identifiers;
diff --git a/src/bin/pg_dump/parallel.h b/src/bin/pg_dump/parallel.h
index 81a823d..744c76b 100644
--- a/src/bin/pg_dump/parallel.h
+++ b/src/bin/pg_dump/parallel.h
@@ -19,10 +19,7 @@
 #ifndef PG_DUMP_PARALLEL_H
 #define PG_DUMP_PARALLEL_H
 
-#include "pg_backup_db.h"
-
-struct _archiveHandle;
-struct _tocEntry;
+#include "pg_backup_archiver.h"
 
 typedef enum
 {
@@ -35,8 +32,8 @@ typedef enum
 /* Arguments needed for a worker process */
 typedef struct ParallelArgs
 {
-	struct _archiveHandle *AH;
-	struct _tocEntry *te;
+	ArchiveHandle	*AH;
+	TocEntry *te;
 } ParallelArgs;
 
 /* State for each parallel activity slot */
@@ -74,20 +71,20 @@ extern void init_parallel_dump_utils(void);
 
 extern int	GetIdleWorker(ParallelState *pstate);
 extern bool IsEveryWorkerIdle(ParallelState *pstate);
-extern void ListenToWorkers(struct _archiveHandle * AH, ParallelState *pstate, bool do_wait);
+extern void ListenToWorkers(ArchiveHandle *AH, ParallelState *pstate, bool do_wait);
 extern int	ReapWorkerStatus(ParallelState *pstate, int *status);
-extern void EnsureIdleWorker(struct _archiveHandle * AH, ParallelState *pstate);
-extern void EnsureWorkersFinished(struct _archiveHandle * AH, ParallelState *pstate);
+extern void EnsureIdleWorker(ArchiveHandle *AH, ParallelState *pstate);
+extern void EnsureWorkersFinished(ArchiveHandle *AH, ParallelState *pstate);
 
-extern ParallelState *ParallelBackupStart(struct _archiveHandle * AH,
+extern ParallelState *ParallelBackupStart(ArchiveHandle *AH,
 					DumpOptions *dopt,
 					RestoreOptions *ropt);
-extern void DispatchJobForTocEntry(struct _archiveHandle * AH,
+extern void DispatchJobForTocEntry(ArchiveHandle *AH,
 					   ParallelState *pstate,
-					   struct _tocEntry * te, T_Action act);
-extern void ParallelBackupEnd(struct _archiveHandle * AH, ParallelState *pstate);
+					   TocEntry *te, T_Action act);
+extern void ParallelBackupEnd(ArchiveHandle *AH, ParallelState *pstate);
 
-extern void checkAborting(struct _archiveHandle * AH);
+extern void checkAborting(ArchiveHandle *AH);
 
 extern void
 exit_horribly(const char *modulename, const char *fmt,...)
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 915cd50..664a7cc 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -25,11 +25,35 @@
 
 #include "postgres_fe.h"
 
-#include "pg_dump.h"
+#include "pg_dump_structs.h"
 #include "dumputils.h"
 
 #include "libpq-fe.h"
 
+/*
+ * pg_dump uses two different mechanisms for identifying database objects:
+ *
+ * CatalogId represents an object by the tableoid and oid of its defining
+ * entry in the system catalogs.  We need this to interpret pg_depend entries,
+ * for instance.
+ *
+ * DumpId is a simple sequential integer counter assigned as dumpable objects
+ * are identified during a pg_dump run.  We use DumpId internally in preference
+ * to CatalogId for two reasons: it's more compact, and we can assign DumpIds
+ * to "objects" that don't have a separate CatalogId.  For example, it is
+ * convenient to consider a table, its data, and its ACL as three separate
+ * dumpable "objects" with distinct DumpIds --- this lets us reason about the
+ * order in which to dump these things.
+ */
+
+typedef struct
+{
+	Oid			tableoid;
+	Oid			oid;
+} CatalogId;
+
+typedef int DumpId;
+
 
 #define atooid(x)  ((Oid) strtoul((x), NULL, 10))
 #define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ?  1 : 0) )
@@ -38,167 +62,6 @@
 #define oidge(x,y) ( (x) >= (y) )
 #define oidzero(x) ( (x) == 0 )
 
-enum trivalue
-{
-	TRI_DEFAULT,
-	TRI_NO,
-	TRI_YES
-};
-
-typedef enum _archiveFormat
-{
-	archUnknown = 0,
-	archCustom = 1,
-	archTar = 3,
-	archNull = 4,
-	archDirectory = 5
-} ArchiveFormat;
-
-typedef enum _archiveMode
-{
-	archModeAppend,
-	archModeWrite,
-	archModeRead
-} ArchiveMode;
-
-typedef enum _teSection
-{
-	SECTION_NONE = 1,			/* COMMENTs, ACLs, etc; can be anywhere */
-	SECTION_PRE_DATA,			/* stuff to be processed before data */
-	SECTION_DATA,				/* TABLE DATA, BLOBS, BLOB COMMENTS */
-	SECTION_POST_DATA			/* stuff to be processed after data */
-} teSection;
-
-/*
- *	We may want to have some more user-readable data, but in the mean
- *	time this gives us some abstraction and type checking.
- */
-struct Archive
-{
-	int			verbose;
-	char	   *remoteVersionStr;		/* server's version string */
-	int			remoteVersion;	/* same in numeric form */
-
-	int			minRemoteVersion;		/* allowable range */
-	int			maxRemoteVersion;
-
-	int			numWorkers;		/* number of parallel processes */
-	char	   *sync_snapshot_id;		/* sync snapshot id for parallel
-										 * operation */
-
-	/* info needed for string escaping */
-	int			encoding;		/* libpq code for client_encoding */
-	bool		std_strings;	/* standard_conforming_strings */
-	char	   *use_role;		/* Issue SET ROLE to this */
-
-	/* error handling */
-	bool		exit_on_error;	/* whether to exit on SQL errors... */
-	int			n_errors;		/* number of errors (if no die) */
-
-	/* The rest is private */
-};
-
-typedef struct _restoreOptions
-{
-	int			createDB;		/* Issue commands to create the database */
-	int			noOwner;		/* Don't try to match original object owner */
-	int			noTablespace;	/* Don't issue tablespace-related commands */
-	int			disable_triggers;		/* disable triggers during data-only
-										 * restore */
-	int			use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
-								 * instead of OWNER TO */
-	char	   *superuser;		/* Username to use as superuser */
-	char	   *use_role;		/* Issue SET ROLE to this */
-	int			dropSchema;
-	int			disable_dollar_quoting;
-	int			dump_inserts;
-	int			column_inserts;
-	int			if_exists;
-	int			no_security_labels;		/* Skip security label entries */
-
-	const char *filename;
-	int			dataOnly;
-	int			schemaOnly;
-	int			dumpSections;
-	int			verbose;
-	int			aclsSkip;
-	const char *lockWaitTimeout;
-	int			include_everything;
-
-	int			tocSummary;
-	char	   *tocFile;
-	int			format;
-	char	   *formatName;
-
-	int			selTypes;
-	int			selIndex;
-	int			selFunction;
-	int			selTrigger;
-	int			selTable;
-	SimpleStringList indexNames;
-	SimpleStringList functionNames;
-	SimpleStringList schemaNames;
-	SimpleStringList triggerNames;
-	SimpleStringList tableNames;
-
-	int			useDB;
-	char	   *dbname;
-	char	   *pgport;
-	char	   *pghost;
-	char	   *username;
-	int			noDataForFailedTables;
-	enum trivalue promptPassword;
-	int			exit_on_error;
-	int			compression;
-	int			suppressDumpWarnings;	/* Suppress output of WARNING entries
-										 * to stderr */
-	bool		single_txn;
-
-	bool	   *idWanted;		/* array showing which dump IDs to emit */
-	int			enable_row_security;
-} RestoreOptions;
-
-typedef struct _dumpOptions
-{
-	const char *dbname;
-	const char *pghost;
-	const char *pgport;
-	const char *username;
-	bool		oids;
-
-	int			binary_upgrade;
-
-	/* various user-settable parameters */
-	bool		schemaOnly;
-	bool		dataOnly;
-	int			dumpSections;	/* bitmask of chosen sections */
-	bool		aclsSkip;
-	const char *lockWaitTimeout;
-
-	/* flags for various command-line long options */
-	int			disable_dollar_quoting;
-	int			dump_inserts;
-	int			column_inserts;
-	int			if_exists;
-	int			no_security_labels;
-	int			no_synchronized_snapshots;
-	int			no_unlogged_table_data;
-	int			serializable_deferrable;
-	int			quote_all_identifiers;
-	int			disable_triggers;
-	int			outputNoTablespaces;
-	int			use_setsessauth;
-	int			enable_row_security;
-
-	/* default, if no "inclusion" switches appear, is to dump everything */
-	bool		include_everything;
-
-	int			outputClean;
-	int			outputCreateDB;
-	bool		outputBlobs;
-	int			outputNoOwner;
-	char	   *outputSuperuser;
-} DumpOptions;
 
 typedef int (*DataDumperPtr) (Archive *AH, DumpOptions *dopt, void *userArg);
 
@@ -213,7 +76,7 @@ extern void ConnectDatabase(Archive *AH,
 				const char *pghost,
 				const char *pgport,
 				const char *username,
-				enum trivalue prompt_password);
+				trivalue prompt_password);
 extern void DisconnectDatabase(Archive *AHX);
 extern PGconn *GetConnection(Archive *AHX);
 
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index 2dac52c..59c7721 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -29,6 +29,7 @@
 
 #include <time.h>
 
+#include "pg_dump.h"
 #include "pg_backup.h"
 
 #include "libpq-fe.h"
@@ -111,9 +112,8 @@ typedef z_stream *z_streamp;
 #define WORKER_INHIBIT_DATA			  11
 #define WORKER_IGNORED_ERRORS		  12
 
-struct _archiveHandle;
-struct _tocEntry;
-struct _restoreList;
+typedef struct _archiveHandle ArchiveHandle;
+typedef struct _tocEntry TocEntry;
 struct ParallelArgs;
 struct ParallelState;
 
@@ -139,40 +139,40 @@ typedef enum T_Action
 	ACT_RESTORE
 } T_Action;
 
-typedef void (*ClosePtr) (struct _archiveHandle * AH, DumpOptions *dopt);
-typedef void (*ReopenPtr) (struct _archiveHandle * AH);
-typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+typedef void (*ClosePtr) (ArchiveHandle *AH, DumpOptions *dopt);
+typedef void (*ReopenPtr) (ArchiveHandle *AH);
+typedef void (*ArchiveEntryPtr) (ArchiveHandle *AH, TocEntry *te);
 
-typedef void (*StartDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*WriteDataPtr) (struct _archiveHandle * AH, const void *data, size_t dLen);
-typedef void (*EndDataPtr) (struct _archiveHandle * AH, struct _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) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*StartBlobPtr) (struct _archiveHandle * AH, struct _tocEntry * te, Oid oid);
-typedef void (*EndBlobPtr) (struct _archiveHandle * AH, struct _tocEntry * te, Oid oid);
-typedef void (*EndBlobsPtr) (struct _archiveHandle * AH, struct _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) (struct _archiveHandle * AH, const int i);
-typedef int (*ReadBytePtr) (struct _archiveHandle * AH);
-typedef void (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, size_t len);
-typedef void (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, size_t len);
-typedef void (*SaveArchivePtr) (struct _archiveHandle * AH);
-typedef void (*WriteExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*ReadExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*PrintExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*PrintTocDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te, RestoreOptions *ropt);
+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, RestoreOptions *ropt);
 
-typedef void (*ClonePtr) (struct _archiveHandle * AH);
-typedef void (*DeClonePtr) (struct _archiveHandle * AH);
+typedef void (*ClonePtr) (ArchiveHandle *AH);
+typedef void (*DeClonePtr) (ArchiveHandle *AH);
 
-typedef char *(*WorkerJobRestorePtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef char *(*WorkerJobDumpPtr) (struct _archiveHandle * AH, DumpOptions *dopt, struct _tocEntry * te);
-typedef char *(*MasterStartParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
+typedef char *(*WorkerJobRestorePtr) (ArchiveHandle *AH, TocEntry *te);
+typedef char *(*WorkerJobDumpPtr) (ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te);
+typedef char *(*MasterStartParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
 														 T_Action act);
-typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
+typedef int (*MasterEndParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
 											  const char *str, T_Action act);
 
-typedef size_t (*CustomOutPtr) (struct _archiveHandle * AH, const void *buf, size_t len);
+typedef size_t (*CustomOutPtr) (ArchiveHandle *AH, const void *buf, size_t len);
 
 typedef enum
 {
@@ -210,7 +210,7 @@ typedef enum
 	REQ_SPECIAL = 0x04			/* for special TOC entries */
 } teReqs;
 
-typedef struct _archiveHandle
+struct _archiveHandle
 {
 	Archive		public;			/* Public part of archive */
 	char		vmaj;			/* Version of file */
@@ -284,7 +284,7 @@ typedef struct _archiveHandle
 
 	/* Stuff for direct DB connection */
 	char	   *archdbname;		/* DB name *read* from archive */
-	enum trivalue promptPassword;
+	trivalue	promptPassword;
 	char	   *savedPassword;	/* password for ropt->username, if known */
 	char	   *use_role;
 	PGconn	   *connection;
@@ -336,9 +336,9 @@ typedef struct _archiveHandle
 	ArchiverStage lastErrorStage;
 	struct _tocEntry *currentTE;
 	struct _tocEntry *lastErrorTE;
-} ArchiveHandle;
+};
 
-typedef struct _tocEntry
+struct _tocEntry
 {
 	struct _tocEntry *prev;
 	struct _tocEntry *next;
@@ -376,7 +376,7 @@ typedef struct _tocEntry
 	int			nRevDeps;		/* number of such dependencies */
 	DumpId	   *lockDeps;		/* dumpIds of objects this one needs lock on */
 	int			nLockDeps;		/* number of such dependencies */
-} TocEntry;
+};
 
 extern int	parallel_restore(struct ParallelArgs *args);
 extern void on_exit_close_archive(Archive *AHX);
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c
index 4d1d14f..85bf92c 100644
--- a/src/bin/pg_dump/pg_backup_db.c
+++ b/src/bin/pg_dump/pg_backup_db.c
@@ -217,7 +217,7 @@ ConnectDatabase(Archive *AHX,
 				const char *pghost,
 				const char *pgport,
 				const char *username,
-				enum trivalue prompt_password)
+				trivalue prompt_password)
 {
 	ArchiveHandle *AH = (ArchiveHandle *) AHX;
 	char	   *password = AH->savedPassword;
diff --git a/src/bin/pg_dump/pg_backup_db.h b/src/bin/pg_dump/pg_backup_db.h
index 2eea1c3..26eaa4e 100644
--- a/src/bin/pg_dump/pg_backup_db.h
+++ b/src/bin/pg_dump/pg_backup_db.h
@@ -16,7 +16,7 @@ extern void ExecuteSqlStatement(Archive *AHX, const char *query);
 extern PGresult *ExecuteSqlQuery(Archive *AHX, const char *query,
 				ExecStatusType status);
 
-extern void EndDBCopyMode(ArchiveHandle *AH, struct _tocEntry * te);
+extern void EndDBCopyMode(ArchiveHandle *AH, TocEntry *te);
 
 extern void StartTransaction(ArchiveHandle *AH);
 extern void CommitTransaction(ArchiveHandle *AH);
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 7240ee3..53a1254 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -81,6 +81,14 @@ typedef struct
 	int			objsubid;		/* subobject (table column #) */
 } SecLabelItem;
 
+typedef enum OidOptions
+{
+	zeroAsOpaque = 1,
+	zeroAsAny = 2,
+	zeroAsStar = 4,
+	zeroAsNone = 8
+} OidOptions;
+
 /* global decls */
 bool		g_verbose;			/* User wants verbose narration of our
 								 * activities. */
@@ -265,7 +273,7 @@ main(int argc, char **argv)
 	const char *dumpencoding = NULL;
 	char	   *use_role = NULL;
 	int			numWorkers = 1;
-	enum trivalue prompt_password = TRI_DEFAULT;
+	trivalue	prompt_password = TRI_DEFAULT;
 	int			compressLevel = -1;
 	int			plainText = 0;
 	ArchiveFormat archiveFormat = archUnknown;
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index e81c390..72a12f7 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -16,47 +16,8 @@
 
 #include "postgres_fe.h"
 
-/*
- * pg_dump uses two different mechanisms for identifying database objects:
- *
- * CatalogId represents an object by the tableoid and oid of its defining
- * entry in the system catalogs.  We need this to interpret pg_depend entries,
- * for instance.
- *
- * DumpId is a simple sequential integer counter assigned as dumpable objects
- * are identified during a pg_dump run.  We use DumpId internally in preference
- * to CatalogId for two reasons: it's more compact, and we can assign DumpIds
- * to "objects" that don't have a separate CatalogId.  For example, it is
- * convenient to consider a table, its data, and its ACL as three separate
- * dumpable "objects" with distinct DumpIds --- this lets us reason about the
- * order in which to dump these things.
- */
-
-typedef struct
-{
-	Oid			tableoid;
-	Oid			oid;
-} CatalogId;
-
-typedef int DumpId;
-
-/*
- * Data structures for simple lists of OIDs and strings.  The support for
- * these is very primitive compared to the backend's List facilities, but
- * it's all we need in pg_dump.
- */
-
-typedef struct SimpleOidListCell
-{
-	struct SimpleOidListCell *next;
-	Oid			val;
-} SimpleOidListCell;
-
-typedef struct SimpleOidList
-{
-	SimpleOidListCell *head;
-	SimpleOidListCell *tail;
-} SimpleOidList;
+#include "pg_backup.h"
+#include "pg_dump_structs.h"
 
 
 /*
@@ -519,20 +480,7 @@ extern char g_opaque_type[10];	/* name for the opaque type */
  *	common utility functions
  */
 
-struct Archive;
-typedef struct Archive Archive;
-
-struct _dumpOptions;
-
-extern TableInfo *getSchemaData(Archive *, struct _dumpOptions * dopt, int *numTablesPtr);
-
-typedef enum _OidOptions
-{
-	zeroAsOpaque = 1,
-	zeroAsAny = 2,
-	zeroAsStar = 4,
-	zeroAsNone = 8
-} OidOptions;
+extern TableInfo *getSchemaData(Archive *, DumpOptions *dopt, int *numTablesPtr);
 
 extern void AssignDumpId(DumpableObject *dobj);
 extern DumpId createDumpId(void);
@@ -566,16 +514,16 @@ extern void sortDataAndIndexObjectsBySize(DumpableObject **objs, int numObjs);
  * version specific routines
  */
 extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
-extern ExtensionInfo *getExtensions(Archive *fout, struct _dumpOptions * dopt, int *numExtensions);
+extern ExtensionInfo *getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions);
 extern TypeInfo *getTypes(Archive *fout, int *numTypes);
-extern FuncInfo *getFuncs(Archive *fout, struct _dumpOptions * dopt, int *numFuncs);
-extern AggInfo *getAggregates(Archive *fout, struct _dumpOptions * dopt, int *numAggregates);
+extern FuncInfo *getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs);
+extern AggInfo *getAggregates(Archive *fout, DumpOptions *dopt, int *numAggregates);
 extern OprInfo *getOperators(Archive *fout, int *numOperators);
 extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses);
 extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
 extern CollInfo *getCollations(Archive *fout, int *numCollations);
 extern ConvInfo *getConversions(Archive *fout, int *numConversions);
-extern TableInfo *getTables(Archive *fout, struct _dumpOptions * dopt, int *numTables);
+extern TableInfo *getTables(Archive *fout, DumpOptions *dopt, int *numTables);
 extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
 extern InhInfo *getInherits(Archive *fout, int *numInherits);
 extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
@@ -584,8 +532,8 @@ extern RuleInfo *getRules(Archive *fout, int *numRules);
 extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables);
 extern ProcLangInfo *getProcLangs(Archive *fout, int *numProcLangs);
 extern CastInfo *getCasts(Archive *fout, int *numCasts);
-extern void getTableAttrs(Archive *fout, struct _dumpOptions * dopt, TableInfo *tbinfo, int numTables);
-extern bool shouldPrintColumn(struct _dumpOptions * dopt, TableInfo *tbinfo, int colno);
+extern void getTableAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, int numTables);
+extern bool shouldPrintColumn(DumpOptions *dopt, TableInfo *tbinfo, int colno);
 extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers);
 extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts);
 extern TSTemplateInfo *getTSTemplates(Archive *fout, int *numTSTemplates);
@@ -594,8 +542,8 @@ extern FdwInfo *getForeignDataWrappers(Archive *fout,
 					   int *numForeignDataWrappers);
 extern ForeignServerInfo *getForeignServers(Archive *fout,
 				  int *numForeignServers);
-extern DefaultACLInfo *getDefaultACLs(Archive *fout, struct _dumpOptions * dopt, int *numDefaultACLs);
-extern void getExtensionMembership(Archive *fout, struct _dumpOptions * dopt, ExtensionInfo extinfo[],
+extern DefaultACLInfo *getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs);
+extern void getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[],
 					   int numExtensions);
 extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
 extern void getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables);
diff --git a/src/bin/pg_dump/pg_dump_structs.h b/src/bin/pg_dump/pg_dump_structs.h
new file mode 100644
index 0000000..b733182
--- /dev/null
+++ b/src/bin/pg_dump/pg_dump_structs.h
@@ -0,0 +1,216 @@
+/*-------------------------------------------------------------------------
+ *
+ * pg_dump_structs.h
+ *
+ *	Struct definitions used across all pg_dump utilities
+ *
+ * Copyright (c) 2000, Philip Warner
+ *		Rights are granted to use this software in any way so long
+ *		as this notice is not removed.
+ *
+ *	The author is not responsible for loss or damages that may
+ *	result from it's use.
+ *
+ *
+ * IDENTIFICATION
+ *		src/bin/pg_dump/pg_dump_structs.h
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef PG_DUMP_STRUCTS_H
+#define PG_DUMP_STRUCTS_H
+
+
+/*
+ * Data structures for simple lists of OIDs and strings.  The support for
+ * these is very primitive compared to the backend's List facilities, but
+ * it's all we need in pg_dump.
+ */
+typedef struct SimpleOidListCell
+{
+	struct SimpleOidListCell *next;
+	Oid			val;
+} SimpleOidListCell;
+
+typedef struct SimpleOidList
+{
+	SimpleOidListCell *head;
+	SimpleOidListCell *tail;
+} SimpleOidList;
+
+typedef struct SimpleStringListCell
+{
+	struct SimpleStringListCell *next;
+	char		val[1];			/* VARIABLE LENGTH FIELD */
+} SimpleStringListCell;
+
+typedef struct SimpleStringList
+{
+	SimpleStringListCell *head;
+	SimpleStringListCell *tail;
+} SimpleStringList;
+
+typedef enum trivalue
+{
+	TRI_DEFAULT,
+	TRI_NO,
+	TRI_YES
+} trivalue;
+
+typedef enum _archiveFormat
+{
+	archUnknown = 0,
+	archCustom = 1,
+	archTar = 3,
+	archNull = 4,
+	archDirectory = 5
+} ArchiveFormat;
+
+typedef enum _archiveMode
+{
+	archModeAppend,
+	archModeWrite,
+	archModeRead
+} ArchiveMode;
+
+typedef enum _teSection
+{
+	SECTION_NONE = 1,			/* COMMENTs, ACLs, etc; can be anywhere */
+	SECTION_PRE_DATA,			/* stuff to be processed before data */
+	SECTION_DATA,				/* TABLE DATA, BLOBS, BLOB COMMENTS */
+	SECTION_POST_DATA			/* stuff to be processed after data */
+} teSection;
+
+/*
+ *	We may want to have some more user-readable data, but in the mean
+ *	time this gives us some abstraction and type checking.
+ */
+typedef struct Archive
+{
+	int			verbose;
+	char	   *remoteVersionStr;		/* server's version string */
+	int			remoteVersion;	/* same in numeric form */
+
+	int			minRemoteVersion;		/* allowable range */
+	int			maxRemoteVersion;
+
+	int			numWorkers;		/* number of parallel processes */
+	char	   *sync_snapshot_id;		/* sync snapshot id for parallel
+										 * operation */
+
+	/* info needed for string escaping */
+	int			encoding;		/* libpq code for client_encoding */
+	bool		std_strings;	/* standard_conforming_strings */
+	char	   *use_role;		/* Issue SET ROLE to this */
+
+	/* error handling */
+	bool		exit_on_error;	/* whether to exit on SQL errors... */
+	int			n_errors;		/* number of errors (if no die) */
+
+	/* The rest is private */
+} Archive;
+
+typedef struct _restoreOptions
+{
+	int			createDB;		/* Issue commands to create the database */
+	int			noOwner;		/* Don't try to match original object owner */
+	int			noTablespace;	/* Don't issue tablespace-related commands */
+	int			disable_triggers;		/* disable triggers during data-only
+										 * restore */
+	int			use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
+								 * instead of OWNER TO */
+	char	   *superuser;		/* Username to use as superuser */
+	char	   *use_role;		/* Issue SET ROLE to this */
+	int			dropSchema;
+	int			disable_dollar_quoting;
+	int			dump_inserts;
+	int			column_inserts;
+	int			if_exists;
+	int			no_security_labels;		/* Skip security label entries */
+
+	const char *filename;
+	int			dataOnly;
+	int			schemaOnly;
+	int			dumpSections;
+	int			verbose;
+	int			aclsSkip;
+	const char *lockWaitTimeout;
+	int			include_everything;
+
+	int			tocSummary;
+	char	   *tocFile;
+	int			format;
+	char	   *formatName;
+
+	int			selTypes;
+	int			selIndex;
+	int			selFunction;
+	int			selTrigger;
+	int			selTable;
+	SimpleStringList indexNames;
+	SimpleStringList functionNames;
+	SimpleStringList schemaNames;
+	SimpleStringList triggerNames;
+	SimpleStringList tableNames;
+
+	int			useDB;
+	char	   *dbname;
+	char	   *pgport;
+	char	   *pghost;
+	char	   *username;
+	int			noDataForFailedTables;
+	trivalue	promptPassword;
+	int			exit_on_error;
+	int			compression;
+	int			suppressDumpWarnings;	/* Suppress output of WARNING entries
+										 * to stderr */
+	bool		single_txn;
+
+	bool	   *idWanted;		/* array showing which dump IDs to emit */
+	int			enable_row_security;
+} RestoreOptions;
+
+typedef struct _dumpOptions
+{
+	const char *dbname;
+	const char *pghost;
+	const char *pgport;
+	const char *username;
+	bool		oids;
+
+	int			binary_upgrade;
+
+	/* various user-settable parameters */
+	bool		schemaOnly;
+	bool		dataOnly;
+	int			dumpSections;	/* bitmask of chosen sections */
+	bool		aclsSkip;
+	const char *lockWaitTimeout;
+
+	/* flags for various command-line long options */
+	int			disable_dollar_quoting;
+	int			dump_inserts;
+	int			column_inserts;
+	int			if_exists;
+	int			no_security_labels;
+	int			no_synchronized_snapshots;
+	int			no_unlogged_table_data;
+	int			serializable_deferrable;
+	int			quote_all_identifiers;
+	int			disable_triggers;
+	int			outputNoTablespaces;
+	int			use_setsessauth;
+	int			enable_row_security;
+
+	/* default, if no "inclusion" switches appear, is to dump everything */
+	bool		include_everything;
+
+	int			outputClean;
+	int			outputCreateDB;
+	bool		outputBlobs;
+	int			outputNoOwner;
+	char	   *outputSuperuser;
+} DumpOptions;
+
+#endif   /* PG_DUMP_STRUCTS_H */
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index c25ea85..6d72ef9 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -57,7 +57,7 @@ static void buildShSecLabels(PGconn *conn, const char *catalog_name,
 				 uint32 objectId, PQExpBuffer buffer,
 				 const char *target, const char *objname);
 static PGconn *connectDatabase(const char *dbname, const char *connstr, const char *pghost, const char *pgport,
-	  const char *pguser, enum trivalue prompt_password, bool fail_on_error);
+	  const char *pguser, trivalue prompt_password, bool fail_on_error);
 static char *constructConnStr(const char **keywords, const char **values);
 static PGresult *executeQuery(PGconn *conn, const char *query);
 static void executeCommand(PGconn *conn, const char *query);
@@ -138,7 +138,7 @@ main(int argc, char *argv[])
 	char	   *pguser = NULL;
 	char	   *pgdb = NULL;
 	char	   *use_role = NULL;
-	enum trivalue prompt_password = TRI_DEFAULT;
+	trivalue	prompt_password = TRI_DEFAULT;
 	bool		data_only = false;
 	bool		globals_only = false;
 	bool		output_clean = false;
@@ -1765,7 +1765,7 @@ buildShSecLabels(PGconn *conn, const char *catalog_name, uint32 objectId,
 static PGconn *
 connectDatabase(const char *dbname, const char *connection_string,
 				const char *pghost, const char *pgport, const char *pguser,
-				enum trivalue prompt_password, bool fail_on_error)
+				trivalue prompt_password, bool fail_on_error)
 {
 	PGconn	   *conn;
 	bool		new_pass;
