diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c new file mode 100644 index 94e9147..41792e8 *** a/src/bin/pg_dump/common.c --- b/src/bin/pg_dump/common.c *************** static DumpableObject **nspinfoindex; *** 64,70 **** static void flagInhTables(TableInfo *tbinfo, int numTables, InhInfo *inhinfo, int numInherits); ! static void flagInhAttrs(TableInfo *tblinfo, int numTables); static DumpableObject **buildIndexArray(void *objArray, int numObjs, Size objSize); static int DOCatalogIdCompare(const void *p1, const void *p2); --- 64,70 ---- static void flagInhTables(TableInfo *tbinfo, int numTables, InhInfo *inhinfo, int numInherits); ! static void flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables); static DumpableObject **buildIndexArray(void *objArray, int numObjs, Size objSize); static int DOCatalogIdCompare(const void *p1, const void *p2); *************** static int strInArray(const char *patter *** 78,84 **** * Collect information about all potentially dumpable objects */ TableInfo * ! getSchemaData(Archive *fout, int *numTablesPtr) { ExtensionInfo *extinfo; InhInfo *inhinfo; --- 78,84 ---- * Collect information about all potentially dumpable objects */ TableInfo * ! getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr) { ExtensionInfo *extinfo; InhInfo *inhinfo; *************** getSchemaData(Archive *fout, int *numTab *** 114,120 **** */ if (g_verbose) write_msg(NULL, "reading user-defined tables\n"); ! tblinfo = getTables(fout, &numTables); tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo)); /* Do this after we've built tblinfoindex */ --- 114,120 ---- */ if (g_verbose) write_msg(NULL, "reading user-defined tables\n"); ! tblinfo = getTables(fout, dopt, &numTables); tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo)); /* Do this after we've built tblinfoindex */ *************** getSchemaData(Archive *fout, int *numTab *** 122,132 **** if (g_verbose) write_msg(NULL, "reading extensions\n"); ! extinfo = getExtensions(fout, &numExtensions); if (g_verbose) write_msg(NULL, "reading user-defined functions\n"); ! funinfo = getFuncs(fout, &numFuncs); funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo)); /* this must be after getTables and getFuncs */ --- 122,132 ---- if (g_verbose) write_msg(NULL, "reading extensions\n"); ! extinfo = getExtensions(fout, dopt, &numExtensions); if (g_verbose) write_msg(NULL, "reading user-defined functions\n"); ! funinfo = getFuncs(fout, dopt, &numFuncs); funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo)); /* this must be after getTables and getFuncs */ *************** getSchemaData(Archive *fout, int *numTab *** 142,148 **** if (g_verbose) write_msg(NULL, "reading user-defined aggregate functions\n"); ! getAggregates(fout, &numAggregates); if (g_verbose) write_msg(NULL, "reading user-defined operators\n"); --- 142,148 ---- if (g_verbose) write_msg(NULL, "reading user-defined aggregate functions\n"); ! getAggregates(fout, dopt, &numAggregates); if (g_verbose) write_msg(NULL, "reading user-defined operators\n"); *************** getSchemaData(Archive *fout, int *numTab *** 183,189 **** if (g_verbose) write_msg(NULL, "reading default privileges\n"); ! getDefaultACLs(fout, &numDefaultACLs); if (g_verbose) write_msg(NULL, "reading user-defined collations\n"); --- 183,189 ---- if (g_verbose) write_msg(NULL, "reading default privileges\n"); ! getDefaultACLs(fout, dopt, &numDefaultACLs); if (g_verbose) write_msg(NULL, "reading user-defined collations\n"); *************** getSchemaData(Archive *fout, int *numTab *** 213,219 **** */ if (g_verbose) write_msg(NULL, "finding extension members\n"); ! getExtensionMembership(fout, extinfo, numExtensions); /* Link tables to parents, mark parents of target tables interesting */ if (g_verbose) --- 213,219 ---- */ if (g_verbose) write_msg(NULL, "finding extension members\n"); ! getExtensionMembership(fout, dopt, extinfo, numExtensions); /* Link tables to parents, mark parents of target tables interesting */ if (g_verbose) *************** getSchemaData(Archive *fout, int *numTab *** 222,232 **** if (g_verbose) write_msg(NULL, "reading column info for interesting tables\n"); ! getTableAttrs(fout, tblinfo, numTables); if (g_verbose) write_msg(NULL, "flagging inherited columns in subtables\n"); ! flagInhAttrs(tblinfo, numTables); if (g_verbose) write_msg(NULL, "reading indexes\n"); --- 222,232 ---- if (g_verbose) write_msg(NULL, "reading column info for interesting tables\n"); ! getTableAttrs(fout, dopt, tblinfo, numTables); if (g_verbose) write_msg(NULL, "flagging inherited columns in subtables\n"); ! flagInhAttrs(dopt, tblinfo, numTables); if (g_verbose) write_msg(NULL, "reading indexes\n"); *************** flagInhTables(TableInfo *tblinfo, int nu *** 303,309 **** * modifies tblinfo */ static void ! flagInhAttrs(TableInfo *tblinfo, int numTables) { int i, j, --- 303,309 ---- * modifies tblinfo */ static void ! flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables) { int i, j, *************** flagInhAttrs(TableInfo *tblinfo, int num *** 380,386 **** attrDef->adef_expr = pg_strdup("NULL"); /* Will column be dumped explicitly? */ ! if (shouldPrintColumn(tbinfo, j)) { attrDef->separate = false; /* No dependency needed: NULL cannot have dependencies */ --- 380,386 ---- attrDef->adef_expr = pg_strdup("NULL"); /* Will column be dumped explicitly? */ ! if (shouldPrintColumn(dopt, tbinfo, j)) { attrDef->separate = false; /* No dependency needed: NULL cannot have dependencies */ diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c new file mode 100644 index e50dd8b..ceed115 *** a/src/bin/pg_dump/parallel.c --- b/src/bin/pg_dump/parallel.c *************** static void WaitForTerminatingWorkers(Pa *** 89,99 **** static void sigTermHandler(int signum); #endif static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker, RestoreOptions *ropt); static bool HasEveryWorkerTerminated(ParallelState *pstate); static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te); ! static void WaitForCommands(ArchiveHandle *AH, int pipefd[2]); static char *getMessageFromMaster(int pipefd[2]); static void sendMessageToMaster(int pipefd[2], const char *str); static int select_loop(int maxFd, fd_set *workerset); --- 89,100 ---- static void sigTermHandler(int signum); #endif static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker, + DumpOptions *dopt, RestoreOptions *ropt); static bool HasEveryWorkerTerminated(ParallelState *pstate); static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te); ! static void WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]); static char *getMessageFromMaster(int pipefd[2]); static void sendMessageToMaster(int pipefd[2], const char *str); static int select_loop(int maxFd, fd_set *workerset); *************** sigTermHandler(int signum) *** 436,441 **** --- 437,443 ---- */ static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker, + DumpOptions *dopt, RestoreOptions *ropt) { /* *************** SetupWorker(ArchiveHandle *AH, int pipef *** 445,455 **** * properly when we shut down. This happens only that way when it is * brought down because of an error. */ ! (AH->SetupWorkerPtr) ((Archive *) AH, ropt); Assert(AH->connection != NULL); ! WaitForCommands(AH, pipefd); closesocket(pipefd[PIPE_READ]); closesocket(pipefd[PIPE_WRITE]); --- 447,457 ---- * properly when we shut down. This happens only that way when it is * brought down because of an error. */ ! (AH->SetupWorkerPtr) ((Archive *) AH, dopt, ropt); Assert(AH->connection != NULL); ! WaitForCommands(AH, dopt, pipefd); closesocket(pipefd[PIPE_READ]); closesocket(pipefd[PIPE_WRITE]); *************** init_spawned_worker_win32(WorkerInfo *wi *** 481,487 **** * of threads while it does a fork() on Unix. */ ParallelState * ! ParallelBackupStart(ArchiveHandle *AH, RestoreOptions *ropt) { ParallelState *pstate; int i; --- 483,489 ---- * of threads while it does a fork() on Unix. */ ParallelState * ! ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt) { ParallelState *pstate; int i; *************** ParallelBackupStart(ArchiveHandle *AH, R *** 598,604 **** closesocket(pstate->parallelSlot[j].pipeWrite); } ! SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, ropt); exit(0); } --- 600,606 ---- closesocket(pstate->parallelSlot[j].pipeWrite); } ! SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, dopt, ropt); exit(0); } *************** lockTableNoWait(ArchiveHandle *AH, TocEn *** 856,862 **** * exit. */ static void ! WaitForCommands(ArchiveHandle *AH, int pipefd[2]) { char *command; DumpId dumpId; --- 858,864 ---- * exit. */ static void ! WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]) { char *command; DumpId dumpId; *************** WaitForCommands(ArchiveHandle *AH, int p *** 896,902 **** * The message we return here has been pg_malloc()ed and we are * responsible for free()ing it. */ ! str = (AH->WorkerJobDumpPtr) (AH, te); Assert(AH->connection != NULL); sendMessageToMaster(pipefd, str); free(str); --- 898,904 ---- * The message we return here has been pg_malloc()ed and we are * responsible for free()ing it. */ ! str = (AH->WorkerJobDumpPtr) (AH, dopt, te); Assert(AH->connection != NULL); sendMessageToMaster(pipefd, str); free(str); diff --git a/src/bin/pg_dump/parallel.h b/src/bin/pg_dump/parallel.h new file mode 100644 index 7a32a9b..81a823d *** a/src/bin/pg_dump/parallel.h --- b/src/bin/pg_dump/parallel.h *************** extern void EnsureIdleWorker(struct _arc *** 80,85 **** --- 80,86 ---- extern void EnsureWorkersFinished(struct _archiveHandle * AH, ParallelState *pstate); extern ParallelState *ParallelBackupStart(struct _archiveHandle * AH, + DumpOptions *dopt, RestoreOptions *ropt); extern void DispatchJobForTocEntry(struct _archiveHandle * AH, ParallelState *pstate, diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h new file mode 100644 index 25780cf..4dc0002 *** a/src/bin/pg_dump/pg_backup.h --- b/src/bin/pg_dump/pg_backup.h *************** struct Archive *** 98,105 **** /* The rest is private */ }; - typedef int (*DataDumperPtr) (Archive *AH, void *userArg); - typedef struct _restoreOptions { int createDB; /* Issue commands to create the database */ --- 98,103 ---- *************** typedef struct _restoreOptions *** 109,125 **** * restore */ int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands * instead of OWNER TO */ - int no_security_labels; /* Skip security label entries */ char *superuser; /* Username to use as superuser */ char *use_role; /* Issue SET ROLE to this */ int dropSchema; int if_exists; const char *filename; int dataOnly; int schemaOnly; int dumpSections; int verbose; int aclsSkip; int tocSummary; char *tocFile; int format; --- 107,130 ---- * 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; *************** typedef struct _restoreOptions *** 152,158 **** bool *idWanted; /* array showing which dump IDs to emit */ } RestoreOptions; ! typedef void (*SetupWorkerPtr) (Archive *AH, RestoreOptions *ropt); /* * Main archiver interface. --- 157,208 ---- bool *idWanted; /* array showing which dump IDs to emit */ } 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; ! ! /* default, if no "inclusion" switches appear, is to dump everything */ ! bool include_everything; ! ! int outputClean; ! int outputCreateDB; ! bool outputBlobs; ! int outputNoOwner; ! char *outputSuperuser; ! ! int disable_triggers; ! int outputNoTablespaces; ! int use_setsessauth; ! ! } DumpOptions; ! ! typedef int (*DataDumperPtr) (Archive *AH, DumpOptions *dopt, void *userArg); ! ! typedef void (*SetupWorkerPtr) (Archive *AH, DumpOptions *dopt, RestoreOptions *ropt); /* * Main archiver interface. *************** extern void WriteData(Archive *AH, const *** 185,191 **** extern int StartBlob(Archive *AH, Oid oid); extern int EndBlob(Archive *AH, Oid oid); ! extern void CloseArchive(Archive *AH); extern void SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt); --- 235,241 ---- extern int StartBlob(Archive *AH, Oid oid); extern int EndBlob(Archive *AH, Oid oid); ! extern void CloseArchive(Archive *AH, DumpOptions *dopt); extern void SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt); *************** extern void PrintTOCSummary(Archive *AH, *** 204,209 **** --- 254,262 ---- extern RestoreOptions *NewRestoreOptions(void); + extern DumpOptions* NewDumpOptions(void); + extern DumpOptions* dumpOptionsFromRestoreOptions(RestoreOptions *ropt); + /* Rearrange and filter TOC entries */ extern void SortTocFromFile(Archive *AHX, RestoreOptions *ropt); diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c new file mode 100644 index ded9135..81f7300 *** a/src/bin/pg_dump/pg_backup_archiver.c --- b/src/bin/pg_dump/pg_backup_archiver.c *************** static void mark_create_done(ArchiveHand *** 107,112 **** --- 107,166 ---- static void inhibit_data_for_failed_table(ArchiveHandle *AH, TocEntry *te); /* + * Allocate a new DumpOptions block. + * This is mainly so we can initialize it, but also for future expansion. + * We pg_malloc0 the structure, so we don't need to initialize whatever is + * 0, NULL or false anyway. + */ + DumpOptions* + NewDumpOptions(void) + { + DumpOptions *opts; + + opts = (DumpOptions *) pg_malloc0(sizeof(DumpOptions)); + + /* set any fields that shouldn't default to zeroes */ + opts->include_everything = true; + opts->dumpSections = DUMP_UNSECTIONED; + + return opts; + } + + /* + * We do a plaintext dump by printing out the restore command that would create + * a certain object. Since in those functions we only have RestoreOptions, we + * crate ad-hoc DumpOptions. + */ + DumpOptions* + dumpOptionsFromRestoreOptions(RestoreOptions *ropt) { + DumpOptions* dopt = NewDumpOptions(); + + /* this is the inverse of what's at the end of pg_dump.c's main() */ + dopt->outputClean = ropt->dropSchema; + dopt->dataOnly = ropt->dataOnly; + dopt->schemaOnly = ropt->schemaOnly; + dopt->if_exists = ropt->if_exists; + dopt->column_inserts = ropt->column_inserts; + dopt->dumpSections = ropt->dumpSections; + dopt->aclsSkip = ropt->aclsSkip; + dopt->outputSuperuser = ropt->superuser; + dopt->outputCreateDB = ropt->createDB; + dopt->outputNoOwner = ropt->noOwner; + dopt->outputNoTablespaces = ropt->noTablespace; + dopt->disable_triggers = ropt->disable_triggers; + dopt->use_setsessauth = ropt->use_setsessauth; + + dopt->disable_dollar_quoting = ropt->disable_dollar_quoting; + dopt->dump_inserts = ropt->dump_inserts; + dopt->no_security_labels = ropt->no_security_labels; + dopt->lockWaitTimeout = ropt->lockWaitTimeout; + dopt->include_everything = ropt->include_everything; + + return dopt; + } + + + /* * Wrapper functions. * * The objective it to make writing new formats and dumpers as simple *************** static void inhibit_data_for_failed_tabl *** 120,126 **** * setup doesn't need to know anything much, so it's defined here. */ static void ! setupRestoreWorker(Archive *AHX, RestoreOptions *ropt) { ArchiveHandle *AH = (ArchiveHandle *) AHX; --- 174,180 ---- * setup doesn't need to know anything much, so it's defined here. */ static void ! setupRestoreWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt) { ArchiveHandle *AH = (ArchiveHandle *) AHX; *************** OpenArchive(const char *FileSpec, const *** 152,163 **** /* Public */ void ! CloseArchive(Archive *AHX) { int res = 0; ArchiveHandle *AH = (ArchiveHandle *) AHX; ! (*AH->ClosePtr) (AH); /* Close the output */ if (AH->gzOut) --- 206,217 ---- /* Public */ void ! CloseArchive(Archive *AHX, DumpOptions *dopt) { int res = 0; ArchiveHandle *AH = (ArchiveHandle *) AHX; ! (*AH->ClosePtr) (AH, dopt); /* Close the output */ if (AH->gzOut) *************** RestoreArchive(Archive *AHX) *** 522,528 **** Assert(AH->connection == NULL); /* ParallelBackupStart() will actually fork the processes */ ! pstate = ParallelBackupStart(AH, ropt); restore_toc_entries_parallel(AH, pstate, &pending_list); ParallelBackupEnd(AH, pstate); --- 576,582 ---- Assert(AH->connection == NULL); /* ParallelBackupStart() will actually fork the processes */ ! pstate = ParallelBackupStart(AH, NULL, ropt); restore_toc_entries_parallel(AH, pstate, &pending_list); ParallelBackupEnd(AH, pstate); *************** _allocAH(const char *FileSpec, const Arc *** 2214,2220 **** } void ! WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate) { TocEntry *te; --- 2268,2274 ---- } void ! WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate) { TocEntry *te; *************** WriteDataChunks(ArchiveHandle *AH, Paral *** 2237,2249 **** DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP); } else ! WriteDataChunksForTocEntry(AH, te); } EnsureWorkersFinished(AH, pstate); } void ! WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te) { StartDataPtr startPtr; EndDataPtr endPtr; --- 2291,2303 ---- DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP); } else ! WriteDataChunksForTocEntry(AH, dopt, te); } EnsureWorkersFinished(AH, pstate); } void ! WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te) { StartDataPtr startPtr; EndDataPtr endPtr; *************** WriteDataChunksForTocEntry(ArchiveHandle *** 2267,2273 **** /* * The user-provided DataDumper routine needs to call AH->WriteData */ ! (*te->dataDumper) ((Archive *) AH, te->dataDumperArg); if (endPtr != NULL) (*endPtr) (AH, te); --- 2321,2327 ---- /* * The user-provided DataDumper routine needs to call AH->WriteData */ ! (*te->dataDumper) ((Archive *) AH, dopt, te->dataDumperArg); if (endPtr != NULL) (*endPtr) (AH, te); diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h new file mode 100644 index c163f29..2dac52c *** a/src/bin/pg_dump/pg_backup_archiver.h --- b/src/bin/pg_dump/pg_backup_archiver.h *************** typedef enum T_Action *** 139,145 **** ACT_RESTORE } T_Action; ! typedef void (*ClosePtr) (struct _archiveHandle * AH); typedef void (*ReopenPtr) (struct _archiveHandle * AH); typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te); --- 139,145 ---- 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 (*ClonePtr) (struct _archiv *** 166,172 **** typedef void (*DeClonePtr) (struct _archiveHandle * AH); typedef char *(*WorkerJobRestorePtr) (struct _archiveHandle * AH, struct _tocEntry * te); ! typedef char *(*WorkerJobDumpPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef char *(*MasterStartParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te, T_Action act); typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te, --- 166,172 ---- typedef void (*DeClonePtr) (struct _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, T_Action act); typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te, *************** extern void WriteHead(ArchiveHandle *AH) *** 389,396 **** extern void ReadHead(ArchiveHandle *AH); extern void WriteToc(ArchiveHandle *AH); extern void ReadToc(ArchiveHandle *AH); ! extern void WriteDataChunks(ArchiveHandle *AH, struct ParallelState *pstate); ! extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te); extern ArchiveHandle *CloneArchive(ArchiveHandle *AH); extern void DeCloneArchive(ArchiveHandle *AH); --- 389,396 ---- extern void ReadHead(ArchiveHandle *AH); extern void WriteToc(ArchiveHandle *AH); extern void ReadToc(ArchiveHandle *AH); ! extern void WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, struct ParallelState *pstate); ! extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te); extern ArchiveHandle *CloneArchive(ArchiveHandle *AH); extern void DeCloneArchive(ArchiveHandle *AH); diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c new file mode 100644 index 06cd0a7..d6bb471 *** a/src/bin/pg_dump/pg_backup_custom.c --- b/src/bin/pg_dump/pg_backup_custom.c *************** static int _WriteByte(ArchiveHandle *AH, *** 41,47 **** static int _ReadByte(ArchiveHandle *); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len); ! static void _CloseArchive(ArchiveHandle *AH); static void _ReopenArchive(ArchiveHandle *AH); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te); --- 41,47 ---- static int _ReadByte(ArchiveHandle *); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len); ! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt); static void _ReopenArchive(ArchiveHandle *AH); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te); *************** _ReadBuf(ArchiveHandle *AH, void *buf, s *** 694,700 **** * */ static void ! _CloseArchive(ArchiveHandle *AH) { lclContext *ctx = (lclContext *) AH->formatData; pgoff_t tpos; --- 694,700 ---- * */ static void ! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) { lclContext *ctx = (lclContext *) AH->formatData; pgoff_t tpos; *************** _CloseArchive(ArchiveHandle *AH) *** 709,715 **** strerror(errno)); WriteToc(AH); ctx->dataStart = _getFilePos(AH, ctx); ! WriteDataChunks(AH, NULL); /* * If possible, re-write the TOC in order to update the data offset --- 709,715 ---- strerror(errno)); WriteToc(AH); ctx->dataStart = _getFilePos(AH, ctx); ! WriteDataChunks(AH, dopt, NULL); /* * If possible, re-write the TOC in order to update the data offset diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c new file mode 100644 index 39e29d8..01b0e97 *** a/src/bin/pg_dump/pg_backup_directory.c --- b/src/bin/pg_dump/pg_backup_directory.c *************** static int _WriteByte(ArchiveHandle *AH, *** 71,77 **** static int _ReadByte(ArchiveHandle *); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len); ! static void _CloseArchive(ArchiveHandle *AH); static void _ReopenArchive(ArchiveHandle *AH); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); --- 71,77 ---- static int _ReadByte(ArchiveHandle *); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len); ! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt); static void _ReopenArchive(ArchiveHandle *AH); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); *************** static char *_MasterStartParallelItem(Ar *** 92,98 **** static int _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te, const char *str, T_Action act); static char *_WorkerJobRestoreDirectory(ArchiveHandle *AH, TocEntry *te); ! static char *_WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te); static void setFilePath(ArchiveHandle *AH, char *buf, const char *relativeFilename); --- 92,98 ---- static int _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te, const char *str, T_Action act); static char *_WorkerJobRestoreDirectory(ArchiveHandle *AH, TocEntry *te); ! static char *_WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te); static void setFilePath(ArchiveHandle *AH, char *buf, const char *relativeFilename); *************** _ReadBuf(ArchiveHandle *AH, void *buf, s *** 566,572 **** * WriteDataChunks to save all DATA & BLOBs. */ static void ! _CloseArchive(ArchiveHandle *AH) { lclContext *ctx = (lclContext *) AH->formatData; --- 566,572 ---- * WriteDataChunks to save all DATA & BLOBs. */ static void ! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) { lclContext *ctx = (lclContext *) AH->formatData; *************** _CloseArchive(ArchiveHandle *AH) *** 578,584 **** setFilePath(AH, fname, "toc.dat"); /* this will actually fork the processes for a parallel backup */ ! ctx->pstate = ParallelBackupStart(AH, NULL); /* The TOC is always created uncompressed */ tocFH = cfopen_write(fname, PG_BINARY_W, 0); --- 578,584 ---- setFilePath(AH, fname, "toc.dat"); /* this will actually fork the processes for a parallel backup */ ! ctx->pstate = ParallelBackupStart(AH, dopt, NULL); /* The TOC is always created uncompressed */ tocFH = cfopen_write(fname, PG_BINARY_W, 0); *************** _CloseArchive(ArchiveHandle *AH) *** 599,605 **** if (cfclose(tocFH) != 0) exit_horribly(modulename, "could not close TOC file: %s\n", strerror(errno)); ! WriteDataChunks(AH, ctx->pstate); ParallelBackupEnd(AH, ctx->pstate); } --- 599,605 ---- if (cfclose(tocFH) != 0) exit_horribly(modulename, "could not close TOC file: %s\n", strerror(errno)); ! WriteDataChunks(AH, dopt, ctx->pstate); ParallelBackupEnd(AH, ctx->pstate); } *************** _MasterStartParallelItem(ArchiveHandle * *** 790,796 **** * function of the respective dump format. */ static char * ! _WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te) { /* * short fixed-size string + some ID so far, this needs to be malloc'ed --- 790,796 ---- * function of the respective dump format. */ static char * ! _WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te) { /* * short fixed-size string + some ID so far, this needs to be malloc'ed *************** _WorkerJobDumpDirectory(ArchiveHandle *A *** 809,815 **** * succeed... A failure will be detected by the parent when the child dies * unexpectedly. */ ! WriteDataChunksForTocEntry(AH, te); snprintf(buf, buflen, "OK DUMP %d", te->dumpId); --- 809,815 ---- * succeed... A failure will be detected by the parent when the child dies * unexpectedly. */ ! WriteDataChunksForTocEntry(AH, dopt, te); snprintf(buf, buflen, "OK DUMP %d", te->dumpId); diff --git a/src/bin/pg_dump/pg_backup_null.c b/src/bin/pg_dump/pg_backup_null.c new file mode 100644 index 3bce588..b1c28c1 *** a/src/bin/pg_dump/pg_backup_null.c --- b/src/bin/pg_dump/pg_backup_null.c *************** static void _WriteBlobData(ArchiveHandle *** 35,41 **** static void _EndData(ArchiveHandle *AH, TocEntry *te); static int _WriteByte(ArchiveHandle *AH, const int i); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); ! static void _CloseArchive(ArchiveHandle *AH); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _StartBlobs(ArchiveHandle *AH, TocEntry *te); static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid); --- 35,41 ---- static void _EndData(ArchiveHandle *AH, TocEntry *te); static int _WriteByte(ArchiveHandle *AH, const int i); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); ! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _StartBlobs(ArchiveHandle *AH, TocEntry *te); static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid); *************** _PrintTocData(ArchiveHandle *AH, TocEntr *** 198,209 **** { if (te->dataDumper) { AH->currToc = te; if (strcmp(te->desc, "BLOBS") == 0) _StartBlobs(AH, te); ! (*te->dataDumper) ((Archive *) AH, te->dataDumperArg); if (strcmp(te->desc, "BLOBS") == 0) _EndBlobs(AH, te); --- 198,212 ---- { if (te->dataDumper) { + DumpOptions *dopt; AH->currToc = te; if (strcmp(te->desc, "BLOBS") == 0) _StartBlobs(AH, te); ! dopt = dumpOptionsFromRestoreOptions(ropt); ! (*te->dataDumper) ((Archive *) AH, dopt, te->dataDumperArg); ! free(dopt); if (strcmp(te->desc, "BLOBS") == 0) _EndBlobs(AH, te); *************** _WriteBuf(ArchiveHandle *AH, const void *** 227,233 **** } static void ! _CloseArchive(ArchiveHandle *AH) { /* Nothing to do */ } --- 230,236 ---- } static void ! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) { /* Nothing to do */ } diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c new file mode 100644 index 457b742..1c5056c *** a/src/bin/pg_dump/pg_backup_tar.c --- b/src/bin/pg_dump/pg_backup_tar.c *************** static int _WriteByte(ArchiveHandle *AH, *** 48,54 **** static int _ReadByte(ArchiveHandle *); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len); ! static void _CloseArchive(ArchiveHandle *AH); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te); static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te); --- 48,54 ---- static int _ReadByte(ArchiveHandle *); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len); ! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te); static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te); *************** _ReadBuf(ArchiveHandle *AH, void *buf, s *** 827,833 **** } static void ! _CloseArchive(ArchiveHandle *AH) { lclContext *ctx = (lclContext *) AH->formatData; TAR_MEMBER *th; --- 827,833 ---- } static void ! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) { lclContext *ctx = (lclContext *) AH->formatData; TAR_MEMBER *th; *************** _CloseArchive(ArchiveHandle *AH) *** 850,856 **** /* * Now send the data (tables & blobs) */ ! WriteDataChunks(AH, NULL); /* * Now this format wants to append a script which does a full restore --- 850,856 ---- /* * Now send the data (tables & blobs) */ ! WriteDataChunks(AH, dopt, NULL); /* * Now this format wants to append a script which does a full restore diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c new file mode 100644 index c084ee9..76eb64a *** a/src/bin/pg_dump/pg_dump.c --- b/src/bin/pg_dump/pg_dump.c *************** typedef struct *** 85,97 **** bool g_verbose; /* User wants verbose narration of our * activities. */ - /* various user-settable parameters */ - static bool schemaOnly; - static bool dataOnly; - static int dumpSections; /* bitmask of chosen sections */ - static bool aclsSkip; - static const char *lockWaitTimeout; - /* subquery used to convert user ID (eg, datdba) to user name */ static const char *username_subquery; --- 85,90 ---- *************** static SimpleOidList table_exclude_oids *** 116,123 **** static SimpleStringList tabledata_exclude_patterns = {NULL, NULL}; static SimpleOidList tabledata_exclude_oids = {NULL, NULL}; - /* default, if no "inclusion" switches appear, is to dump everything */ - static bool include_everything = true; char g_opaque_type[10]; /* name for the opaque type */ --- 109,114 ---- *************** char g_comment_end[10]; *** 127,147 **** static const CatalogId nilCatalogId = {0, 0}; - /* flags for various command-line long options */ - static int binary_upgrade = 0; - static int disable_dollar_quoting = 0; - static int dump_inserts = 0; - static int column_inserts = 0; - static int if_exists = 0; - static int no_security_labels = 0; - static int no_synchronized_snapshots = 0; - static int no_unlogged_table_data = 0; - static int serializable_deferrable = 0; - - static void help(const char *progname); ! static void setup_connection(Archive *AH, const char *dumpencoding, ! char *use_role); static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode); static void expand_schema_name_patterns(Archive *fout, SimpleStringList *patterns, --- 118,125 ---- static const CatalogId nilCatalogId = {0, 0}; static void help(const char *progname); ! static void setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding, char *use_role); static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode); static void expand_schema_name_patterns(Archive *fout, SimpleStringList *patterns, *************** static void expand_table_name_patterns(A *** 150,213 **** SimpleStringList *patterns, SimpleOidList *oids); static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid); ! static void dumpTableData(Archive *fout, TableDataInfo *tdinfo); static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo); static void guessConstraintInheritance(TableInfo *tblinfo, int numTables); ! static void dumpComment(Archive *fout, const char *target, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId); static int findComments(Archive *fout, Oid classoid, Oid objoid, CommentItem **items); static int collectComments(Archive *fout, CommentItem **items); ! static void dumpSecLabel(Archive *fout, const char *target, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId); static int findSecLabels(Archive *fout, Oid classoid, Oid objoid, SecLabelItem **items); static int collectSecLabels(Archive *fout, SecLabelItem **items); ! static void dumpDumpableObject(Archive *fout, DumpableObject *dobj); ! static void dumpNamespace(Archive *fout, NamespaceInfo *nspinfo); ! static void dumpExtension(Archive *fout, ExtensionInfo *extinfo); ! static void dumpType(Archive *fout, TypeInfo *tyinfo); ! static void dumpBaseType(Archive *fout, TypeInfo *tyinfo); ! static void dumpEnumType(Archive *fout, TypeInfo *tyinfo); ! static void dumpRangeType(Archive *fout, TypeInfo *tyinfo); ! static void dumpDomain(Archive *fout, TypeInfo *tyinfo); ! static void dumpCompositeType(Archive *fout, TypeInfo *tyinfo); static void dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo); ! static void dumpShellType(Archive *fout, ShellTypeInfo *stinfo); ! static void dumpProcLang(Archive *fout, ProcLangInfo *plang); ! static void dumpFunc(Archive *fout, FuncInfo *finfo); ! static void dumpCast(Archive *fout, CastInfo *cast); ! static void dumpOpr(Archive *fout, OprInfo *oprinfo); ! static void dumpOpclass(Archive *fout, OpclassInfo *opcinfo); ! static void dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo); ! static void dumpCollation(Archive *fout, CollInfo *convinfo); ! static void dumpConversion(Archive *fout, ConvInfo *convinfo); ! static void dumpRule(Archive *fout, RuleInfo *rinfo); ! static void dumpAgg(Archive *fout, AggInfo *agginfo); ! static void dumpTrigger(Archive *fout, TriggerInfo *tginfo); ! static void dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo); ! static void dumpTable(Archive *fout, TableInfo *tbinfo); ! static void dumpTableSchema(Archive *fout, TableInfo *tbinfo); ! static void dumpAttrDef(Archive *fout, AttrDefInfo *adinfo); ! static void dumpSequence(Archive *fout, TableInfo *tbinfo); static void dumpSequenceData(Archive *fout, TableDataInfo *tdinfo); ! static void dumpIndex(Archive *fout, IndxInfo *indxinfo); ! static void dumpConstraint(Archive *fout, ConstraintInfo *coninfo); ! static void dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo); ! static void dumpTSParser(Archive *fout, TSParserInfo *prsinfo); ! static void dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo); ! static void dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo); ! static void dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo); ! static void dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo); ! static void dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo); static void dumpUserMappings(Archive *fout, const char *servername, const char *namespace, const char *owner, CatalogId catalogId, DumpId dumpId); ! static void dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo); ! static void dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId, const char *type, const char *name, const char *subname, const char *tag, const char *nspname, const char *owner, const char *acls); --- 128,191 ---- SimpleStringList *patterns, SimpleOidList *oids); static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid); ! static void dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo); static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo); static void guessConstraintInheritance(TableInfo *tblinfo, int numTables); ! static void dumpComment(Archive *fout, DumpOptions* dopt, const char *target, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId); static int findComments(Archive *fout, Oid classoid, Oid objoid, CommentItem **items); static int collectComments(Archive *fout, CommentItem **items); ! static void dumpSecLabel(Archive *fout, DumpOptions* dopt, const char *target, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId); static int findSecLabels(Archive *fout, Oid classoid, Oid objoid, SecLabelItem **items); static int collectSecLabels(Archive *fout, SecLabelItem **items); ! static void dumpDumpableObject(Archive *fout, DumpOptions* dopt, DumpableObject *dobj); ! static void dumpNamespace(Archive *fout, DumpOptions* dopt, NamespaceInfo *nspinfo); ! static void dumpExtension(Archive *fout, DumpOptions* dopt, ExtensionInfo *extinfo); ! static void dumpType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo); ! static void dumpBaseType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo); ! static void dumpEnumType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo); ! static void dumpRangeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo); ! static void dumpDomain(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo); ! static void dumpCompositeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo); static void dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo); ! static void dumpShellType(Archive *fout, DumpOptions* dopt, ShellTypeInfo *stinfo); ! static void dumpProcLang(Archive *fout, DumpOptions* dopt, ProcLangInfo *plang); ! static void dumpFunc(Archive *fout, DumpOptions* dopt, FuncInfo *finfo); ! static void dumpCast(Archive *fout, DumpOptions* dopt, CastInfo *cast); ! static void dumpOpr(Archive *fout, DumpOptions* dopt, OprInfo *oprinfo); ! static void dumpOpclass(Archive *fout, DumpOptions* dopt, OpclassInfo *opcinfo); ! static void dumpOpfamily(Archive *fout, DumpOptions* dopt, OpfamilyInfo *opfinfo); ! static void dumpCollation(Archive *fout, DumpOptions* dopt, CollInfo *convinfo); ! static void dumpConversion(Archive *fout, DumpOptions* dopt, ConvInfo *convinfo); ! static void dumpRule(Archive *fout, DumpOptions* dopt, RuleInfo *rinfo); ! static void dumpAgg(Archive *fout, DumpOptions* dopt, AggInfo *agginfo); ! static void dumpTrigger(Archive *fout, DumpOptions* dopt, TriggerInfo *tginfo); ! static void dumpEventTrigger(Archive *fout, DumpOptions* dopt, EventTriggerInfo *evtinfo); ! static void dumpTable(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo); ! static void dumpTableSchema(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo); ! static void dumpAttrDef(Archive *fout, DumpOptions* dopt, AttrDefInfo *adinfo); ! static void dumpSequence(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo); static void dumpSequenceData(Archive *fout, TableDataInfo *tdinfo); ! static void dumpIndex(Archive *fout, DumpOptions* dopt, IndxInfo *indxinfo); ! static void dumpConstraint(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo); ! static void dumpTableConstraintComment(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo); ! static void dumpTSParser(Archive *fout, DumpOptions* dopt, TSParserInfo *prsinfo); ! static void dumpTSDictionary(Archive *fout, DumpOptions* dopt, TSDictInfo *dictinfo); ! static void dumpTSTemplate(Archive *fout, DumpOptions* dopt, TSTemplateInfo *tmplinfo); ! static void dumpTSConfig(Archive *fout, DumpOptions* dopt, TSConfigInfo *cfginfo); ! static void dumpForeignDataWrapper(Archive *fout, DumpOptions* dopt, FdwInfo *fdwinfo); ! static void dumpForeignServer(Archive *fout, DumpOptions* dopt, ForeignServerInfo *srvinfo); static void dumpUserMappings(Archive *fout, const char *servername, const char *namespace, const char *owner, CatalogId catalogId, DumpId dumpId); ! static void dumpDefaultACL(Archive *fout, DumpOptions* dopt, DefaultACLInfo *daclinfo); ! static void dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId, const char *type, const char *name, const char *subname, const char *tag, const char *nspname, const char *owner, const char *acls); *************** static void addBoundaryDependencies(Dump *** 222,229 **** DumpableObject *boundaryObjs); static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo); ! static void getTableData(TableInfo *tblinfo, int numTables, bool oids); ! static void makeTableDataInfo(TableInfo *tbinfo, bool oids); static void buildMatViewRefreshDependencies(Archive *fout); static void getTableDataFKConstraints(void); static char *format_function_arguments(FuncInfo *finfo, char *funcargs, --- 200,207 ---- DumpableObject *boundaryObjs); static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo); ! static void getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids); ! static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids); static void buildMatViewRefreshDependencies(Archive *fout); static void getTableDataFKConstraints(void); static char *format_function_arguments(FuncInfo *finfo, char *funcargs, *************** static void selectSourceSchema(Archive * *** 245,253 **** static char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts); static char *myFormatType(const char *typname, int32 typmod); static void getBlobs(Archive *fout); ! static void dumpBlob(Archive *fout, BlobInfo *binfo); ! static int dumpBlobs(Archive *fout, void *arg); ! static void dumpDatabase(Archive *AH); static void dumpEncoding(Archive *AH); static void dumpStdStrings(Archive *AH); static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, --- 223,231 ---- static char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts); static char *myFormatType(const char *typname, int32 typmod); static void getBlobs(Archive *fout); ! static void dumpBlob(Archive *fout, DumpOptions *dopt, BlobInfo *binfo); ! static int dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg); ! static void dumpDatabase(Archive *AH, DumpOptions *dopt); static void dumpEncoding(Archive *AH); static void dumpStdStrings(Archive *AH); static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout, *************** static const char *getAttrName(int attrn *** 264,270 **** static const char *fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer); static char *get_synchronized_snapshot(Archive *fout); static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query); ! static void setupDumpWorker(Archive *AHX, RestoreOptions *ropt); int --- 242,248 ---- static const char *fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer); static char *get_synchronized_snapshot(Archive *fout); static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query); ! static void setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt); int *************** main(int argc, char **argv) *** 273,311 **** int c; const char *filename = NULL; const char *format = "p"; - const char *dbname = NULL; - const char *pghost = NULL; - const char *pgport = NULL; - const char *username = NULL; - const char *dumpencoding = NULL; - bool oids = false; TableInfo *tblinfo; int numTables; DumpableObject **dobjs; int numObjs; DumpableObject *boundaryObjs; int i; int numWorkers = 1; enum trivalue prompt_password = TRI_DEFAULT; int compressLevel = -1; int plainText = 0; - int outputClean = 0; - int outputCreateDB = 0; - bool outputBlobs = false; - int outputNoOwner = 0; - char *outputSuperuser = NULL; - char *use_role = NULL; - int optindex; - RestoreOptions *ropt; ArchiveFormat archiveFormat = archUnknown; ! ArchiveMode archiveMode; ! Archive *fout; /* the script file */ ! static int disable_triggers = 0; ! static int outputNoTablespaces = 0; ! static int use_setsessauth = 0; ! static struct option long_options[] = { {"data-only", no_argument, NULL, 'a'}, {"blobs", no_argument, NULL, 'b'}, {"clean", no_argument, NULL, 'c'}, --- 251,277 ---- int c; const char *filename = NULL; const char *format = "p"; TableInfo *tblinfo; int numTables; DumpableObject **dobjs; int numObjs; DumpableObject *boundaryObjs; int i; + int optindex; + RestoreOptions *ropt; + Archive *fout; /* the script file */ + const char *dumpencoding = NULL; + char *use_role = NULL; int numWorkers = 1; enum trivalue prompt_password = TRI_DEFAULT; int compressLevel = -1; int plainText = 0; ArchiveFormat archiveFormat = archUnknown; ! ArchiveMode archiveMode; ! DumpOptions *dopt = NewDumpOptions(); ! struct option long_options[] = { {"data-only", no_argument, NULL, 'a'}, {"blobs", no_argument, NULL, 'b'}, {"clean", no_argument, NULL, 'c'}, *************** main(int argc, char **argv) *** 340,363 **** /* * the following options don't have an equivalent short option letter */ ! {"attribute-inserts", no_argument, &column_inserts, 1}, ! {"binary-upgrade", no_argument, &binary_upgrade, 1}, ! {"column-inserts", no_argument, &column_inserts, 1}, ! {"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1}, ! {"disable-triggers", no_argument, &disable_triggers, 1}, {"exclude-table-data", required_argument, NULL, 4}, ! {"if-exists", no_argument, &if_exists, 1}, ! {"inserts", no_argument, &dump_inserts, 1}, {"lock-wait-timeout", required_argument, NULL, 2}, ! {"no-tablespaces", no_argument, &outputNoTablespaces, 1}, {"quote-all-identifiers", no_argument, "e_all_identifiers, 1}, {"role", required_argument, NULL, 3}, {"section", required_argument, NULL, 5}, ! {"serializable-deferrable", no_argument, &serializable_deferrable, 1}, ! {"use-set-session-authorization", no_argument, &use_setsessauth, 1}, ! {"no-security-labels", no_argument, &no_security_labels, 1}, ! {"no-synchronized-snapshots", no_argument, &no_synchronized_snapshots, 1}, ! {"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1}, {NULL, 0, NULL, 0} }; --- 306,329 ---- /* * the following options don't have an equivalent short option letter */ ! {"attribute-inserts", no_argument, &dopt->column_inserts, 1}, ! {"binary-upgrade", no_argument, &dopt->binary_upgrade, 1}, ! {"column-inserts", no_argument, &dopt->column_inserts, 1}, ! {"disable-dollar-quoting", no_argument, &dopt->disable_dollar_quoting, 1}, ! {"disable-triggers", no_argument, &dopt->disable_triggers, 1}, {"exclude-table-data", required_argument, NULL, 4}, ! {"if-exists", no_argument, &dopt->if_exists, 1}, ! {"inserts", no_argument, &dopt->dump_inserts, 1}, {"lock-wait-timeout", required_argument, NULL, 2}, ! {"no-tablespaces", no_argument, &dopt->outputNoTablespaces, 1}, {"quote-all-identifiers", no_argument, "e_all_identifiers, 1}, {"role", required_argument, NULL, 3}, {"section", required_argument, NULL, 5}, ! {"serializable-deferrable", no_argument, &dopt->serializable_deferrable, 1}, ! {"use-set-session-authorization", no_argument, &dopt->use_setsessauth, 1}, ! {"no-security-labels", no_argument, &dopt->no_security_labels, 1}, ! {"no-synchronized-snapshots", no_argument, &dopt->no_synchronized_snapshots, 1}, ! {"no-unlogged-table-data", no_argument, &dopt->no_unlogged_table_data, 1}, {NULL, 0, NULL, 0} }; *************** main(int argc, char **argv) *** 376,385 **** g_comment_end[0] = '\0'; strcpy(g_opaque_type, "opaque"); - dataOnly = schemaOnly = false; - dumpSections = DUMP_UNSECTIONED; - lockWaitTimeout = NULL; - progname = get_progname(argv[0]); /* Set default options based on progname */ --- 342,347 ---- *************** main(int argc, char **argv) *** 406,428 **** switch (c) { case 'a': /* Dump data only */ ! dataOnly = true; break; case 'b': /* Dump blobs */ ! outputBlobs = true; break; case 'c': /* clean (i.e., drop) schema prior to create */ ! outputClean = 1; break; case 'C': /* Create DB */ ! outputCreateDB = 1; break; case 'd': /* database name */ ! dbname = pg_strdup(optarg); break; case 'E': /* Dump encoding */ --- 368,390 ---- switch (c) { case 'a': /* Dump data only */ ! dopt->dataOnly = true; break; case 'b': /* Dump blobs */ ! dopt->outputBlobs = true; break; case 'c': /* clean (i.e., drop) schema prior to create */ ! dopt->outputClean = 1; break; case 'C': /* Create DB */ ! dopt->outputCreateDB = 1; break; case 'd': /* database name */ ! dopt->dbname = pg_strdup(optarg); break; case 'E': /* Dump encoding */ *************** main(int argc, char **argv) *** 438,444 **** break; case 'h': /* server host */ ! pghost = pg_strdup(optarg); break; case 'i': --- 400,406 ---- break; case 'h': /* server host */ ! dopt->pghost = pg_strdup(optarg); break; case 'i': *************** main(int argc, char **argv) *** 451,457 **** case 'n': /* include schema(s) */ simple_string_list_append(&schema_include_patterns, optarg); ! include_everything = false; break; case 'N': /* exclude schema(s) */ --- 413,419 ---- case 'n': /* include schema(s) */ simple_string_list_append(&schema_include_patterns, optarg); ! dopt->include_everything = false; break; case 'N': /* exclude schema(s) */ *************** main(int argc, char **argv) *** 459,473 **** break; case 'o': /* Dump oids */ ! oids = true; break; case 'O': /* Don't reconnect to match owner */ ! outputNoOwner = 1; break; case 'p': /* server port */ ! pgport = pg_strdup(optarg); break; case 'R': --- 421,435 ---- break; case 'o': /* Dump oids */ ! dopt->oids = true; break; case 'O': /* Don't reconnect to match owner */ ! dopt->outputNoOwner = 1; break; case 'p': /* server port */ ! dopt->pgport = pg_strdup(optarg); break; case 'R': *************** main(int argc, char **argv) *** 475,490 **** break; case 's': /* dump schema only */ ! schemaOnly = true; break; case 'S': /* Username for superuser in plain text output */ ! outputSuperuser = pg_strdup(optarg); break; case 't': /* include table(s) */ simple_string_list_append(&table_include_patterns, optarg); ! include_everything = false; break; case 'T': /* exclude table(s) */ --- 437,452 ---- break; case 's': /* dump schema only */ ! dopt->schemaOnly = true; break; case 'S': /* Username for superuser in plain text output */ ! dopt->outputSuperuser = pg_strdup(optarg); break; case 't': /* include table(s) */ simple_string_list_append(&table_include_patterns, optarg); ! dopt->include_everything = false; break; case 'T': /* exclude table(s) */ *************** main(int argc, char **argv) *** 492,498 **** break; case 'U': ! username = pg_strdup(optarg); break; case 'v': /* verbose */ --- 454,460 ---- break; case 'U': ! dopt->username = pg_strdup(optarg); break; case 'v': /* verbose */ *************** main(int argc, char **argv) *** 508,514 **** break; case 'x': /* skip ACL dump */ ! aclsSkip = true; break; case 'Z': /* Compression Level */ --- 470,476 ---- break; case 'x': /* skip ACL dump */ ! dopt->aclsSkip = true; break; case 'Z': /* Compression Level */ *************** main(int argc, char **argv) *** 520,526 **** break; case 2: /* lock-wait-timeout */ ! lockWaitTimeout = pg_strdup(optarg); break; case 3: /* SET ROLE */ --- 482,488 ---- break; case 2: /* lock-wait-timeout */ ! dopt->lockWaitTimeout = pg_strdup(optarg); break; case 3: /* SET ROLE */ *************** main(int argc, char **argv) *** 532,538 **** break; case 5: /* section */ ! set_dump_section(optarg, &dumpSections); break; default: --- 494,500 ---- break; case 5: /* section */ ! set_dump_section(optarg, &dopt->dumpSections); break; default: *************** main(int argc, char **argv) *** 545,552 **** * Non-option argument specifies database name as long as it wasn't * already specified with -d / --dbname */ ! if (optind < argc && dbname == NULL) ! dbname = argv[optind++]; /* Complain if any arguments remain */ if (optind < argc) --- 507,514 ---- * Non-option argument specifies database name as long as it wasn't * already specified with -d / --dbname */ ! if (optind < argc && dopt->dbname == NULL) ! dopt->dbname = argv[optind++]; /* Complain if any arguments remain */ if (optind < argc) *************** main(int argc, char **argv) *** 559,587 **** } /* --column-inserts implies --inserts */ ! if (column_inserts) ! dump_inserts = 1; ! if (dataOnly && schemaOnly) { write_msg(NULL, "options -s/--schema-only and -a/--data-only cannot be used together\n"); exit_nicely(1); } ! if (dataOnly && outputClean) { write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n"); exit_nicely(1); } ! if (dump_inserts && oids) { write_msg(NULL, "options --inserts/--column-inserts and -o/--oids cannot be used together\n"); write_msg(NULL, "(The INSERT command cannot set OIDs.)\n"); exit_nicely(1); } ! if (if_exists && !outputClean) exit_horribly(NULL, "option --if-exists requires option -c/--clean\n"); /* Identify archive format to emit */ --- 521,549 ---- } /* --column-inserts implies --inserts */ ! if (dopt->column_inserts) ! dopt->dump_inserts = 1; ! if (dopt->dataOnly && dopt->schemaOnly) { write_msg(NULL, "options -s/--schema-only and -a/--data-only cannot be used together\n"); exit_nicely(1); } ! if (dopt->dataOnly && dopt->outputClean) { write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n"); exit_nicely(1); } ! if (dopt->dump_inserts && dopt->oids) { write_msg(NULL, "options --inserts/--column-inserts and -o/--oids cannot be used together\n"); write_msg(NULL, "(The INSERT command cannot set OIDs.)\n"); exit_nicely(1); } ! if (dopt->if_exists && !dopt->outputClean) exit_horribly(NULL, "option --if-exists requires option -c/--clean\n"); /* Identify archive format to emit */ *************** main(int argc, char **argv) *** 642,656 **** * Open the database using the Archiver, so it knows about it. Errors mean * death. */ ! ConnectDatabase(fout, dbname, pghost, pgport, username, prompt_password); ! setup_connection(fout, dumpencoding, use_role); /* * Disable security label support if server version < v9.1.x (prevents * access to nonexistent pg_seclabel catalog) */ if (fout->remoteVersion < 90100) ! no_security_labels = 1; /* * When running against 9.0 or later, check if we are in recovery mode, --- 604,618 ---- * Open the database using the Archiver, so it knows about it. Errors mean * death. */ ! ConnectDatabase(fout, dopt->dbname, dopt->pghost, dopt->pgport, dopt->username, prompt_password); ! setup_connection(fout, dopt, dumpencoding, use_role); /* * Disable security label support if server version < v9.1.x (prevents * access to nonexistent pg_seclabel catalog) */ if (fout->remoteVersion < 90100) ! dopt->no_security_labels = 1; /* * When running against 9.0 or later, check if we are in recovery mode, *************** main(int argc, char **argv) *** 666,672 **** * On hot standby slaves, never try to dump unlogged table data, * since it will just throw an error. */ ! no_unlogged_table_data = true; } PQclear(res); } --- 628,634 ---- * On hot standby slaves, never try to dump unlogged table data, * since it will just throw an error. */ ! dopt->no_unlogged_table_data = true; } PQclear(res); } *************** main(int argc, char **argv) *** 681,687 **** /* check the version for the synchronized snapshots feature */ if (numWorkers > 1 && fout->remoteVersion < 90200 ! && !no_synchronized_snapshots) exit_horribly(NULL, "Synchronized snapshots are not supported by this server version.\n" "Run with --no-synchronized-snapshots instead if you do not need\n" --- 643,649 ---- /* check the version for the synchronized snapshots feature */ if (numWorkers > 1 && fout->remoteVersion < 90200 ! && !dopt->no_synchronized_snapshots) exit_horribly(NULL, "Synchronized snapshots are not supported by this server version.\n" "Run with --no-synchronized-snapshots instead if you do not need\n" *************** main(int argc, char **argv) *** 731,757 **** * Dumping blobs is now default unless we saw an inclusion switch or -s * ... but even if we did see one of these, -b turns it back on. */ ! if (include_everything && !schemaOnly) ! outputBlobs = true; /* * Now scan the database and create DumpableObject structs for all the * objects we intend to dump. */ ! tblinfo = getSchemaData(fout, &numTables); if (fout->remoteVersion < 80400) guessConstraintInheritance(tblinfo, numTables); ! if (!schemaOnly) { ! getTableData(tblinfo, numTables, oids); buildMatViewRefreshDependencies(fout); ! if (dataOnly) getTableDataFKConstraints(); } ! if (outputBlobs) getBlobs(fout); /* --- 693,719 ---- * Dumping blobs is now default unless we saw an inclusion switch or -s * ... but even if we did see one of these, -b turns it back on. */ ! if (dopt->include_everything && !dopt->schemaOnly) ! dopt->outputBlobs = true; /* * Now scan the database and create DumpableObject structs for all the * objects we intend to dump. */ ! tblinfo = getSchemaData(fout, dopt, &numTables); if (fout->remoteVersion < 80400) guessConstraintInheritance(tblinfo, numTables); ! if (!dopt->schemaOnly) { ! getTableData(dopt, tblinfo, numTables, dopt->oids); buildMatViewRefreshDependencies(fout); ! if (dopt->dataOnly) getTableDataFKConstraints(); } ! if (dopt->outputBlobs) getBlobs(fout); /* *************** main(int argc, char **argv) *** 801,830 **** dumpStdStrings(fout); /* The database item is always next, unless we don't want it at all */ ! if (include_everything && !dataOnly) ! dumpDatabase(fout); /* Now the rearrangeable objects. */ for (i = 0; i < numObjs; i++) ! dumpDumpableObject(fout, dobjs[i]); /* * Set up options info to ensure we dump what we want. */ ropt = NewRestoreOptions(); ropt->filename = filename; ! ropt->dropSchema = outputClean; ! ropt->dataOnly = dataOnly; ! ropt->schemaOnly = schemaOnly; ! ropt->if_exists = if_exists; ! ropt->dumpSections = dumpSections; ! ropt->aclsSkip = aclsSkip; ! ropt->superuser = outputSuperuser; ! ropt->createDB = outputCreateDB; ! ropt->noOwner = outputNoOwner; ! ropt->noTablespace = outputNoTablespaces; ! ropt->disable_triggers = disable_triggers; ! ropt->use_setsessauth = use_setsessauth; if (compressLevel == -1) ropt->compression = 0; --- 763,798 ---- dumpStdStrings(fout); /* The database item is always next, unless we don't want it at all */ ! if (dopt->include_everything && !dopt->dataOnly) ! dumpDatabase(fout, dopt); /* Now the rearrangeable objects. */ for (i = 0; i < numObjs; i++) ! dumpDumpableObject(fout, dopt, dobjs[i]); /* * Set up options info to ensure we dump what we want. */ ropt = NewRestoreOptions(); ropt->filename = filename; ! ropt->dropSchema = dopt->outputClean; ! ropt->dataOnly = dopt->dataOnly; ! ropt->schemaOnly = dopt->schemaOnly; ! ropt->if_exists = dopt->if_exists; ! ropt->column_inserts = dopt->column_inserts; ! ropt->dumpSections = dopt->dumpSections; ! ropt->aclsSkip = dopt->aclsSkip; ! ropt->superuser = dopt->outputSuperuser; ! ropt->createDB = dopt->outputCreateDB; ! ropt->noOwner = dopt->outputNoOwner; ! ropt->noTablespace = dopt->outputNoTablespaces; ! ropt->disable_triggers = dopt->disable_triggers; ! ropt->use_setsessauth = dopt->use_setsessauth; ! ropt->disable_dollar_quoting = dopt->disable_dollar_quoting; ! ropt->dump_inserts = dopt->dump_inserts; ! ropt->no_security_labels = dopt->no_security_labels; ! ropt->lockWaitTimeout = dopt->lockWaitTimeout; ! ropt->include_everything = dopt->include_everything; if (compressLevel == -1) ropt->compression = 0; *************** main(int argc, char **argv) *** 853,859 **** if (plainText) RestoreArchive(fout); ! CloseArchive(fout); exit_nicely(0); } --- 821,827 ---- if (plainText) RestoreArchive(fout); ! CloseArchive(fout, dopt); exit_nicely(0); } *************** help(const char *progname) *** 926,932 **** } static void ! setup_connection(Archive *AH, const char *dumpencoding, char *use_role) { PGconn *conn = GetConnection(AH); const char *std_strings; --- 894,900 ---- } static void ! setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding, char *use_role) { PGconn *conn = GetConnection(AH); const char *std_strings; *************** setup_connection(Archive *AH, const char *** 1014,1020 **** ExecuteSqlStatement(AH, "BEGIN"); if (AH->remoteVersion >= 90100) { ! if (serializable_deferrable) ExecuteSqlStatement(AH, "SET TRANSACTION ISOLATION LEVEL " "SERIALIZABLE, READ ONLY, DEFERRABLE"); --- 982,988 ---- ExecuteSqlStatement(AH, "BEGIN"); if (AH->remoteVersion >= 90100) { ! if (dopt->serializable_deferrable) ExecuteSqlStatement(AH, "SET TRANSACTION ISOLATION LEVEL " "SERIALIZABLE, READ ONLY, DEFERRABLE"); *************** setup_connection(Archive *AH, const char *** 1036,1042 **** ! if (AH->numWorkers > 1 && AH->remoteVersion >= 90200 && !no_synchronized_snapshots) { if (AH->sync_snapshot_id) { --- 1004,1010 ---- ! if (AH->numWorkers > 1 && AH->remoteVersion >= 90200 && !dopt->no_synchronized_snapshots) { if (AH->sync_snapshot_id) { *************** setup_connection(Archive *AH, const char *** 1053,1061 **** } static void ! setupDumpWorker(Archive *AHX, RestoreOptions *ropt) { ! setup_connection(AHX, NULL, NULL); } static char * --- 1021,1029 ---- } static void ! setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt) { ! setup_connection(AHX, dopt, NULL, NULL); } static char * *************** selectDumpableType(TypeInfo *tyinfo) *** 1326,1337 **** * and aclsSkip are checked separately. */ static void ! selectDumpableDefaultACL(DefaultACLInfo *dinfo) { if (dinfo->dobj.namespace) dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump; else ! dinfo->dobj.dump = include_everything; } /* --- 1294,1305 ---- * and aclsSkip are checked separately. */ static void ! selectDumpableDefaultACL(DumpOptions *dopt, DefaultACLInfo *dinfo) { if (dinfo->dobj.namespace) dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump; else ! dinfo->dobj.dump = dopt->include_everything; } /* *************** selectDumpableDefaultACL(DefaultACLInfo *** 1345,1356 **** * such extensions by their having OIDs in the range reserved for initdb. */ static void ! selectDumpableExtension(ExtensionInfo *extinfo) { ! if (binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId) extinfo->dobj.dump = false; else ! extinfo->dobj.dump = include_everything; } /* --- 1313,1324 ---- * such extensions by their having OIDs in the range reserved for initdb. */ static void ! selectDumpableExtension(DumpOptions *dopt, ExtensionInfo *extinfo) { ! if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId) extinfo->dobj.dump = false; else ! extinfo->dobj.dump = dopt->include_everything; } /* *************** selectDumpableObject(DumpableObject *dob *** 1379,1385 **** */ static int ! dumpTableData_copy(Archive *fout, void *dcontext) { TableDataInfo *tdinfo = (TableDataInfo *) dcontext; TableInfo *tbinfo = tdinfo->tdtable; --- 1347,1353 ---- */ static int ! dumpTableData_copy(Archive *fout, DumpOptions *dopt, void *dcontext) { TableDataInfo *tdinfo = (TableDataInfo *) dcontext; TableInfo *tbinfo = tdinfo->tdtable; *************** dumpTableData_copy(Archive *fout, void * *** 1554,1560 **** * E'' strings, or dollar-quoted strings. So don't emit anything like that. */ static int ! dumpTableData_insert(Archive *fout, void *dcontext) { TableDataInfo *tdinfo = (TableDataInfo *) dcontext; TableInfo *tbinfo = tdinfo->tdtable; --- 1522,1528 ---- * E'' strings, or dollar-quoted strings. So don't emit anything like that. */ static int ! dumpTableData_insert(Archive *fout, DumpOptions *dopt, void *dcontext) { TableDataInfo *tdinfo = (TableDataInfo *) dcontext; TableInfo *tbinfo = tdinfo->tdtable; *************** dumpTableData_insert(Archive *fout, void *** 1623,1629 **** else { /* append the list of column names if required */ ! if (column_inserts) { appendPQExpBufferStr(insertStmt, "("); for (field = 0; field < nfields; field++) --- 1591,1597 ---- else { /* append the list of column names if required */ ! if (dopt->column_inserts) { appendPQExpBufferStr(insertStmt, "("); for (field = 0; field < nfields; field++) *************** dumpTableData_insert(Archive *fout, void *** 1740,1746 **** * Actually, this just makes an ArchiveEntry for the table contents. */ static void ! dumpTableData(Archive *fout, TableDataInfo *tdinfo) { TableInfo *tbinfo = tdinfo->tdtable; PQExpBuffer copyBuf = createPQExpBuffer(); --- 1708,1714 ---- * Actually, this just makes an ArchiveEntry for the table contents. */ static void ! dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo) { TableInfo *tbinfo = tdinfo->tdtable; PQExpBuffer copyBuf = createPQExpBuffer(); *************** dumpTableData(Archive *fout, TableDataIn *** 1748,1754 **** DataDumperPtr dumpFn; char *copyStmt; ! if (!dump_inserts) { /* Dump/restore using COPY */ dumpFn = dumpTableData_copy; --- 1716,1722 ---- DataDumperPtr dumpFn; char *copyStmt; ! if (!dopt->dump_inserts) { /* Dump/restore using COPY */ dumpFn = dumpTableData_copy; *************** refreshMatViewData(Archive *fout, TableD *** 1832,1845 **** * set up dumpable objects representing the contents of tables */ static void ! getTableData(TableInfo *tblinfo, int numTables, bool oids) { int i; for (i = 0; i < numTables; i++) { if (tblinfo[i].dobj.dump) ! makeTableDataInfo(&(tblinfo[i]), oids); } } --- 1800,1813 ---- * set up dumpable objects representing the contents of tables */ static void ! getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids) { int i; for (i = 0; i < numTables; i++) { if (tblinfo[i].dobj.dump) ! makeTableDataInfo(dopt, &(tblinfo[i]), oids); } } *************** getTableData(TableInfo *tblinfo, int num *** 1850,1856 **** * table data; the "dump" flag in such objects isn't used. */ static void ! makeTableDataInfo(TableInfo *tbinfo, bool oids) { TableDataInfo *tdinfo; --- 1818,1824 ---- * table data; the "dump" flag in such objects isn't used. */ static void ! makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids) { TableDataInfo *tdinfo; *************** makeTableDataInfo(TableInfo *tbinfo, boo *** 1870,1876 **** /* Don't dump data in unlogged tables, if so requested */ if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED && ! no_unlogged_table_data) return; /* Check that the data is not explicitly excluded */ --- 1838,1844 ---- /* Don't dump data in unlogged tables, if so requested */ if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED && ! dopt->no_unlogged_table_data) return; /* Check that the data is not explicitly excluded */ *************** guessConstraintInheritance(TableInfo *tb *** 2143,2149 **** * dump the database definition */ static void ! dumpDatabase(Archive *fout) { PQExpBuffer dbQry = createPQExpBuffer(); PQExpBuffer delQry = createPQExpBuffer(); --- 2111,2117 ---- * dump the database definition */ static void ! dumpDatabase(Archive *fout, DumpOptions *dopt) { PQExpBuffer dbQry = createPQExpBuffer(); PQExpBuffer delQry = createPQExpBuffer(); *************** dumpDatabase(Archive *fout) *** 2305,2311 **** fmtId(tablespace)); appendPQExpBufferStr(creaQry, ";\n"); ! if (binary_upgrade) { appendPQExpBufferStr(creaQry, "\n-- For binary upgrade, set datfrozenxid and datminmxid.\n"); appendPQExpBuffer(creaQry, "UPDATE pg_catalog.pg_database\n" --- 2273,2279 ---- fmtId(tablespace)); appendPQExpBufferStr(creaQry, ";\n"); ! if (dopt->binary_upgrade) { appendPQExpBufferStr(creaQry, "\n-- For binary upgrade, set datfrozenxid and datminmxid.\n"); appendPQExpBuffer(creaQry, "UPDATE pg_catalog.pg_database\n" *************** dumpDatabase(Archive *fout) *** 2344,2350 **** * pg_largeobject and pg_largeobject_metadata come from the old system * intact, so set their relfrozenxids and relminmxids. */ ! if (binary_upgrade) { PGresult *lo_res; PQExpBuffer loFrozenQry = createPQExpBuffer(); --- 2312,2318 ---- * pg_largeobject and pg_largeobject_metadata come from the old system * intact, so set their relfrozenxids and relminmxids. */ ! if (dopt->binary_upgrade) { PGresult *lo_res; PQExpBuffer loFrozenQry = createPQExpBuffer(); *************** dumpDatabase(Archive *fout) *** 2462,2475 **** { resetPQExpBuffer(dbQry); appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname)); ! dumpComment(fout, dbQry->data, NULL, "", dbCatId, 0, dbDumpId); } PQclear(res); /* Dump shared security label. */ ! if (!no_security_labels && fout->remoteVersion >= 90200) { PQExpBuffer seclabelQry = createPQExpBuffer(); --- 2430,2443 ---- { resetPQExpBuffer(dbQry); appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname)); ! dumpComment(fout, dopt, dbQry->data, NULL, "", dbCatId, 0, dbDumpId); } PQclear(res); /* Dump shared security label. */ ! if (!dopt->no_security_labels && fout->remoteVersion >= 90200) { PQExpBuffer seclabelQry = createPQExpBuffer(); *************** dumpDatabase(Archive *fout) *** 2490,2496 **** destroyPQExpBuffer(creaQry); } - /* * dumpEncoding: put the correct encoding into the archive */ --- 2458,2463 ---- *************** getBlobs(Archive *fout) *** 2630,2636 **** * dump the definition (metadata) of the given large object */ static void ! dumpBlob(Archive *fout, BlobInfo *binfo) { PQExpBuffer cquery = createPQExpBuffer(); PQExpBuffer dquery = createPQExpBuffer(); --- 2597,2603 ---- * dump the definition (metadata) of the given large object */ static void ! dumpBlob(Archive *fout, DumpOptions* dopt, BlobInfo *binfo) { PQExpBuffer cquery = createPQExpBuffer(); PQExpBuffer dquery = createPQExpBuffer(); *************** dumpBlob(Archive *fout, BlobInfo *binfo) *** 2657,2674 **** appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name); /* Dump comment if any */ ! dumpComment(fout, cquery->data, NULL, binfo->rolname, binfo->dobj.catId, 0, binfo->dobj.dumpId); /* Dump security label if any */ ! dumpSecLabel(fout, cquery->data, NULL, binfo->rolname, binfo->dobj.catId, 0, binfo->dobj.dumpId); /* Dump ACL if any */ if (binfo->blobacl) ! dumpACL(fout, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT", binfo->dobj.name, NULL, cquery->data, NULL, binfo->rolname, binfo->blobacl); --- 2624,2641 ---- appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name); /* Dump comment if any */ ! dumpComment(fout, dopt, cquery->data, NULL, binfo->rolname, binfo->dobj.catId, 0, binfo->dobj.dumpId); /* Dump security label if any */ ! dumpSecLabel(fout, dopt, cquery->data, NULL, binfo->rolname, binfo->dobj.catId, 0, binfo->dobj.dumpId); /* Dump ACL if any */ if (binfo->blobacl) ! dumpACL(fout, dopt, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT", binfo->dobj.name, NULL, cquery->data, NULL, binfo->rolname, binfo->blobacl); *************** dumpBlob(Archive *fout, BlobInfo *binfo) *** 2681,2687 **** * dump the data contents of all large objects */ static int ! dumpBlobs(Archive *fout, void *arg) { const char *blobQry; const char *blobFetchQry; --- 2648,2654 ---- * dump the data contents of all large objects */ static int ! dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg) { const char *blobQry; const char *blobFetchQry; *************** findNamespace(Archive *fout, Oid nsoid, *** 3092,3098 **** * numExtensions is set to the number of extensions read in */ ExtensionInfo * ! getExtensions(Archive *fout, int *numExtensions) { PGresult *res; int ntups; --- 3059,3065 ---- * numExtensions is set to the number of extensions read in */ ExtensionInfo * ! getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions) { PGresult *res; int ntups; *************** getExtensions(Archive *fout, int *numExt *** 3156,3162 **** extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition)); /* Decide whether we want to dump it */ ! selectDumpableExtension(&(extinfo[i])); } PQclear(res); --- 3123,3129 ---- extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition)); /* Decide whether we want to dump it */ ! selectDumpableExtension(dopt, &(extinfo[i])); } PQclear(res); *************** getOpfamilies(Archive *fout, int *numOpf *** 3907,3913 **** * numAggs is set to the number of aggregates read in */ AggInfo * ! getAggregates(Archive *fout, int *numAggs) { PGresult *res; int ntups; --- 3874,3880 ---- * numAggs is set to the number of aggregates read in */ AggInfo * ! getAggregates(Archive *fout, DumpOptions *dopt, int *numAggs) { PGresult *res; int ntups; *************** getAggregates(Archive *fout, int *numAgg *** 3946,3952 **** "(SELECT oid FROM pg_namespace " "WHERE nspname = 'pg_catalog')", username_subquery); ! if (binary_upgrade && fout->remoteVersion >= 90100) appendPQExpBufferStr(query, " OR EXISTS(SELECT 1 FROM pg_depend WHERE " "classid = 'pg_proc'::regclass AND " --- 3913,3919 ---- "(SELECT oid FROM pg_namespace " "WHERE nspname = 'pg_catalog')", username_subquery); ! if (dopt->binary_upgrade && fout->remoteVersion >= 90100) appendPQExpBufferStr(query, " OR EXISTS(SELECT 1 FROM pg_depend WHERE " "classid = 'pg_proc'::regclass AND " *************** getAggregates(Archive *fout, int *numAgg *** 4086,4092 **** * numFuncs is set to the number of functions read in */ FuncInfo * ! getFuncs(Archive *fout, int *numFuncs) { PGresult *res; int ntups; --- 4053,4059 ---- * numFuncs is set to the number of functions read in */ FuncInfo * ! getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs) { PGresult *res; int ntups; *************** getFuncs(Archive *fout, int *numFuncs) *** 4143,4149 **** "\n AND NOT EXISTS (SELECT 1 FROM pg_depend " "WHERE classid = 'pg_proc'::regclass AND " "objid = p.oid AND deptype = 'i')"); ! if (binary_upgrade && fout->remoteVersion >= 90100) appendPQExpBufferStr(query, "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE " "classid = 'pg_proc'::regclass AND " --- 4110,4116 ---- "\n AND NOT EXISTS (SELECT 1 FROM pg_depend " "WHERE classid = 'pg_proc'::regclass AND " "objid = p.oid AND deptype = 'i')"); ! if (dopt->binary_upgrade && fout->remoteVersion >= 90100) appendPQExpBufferStr(query, "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE " "classid = 'pg_proc'::regclass AND " *************** getFuncs(Archive *fout, int *numFuncs) *** 4269,4275 **** * numTables is set to the number of tables read in */ TableInfo * ! getTables(Archive *fout, int *numTables) { PGresult *res; int ntups; --- 4236,4242 ---- * numTables is set to the number of tables read in */ TableInfo * ! getTables(Archive *fout, DumpOptions *dopt, int *numTables) { PGresult *res; int ntups; *************** getTables(Archive *fout, int *numTables) *** 4766,4772 **** i_toastreloptions = PQfnumber(res, "toast_reloptions"); i_reloftype = PQfnumber(res, "reloftype"); ! if (lockWaitTimeout && fout->remoteVersion >= 70300) { /* * Arrange to fail instead of waiting forever for a table lock. --- 4733,4739 ---- i_toastreloptions = PQfnumber(res, "toast_reloptions"); i_reloftype = PQfnumber(res, "reloftype"); ! if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300) { /* * Arrange to fail instead of waiting forever for a table lock. *************** getTables(Archive *fout, int *numTables) *** 4777,4783 **** */ resetPQExpBuffer(query); appendPQExpBufferStr(query, "SET statement_timeout = "); ! appendStringLiteralConn(query, lockWaitTimeout, GetConnection(fout)); ExecuteSqlStatement(fout, query->data); } --- 4744,4750 ---- */ resetPQExpBuffer(query); appendPQExpBufferStr(query, "SET statement_timeout = "); ! appendStringLiteralConn(query, dopt->lockWaitTimeout, GetConnection(fout)); ExecuteSqlStatement(fout, query->data); } *************** getTables(Archive *fout, int *numTables) *** 4872,4878 **** tblinfo[i].dobj.name); } ! if (lockWaitTimeout && fout->remoteVersion >= 70300) { ExecuteSqlStatement(fout, "SET statement_timeout = 0"); } --- 4839,4845 ---- tblinfo[i].dobj.name); } ! if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300) { ExecuteSqlStatement(fout, "SET statement_timeout = 0"); } *************** getCasts(Archive *fout, int *numCasts) *** 6287,6293 **** * modifies tblinfo */ void ! getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) { int i, j; --- 6254,6260 ---- * modifies tblinfo */ void ! getTableAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tblinfo, int numTables) { int i, j; *************** getTableAttrs(Archive *fout, TableInfo * *** 6642,6648 **** addObjectDependency(&attrdefs[j].dobj, tbinfo->dobj.dumpId); } ! else if (!shouldPrintColumn(tbinfo, adnum - 1)) { /* column will be suppressed, print default separately */ attrdefs[j].separate = true; --- 6609,6615 ---- addObjectDependency(&attrdefs[j].dobj, tbinfo->dobj.dumpId); } ! else if (!shouldPrintColumn(dopt, tbinfo, adnum - 1)) { /* column will be suppressed, print default separately */ attrdefs[j].separate = true; *************** getTableAttrs(Archive *fout, TableInfo * *** 6855,6863 **** * must be kept in sync with this decision. */ bool ! shouldPrintColumn(TableInfo *tbinfo, int colno) { ! if (binary_upgrade) return true; return (tbinfo->attislocal[colno] && !tbinfo->attisdropped[colno]); } --- 6822,6830 ---- * must be kept in sync with this decision. */ bool ! shouldPrintColumn(DumpOptions *dopt, TableInfo *tbinfo, int colno) { ! if (dopt->binary_upgrade) return true; return (tbinfo->attislocal[colno] && !tbinfo->attisdropped[colno]); } *************** getForeignServers(Archive *fout, int *nu *** 7403,7409 **** * numDefaultACLs is set to the number of ACLs read in */ DefaultACLInfo * ! getDefaultACLs(Archive *fout, int *numDefaultACLs) { DefaultACLInfo *daclinfo; PQExpBuffer query; --- 7370,7376 ---- * numDefaultACLs is set to the number of ACLs read in */ DefaultACLInfo * ! getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs) { DefaultACLInfo *daclinfo; PQExpBuffer query; *************** getDefaultACLs(Archive *fout, int *numDe *** 7472,7478 **** daclinfo[i].defaclacl = pg_strdup(PQgetvalue(res, i, i_defaclacl)); /* Decide whether we want to dump it */ ! selectDumpableDefaultACL(&(daclinfo[i])); } PQclear(res); --- 7439,7445 ---- daclinfo[i].defaclacl = pg_strdup(PQgetvalue(res, i, i_defaclacl)); /* Decide whether we want to dump it */ ! selectDumpableDefaultACL(dopt, &(daclinfo[i])); } PQclear(res); *************** getDefaultACLs(Archive *fout, int *numDe *** 7501,7507 **** * calling ArchiveEntry() for the specified object. */ static void ! dumpComment(Archive *fout, const char *target, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId) { --- 7468,7474 ---- * calling ArchiveEntry() for the specified object. */ static void ! dumpComment(Archive *fout, DumpOptions *dopt, const char *target, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId) { *************** dumpComment(Archive *fout, const char *t *** 7511,7522 **** /* Comments are schema not data ... except blob comments are data */ if (strncmp(target, "LARGE OBJECT ", 13) != 0) { ! if (dataOnly) return; } else { ! if (schemaOnly) return; } --- 7478,7489 ---- /* Comments are schema not data ... except blob comments are data */ if (strncmp(target, "LARGE OBJECT ", 13) != 0) { ! if (dopt->dataOnly) return; } else { ! if (dopt->schemaOnly) return; } *************** dumpComment(Archive *fout, const char *t *** 7565,7571 **** * and its columns. */ static void ! dumpTableComment(Archive *fout, TableInfo *tbinfo, const char *reltypename) { CommentItem *comments; --- 7532,7538 ---- * and its columns. */ static void ! dumpTableComment(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, const char *reltypename) { CommentItem *comments; *************** dumpTableComment(Archive *fout, TableInf *** 7574,7580 **** PQExpBuffer target; /* Comments are SCHEMA not data */ ! if (dataOnly) return; /* Search for comments associated with relation, using table */ --- 7541,7547 ---- PQExpBuffer target; /* Comments are SCHEMA not data */ ! if (dopt->dataOnly) return; /* Search for comments associated with relation, using table */ *************** collectComments(Archive *fout, CommentIt *** 7819,7926 **** * ArchiveEntries (TOC objects) for each object to be dumped. */ static void ! dumpDumpableObject(Archive *fout, DumpableObject *dobj) { switch (dobj->objType) { case DO_NAMESPACE: ! dumpNamespace(fout, (NamespaceInfo *) dobj); break; case DO_EXTENSION: ! dumpExtension(fout, (ExtensionInfo *) dobj); break; case DO_TYPE: ! dumpType(fout, (TypeInfo *) dobj); break; case DO_SHELL_TYPE: ! dumpShellType(fout, (ShellTypeInfo *) dobj); break; case DO_FUNC: ! dumpFunc(fout, (FuncInfo *) dobj); break; case DO_AGG: ! dumpAgg(fout, (AggInfo *) dobj); break; case DO_OPERATOR: ! dumpOpr(fout, (OprInfo *) dobj); break; case DO_OPCLASS: ! dumpOpclass(fout, (OpclassInfo *) dobj); break; case DO_OPFAMILY: ! dumpOpfamily(fout, (OpfamilyInfo *) dobj); break; case DO_COLLATION: ! dumpCollation(fout, (CollInfo *) dobj); break; case DO_CONVERSION: ! dumpConversion(fout, (ConvInfo *) dobj); break; case DO_TABLE: ! dumpTable(fout, (TableInfo *) dobj); break; case DO_ATTRDEF: ! dumpAttrDef(fout, (AttrDefInfo *) dobj); break; case DO_INDEX: ! dumpIndex(fout, (IndxInfo *) dobj); break; case DO_REFRESH_MATVIEW: refreshMatViewData(fout, (TableDataInfo *) dobj); break; case DO_RULE: ! dumpRule(fout, (RuleInfo *) dobj); break; case DO_TRIGGER: ! dumpTrigger(fout, (TriggerInfo *) dobj); break; case DO_EVENT_TRIGGER: ! dumpEventTrigger(fout, (EventTriggerInfo *) dobj); break; case DO_CONSTRAINT: ! dumpConstraint(fout, (ConstraintInfo *) dobj); break; case DO_FK_CONSTRAINT: ! dumpConstraint(fout, (ConstraintInfo *) dobj); break; case DO_PROCLANG: ! dumpProcLang(fout, (ProcLangInfo *) dobj); break; case DO_CAST: ! dumpCast(fout, (CastInfo *) dobj); break; case DO_TABLE_DATA: if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE) dumpSequenceData(fout, (TableDataInfo *) dobj); else ! dumpTableData(fout, (TableDataInfo *) dobj); break; case DO_DUMMY_TYPE: /* table rowtypes and array types are never dumped separately */ break; case DO_TSPARSER: ! dumpTSParser(fout, (TSParserInfo *) dobj); break; case DO_TSDICT: ! dumpTSDictionary(fout, (TSDictInfo *) dobj); break; case DO_TSTEMPLATE: ! dumpTSTemplate(fout, (TSTemplateInfo *) dobj); break; case DO_TSCONFIG: ! dumpTSConfig(fout, (TSConfigInfo *) dobj); break; case DO_FDW: ! dumpForeignDataWrapper(fout, (FdwInfo *) dobj); break; case DO_FOREIGN_SERVER: ! dumpForeignServer(fout, (ForeignServerInfo *) dobj); break; case DO_DEFAULT_ACL: ! dumpDefaultACL(fout, (DefaultACLInfo *) dobj); break; case DO_BLOB: ! dumpBlob(fout, (BlobInfo *) dobj); break; case DO_BLOB_DATA: ArchiveEntry(fout, dobj->catId, dobj->dumpId, --- 7786,7893 ---- * ArchiveEntries (TOC objects) for each object to be dumped. */ static void ! dumpDumpableObject(Archive *fout, DumpOptions *dopt, DumpableObject *dobj) { switch (dobj->objType) { case DO_NAMESPACE: ! dumpNamespace(fout, dopt, (NamespaceInfo *) dobj); break; case DO_EXTENSION: ! dumpExtension(fout, dopt, (ExtensionInfo *) dobj); break; case DO_TYPE: ! dumpType(fout, dopt, (TypeInfo *) dobj); break; case DO_SHELL_TYPE: ! dumpShellType(fout, dopt, (ShellTypeInfo *) dobj); break; case DO_FUNC: ! dumpFunc(fout, dopt, (FuncInfo *) dobj); break; case DO_AGG: ! dumpAgg(fout, dopt, (AggInfo *) dobj); break; case DO_OPERATOR: ! dumpOpr(fout, dopt, (OprInfo *) dobj); break; case DO_OPCLASS: ! dumpOpclass(fout, dopt, (OpclassInfo *) dobj); break; case DO_OPFAMILY: ! dumpOpfamily(fout, dopt, (OpfamilyInfo *) dobj); break; case DO_COLLATION: ! dumpCollation(fout, dopt, (CollInfo *) dobj); break; case DO_CONVERSION: ! dumpConversion(fout, dopt, (ConvInfo *) dobj); break; case DO_TABLE: ! dumpTable(fout, dopt, (TableInfo *) dobj); break; case DO_ATTRDEF: ! dumpAttrDef(fout, dopt, (AttrDefInfo *) dobj); break; case DO_INDEX: ! dumpIndex(fout, dopt, (IndxInfo *) dobj); break; case DO_REFRESH_MATVIEW: refreshMatViewData(fout, (TableDataInfo *) dobj); break; case DO_RULE: ! dumpRule(fout, dopt, (RuleInfo *) dobj); break; case DO_TRIGGER: ! dumpTrigger(fout, dopt, (TriggerInfo *) dobj); break; case DO_EVENT_TRIGGER: ! dumpEventTrigger(fout, dopt, (EventTriggerInfo *) dobj); break; case DO_CONSTRAINT: ! dumpConstraint(fout, dopt, (ConstraintInfo *) dobj); break; case DO_FK_CONSTRAINT: ! dumpConstraint(fout, dopt, (ConstraintInfo *) dobj); break; case DO_PROCLANG: ! dumpProcLang(fout, dopt, (ProcLangInfo *) dobj); break; case DO_CAST: ! dumpCast(fout, dopt, (CastInfo *) dobj); break; case DO_TABLE_DATA: if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE) dumpSequenceData(fout, (TableDataInfo *) dobj); else ! dumpTableData(fout, dopt, (TableDataInfo *) dobj); break; case DO_DUMMY_TYPE: /* table rowtypes and array types are never dumped separately */ break; case DO_TSPARSER: ! dumpTSParser(fout, dopt, (TSParserInfo *) dobj); break; case DO_TSDICT: ! dumpTSDictionary(fout, dopt, (TSDictInfo *) dobj); break; case DO_TSTEMPLATE: ! dumpTSTemplate(fout, dopt, (TSTemplateInfo *) dobj); break; case DO_TSCONFIG: ! dumpTSConfig(fout, dopt, (TSConfigInfo *) dobj); break; case DO_FDW: ! dumpForeignDataWrapper(fout, dopt, (FdwInfo *) dobj); break; case DO_FOREIGN_SERVER: ! dumpForeignServer(fout, dopt, (ForeignServerInfo *) dobj); break; case DO_DEFAULT_ACL: ! dumpDefaultACL(fout, dopt, (DefaultACLInfo *) dobj); break; case DO_BLOB: ! dumpBlob(fout, dopt, (BlobInfo *) dobj); break; case DO_BLOB_DATA: ArchiveEntry(fout, dobj->catId, dobj->dumpId, *************** dumpDumpableObject(Archive *fout, Dumpab *** 7942,7948 **** * writes out to fout the queries to recreate a user-defined namespace */ static void ! dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) { PQExpBuffer q; PQExpBuffer delq; --- 7909,7915 ---- * writes out to fout the queries to recreate a user-defined namespace */ static void ! dumpNamespace(Archive *fout, DumpOptions *dopt, NamespaceInfo *nspinfo) { PQExpBuffer q; PQExpBuffer delq; *************** dumpNamespace(Archive *fout, NamespaceIn *** 7950,7956 **** char *qnspname; /* Skip if not to be dumped */ ! if (!nspinfo->dobj.dump || dataOnly) return; /* don't dump dummy namespace from pre-7.3 source */ --- 7917,7923 ---- char *qnspname; /* Skip if not to be dumped */ ! if (!nspinfo->dobj.dump || dopt->dataOnly) return; /* don't dump dummy namespace from pre-7.3 source */ *************** dumpNamespace(Archive *fout, NamespaceIn *** 7969,7975 **** appendPQExpBuffer(labelq, "SCHEMA %s", qnspname); ! if (binary_upgrade) binary_upgrade_extension_member(q, &nspinfo->dobj, labelq->data); ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, --- 7936,7942 ---- appendPQExpBuffer(labelq, "SCHEMA %s", qnspname); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &nspinfo->dobj, labelq->data); ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, *************** dumpNamespace(Archive *fout, NamespaceIn *** 7982,7995 **** NULL, NULL); /* Dump Schema Comments and Security Labels */ ! dumpComment(fout, labelq->data, NULL, nspinfo->rolname, nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId); ! dumpSecLabel(fout, labelq->data, NULL, nspinfo->rolname, nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId); ! dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA", qnspname, NULL, nspinfo->dobj.name, NULL, nspinfo->rolname, nspinfo->nspacl); --- 7949,7962 ---- NULL, NULL); /* Dump Schema Comments and Security Labels */ ! dumpComment(fout, dopt, labelq->data, NULL, nspinfo->rolname, nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, NULL, nspinfo->rolname, nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId); ! dumpACL(fout, dopt, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA", qnspname, NULL, nspinfo->dobj.name, NULL, nspinfo->rolname, nspinfo->nspacl); *************** dumpNamespace(Archive *fout, NamespaceIn *** 8005,8011 **** * writes out to fout the queries to recreate an extension */ static void ! dumpExtension(Archive *fout, ExtensionInfo *extinfo) { PQExpBuffer q; PQExpBuffer delq; --- 7972,7978 ---- * writes out to fout the queries to recreate an extension */ static void ! dumpExtension(Archive *fout, DumpOptions *dopt, ExtensionInfo *extinfo) { PQExpBuffer q; PQExpBuffer delq; *************** dumpExtension(Archive *fout, ExtensionIn *** 8013,8019 **** char *qextname; /* Skip if not to be dumped */ ! if (!extinfo->dobj.dump || dataOnly) return; q = createPQExpBuffer(); --- 7980,7986 ---- char *qextname; /* Skip if not to be dumped */ ! if (!extinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpExtension(Archive *fout, ExtensionIn *** 8024,8030 **** appendPQExpBuffer(delq, "DROP EXTENSION %s;\n", qextname); ! if (!binary_upgrade) { /* * In a regular dump, we use IF NOT EXISTS so that there isn't a --- 7991,7997 ---- appendPQExpBuffer(delq, "DROP EXTENSION %s;\n", qextname); ! if (!dopt->binary_upgrade) { /* * In a regular dump, we use IF NOT EXISTS so that there isn't a *************** dumpExtension(Archive *fout, ExtensionIn *** 8110,8119 **** NULL, NULL); /* Dump Extension Comments and Security Labels */ ! dumpComment(fout, labelq->data, NULL, "", extinfo->dobj.catId, 0, extinfo->dobj.dumpId); ! dumpSecLabel(fout, labelq->data, NULL, "", extinfo->dobj.catId, 0, extinfo->dobj.dumpId); --- 8077,8086 ---- NULL, NULL); /* Dump Extension Comments and Security Labels */ ! dumpComment(fout, dopt, labelq->data, NULL, "", extinfo->dobj.catId, 0, extinfo->dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, NULL, "", extinfo->dobj.catId, 0, extinfo->dobj.dumpId); *************** dumpExtension(Archive *fout, ExtensionIn *** 8129,8151 **** * writes out to fout the queries to recreate a user-defined type */ static void ! dumpType(Archive *fout, TypeInfo *tyinfo) { /* Skip if not to be dumped */ ! if (!tyinfo->dobj.dump || dataOnly) return; /* Dump out in proper style */ if (tyinfo->typtype == TYPTYPE_BASE) ! dumpBaseType(fout, tyinfo); else if (tyinfo->typtype == TYPTYPE_DOMAIN) ! dumpDomain(fout, tyinfo); else if (tyinfo->typtype == TYPTYPE_COMPOSITE) ! dumpCompositeType(fout, tyinfo); else if (tyinfo->typtype == TYPTYPE_ENUM) ! dumpEnumType(fout, tyinfo); else if (tyinfo->typtype == TYPTYPE_RANGE) ! dumpRangeType(fout, tyinfo); else write_msg(NULL, "WARNING: typtype of data type \"%s\" appears to be invalid\n", tyinfo->dobj.name); --- 8096,8118 ---- * writes out to fout the queries to recreate a user-defined type */ static void ! dumpType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo) { /* Skip if not to be dumped */ ! if (!tyinfo->dobj.dump || dopt->dataOnly) return; /* Dump out in proper style */ if (tyinfo->typtype == TYPTYPE_BASE) ! dumpBaseType(fout, dopt, tyinfo); else if (tyinfo->typtype == TYPTYPE_DOMAIN) ! dumpDomain(fout, dopt, tyinfo); else if (tyinfo->typtype == TYPTYPE_COMPOSITE) ! dumpCompositeType(fout, dopt, tyinfo); else if (tyinfo->typtype == TYPTYPE_ENUM) ! dumpEnumType(fout, dopt, tyinfo); else if (tyinfo->typtype == TYPTYPE_RANGE) ! dumpRangeType(fout, dopt, tyinfo); else write_msg(NULL, "WARNING: typtype of data type \"%s\" appears to be invalid\n", tyinfo->dobj.name); *************** dumpType(Archive *fout, TypeInfo *tyinfo *** 8156,8162 **** * writes out to fout the queries to recreate a user-defined enum type */ static void ! dumpEnumType(Archive *fout, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); --- 8123,8129 ---- * writes out to fout the queries to recreate a user-defined enum type */ static void ! dumpEnumType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); *************** dumpEnumType(Archive *fout, TypeInfo *ty *** 8201,8214 **** appendPQExpBuffer(delq, "%s;\n", qtypname); ! if (binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); appendPQExpBuffer(q, "CREATE TYPE %s AS ENUM (", qtypname); ! if (!binary_upgrade) { /* Labels with server-assigned oids */ for (i = 0; i < num; i++) --- 8168,8181 ---- appendPQExpBuffer(delq, "%s;\n", qtypname); ! if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); appendPQExpBuffer(q, "CREATE TYPE %s AS ENUM (", qtypname); ! if (!dopt->binary_upgrade) { /* Labels with server-assigned oids */ for (i = 0; i < num; i++) *************** dumpEnumType(Archive *fout, TypeInfo *ty *** 8223,8229 **** appendPQExpBufferStr(q, "\n);\n"); ! if (binary_upgrade) { /* Labels with dump-assigned (preserved) oids */ for (i = 0; i < num; i++) --- 8190,8196 ---- appendPQExpBufferStr(q, "\n);\n"); ! if (dopt->binary_upgrade) { /* Labels with dump-assigned (preserved) oids */ for (i = 0; i < num; i++) *************** dumpEnumType(Archive *fout, TypeInfo *ty *** 8247,8253 **** appendPQExpBuffer(labelq, "TYPE %s", qtypname); ! if (binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, --- 8214,8220 ---- appendPQExpBuffer(labelq, "TYPE %s", qtypname); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, *************** dumpEnumType(Archive *fout, TypeInfo *ty *** 8261,8274 **** NULL, NULL); /* Dump Type Comments and Security Labels */ ! dumpComment(fout, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpSecLabel(fout, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); --- 8228,8241 ---- NULL, NULL); /* Dump Type Comments and Security Labels */ ! dumpComment(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); *************** dumpEnumType(Archive *fout, TypeInfo *ty *** 8285,8291 **** * writes out to fout the queries to recreate a user-defined range type */ static void ! dumpRangeType(Archive *fout, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); --- 8252,8258 ---- * writes out to fout the queries to recreate a user-defined range type */ static void ! dumpRangeType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); *************** dumpRangeType(Archive *fout, TypeInfo *t *** 8331,8337 **** appendPQExpBuffer(delq, "%s;\n", qtypname); ! if (binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); --- 8298,8304 ---- appendPQExpBuffer(delq, "%s;\n", qtypname); ! if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); *************** dumpRangeType(Archive *fout, TypeInfo *t *** 8379,8385 **** appendPQExpBuffer(labelq, "TYPE %s", qtypname); ! if (binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, --- 8346,8352 ---- appendPQExpBuffer(labelq, "TYPE %s", qtypname); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, *************** dumpRangeType(Archive *fout, TypeInfo *t *** 8393,8406 **** NULL, NULL); /* Dump Type Comments and Security Labels */ ! dumpComment(fout, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpSecLabel(fout, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); --- 8360,8373 ---- NULL, NULL); /* Dump Type Comments and Security Labels */ ! dumpComment(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); *************** dumpRangeType(Archive *fout, TypeInfo *t *** 8417,8423 **** * writes out to fout the queries to recreate a user-defined base type */ static void ! dumpBaseType(Archive *fout, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); --- 8384,8390 ---- * writes out to fout the queries to recreate a user-defined base type */ static void ! dumpBaseType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); *************** dumpBaseType(Archive *fout, TypeInfo *ty *** 8671,8677 **** qtypname); /* We might already have a shell type, but setting pg_type_oid is harmless */ ! if (binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); --- 8638,8644 ---- qtypname); /* We might already have a shell type, but setting pg_type_oid is harmless */ ! if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); *************** dumpBaseType(Archive *fout, TypeInfo *ty *** 8769,8775 **** appendPQExpBuffer(labelq, "TYPE %s", qtypname); ! if (binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, --- 8736,8742 ---- appendPQExpBuffer(labelq, "TYPE %s", qtypname); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, *************** dumpBaseType(Archive *fout, TypeInfo *ty *** 8783,8796 **** NULL, NULL); /* Dump Type Comments and Security Labels */ ! dumpComment(fout, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpSecLabel(fout, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); --- 8750,8763 ---- NULL, NULL); /* Dump Type Comments and Security Labels */ ! dumpComment(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); *************** dumpBaseType(Archive *fout, TypeInfo *ty *** 8807,8813 **** * writes out to fout the queries to recreate a user-defined domain */ static void ! dumpDomain(Archive *fout, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); --- 8774,8780 ---- * writes out to fout the queries to recreate a user-defined domain */ static void ! dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); *************** dumpDomain(Archive *fout, TypeInfo *tyin *** 8867,8873 **** typdefault = NULL; typcollation = atooid(PQgetvalue(res, 0, PQfnumber(res, "typcollation"))); ! if (binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); --- 8834,8840 ---- typdefault = NULL; typcollation = atooid(PQgetvalue(res, 0, PQfnumber(res, "typcollation"))); ! if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); *************** dumpDomain(Archive *fout, TypeInfo *tyin *** 8931,8937 **** appendPQExpBuffer(labelq, "DOMAIN %s", qtypname); ! if (binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, --- 8898,8904 ---- appendPQExpBuffer(labelq, "DOMAIN %s", qtypname); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, *************** dumpDomain(Archive *fout, TypeInfo *tyin *** 8945,8958 **** NULL, NULL); /* Dump Domain Comments and Security Labels */ ! dumpComment(fout, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpSecLabel(fout, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); --- 8912,8925 ---- NULL, NULL); /* Dump Domain Comments and Security Labels */ ! dumpComment(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); *************** dumpDomain(Archive *fout, TypeInfo *tyin *** 8969,8975 **** * composite type */ static void ! dumpCompositeType(Archive *fout, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer dropped = createPQExpBuffer(); --- 8936,8942 ---- * composite type */ static void ! dumpCompositeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer dropped = createPQExpBuffer(); *************** dumpCompositeType(Archive *fout, TypeInf *** 9046,9052 **** i_attcollation = PQfnumber(res, "attcollation"); i_typrelid = PQfnumber(res, "typrelid"); ! if (binary_upgrade) { Oid typrelid = atooid(PQgetvalue(res, 0, i_typrelid)); --- 9013,9019 ---- i_attcollation = PQfnumber(res, "attcollation"); i_typrelid = PQfnumber(res, "typrelid"); ! if (dopt->binary_upgrade) { Oid typrelid = atooid(PQgetvalue(res, 0, i_typrelid)); *************** dumpCompositeType(Archive *fout, TypeInf *** 9077,9083 **** attisdropped = (PQgetvalue(res, i, i_attisdropped)[0] == 't'); attcollation = atooid(PQgetvalue(res, i, i_attcollation)); ! if (attisdropped && !binary_upgrade) continue; /* Format properly if not first attr */ --- 9044,9050 ---- attisdropped = (PQgetvalue(res, i, i_attisdropped)[0] == 't'); attcollation = atooid(PQgetvalue(res, i, i_attcollation)); ! if (attisdropped && !dopt->binary_upgrade) continue; /* Format properly if not first attr */ *************** dumpCompositeType(Archive *fout, TypeInf *** 9145,9151 **** appendPQExpBuffer(labelq, "TYPE %s", qtypname); ! if (binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, --- 9112,9118 ---- appendPQExpBuffer(labelq, "TYPE %s", qtypname); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, *************** dumpCompositeType(Archive *fout, TypeInf *** 9160,9173 **** /* Dump Type Comments and Security Labels */ ! dumpComment(fout, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpSecLabel(fout, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); --- 9127,9140 ---- /* Dump Type Comments and Security Labels */ ! dumpComment(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); ! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); *************** dumpCompositeTypeColComments(Archive *fo *** 9298,9309 **** * We dump a shell definition in advance of the I/O functions for the type. */ static void ! dumpShellType(Archive *fout, ShellTypeInfo *stinfo) { PQExpBuffer q; /* Skip if not to be dumped */ ! if (!stinfo->dobj.dump || dataOnly) return; q = createPQExpBuffer(); --- 9265,9276 ---- * We dump a shell definition in advance of the I/O functions for the type. */ static void ! dumpShellType(Archive *fout, DumpOptions *dopt, ShellTypeInfo *stinfo) { PQExpBuffer q; /* Skip if not to be dumped */ ! if (!stinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpShellType(Archive *fout, ShellTypeIn *** 9317,9323 **** * after it's filled in, otherwise the backend complains. */ ! if (binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, stinfo->baseType->dobj.catId.oid); --- 9284,9290 ---- * after it's filled in, otherwise the backend complains. */ ! if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, stinfo->baseType->dobj.catId.oid); *************** dumpShellType(Archive *fout, ShellTypeIn *** 9353,9364 **** * That case isn't checked here either. */ static bool ! shouldDumpProcLangs(void) { ! if (!include_everything) return false; /* And they're schema not data */ ! if (dataOnly) return false; return true; } --- 9320,9331 ---- * That case isn't checked here either. */ static bool ! shouldDumpProcLangs(DumpOptions *dopt) { ! if (!dopt->include_everything) return false; /* And they're schema not data */ ! if (dopt->dataOnly) return false; return true; } *************** shouldDumpProcLangs(void) *** 9369,9375 **** * procedural language */ static void ! dumpProcLang(Archive *fout, ProcLangInfo *plang) { PQExpBuffer defqry; PQExpBuffer delqry; --- 9336,9342 ---- * procedural language */ static void ! dumpProcLang(Archive *fout, DumpOptions* dopt, ProcLangInfo *plang) { PQExpBuffer defqry; PQExpBuffer delqry; *************** dumpProcLang(Archive *fout, ProcLangInfo *** 9382,9388 **** FuncInfo *validatorInfo = NULL; /* Skip if not to be dumped */ ! if (!plang->dobj.dump || dataOnly) return; /* --- 9349,9355 ---- FuncInfo *validatorInfo = NULL; /* Skip if not to be dumped */ ! if (!plang->dobj.dump || dopt->dataOnly) return; /* *************** dumpProcLang(Archive *fout, ProcLangInfo *** 9428,9434 **** if (!plang->dobj.ext_member) { ! if (!useParams && !shouldDumpProcLangs()) return; } --- 9395,9401 ---- if (!plang->dobj.ext_member) { ! if (!useParams && !shouldDumpProcLangs(dopt)) return; } *************** dumpProcLang(Archive *fout, ProcLangInfo *** 9495,9501 **** appendPQExpBuffer(labelq, "LANGUAGE %s", qlanname); ! if (binary_upgrade) binary_upgrade_extension_member(defqry, &plang->dobj, labelq->data); ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId, --- 9462,9468 ---- appendPQExpBuffer(labelq, "LANGUAGE %s", qlanname); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(defqry, &plang->dobj, labelq->data); ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId, *************** dumpProcLang(Archive *fout, ProcLangInfo *** 9507,9521 **** NULL, NULL); /* Dump Proc Lang Comments and Security Labels */ ! dumpComment(fout, labelq->data, NULL, "", plang->dobj.catId, 0, plang->dobj.dumpId); ! dumpSecLabel(fout, labelq->data, NULL, "", plang->dobj.catId, 0, plang->dobj.dumpId); if (plang->lanpltrusted) ! dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE", qlanname, NULL, plang->dobj.name, lanschema, plang->lanowner, plang->lanacl); --- 9474,9488 ---- NULL, NULL); /* Dump Proc Lang Comments and Security Labels */ ! dumpComment(fout, dopt, labelq->data, NULL, "", plang->dobj.catId, 0, plang->dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, NULL, "", plang->dobj.catId, 0, plang->dobj.dumpId); if (plang->lanpltrusted) ! dumpACL(fout, dopt, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE", qlanname, NULL, plang->dobj.name, lanschema, plang->lanowner, plang->lanacl); *************** format_function_signature(Archive *fout, *** 9662,9668 **** * dump out one function */ static void ! dumpFunc(Archive *fout, FuncInfo *finfo) { PQExpBuffer query; PQExpBuffer q; --- 9629,9635 ---- * dump out one function */ static void ! dumpFunc(Archive *fout, DumpOptions* dopt, FuncInfo *finfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpFunc(Archive *fout, FuncInfo *finfo) *** 9701,9707 **** int i; /* Skip if not to be dumped */ ! if (!finfo->dobj.dump || dataOnly) return; query = createPQExpBuffer(); --- 9668,9674 ---- int i; /* Skip if not to be dumped */ ! if (!finfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); *************** dumpFunc(Archive *fout, FuncInfo *finfo) *** 9894,9900 **** * where we have bin, use dollar quoting if allowed and src * contains quote or backslash; else use regular quoting. */ ! if (disable_dollar_quoting || (strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL)) appendStringLiteralAH(asPart, prosrc, fout); else --- 9861,9867 ---- * where we have bin, use dollar quoting if allowed and src * contains quote or backslash; else use regular quoting. */ ! if (dopt->disable_dollar_quoting || (strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL)) appendStringLiteralAH(asPart, prosrc, fout); else *************** dumpFunc(Archive *fout, FuncInfo *finfo) *** 9907,9913 **** { appendPQExpBufferStr(asPart, "AS "); /* with no bin, dollar quote src unconditionally if allowed */ ! if (disable_dollar_quoting) appendStringLiteralAH(asPart, prosrc, fout); else appendStringLiteralDQ(asPart, prosrc, NULL); --- 9874,9880 ---- { appendPQExpBufferStr(asPart, "AS "); /* with no bin, dollar quote src unconditionally if allowed */ ! if (dopt->disable_dollar_quoting) appendStringLiteralAH(asPart, prosrc, fout); else appendStringLiteralDQ(asPart, prosrc, NULL); *************** dumpFunc(Archive *fout, FuncInfo *finfo) *** 10083,10089 **** appendPQExpBuffer(labelq, "FUNCTION %s", funcsig); ! if (binary_upgrade) binary_upgrade_extension_member(q, &finfo->dobj, labelq->data); ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId, --- 10050,10056 ---- appendPQExpBuffer(labelq, "FUNCTION %s", funcsig); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &finfo->dobj, labelq->data); ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId, *************** dumpFunc(Archive *fout, FuncInfo *finfo) *** 10097,10110 **** NULL, NULL); /* Dump Function Comments and Security Labels */ ! dumpComment(fout, labelq->data, finfo->dobj.namespace->dobj.name, finfo->rolname, finfo->dobj.catId, 0, finfo->dobj.dumpId); ! dumpSecLabel(fout, labelq->data, finfo->dobj.namespace->dobj.name, finfo->rolname, finfo->dobj.catId, 0, finfo->dobj.dumpId); ! dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION", funcsig, NULL, funcsig_tag, finfo->dobj.namespace->dobj.name, finfo->rolname, finfo->proacl); --- 10064,10077 ---- NULL, NULL); /* Dump Function Comments and Security Labels */ ! dumpComment(fout, dopt, labelq->data, finfo->dobj.namespace->dobj.name, finfo->rolname, finfo->dobj.catId, 0, finfo->dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, finfo->dobj.namespace->dobj.name, finfo->rolname, finfo->dobj.catId, 0, finfo->dobj.dumpId); ! dumpACL(fout, dopt, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION", funcsig, NULL, funcsig_tag, finfo->dobj.namespace->dobj.name, finfo->rolname, finfo->proacl); *************** dumpFunc(Archive *fout, FuncInfo *finfo) *** 10135,10141 **** * Dump a user-defined cast */ static void ! dumpCast(Archive *fout, CastInfo *cast) { PQExpBuffer defqry; PQExpBuffer delqry; --- 10102,10108 ---- * Dump a user-defined cast */ static void ! dumpCast(Archive *fout, DumpOptions* dopt, CastInfo *cast) { PQExpBuffer defqry; PQExpBuffer delqry; *************** dumpCast(Archive *fout, CastInfo *cast) *** 10143,10149 **** FuncInfo *funcInfo = NULL; /* Skip if not to be dumped */ ! if (!cast->dobj.dump || dataOnly) return; /* Cannot dump if we don't have the cast function's info */ --- 10110,10116 ---- FuncInfo *funcInfo = NULL; /* Skip if not to be dumped */ ! if (!cast->dobj.dump || dopt->dataOnly) return; /* Cannot dump if we don't have the cast function's info */ *************** dumpCast(Archive *fout, CastInfo *cast) *** 10257,10263 **** getFormattedTypeName(fout, cast->castsource, zeroAsNone), getFormattedTypeName(fout, cast->casttarget, zeroAsNone)); ! if (binary_upgrade) binary_upgrade_extension_member(defqry, &cast->dobj, labelq->data); ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId, --- 10224,10230 ---- getFormattedTypeName(fout, cast->castsource, zeroAsNone), getFormattedTypeName(fout, cast->casttarget, zeroAsNone)); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(defqry, &cast->dobj, labelq->data); ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId, *************** dumpCast(Archive *fout, CastInfo *cast) *** 10269,10275 **** NULL, NULL); /* Dump Cast Comments */ ! dumpComment(fout, labelq->data, NULL, "", cast->dobj.catId, 0, cast->dobj.dumpId); --- 10236,10242 ---- NULL, NULL); /* Dump Cast Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, "", cast->dobj.catId, 0, cast->dobj.dumpId); *************** dumpCast(Archive *fout, CastInfo *cast) *** 10283,10289 **** * write out a single operator definition */ static void ! dumpOpr(Archive *fout, OprInfo *oprinfo) { PQExpBuffer query; PQExpBuffer q; --- 10250,10256 ---- * write out a single operator definition */ static void ! dumpOpr(Archive *fout, DumpOptions* dopt, OprInfo *oprinfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpOpr(Archive *fout, OprInfo *oprinfo) *** 10317,10323 **** char *oprref; /* Skip if not to be dumped */ ! if (!oprinfo->dobj.dump || dataOnly) return; /* --- 10284,10290 ---- char *oprref; /* Skip if not to be dumped */ ! if (!oprinfo->dobj.dump || dopt->dataOnly) return; /* *************** dumpOpr(Archive *fout, OprInfo *oprinfo) *** 10507,10513 **** appendPQExpBuffer(labelq, "OPERATOR %s", oprid->data); ! if (binary_upgrade) binary_upgrade_extension_member(q, &oprinfo->dobj, labelq->data); ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId, --- 10474,10480 ---- appendPQExpBuffer(labelq, "OPERATOR %s", oprid->data); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &oprinfo->dobj, labelq->data); ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId, *************** dumpOpr(Archive *fout, OprInfo *oprinfo) *** 10521,10527 **** NULL, NULL); /* Dump Operator Comments */ ! dumpComment(fout, labelq->data, oprinfo->dobj.namespace->dobj.name, oprinfo->rolname, oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId); --- 10488,10494 ---- NULL, NULL); /* Dump Operator Comments */ ! dumpComment(fout, dopt, labelq->data, oprinfo->dobj.namespace->dobj.name, oprinfo->rolname, oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId); *************** convertTSFunction(Archive *fout, Oid fun *** 10671,10677 **** * write out a single operator class definition */ static void ! dumpOpclass(Archive *fout, OpclassInfo *opcinfo) { PQExpBuffer query; PQExpBuffer q; --- 10638,10644 ---- * write out a single operator class definition */ static void ! dumpOpclass(Archive *fout, DumpOptions* dopt, OpclassInfo *opcinfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpOpclass(Archive *fout, OpclassInfo * *** 10715,10721 **** int i; /* Skip if not to be dumped */ ! if (!opcinfo->dobj.dump || dataOnly) return; /* --- 10682,10688 ---- int i; /* Skip if not to be dumped */ ! if (!opcinfo->dobj.dump || dopt->dataOnly) return; /* *************** dumpOpclass(Archive *fout, OpclassInfo * *** 11015,11021 **** appendPQExpBuffer(labelq, " USING %s", fmtId(amname)); ! if (binary_upgrade) binary_upgrade_extension_member(q, &opcinfo->dobj, labelq->data); ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId, --- 10982,10988 ---- appendPQExpBuffer(labelq, " USING %s", fmtId(amname)); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &opcinfo->dobj, labelq->data); ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId, *************** dumpOpclass(Archive *fout, OpclassInfo * *** 11029,11035 **** NULL, NULL); /* Dump Operator Class Comments */ ! dumpComment(fout, labelq->data, NULL, opcinfo->rolname, opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId); --- 10996,11002 ---- NULL, NULL); /* Dump Operator Class Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, opcinfo->rolname, opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId); *************** dumpOpclass(Archive *fout, OpclassInfo * *** 11048,11054 **** * specific opclass within the opfamily. */ static void ! dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo) { PQExpBuffer query; PQExpBuffer q; --- 11015,11021 ---- * specific opclass within the opfamily. */ static void ! dumpOpfamily(Archive *fout, DumpOptions* dopt, OpfamilyInfo *opfinfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpOpfamily(Archive *fout, OpfamilyInfo *** 11082,11088 **** int i; /* Skip if not to be dumped */ ! if (!opfinfo->dobj.dump || dataOnly) return; /* --- 11049,11055 ---- int i; /* Skip if not to be dumped */ ! if (!opfinfo->dobj.dump || dopt->dataOnly) return; /* *************** dumpOpfamily(Archive *fout, OpfamilyInfo *** 11328,11334 **** appendPQExpBuffer(labelq, " USING %s", fmtId(amname)); ! if (binary_upgrade) binary_upgrade_extension_member(q, &opfinfo->dobj, labelq->data); ArchiveEntry(fout, opfinfo->dobj.catId, opfinfo->dobj.dumpId, --- 11295,11301 ---- appendPQExpBuffer(labelq, " USING %s", fmtId(amname)); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &opfinfo->dobj, labelq->data); ArchiveEntry(fout, opfinfo->dobj.catId, opfinfo->dobj.dumpId, *************** dumpOpfamily(Archive *fout, OpfamilyInfo *** 11342,11348 **** NULL, NULL); /* Dump Operator Family Comments */ ! dumpComment(fout, labelq->data, NULL, opfinfo->rolname, opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId); --- 11309,11315 ---- NULL, NULL); /* Dump Operator Family Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, opfinfo->rolname, opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId); *************** dumpOpfamily(Archive *fout, OpfamilyInfo *** 11360,11366 **** * write out a single collation definition */ static void ! dumpCollation(Archive *fout, CollInfo *collinfo) { PQExpBuffer query; PQExpBuffer q; --- 11327,11333 ---- * write out a single collation definition */ static void ! dumpCollation(Archive *fout, DumpOptions* dopt, CollInfo *collinfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpCollation(Archive *fout, CollInfo *c *** 11373,11379 **** const char *collctype; /* Skip if not to be dumped */ ! if (!collinfo->dobj.dump || dataOnly) return; query = createPQExpBuffer(); --- 11340,11346 ---- const char *collctype; /* Skip if not to be dumped */ ! if (!collinfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); *************** dumpCollation(Archive *fout, CollInfo *c *** 11417,11423 **** appendPQExpBuffer(labelq, "COLLATION %s", fmtId(collinfo->dobj.name)); ! if (binary_upgrade) binary_upgrade_extension_member(q, &collinfo->dobj, labelq->data); ArchiveEntry(fout, collinfo->dobj.catId, collinfo->dobj.dumpId, --- 11384,11390 ---- appendPQExpBuffer(labelq, "COLLATION %s", fmtId(collinfo->dobj.name)); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &collinfo->dobj, labelq->data); ArchiveEntry(fout, collinfo->dobj.catId, collinfo->dobj.dumpId, *************** dumpCollation(Archive *fout, CollInfo *c *** 11431,11437 **** NULL, NULL); /* Dump Collation Comments */ ! dumpComment(fout, labelq->data, collinfo->dobj.namespace->dobj.name, collinfo->rolname, collinfo->dobj.catId, 0, collinfo->dobj.dumpId); --- 11398,11404 ---- NULL, NULL); /* Dump Collation Comments */ ! dumpComment(fout, dopt, labelq->data, collinfo->dobj.namespace->dobj.name, collinfo->rolname, collinfo->dobj.catId, 0, collinfo->dobj.dumpId); *************** dumpCollation(Archive *fout, CollInfo *c *** 11448,11454 **** * write out a single conversion definition */ static void ! dumpConversion(Archive *fout, ConvInfo *convinfo) { PQExpBuffer query; PQExpBuffer q; --- 11415,11421 ---- * write out a single conversion definition */ static void ! dumpConversion(Archive *fout, DumpOptions* dopt, ConvInfo *convinfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpConversion(Archive *fout, ConvInfo * *** 11465,11471 **** bool condefault; /* Skip if not to be dumped */ ! if (!convinfo->dobj.dump || dataOnly) return; query = createPQExpBuffer(); --- 11432,11438 ---- bool condefault; /* Skip if not to be dumped */ ! if (!convinfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); *************** dumpConversion(Archive *fout, ConvInfo * *** 11516,11522 **** appendPQExpBuffer(labelq, "CONVERSION %s", fmtId(convinfo->dobj.name)); ! if (binary_upgrade) binary_upgrade_extension_member(q, &convinfo->dobj, labelq->data); ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId, --- 11483,11489 ---- appendPQExpBuffer(labelq, "CONVERSION %s", fmtId(convinfo->dobj.name)); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &convinfo->dobj, labelq->data); ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId, *************** dumpConversion(Archive *fout, ConvInfo * *** 11530,11536 **** NULL, NULL); /* Dump Conversion Comments */ ! dumpComment(fout, labelq->data, convinfo->dobj.namespace->dobj.name, convinfo->rolname, convinfo->dobj.catId, 0, convinfo->dobj.dumpId); --- 11497,11503 ---- NULL, NULL); /* Dump Conversion Comments */ ! dumpComment(fout, dopt, labelq->data, convinfo->dobj.namespace->dobj.name, convinfo->rolname, convinfo->dobj.catId, 0, convinfo->dobj.dumpId); *************** format_aggregate_signature(AggInfo *aggi *** 11587,11593 **** * write out a single aggregate definition */ static void ! dumpAgg(Archive *fout, AggInfo *agginfo) { PQExpBuffer query; PQExpBuffer q; --- 11554,11560 ---- * write out a single aggregate definition */ static void ! dumpAgg(Archive *fout, DumpOptions* dopt, AggInfo *agginfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpAgg(Archive *fout, AggInfo *agginfo) *** 11633,11639 **** bool convertok; /* Skip if not to be dumped */ ! if (!agginfo->aggfn.dobj.dump || dataOnly) return; query = createPQExpBuffer(); --- 11600,11606 ---- bool convertok; /* Skip if not to be dumped */ ! if (!agginfo->aggfn.dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); *************** dumpAgg(Archive *fout, AggInfo *agginfo) *** 11912,11918 **** appendPQExpBuffer(labelq, "AGGREGATE %s", aggsig); ! if (binary_upgrade) binary_upgrade_extension_member(q, &agginfo->aggfn.dobj, labelq->data); ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId, --- 11879,11885 ---- appendPQExpBuffer(labelq, "AGGREGATE %s", aggsig); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &agginfo->aggfn.dobj, labelq->data); ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId, *************** dumpAgg(Archive *fout, AggInfo *agginfo) *** 11926,11935 **** NULL, NULL); /* Dump Aggregate Comments */ ! dumpComment(fout, labelq->data, agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname, agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId); ! dumpSecLabel(fout, labelq->data, agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname, agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId); --- 11893,11902 ---- NULL, NULL); /* Dump Aggregate Comments */ ! dumpComment(fout, dopt, labelq->data, agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname, agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname, agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId); *************** dumpAgg(Archive *fout, AggInfo *agginfo) *** 11944,11950 **** aggsig = format_function_signature(fout, &agginfo->aggfn, true); aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false); ! dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId, "FUNCTION", aggsig, NULL, aggsig_tag, agginfo->aggfn.dobj.namespace->dobj.name, --- 11911,11917 ---- aggsig = format_function_signature(fout, &agginfo->aggfn, true); aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false); ! dumpACL(fout, dopt, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId, "FUNCTION", aggsig, NULL, aggsig_tag, agginfo->aggfn.dobj.namespace->dobj.name, *************** dumpAgg(Archive *fout, AggInfo *agginfo) *** 11969,11982 **** * write out a single text search parser */ static void ! dumpTSParser(Archive *fout, TSParserInfo *prsinfo) { PQExpBuffer q; PQExpBuffer delq; PQExpBuffer labelq; /* Skip if not to be dumped */ ! if (!prsinfo->dobj.dump || dataOnly) return; q = createPQExpBuffer(); --- 11936,11949 ---- * write out a single text search parser */ static void ! dumpTSParser(Archive *fout, DumpOptions* dopt, TSParserInfo *prsinfo) { PQExpBuffer q; PQExpBuffer delq; PQExpBuffer labelq; /* Skip if not to be dumped */ ! if (!prsinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpTSParser(Archive *fout, TSParserInfo *** 12012,12018 **** appendPQExpBuffer(labelq, "TEXT SEARCH PARSER %s", fmtId(prsinfo->dobj.name)); ! if (binary_upgrade) binary_upgrade_extension_member(q, &prsinfo->dobj, labelq->data); ArchiveEntry(fout, prsinfo->dobj.catId, prsinfo->dobj.dumpId, --- 11979,11985 ---- appendPQExpBuffer(labelq, "TEXT SEARCH PARSER %s", fmtId(prsinfo->dobj.name)); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &prsinfo->dobj, labelq->data); ArchiveEntry(fout, prsinfo->dobj.catId, prsinfo->dobj.dumpId, *************** dumpTSParser(Archive *fout, TSParserInfo *** 12026,12032 **** NULL, NULL); /* Dump Parser Comments */ ! dumpComment(fout, labelq->data, NULL, "", prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId); --- 11993,11999 ---- NULL, NULL); /* Dump Parser Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, "", prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId); *************** dumpTSParser(Archive *fout, TSParserInfo *** 12040,12046 **** * write out a single text search dictionary */ static void ! dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo) { PQExpBuffer q; PQExpBuffer delq; --- 12007,12013 ---- * write out a single text search dictionary */ static void ! dumpTSDictionary(Archive *fout, DumpOptions* dopt, TSDictInfo *dictinfo) { PQExpBuffer q; PQExpBuffer delq; *************** dumpTSDictionary(Archive *fout, TSDictIn *** 12051,12057 **** char *tmplname; /* Skip if not to be dumped */ ! if (!dictinfo->dobj.dump || dataOnly) return; q = createPQExpBuffer(); --- 12018,12024 ---- char *tmplname; /* Skip if not to be dumped */ ! if (!dictinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpTSDictionary(Archive *fout, TSDictIn *** 12099,12105 **** appendPQExpBuffer(labelq, "TEXT SEARCH DICTIONARY %s", fmtId(dictinfo->dobj.name)); ! if (binary_upgrade) binary_upgrade_extension_member(q, &dictinfo->dobj, labelq->data); ArchiveEntry(fout, dictinfo->dobj.catId, dictinfo->dobj.dumpId, --- 12066,12072 ---- appendPQExpBuffer(labelq, "TEXT SEARCH DICTIONARY %s", fmtId(dictinfo->dobj.name)); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &dictinfo->dobj, labelq->data); ArchiveEntry(fout, dictinfo->dobj.catId, dictinfo->dobj.dumpId, *************** dumpTSDictionary(Archive *fout, TSDictIn *** 12113,12119 **** NULL, NULL); /* Dump Dictionary Comments */ ! dumpComment(fout, labelq->data, NULL, dictinfo->rolname, dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId); --- 12080,12086 ---- NULL, NULL); /* Dump Dictionary Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, dictinfo->rolname, dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId); *************** dumpTSDictionary(Archive *fout, TSDictIn *** 12128,12141 **** * write out a single text search template */ static void ! dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo) { PQExpBuffer q; PQExpBuffer delq; PQExpBuffer labelq; /* Skip if not to be dumped */ ! if (!tmplinfo->dobj.dump || dataOnly) return; q = createPQExpBuffer(); --- 12095,12108 ---- * write out a single text search template */ static void ! dumpTSTemplate(Archive *fout, DumpOptions* dopt, TSTemplateInfo *tmplinfo) { PQExpBuffer q; PQExpBuffer delq; PQExpBuffer labelq; /* Skip if not to be dumped */ ! if (!tmplinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpTSTemplate(Archive *fout, TSTemplate *** 12165,12171 **** appendPQExpBuffer(labelq, "TEXT SEARCH TEMPLATE %s", fmtId(tmplinfo->dobj.name)); ! if (binary_upgrade) binary_upgrade_extension_member(q, &tmplinfo->dobj, labelq->data); ArchiveEntry(fout, tmplinfo->dobj.catId, tmplinfo->dobj.dumpId, --- 12132,12138 ---- appendPQExpBuffer(labelq, "TEXT SEARCH TEMPLATE %s", fmtId(tmplinfo->dobj.name)); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tmplinfo->dobj, labelq->data); ArchiveEntry(fout, tmplinfo->dobj.catId, tmplinfo->dobj.dumpId, *************** dumpTSTemplate(Archive *fout, TSTemplate *** 12179,12185 **** NULL, NULL); /* Dump Template Comments */ ! dumpComment(fout, labelq->data, NULL, "", tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId); --- 12146,12152 ---- NULL, NULL); /* Dump Template Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, "", tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId); *************** dumpTSTemplate(Archive *fout, TSTemplate *** 12193,12199 **** * write out a single text search configuration */ static void ! dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo) { PQExpBuffer q; PQExpBuffer delq; --- 12160,12166 ---- * write out a single text search configuration */ static void ! dumpTSConfig(Archive *fout, DumpOptions* dopt, TSConfigInfo *cfginfo) { PQExpBuffer q; PQExpBuffer delq; *************** dumpTSConfig(Archive *fout, TSConfigInfo *** 12208,12214 **** int i_dictname; /* Skip if not to be dumped */ ! if (!cfginfo->dobj.dump || dataOnly) return; q = createPQExpBuffer(); --- 12175,12181 ---- int i_dictname; /* Skip if not to be dumped */ ! if (!cfginfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpTSConfig(Archive *fout, TSConfigInfo *** 12293,12299 **** appendPQExpBuffer(labelq, "TEXT SEARCH CONFIGURATION %s", fmtId(cfginfo->dobj.name)); ! if (binary_upgrade) binary_upgrade_extension_member(q, &cfginfo->dobj, labelq->data); ArchiveEntry(fout, cfginfo->dobj.catId, cfginfo->dobj.dumpId, --- 12260,12266 ---- appendPQExpBuffer(labelq, "TEXT SEARCH CONFIGURATION %s", fmtId(cfginfo->dobj.name)); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &cfginfo->dobj, labelq->data); ArchiveEntry(fout, cfginfo->dobj.catId, cfginfo->dobj.dumpId, *************** dumpTSConfig(Archive *fout, TSConfigInfo *** 12307,12313 **** NULL, NULL); /* Dump Configuration Comments */ ! dumpComment(fout, labelq->data, NULL, cfginfo->rolname, cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId); --- 12274,12280 ---- NULL, NULL); /* Dump Configuration Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, cfginfo->rolname, cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId); *************** dumpTSConfig(Archive *fout, TSConfigInfo *** 12322,12328 **** * write out a single foreign-data wrapper definition */ static void ! dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo) { PQExpBuffer q; PQExpBuffer delq; --- 12289,12295 ---- * write out a single foreign-data wrapper definition */ static void ! dumpForeignDataWrapper(Archive *fout, DumpOptions* dopt, FdwInfo *fdwinfo) { PQExpBuffer q; PQExpBuffer delq; *************** dumpForeignDataWrapper(Archive *fout, Fd *** 12330,12336 **** char *qfdwname; /* Skip if not to be dumped */ ! if (!fdwinfo->dobj.dump || dataOnly) return; /* --- 12297,12303 ---- char *qfdwname; /* Skip if not to be dumped */ ! if (!fdwinfo->dobj.dump || dopt->dataOnly) return; /* *************** dumpForeignDataWrapper(Archive *fout, Fd *** 12338,12344 **** * field. Otherwise omit them if we are only dumping some specific object. */ if (!fdwinfo->dobj.ext_member) ! if (!include_everything) return; q = createPQExpBuffer(); --- 12305,12311 ---- * field. Otherwise omit them if we are only dumping some specific object. */ if (!fdwinfo->dobj.ext_member) ! if (!dopt->include_everything) return; q = createPQExpBuffer(); *************** dumpForeignDataWrapper(Archive *fout, Fd *** 12367,12373 **** appendPQExpBuffer(labelq, "FOREIGN DATA WRAPPER %s", qfdwname); ! if (binary_upgrade) binary_upgrade_extension_member(q, &fdwinfo->dobj, labelq->data); ArchiveEntry(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId, --- 12334,12340 ---- appendPQExpBuffer(labelq, "FOREIGN DATA WRAPPER %s", qfdwname); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &fdwinfo->dobj, labelq->data); ArchiveEntry(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId, *************** dumpForeignDataWrapper(Archive *fout, Fd *** 12381,12394 **** NULL, NULL); /* Handle the ACL */ ! dumpACL(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId, "FOREIGN DATA WRAPPER", qfdwname, NULL, fdwinfo->dobj.name, NULL, fdwinfo->rolname, fdwinfo->fdwacl); /* Dump Foreign Data Wrapper Comments */ ! dumpComment(fout, labelq->data, NULL, fdwinfo->rolname, fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId); --- 12348,12361 ---- NULL, NULL); /* Handle the ACL */ ! dumpACL(fout, dopt, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId, "FOREIGN DATA WRAPPER", qfdwname, NULL, fdwinfo->dobj.name, NULL, fdwinfo->rolname, fdwinfo->fdwacl); /* Dump Foreign Data Wrapper Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, fdwinfo->rolname, fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId); *************** dumpForeignDataWrapper(Archive *fout, Fd *** 12404,12410 **** * write out a foreign server definition */ static void ! dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo) { PQExpBuffer q; PQExpBuffer delq; --- 12371,12377 ---- * write out a foreign server definition */ static void ! dumpForeignServer(Archive *fout, DumpOptions* dopt, ForeignServerInfo *srvinfo) { PQExpBuffer q; PQExpBuffer delq; *************** dumpForeignServer(Archive *fout, Foreign *** 12415,12421 **** char *fdwname; /* Skip if not to be dumped */ ! if (!srvinfo->dobj.dump || dataOnly || !include_everything) return; q = createPQExpBuffer(); --- 12382,12388 ---- char *fdwname; /* Skip if not to be dumped */ ! if (!srvinfo->dobj.dump || dopt->dataOnly || !dopt->include_everything) return; q = createPQExpBuffer(); *************** dumpForeignServer(Archive *fout, Foreign *** 12459,12465 **** appendPQExpBuffer(labelq, "SERVER %s", qsrvname); ! if (binary_upgrade) binary_upgrade_extension_member(q, &srvinfo->dobj, labelq->data); ArchiveEntry(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId, --- 12426,12432 ---- appendPQExpBuffer(labelq, "SERVER %s", qsrvname); ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &srvinfo->dobj, labelq->data); ArchiveEntry(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId, *************** dumpForeignServer(Archive *fout, Foreign *** 12473,12479 **** NULL, NULL); /* Handle the ACL */ ! dumpACL(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId, "FOREIGN SERVER", qsrvname, NULL, srvinfo->dobj.name, NULL, srvinfo->rolname, --- 12440,12446 ---- NULL, NULL); /* Handle the ACL */ ! dumpACL(fout, dopt, srvinfo->dobj.catId, srvinfo->dobj.dumpId, "FOREIGN SERVER", qsrvname, NULL, srvinfo->dobj.name, NULL, srvinfo->rolname, *************** dumpForeignServer(Archive *fout, Foreign *** 12486,12492 **** srvinfo->dobj.catId, srvinfo->dobj.dumpId); /* Dump Foreign Server Comments */ ! dumpComment(fout, labelq->data, NULL, srvinfo->rolname, srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId); --- 12453,12459 ---- srvinfo->dobj.catId, srvinfo->dobj.dumpId); /* Dump Foreign Server Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, srvinfo->rolname, srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId); *************** dumpUserMappings(Archive *fout, *** 12602,12615 **** * Write out default privileges information */ static void ! dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo) { PQExpBuffer q; PQExpBuffer tag; const char *type; /* Skip if not to be dumped */ ! if (!daclinfo->dobj.dump || dataOnly || aclsSkip) return; q = createPQExpBuffer(); --- 12569,12582 ---- * Write out default privileges information */ static void ! dumpDefaultACL(Archive *fout, DumpOptions *dopt, DefaultACLInfo *daclinfo) { PQExpBuffer q; PQExpBuffer tag; const char *type; /* Skip if not to be dumped */ ! if (!daclinfo->dobj.dump || dopt->dataOnly || dopt->aclsSkip) return; q = createPQExpBuffer(); *************** dumpDefaultACL(Archive *fout, DefaultACL *** 12682,12688 **** *---------- */ static void ! dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId, const char *type, const char *name, const char *subname, const char *tag, const char *nspname, const char *owner, const char *acls) --- 12649,12655 ---- *---------- */ static void ! dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId, const char *type, const char *name, const char *subname, const char *tag, const char *nspname, const char *owner, const char *acls) *************** dumpACL(Archive *fout, CatalogId objCatI *** 12690,12700 **** PQExpBuffer sql; /* Do nothing if ACL dump is not enabled */ ! if (aclsSkip) return; /* --data-only skips ACLs *except* BLOB ACLs */ ! if (dataOnly && strcmp(type, "LARGE OBJECT") != 0) return; sql = createPQExpBuffer(); --- 12657,12667 ---- PQExpBuffer sql; /* Do nothing if ACL dump is not enabled */ ! if (dopt->aclsSkip) return; /* --data-only skips ACLs *except* BLOB ACLs */ ! if (dopt->dataOnly && strcmp(type, "LARGE OBJECT") != 0) return; sql = createPQExpBuffer(); *************** dumpACL(Archive *fout, CatalogId objCatI *** 12737,12743 **** * calling ArchiveEntry() for the specified object. */ static void ! dumpSecLabel(Archive *fout, const char *target, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId) { --- 12704,12710 ---- * calling ArchiveEntry() for the specified object. */ static void ! dumpSecLabel(Archive *fout, DumpOptions* dopt, const char *target, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId) { *************** dumpSecLabel(Archive *fout, const char * *** 12747,12764 **** PQExpBuffer query; /* do nothing, if --no-security-labels is supplied */ ! if (no_security_labels) return; /* Comments are schema not data ... except blob comments are data */ if (strncmp(target, "LARGE OBJECT ", 13) != 0) { ! if (dataOnly) return; } else { ! if (schemaOnly) return; } --- 12714,12731 ---- PQExpBuffer query; /* do nothing, if --no-security-labels is supplied */ ! if (dopt->no_security_labels) return; /* Comments are schema not data ... except blob comments are data */ if (strncmp(target, "LARGE OBJECT ", 13) != 0) { ! if (dopt->dataOnly) return; } else { ! if (dopt->schemaOnly) return; } *************** dumpSecLabel(Archive *fout, const char * *** 12801,12807 **** * and its columns. */ static void ! dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename) { SecLabelItem *labels; int nlabels; --- 12768,12774 ---- * and its columns. */ static void ! dumpTableSecLabel(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, const char *reltypename) { SecLabelItem *labels; int nlabels; *************** dumpTableSecLabel(Archive *fout, TableIn *** 12810,12820 **** PQExpBuffer target; /* do nothing, if --no-security-labels is supplied */ ! if (no_security_labels) return; /* SecLabel are SCHEMA not data */ ! if (dataOnly) return; /* Search for comments associated with relation, using table */ --- 12777,12787 ---- PQExpBuffer target; /* do nothing, if --no-security-labels is supplied */ ! if (dopt->no_security_labels) return; /* SecLabel are SCHEMA not data */ ! if (dopt->dataOnly) return; /* Search for comments associated with relation, using table */ *************** collectSecLabels(Archive *fout, SecLabel *** 13022,13041 **** * write out to fout the declarations (not data) of a user-defined table */ static void ! dumpTable(Archive *fout, TableInfo *tbinfo) { ! if (tbinfo->dobj.dump && !dataOnly) { char *namecopy; if (tbinfo->relkind == RELKIND_SEQUENCE) ! dumpSequence(fout, tbinfo); else ! dumpTableSchema(fout, tbinfo); /* Handle the ACL here */ namecopy = pg_strdup(fmtId(tbinfo->dobj.name)); ! dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, (tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" : "TABLE", namecopy, NULL, tbinfo->dobj.name, --- 12989,13008 ---- * write out to fout the declarations (not data) of a user-defined table */ static void ! dumpTable(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo) { ! if (tbinfo->dobj.dump && !dopt->dataOnly) { char *namecopy; if (tbinfo->relkind == RELKIND_SEQUENCE) ! dumpSequence(fout, dopt, tbinfo); else ! dumpTableSchema(fout, dopt, tbinfo); /* Handle the ACL here */ namecopy = pg_strdup(fmtId(tbinfo->dobj.name)); ! dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId, (tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" : "TABLE", namecopy, NULL, tbinfo->dobj.name, *************** dumpTable(Archive *fout, TableInfo *tbin *** 13070,13076 **** attnamecopy = pg_strdup(fmtId(attname)); acltag = psprintf("%s.%s", tbinfo->dobj.name, attname); /* Column's GRANT type is always TABLE */ ! dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE", namecopy, attnamecopy, acltag, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, attacl); --- 13037,13043 ---- attnamecopy = pg_strdup(fmtId(attname)); acltag = psprintf("%s.%s", tbinfo->dobj.name, attname); /* Column's GRANT type is always TABLE */ ! dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE", namecopy, attnamecopy, acltag, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, attacl); *************** createViewAsClause(Archive *fout, TableI *** 13147,13153 **** * write the declaration (not data) of one user-defined table or view */ static void ! dumpTableSchema(Archive *fout, TableInfo *tbinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); --- 13114,13120 ---- * write the declaration (not data) of one user-defined table or view */ static void ! dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); *************** dumpTableSchema(Archive *fout, TableInfo *** 13165,13171 **** /* Make sure we are in proper schema */ selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name); ! if (binary_upgrade) binary_upgrade_set_type_oids_by_rel_oid(fout, q, tbinfo->dobj.catId.oid); --- 13132,13138 ---- /* Make sure we are in proper schema */ selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name); ! if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_rel_oid(fout, q, tbinfo->dobj.catId.oid); *************** dumpTableSchema(Archive *fout, TableInfo *** 13185,13191 **** appendPQExpBuffer(delq, "%s;\n", fmtId(tbinfo->dobj.name)); ! if (binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, tbinfo->dobj.catId.oid, false); --- 13152,13158 ---- appendPQExpBuffer(delq, "%s;\n", fmtId(tbinfo->dobj.name)); ! if (dopt->binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, tbinfo->dobj.catId.oid, false); *************** dumpTableSchema(Archive *fout, TableInfo *** 13265,13271 **** appendPQExpBuffer(labelq, "%s %s", reltypename, fmtId(tbinfo->dobj.name)); ! if (binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, tbinfo->dobj.catId.oid, false); --- 13232,13238 ---- appendPQExpBuffer(labelq, "%s %s", reltypename, fmtId(tbinfo->dobj.name)); ! if (dopt->binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, tbinfo->dobj.catId.oid, false); *************** dumpTableSchema(Archive *fout, TableInfo *** 13279,13285 **** * Attach to type, if reloftype; except in case of a binary upgrade, * we dump the table normally and attach it to the type afterward. */ ! if (tbinfo->reloftype && !binary_upgrade) appendPQExpBuffer(q, " OF %s", tbinfo->reloftype); if (tbinfo->relkind != RELKIND_MATVIEW) --- 13246,13252 ---- * Attach to type, if reloftype; except in case of a binary upgrade, * we dump the table normally and attach it to the type afterward. */ ! if (tbinfo->reloftype && !dopt->binary_upgrade) appendPQExpBuffer(q, " OF %s", tbinfo->reloftype); if (tbinfo->relkind != RELKIND_MATVIEW) *************** dumpTableSchema(Archive *fout, TableInfo *** 13294,13300 **** * columns, and then fix up the dropped and nonlocal cases * below. */ ! if (shouldPrintColumn(tbinfo, j)) { /* * Default value --- suppress if to be printed separately. --- 13261,13267 ---- * columns, and then fix up the dropped and nonlocal cases * below. */ ! if (shouldPrintColumn(dopt, tbinfo, j)) { /* * Default value --- suppress if to be printed separately. *************** dumpTableSchema(Archive *fout, TableInfo *** 13308,13318 **** */ bool has_notnull = (tbinfo->notnull[j] && (!tbinfo->inhNotNull[j] || ! binary_upgrade)); /* Skip column if fully defined by reloftype */ if (tbinfo->reloftype && ! !has_default && !has_notnull && !binary_upgrade) continue; /* Format properly if not first attr */ --- 13275,13285 ---- */ bool has_notnull = (tbinfo->notnull[j] && (!tbinfo->inhNotNull[j] || ! dopt->binary_upgrade)); /* Skip column if fully defined by reloftype */ if (tbinfo->reloftype && ! !has_default && !has_notnull && !dopt->binary_upgrade) continue; /* Format properly if not first attr */ *************** dumpTableSchema(Archive *fout, TableInfo *** 13340,13346 **** } /* Attribute type */ ! if (tbinfo->reloftype && !binary_upgrade) { appendPQExpBufferStr(q, " WITH OPTIONS"); } --- 13307,13313 ---- } /* Attribute type */ ! if (tbinfo->reloftype && !dopt->binary_upgrade) { appendPQExpBufferStr(q, " WITH OPTIONS"); } *************** dumpTableSchema(Archive *fout, TableInfo *** 13405,13411 **** if (actual_atts) appendPQExpBufferStr(q, "\n)"); ! else if (!(tbinfo->reloftype && !binary_upgrade)) { /* * We must have a parenthesized attribute list, even though --- 13372,13378 ---- if (actual_atts) appendPQExpBufferStr(q, "\n)"); ! else if (!(tbinfo->reloftype && !dopt->binary_upgrade)) { /* * We must have a parenthesized attribute list, even though *************** dumpTableSchema(Archive *fout, TableInfo *** 13414,13420 **** appendPQExpBufferStr(q, " (\n)"); } ! if (numParents > 0 && !binary_upgrade) { appendPQExpBufferStr(q, "\nINHERITS ("); for (k = 0; k < numParents; k++) --- 13381,13387 ---- appendPQExpBufferStr(q, " (\n)"); } ! if (numParents > 0 && !dopt->binary_upgrade) { appendPQExpBufferStr(q, "\nINHERITS ("); for (k = 0; k < numParents; k++) *************** dumpTableSchema(Archive *fout, TableInfo *** 13487,13493 **** * attislocal correctly, plus fix up any inherited CHECK constraints. * Analogously, we set up typed tables using ALTER TABLE / OF here. */ ! if (binary_upgrade && (tbinfo->relkind == RELKIND_RELATION || tbinfo->relkind == RELKIND_FOREIGN_TABLE)) { for (j = 0; j < tbinfo->numatts; j++) --- 13454,13460 ---- * attislocal correctly, plus fix up any inherited CHECK constraints. * Analogously, we set up typed tables using ALTER TABLE / OF here. */ ! if (dopt->binary_upgrade && (tbinfo->relkind == RELKIND_RELATION || tbinfo->relkind == RELKIND_FOREIGN_TABLE)) { for (j = 0; j < tbinfo->numatts; j++) *************** dumpTableSchema(Archive *fout, TableInfo *** 13603,13609 **** * REFRESH MATERIALIZED VIEW since it's possible that some underlying * matview is not populated even though this matview is. */ ! if (binary_upgrade && tbinfo->relkind == RELKIND_MATVIEW && tbinfo->relispopulated) { appendPQExpBufferStr(q, "\n-- For binary upgrade, mark materialized view as populated\n"); --- 13570,13576 ---- * REFRESH MATERIALIZED VIEW since it's possible that some underlying * matview is not populated even though this matview is. */ ! if (dopt->binary_upgrade && tbinfo->relkind == RELKIND_MATVIEW && tbinfo->relispopulated) { appendPQExpBufferStr(q, "\n-- For binary upgrade, mark materialized view as populated\n"); *************** dumpTableSchema(Archive *fout, TableInfo *** 13629,13635 **** * it is NOT NULL and did not inherit that property from a parent, * we have to mark it separately. */ ! if (!shouldPrintColumn(tbinfo, j) && tbinfo->notnull[j] && !tbinfo->inhNotNull[j]) { appendPQExpBuffer(q, "ALTER TABLE ONLY %s ", --- 13596,13602 ---- * it is NOT NULL and did not inherit that property from a parent, * we have to mark it separately. */ ! if (!shouldPrintColumn(dopt, tbinfo, j) && tbinfo->notnull[j] && !tbinfo->inhNotNull[j]) { appendPQExpBuffer(q, "ALTER TABLE ONLY %s ", *************** dumpTableSchema(Archive *fout, TableInfo *** 13743,13749 **** } } ! if (binary_upgrade) binary_upgrade_extension_member(q, &tbinfo->dobj, labelq->data); ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, --- 13710,13716 ---- } } ! if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tbinfo->dobj, labelq->data); ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, *************** dumpTableSchema(Archive *fout, TableInfo *** 13760,13769 **** /* Dump Table Comments */ ! dumpTableComment(fout, tbinfo, reltypename); /* Dump Table Security Labels */ ! dumpTableSecLabel(fout, tbinfo, reltypename); /* Dump comments on inlined table constraints */ for (j = 0; j < tbinfo->ncheck; j++) --- 13727,13736 ---- /* Dump Table Comments */ ! dumpTableComment(fout, dopt, tbinfo, reltypename); /* Dump Table Security Labels */ ! dumpTableSecLabel(fout, dopt, tbinfo, reltypename); /* Dump comments on inlined table constraints */ for (j = 0; j < tbinfo->ncheck; j++) *************** dumpTableSchema(Archive *fout, TableInfo *** 13773,13779 **** if (constr->separate || !constr->conislocal) continue; ! dumpTableConstraintComment(fout, constr); } destroyPQExpBuffer(q); --- 13740,13746 ---- if (constr->separate || !constr->conislocal) continue; ! dumpTableConstraintComment(fout, dopt, constr); } destroyPQExpBuffer(q); *************** dumpTableSchema(Archive *fout, TableInfo *** 13785,13791 **** * dumpAttrDef --- dump an attribute's default-value declaration */ static void ! dumpAttrDef(Archive *fout, AttrDefInfo *adinfo) { TableInfo *tbinfo = adinfo->adtable; int adnum = adinfo->adnum; --- 13752,13758 ---- * dumpAttrDef --- dump an attribute's default-value declaration */ static void ! dumpAttrDef(Archive *fout, DumpOptions *dopt, AttrDefInfo *adinfo) { TableInfo *tbinfo = adinfo->adtable; int adnum = adinfo->adnum; *************** dumpAttrDef(Archive *fout, AttrDefInfo * *** 13793,13799 **** PQExpBuffer delq; /* Skip if table definition not to be dumped */ ! if (!tbinfo->dobj.dump || dataOnly) return; /* Skip if not "separate"; it was dumped in the table's definition */ --- 13760,13766 ---- PQExpBuffer delq; /* Skip if table definition not to be dumped */ ! if (!tbinfo->dobj.dump || dopt->dataOnly) return; /* Skip if not "separate"; it was dumped in the table's definition */ *************** getAttrName(int attrnum, TableInfo *tblI *** 13872,13878 **** * write out to fout a user-defined index */ static void ! dumpIndex(Archive *fout, IndxInfo *indxinfo) { TableInfo *tbinfo = indxinfo->indextable; bool is_constraint = (indxinfo->indexconstraint != 0); --- 13839,13845 ---- * write out to fout a user-defined index */ static void ! dumpIndex(Archive *fout, DumpOptions* dopt, IndxInfo *indxinfo) { TableInfo *tbinfo = indxinfo->indextable; bool is_constraint = (indxinfo->indexconstraint != 0); *************** dumpIndex(Archive *fout, IndxInfo *indxi *** 13880,13886 **** PQExpBuffer delq; PQExpBuffer labelq; ! if (dataOnly) return; q = createPQExpBuffer(); --- 13847,13853 ---- PQExpBuffer delq; PQExpBuffer labelq; ! if (dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpIndex(Archive *fout, IndxInfo *indxi *** 13899,13905 **** */ if (!is_constraint) { ! if (binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, indxinfo->dobj.catId.oid, true); --- 13866,13872 ---- */ if (!is_constraint) { ! if (dopt->binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, indxinfo->dobj.catId.oid, true); *************** dumpIndex(Archive *fout, IndxInfo *indxi *** 13945,13951 **** } /* Dump Index Comments */ ! dumpComment(fout, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, indxinfo->dobj.catId, 0, --- 13912,13918 ---- } /* Dump Index Comments */ ! dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, indxinfo->dobj.catId, 0, *************** dumpIndex(Archive *fout, IndxInfo *indxi *** 13962,13975 **** * write out to fout a user-defined constraint */ static void ! dumpConstraint(Archive *fout, ConstraintInfo *coninfo) { TableInfo *tbinfo = coninfo->contable; PQExpBuffer q; PQExpBuffer delq; /* Skip if not to be dumped */ ! if (!coninfo->dobj.dump || dataOnly) return; q = createPQExpBuffer(); --- 13929,13942 ---- * write out to fout a user-defined constraint */ static void ! dumpConstraint(Archive *fout, DumpOptions *dopt, ConstraintInfo *coninfo) { TableInfo *tbinfo = coninfo->contable; PQExpBuffer q; PQExpBuffer delq; /* Skip if not to be dumped */ ! if (!coninfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpConstraint(Archive *fout, Constraint *** 13989,13995 **** exit_horribly(NULL, "missing index for constraint \"%s\"\n", coninfo->dobj.name); ! if (binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, indxinfo->dobj.catId.oid, true); --- 13956,13962 ---- exit_horribly(NULL, "missing index for constraint \"%s\"\n", coninfo->dobj.name); ! if (dopt->binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, indxinfo->dobj.catId.oid, true); *************** dumpConstraint(Archive *fout, Constraint *** 14179,14185 **** /* Dump Constraint Comments --- only works for table constraints */ if (tbinfo && coninfo->separate) ! dumpTableConstraintComment(fout, coninfo); destroyPQExpBuffer(q); destroyPQExpBuffer(delq); --- 14146,14152 ---- /* Dump Constraint Comments --- only works for table constraints */ if (tbinfo && coninfo->separate) ! dumpTableConstraintComment(fout, dopt, coninfo); destroyPQExpBuffer(q); destroyPQExpBuffer(delq); *************** dumpConstraint(Archive *fout, Constraint *** 14193,14199 **** * or as a separate ALTER command. */ static void ! dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo) { TableInfo *tbinfo = coninfo->contable; PQExpBuffer labelq = createPQExpBuffer(); --- 14160,14166 ---- * or as a separate ALTER command. */ static void ! dumpTableConstraintComment(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo) { TableInfo *tbinfo = coninfo->contable; PQExpBuffer labelq = createPQExpBuffer(); *************** dumpTableConstraintComment(Archive *fout *** 14202,14208 **** fmtId(coninfo->dobj.name)); appendPQExpBuffer(labelq, "ON %s", fmtId(tbinfo->dobj.name)); ! dumpComment(fout, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, coninfo->dobj.catId, 0, --- 14169,14175 ---- fmtId(coninfo->dobj.name)); appendPQExpBuffer(labelq, "ON %s", fmtId(tbinfo->dobj.name)); ! dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, coninfo->dobj.catId, 0, *************** findLastBuiltinOid_V70(Archive *fout) *** 14262,14268 **** * write the declaration (not data) of one user-defined sequence */ static void ! dumpSequence(Archive *fout, TableInfo *tbinfo) { PGresult *res; char *startv, --- 14229,14235 ---- * write the declaration (not data) of one user-defined sequence */ static void ! dumpSequence(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo) { PGresult *res; char *startv, *************** dumpSequence(Archive *fout, TableInfo *t *** 14358,14364 **** resetPQExpBuffer(query); ! if (binary_upgrade) { binary_upgrade_set_pg_class_oids(fout, query, tbinfo->dobj.catId.oid, false); --- 14325,14331 ---- resetPQExpBuffer(query); ! if (dopt->binary_upgrade) { binary_upgrade_set_pg_class_oids(fout, query, tbinfo->dobj.catId.oid, false); *************** dumpSequence(Archive *fout, TableInfo *t *** 14395,14401 **** /* binary_upgrade: no need to clear TOAST table oid */ ! if (binary_upgrade) binary_upgrade_extension_member(query, &tbinfo->dobj, labelq->data); --- 14362,14368 ---- /* binary_upgrade: no need to clear TOAST table oid */ ! if (dopt->binary_upgrade) binary_upgrade_extension_member(query, &tbinfo->dobj, labelq->data); *************** dumpSequence(Archive *fout, TableInfo *t *** 14448,14457 **** } /* Dump Sequence Comments and Security Labels */ ! dumpComment(fout, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); ! dumpSecLabel(fout, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); --- 14415,14424 ---- } /* Dump Sequence Comments and Security Labels */ ! dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); ! dumpSecLabel(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); *************** dumpSequenceData(Archive *fout, TableDat *** 14522,14528 **** * write the declaration of one user-defined table trigger */ static void ! dumpTrigger(Archive *fout, TriggerInfo *tginfo) { TableInfo *tbinfo = tginfo->tgtable; PQExpBuffer query; --- 14489,14495 ---- * write the declaration of one user-defined table trigger */ static void ! dumpTrigger(Archive *fout, DumpOptions* dopt, TriggerInfo *tginfo) { TableInfo *tbinfo = tginfo->tgtable; PQExpBuffer query; *************** dumpTrigger(Archive *fout, TriggerInfo * *** 14537,14543 **** * we needn't check dobj.dump because TriggerInfo wouldn't have been * created in the first place for non-dumpable triggers */ ! if (dataOnly) return; query = createPQExpBuffer(); --- 14504,14510 ---- * we needn't check dobj.dump because TriggerInfo wouldn't have been * created in the first place for non-dumpable triggers */ ! if (dopt->dataOnly) return; query = createPQExpBuffer(); *************** dumpTrigger(Archive *fout, TriggerInfo * *** 14718,14724 **** NULL, 0, NULL, NULL); ! dumpComment(fout, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tginfo->dobj.catId, 0, tginfo->dobj.dumpId); --- 14685,14691 ---- NULL, 0, NULL, NULL); ! dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tginfo->dobj.catId, 0, tginfo->dobj.dumpId); *************** dumpTrigger(Archive *fout, TriggerInfo * *** 14732,14744 **** * write the declaration of one user-defined event trigger */ static void ! dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo) { PQExpBuffer query; PQExpBuffer labelq; /* Skip if not to be dumped */ ! if (!evtinfo->dobj.dump || dataOnly) return; query = createPQExpBuffer(); --- 14699,14711 ---- * write the declaration of one user-defined event trigger */ static void ! dumpEventTrigger(Archive *fout, DumpOptions* dopt, EventTriggerInfo *evtinfo) { PQExpBuffer query; PQExpBuffer labelq; /* Skip if not to be dumped */ ! if (!evtinfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); *************** dumpEventTrigger(Archive *fout, EventTri *** 14790,14796 **** "EVENT TRIGGER", SECTION_POST_DATA, query->data, "", NULL, NULL, 0, NULL, NULL); ! dumpComment(fout, labelq->data, NULL, NULL, evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId); --- 14757,14763 ---- "EVENT TRIGGER", SECTION_POST_DATA, query->data, "", NULL, NULL, 0, NULL, NULL); ! dumpComment(fout, dopt, labelq->data, NULL, NULL, evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId); *************** dumpEventTrigger(Archive *fout, EventTri *** 14803,14809 **** * Dump a rule */ static void ! dumpRule(Archive *fout, RuleInfo *rinfo) { TableInfo *tbinfo = rinfo->ruletable; PQExpBuffer query; --- 14770,14776 ---- * Dump a rule */ static void ! dumpRule(Archive *fout, DumpOptions *dopt, RuleInfo *rinfo) { TableInfo *tbinfo = rinfo->ruletable; PQExpBuffer query; *************** dumpRule(Archive *fout, RuleInfo *rinfo) *** 14813,14819 **** PGresult *res; /* Skip if not to be dumped */ ! if (!rinfo->dobj.dump || dataOnly) return; /* --- 14780,14786 ---- PGresult *res; /* Skip if not to be dumped */ ! if (!rinfo->dobj.dump || dopt->dataOnly) return; /* *************** dumpRule(Archive *fout, RuleInfo *rinfo) *** 14918,14924 **** NULL, NULL); /* Dump rule comments */ ! dumpComment(fout, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, rinfo->dobj.catId, 0, rinfo->dobj.dumpId); --- 14885,14891 ---- NULL, NULL); /* Dump rule comments */ ! dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, rinfo->dobj.catId, 0, rinfo->dobj.dumpId); *************** dumpRule(Archive *fout, RuleInfo *rinfo) *** 14935,14941 **** * getExtensionMembership --- obtain extension membership data */ void ! getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], int numExtensions) { PQExpBuffer query; --- 14902,14908 ---- * getExtensionMembership --- obtain extension membership data */ void ! getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[], int numExtensions) { PQExpBuffer query; *************** getExtensionMembership(Archive *fout, Ex *** 15032,15038 **** * idea is to exactly reproduce the database contents rather than * replace the extension contents with something different. */ ! if (!binary_upgrade) dobj->dump = false; else dobj->dump = refdobj->dump; --- 14999,15005 ---- * idea is to exactly reproduce the database contents rather than * replace the extension contents with something different. */ ! if (!dopt->binary_upgrade) dobj->dump = false; else dobj->dump = refdobj->dump; *************** getExtensionMembership(Archive *fout, Ex *** 15111,15117 **** * of the --oids setting. This is because row filtering * conditions aren't compatible with dumping OIDs. */ ! makeTableDataInfo(configtbl, false); if (configtbl->dataObj != NULL) { if (strlen(extconditionarray[j]) > 0) --- 15078,15084 ---- * of the --oids setting. This is because row filtering * conditions aren't compatible with dumping OIDs. */ ! makeTableDataInfo(dopt, configtbl, false); if (configtbl->dataObj != NULL) { if (strlen(extconditionarray[j]) > 0) diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h new file mode 100644 index d184187..c8864a0 *** a/src/bin/pg_dump/pg_dump.h --- b/src/bin/pg_dump/pg_dump.h *************** extern char g_opaque_type[10]; /* name f *** 503,509 **** struct Archive; typedef struct Archive Archive; ! extern TableInfo *getSchemaData(Archive *, int *numTablesPtr); typedef enum _OidOptions { --- 503,511 ---- struct Archive; typedef struct Archive Archive; ! struct _dumpOptions; ! ! extern TableInfo *getSchemaData(Archive *, struct _dumpOptions *dopt, int *numTablesPtr); typedef enum _OidOptions { *************** extern void sortDataAndIndexObjectsBySiz *** 545,560 **** * version specific routines */ extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces); ! extern ExtensionInfo *getExtensions(Archive *fout, int *numExtensions); extern TypeInfo *getTypes(Archive *fout, int *numTypes); ! extern FuncInfo *getFuncs(Archive *fout, int *numFuncs); ! extern AggInfo *getAggregates(Archive *fout, 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, 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); --- 547,562 ---- * version specific routines */ extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces); ! extern ExtensionInfo *getExtensions(Archive *fout, struct _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 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 void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables); extern InhInfo *getInherits(Archive *fout, int *numInherits); extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables); *************** extern RuleInfo *getRules(Archive *fout, *** 563,570 **** 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, TableInfo *tbinfo, int numTables); ! extern bool shouldPrintColumn(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); --- 565,572 ---- 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 TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers); extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts); extern TSTemplateInfo *getTSTemplates(Archive *fout, int *numTSTemplates); *************** extern FdwInfo *getForeignDataWrappers(A *** 573,580 **** int *numForeignDataWrappers); extern ForeignServerInfo *getForeignServers(Archive *fout, int *numForeignServers); ! extern DefaultACLInfo *getDefaultACLs(Archive *fout, int *numDefaultACLs); ! extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], int numExtensions); extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers); --- 575,582 ---- 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[], int numExtensions); extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers); diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c new file mode 100644 index fdfdc19..514615b *** a/src/bin/pg_dump/pg_restore.c --- b/src/bin/pg_dump/pg_restore.c *************** main(int argc, char **argv) *** 420,426 **** /* AH may be freed in CloseArchive? */ exit_code = AH->n_errors ? 1 : 0; ! CloseArchive(AH); return exit_code; } --- 420,426 ---- /* AH may be freed in CloseArchive? */ exit_code = AH->n_errors ? 1 : 0; ! CloseArchive(AH, NULL); return exit_code; }