diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c new file mode 100644 index 94e9147..d01035b *** a/src/bin/pg_dump/common.c --- b/src/bin/pg_dump/common.c *************** 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,128 **** if (g_verbose) write_msg(NULL, "reading extensions\n"); ! extinfo = getExtensions(fout, &numExtensions); if (g_verbose) write_msg(NULL, "reading user-defined functions\n"); --- 122,128 ---- 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"); *************** 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) diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h new file mode 100644 index b387aa1..0f6c88a *** a/src/bin/pg_dump/dumputils.h --- b/src/bin/pg_dump/dumputils.h *************** typedef struct SimpleStringList *** 31,38 **** SimpleStringListCell *tail; } SimpleStringList; - - extern int quote_all_identifiers; extern PQExpBuffer (*getLocalPQExpBuffer) (void); extern const char *fmtId(const char *identifier); --- 31,36 ---- 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..d8c9f69 *** a/src/bin/pg_dump/pg_backup.h --- b/src/bin/pg_dump/pg_backup.h *************** struct Archive *** 98,104 **** /* The rest is private */ }; ! typedef int (*DataDumperPtr) (Archive *AH, void *userArg); typedef struct _restoreOptions { --- 98,106 ---- /* The rest is private */ }; ! struct _dumpOptions; ! ! typedef int (*DataDumperPtr) (Archive *AH, struct _dumpOptions *dopt, void *userArg); typedef struct _restoreOptions { *************** 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; --- 111,134 ---- * 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. --- 161,217 ---- 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; ! const char *dumpencoding; ! bool oids; ! ! /* 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 numWorkers; ! enum trivalue prompt_password; ! int compressLevel; ! int plainText; ! int outputClean; ! int outputCreateDB; ! bool outputBlobs; ! int outputNoOwner; ! char *outputSuperuser; ! char *use_role; ! ! ArchiveFormat archiveFormat; ! ArchiveMode archiveMode; ! ! int disable_triggers; ! int outputNoTablespaces; ! int use_setsessauth; ! ! } DumpOptions; ! ! 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); --- 244,250 ---- 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); 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 3aebac8..b378265 *** 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,170 ---- 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->prompt_password = TRI_DEFAULT; + opts->compressLevel = -1; + opts->archiveFormat = archUnknown; + opts->numWorkers = 1; + 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; + + /* 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; --- 178,184 ---- * 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) --- 210,221 ---- /* 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); --- 580,586 ---- 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 *** 2200,2206 **** } void ! WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate) { TocEntry *te; --- 2258,2264 ---- } void ! WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate) { TocEntry *te; *************** WriteDataChunks(ArchiveHandle *AH, Paral *** 2223,2235 **** DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP); } else ! WriteDataChunksForTocEntry(AH, te); } EnsureWorkersFinished(AH, pstate); } void ! WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te) { StartDataPtr startPtr; EndDataPtr endPtr; --- 2281,2293 ---- 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 *** 2253,2259 **** /* * The user-provided DataDumper routine needs to call AH->WriteData */ ! (*te->dataDumper) ((Archive *) AH, te->dataDumperArg); if (endPtr != NULL) (*endPtr) (AH, te); --- 2311,2317 ---- /* * 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..0f80045 *** 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); *************** int ahprintf(ArchiveHandle *AH, const *** 436,439 **** --- 436,442 ---- void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); + extern DumpOptions* NewDumpOptions(void); + extern DumpOptions dumpOptionsFromRestoreOptions(RestoreOptions *ropt); + #endif 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..77b1eda *** 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,210 ---- { if (te->dataDumper) { + DumpOptions dopt = dumpOptionsFromRestoreOptions(ropt); AH->currToc = te; if (strcmp(te->desc, "BLOBS") == 0) _StartBlobs(AH, te); ! (*te->dataDumper) ((Archive *) AH, &dopt, te->dataDumperArg); if (strcmp(te->desc, "BLOBS") == 0) _EndBlobs(AH, te); *************** _WriteBuf(ArchiveHandle *AH, const void *** 227,233 **** } static void ! _CloseArchive(ArchiveHandle *AH) { /* Nothing to do */ } --- 228,234 ---- } 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 5c0f95f..95f1e5a *** 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_opaque_type[10]; /* name for the *** 125,147 **** char g_comment_start[10]; char g_comment_end[10]; 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, --- 116,129 ---- char g_comment_start[10]; char g_comment_end[10]; + extern int quote_all_identifiers; + static const CatalogId nilCatalogId = {0, 0}; static int binary_upgrade = 0; static void help(const char *progname); ! static void setup_connection(Archive *AH, DumpOptions *dopt); 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); --- 132,195 ---- 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, --- 204,211 ---- 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, --- 227,235 ---- 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 --- 246,252 ---- 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'}, --- 255,273 ---- 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 */ ! 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} }; --- 302,325 ---- /* * the following options don't have an equivalent short option letter */ ! {"attribute-inserts", no_argument, &dopt->column_inserts, 1}, {"binary-upgrade", no_argument, &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 */ --- 338,343 ---- *************** main(int argc, char **argv) *** 406,432 **** 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 */ ! dumpencoding = pg_strdup(optarg); break; case 'f': --- 364,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 */ ! dopt->dumpencoding = pg_strdup(optarg); break; case 'f': *************** main(int argc, char **argv) *** 438,444 **** break; case 'h': /* server host */ ! pghost = pg_strdup(optarg); break; case 'i': --- 396,402 ---- break; case 'h': /* server host */ ! dopt->pghost = pg_strdup(optarg); break; case 'i': *************** main(int argc, char **argv) *** 446,457 **** break; case 'j': /* number of dump jobs */ ! numWorkers = atoi(optarg); break; case 'n': /* include schema(s) */ simple_string_list_append(&schema_include_patterns, optarg); ! include_everything = false; break; case 'N': /* exclude schema(s) */ --- 404,415 ---- break; case 'j': /* number of dump jobs */ ! dopt->numWorkers = atoi(optarg); break; 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': --- 417,431 ---- 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) */ --- 433,448 ---- 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 */ --- 450,456 ---- break; case 'U': ! dopt->username = pg_strdup(optarg); break; case 'v': /* verbose */ *************** main(int argc, char **argv) *** 500,518 **** break; case 'w': ! prompt_password = TRI_NO; break; case 'W': ! prompt_password = TRI_YES; break; case 'x': /* skip ACL dump */ ! aclsSkip = true; break; case 'Z': /* Compression Level */ ! compressLevel = atoi(optarg); break; case 0: --- 458,476 ---- break; case 'w': ! dopt->prompt_password = TRI_NO; break; case 'W': ! dopt->prompt_password = TRI_YES; break; case 'x': /* skip ACL dump */ ! dopt->aclsSkip = true; break; case 'Z': /* Compression Level */ ! dopt->compressLevel = atoi(optarg); break; case 0: *************** main(int argc, char **argv) *** 520,530 **** break; case 2: /* lock-wait-timeout */ ! lockWaitTimeout = pg_strdup(optarg); break; case 3: /* SET ROLE */ ! use_role = pg_strdup(optarg); break; case 4: /* exclude table(s) data */ --- 478,488 ---- break; case 2: /* lock-wait-timeout */ ! dopt->lockWaitTimeout = pg_strdup(optarg); break; case 3: /* SET ROLE */ ! dopt->use_role = pg_strdup(optarg); break; case 4: /* exclude table(s) data */ *************** main(int argc, char **argv) *** 532,538 **** break; case 5: /* section */ ! set_dump_section(optarg, &dumpSections); break; default: --- 490,496 ---- 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) --- 503,510 ---- * 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,603 **** } /* --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 */ ! archiveFormat = parseArchiveFormat(format, &archiveMode); /* archiveFormat specific setup */ ! if (archiveFormat == archNull) ! plainText = 1; /* Custom and directory formats are compressed by default, others not */ ! if (compressLevel == -1) { ! if (archiveFormat == archCustom || archiveFormat == archDirectory) ! compressLevel = Z_DEFAULT_COMPRESSION; else ! compressLevel = 0; } /* --- 517,561 ---- } /* --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 */ ! dopt->archiveFormat = parseArchiveFormat(format, &dopt->archiveMode); /* archiveFormat specific setup */ ! if (dopt->archiveFormat == archNull) ! dopt->plainText = 1; /* Custom and directory formats are compressed by default, others not */ ! if (dopt->compressLevel == -1) { ! if (dopt->archiveFormat == archCustom || dopt->archiveFormat == archDirectory) ! dopt->compressLevel = Z_DEFAULT_COMPRESSION; else ! dopt->compressLevel = 0; } /* *************** main(int argc, char **argv) *** 605,623 **** * parallel jobs because that's the maximum limit for the * WaitForMultipleObjects() call. */ ! if (numWorkers <= 0 #ifdef WIN32 ! || numWorkers > MAXIMUM_WAIT_OBJECTS #endif ) exit_horribly(NULL, "%s: invalid number of parallel jobs\n", progname); /* Parallel backup only in the directory archive format so far */ ! if (archiveFormat != archDirectory && numWorkers > 1) exit_horribly(NULL, "parallel backup only supported by the directory format\n"); /* Open the output file */ ! fout = CreateArchive(filename, archiveFormat, compressLevel, archiveMode, setupDumpWorker); /* Register the cleanup hook */ --- 563,581 ---- * parallel jobs because that's the maximum limit for the * WaitForMultipleObjects() call. */ ! if (dopt->numWorkers <= 0 #ifdef WIN32 ! || dopt->numWorkers > MAXIMUM_WAIT_OBJECTS #endif ) exit_horribly(NULL, "%s: invalid number of parallel jobs\n", progname); /* Parallel backup only in the directory archive format so far */ ! if (dopt->archiveFormat != archDirectory && dopt->numWorkers > 1) exit_horribly(NULL, "parallel backup only supported by the directory format\n"); /* Open the output file */ ! fout = CreateArchive(filename, dopt->archiveFormat, dopt->compressLevel, dopt->archiveMode, setupDumpWorker); /* Register the cleanup hook */ *************** main(int argc, char **argv) *** 636,656 **** fout->minRemoteVersion = 70000; fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99; ! fout->numWorkers = numWorkers; /* * 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, --- 594,614 ---- fout->minRemoteVersion = 70000; fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99; ! fout->numWorkers = dopt->numWorkers; /* * Open the database using the Archiver, so it knows about it. Errors mean * death. */ ! ConnectDatabase(fout, dopt->dbname, dopt->pghost, dopt->pgport, dopt->username, dopt->prompt_password); ! setup_connection(fout, dopt); /* * 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); } --- 624,630 ---- * 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) *** 680,687 **** username_subquery = "SELECT usename FROM pg_user WHERE usesysid ="; /* 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" --- 638,645 ---- username_subquery = "SELECT usename FROM pg_user WHERE usesysid ="; /* check the version for the synchronized snapshots feature */ ! if (dopt->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); /* --- 689,715 ---- * 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) *** 785,791 **** sortDumpableObjectsByTypeOid(dobjs, numObjs); /* If we do a parallel dump, we want the largest tables to go first */ ! if (archiveFormat == archDirectory && numWorkers > 1) sortDataAndIndexObjectsBySize(dobjs, numObjs); sortDumpableObjects(dobjs, numObjs, --- 743,749 ---- sortDumpableObjectsByTypeOid(dobjs, numObjs); /* If we do a parallel dump, we want the largest tables to go first */ ! if (dopt->archiveFormat == archDirectory && dopt->numWorkers > 1) sortDataAndIndexObjectsBySize(dobjs, numObjs); sortDumpableObjects(dobjs, numObjs, *************** main(int argc, char **argv) *** 801,835 **** 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; else ! ropt->compression = compressLevel; ropt->suppressDumpWarnings = true; /* We've already shown them */ --- 759,799 ---- 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 (dopt->compressLevel == -1) ropt->compression = 0; else ! ropt->compression = dopt->compressLevel; ropt->suppressDumpWarnings = true; /* We've already shown them */ *************** main(int argc, char **argv) *** 840,846 **** * be output, so we can set up their dependency lists properly. This isn't * necessary for plain-text output, though. */ ! if (!plainText) BuildArchiveDependencies(fout); /* --- 804,810 ---- * be output, so we can set up their dependency lists properly. This isn't * necessary for plain-text output, though. */ ! if (!dopt->plainText) BuildArchiveDependencies(fout); /* *************** main(int argc, char **argv) *** 850,859 **** * inside CloseArchive(). This is, um, bizarre; but not worth changing * right now. */ ! if (plainText) RestoreArchive(fout); ! CloseArchive(fout); exit_nicely(0); } --- 814,823 ---- * inside CloseArchive(). This is, um, bizarre; but not worth changing * right now. */ ! if (dopt->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; --- 890,896 ---- } static void ! setup_connection(Archive *AH, DumpOptions *dopt) { PGconn *conn = GetConnection(AH); const char *std_strings; *************** setup_connection(Archive *AH, const char *** 937,947 **** * this has already been set in CloneArchive according to the original * connection encoding. */ ! if (dumpencoding) { ! if (PQsetClientEncoding(conn, dumpencoding) < 0) exit_horribly(NULL, "invalid client encoding \"%s\" specified\n", ! dumpencoding); } /* --- 901,911 ---- * this has already been set in CloneArchive according to the original * connection encoding. */ ! if (dopt->dumpencoding) { ! if (PQsetClientEncoding(conn, dopt->dumpencoding) < 0) exit_horribly(NULL, "invalid client encoding \"%s\" specified\n", ! dopt->dumpencoding); } /* *************** setup_connection(Archive *AH, const char *** 954,974 **** AH->std_strings = (std_strings && strcmp(std_strings, "on") == 0); /* Set the role if requested */ ! if (!use_role && AH->use_role) ! use_role = AH->use_role; /* Set the role if requested */ ! if (use_role && AH->remoteVersion >= 80100) { PQExpBuffer query = createPQExpBuffer(); ! appendPQExpBuffer(query, "SET ROLE %s", fmtId(use_role)); ExecuteSqlStatement(AH, query->data); destroyPQExpBuffer(query); /* save this for later use on parallel connections */ if (!AH->use_role) ! AH->use_role = strdup(use_role); } /* Set the datestyle to ISO to ensure the dump's portability */ --- 918,938 ---- AH->std_strings = (std_strings && strcmp(std_strings, "on") == 0); /* Set the role if requested */ ! if (!dopt->use_role && AH->use_role) ! dopt->use_role = AH->use_role; /* Set the role if requested */ ! if (dopt->use_role && AH->remoteVersion >= 80100) { PQExpBuffer query = createPQExpBuffer(); ! appendPQExpBuffer(query, "SET ROLE %s", fmtId(dopt->use_role)); ExecuteSqlStatement(AH, query->data); destroyPQExpBuffer(query); /* save this for later use on parallel connections */ if (!AH->use_role) ! AH->use_role = strdup(dopt->use_role); } /* Set the datestyle to ISO to ensure the dump's portability */ *************** 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"); --- 978,984 ---- 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) { --- 1000,1006 ---- ! 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 * --- 1017,1025 ---- } static void ! setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt) { ! setup_connection(AHX, dopt); } 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; } /* --- 1290,1301 ---- * 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; } /* --- 1309,1320 ---- * such extensions by their having OIDs in the range reserved for initdb. */ static void ! selectDumpableExtension(DumpOptions *dopt, ExtensionInfo *extinfo) { if (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; --- 1343,1349 ---- */ static int ! dumpTableData_copy(Archive *fout, DumpOptions *dopt, void *dcontext) { TableDataInfo *tdinfo = (TableDataInfo *) dcontext; TableInfo *tbinfo = tdinfo->tdtable; *************** dumpTableData_copy(Archive *fout, void * *** 1553,1559 **** * 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; --- 1517,1523 ---- * 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 *** 1622,1628 **** else { /* append the list of column names if required */ ! if (column_inserts) { appendPQExpBufferStr(insertStmt, "("); for (field = 0; field < nfields; field++) --- 1586,1592 ---- 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 *** 1739,1745 **** * Actually, this just makes an ArchiveEntry for the table contents. */ static void ! dumpTableData(Archive *fout, TableDataInfo *tdinfo) { TableInfo *tbinfo = tdinfo->tdtable; PQExpBuffer copyBuf = createPQExpBuffer(); --- 1703,1709 ---- * 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 *** 1747,1753 **** DataDumperPtr dumpFn; char *copyStmt; ! if (!dump_inserts) { /* Dump/restore using COPY */ dumpFn = dumpTableData_copy; --- 1711,1717 ---- DataDumperPtr dumpFn; char *copyStmt; ! if (!dopt->dump_inserts) { /* Dump/restore using COPY */ dumpFn = dumpTableData_copy; *************** refreshMatViewData(Archive *fout, TableD *** 1831,1844 **** * 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); } } --- 1795,1808 ---- * 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 *** 1849,1855 **** * table data; the "dump" flag in such objects isn't used. */ static void ! makeTableDataInfo(TableInfo *tbinfo, bool oids) { TableDataInfo *tdinfo; --- 1813,1819 ---- * 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 *** 1869,1875 **** /* 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 */ --- 1833,1839 ---- /* 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 *** 2142,2148 **** * dump the database definition */ static void ! dumpDatabase(Archive *fout) { PQExpBuffer dbQry = createPQExpBuffer(); PQExpBuffer delQry = createPQExpBuffer(); --- 2106,2112 ---- * dump the database definition */ static void ! dumpDatabase(Archive *fout, DumpOptions *dopt) { PQExpBuffer dbQry = createPQExpBuffer(); PQExpBuffer delQry = createPQExpBuffer(); *************** dumpDatabase(Archive *fout) *** 2461,2474 **** { 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(); --- 2425,2438 ---- { 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) *** 2489,2495 **** destroyPQExpBuffer(creaQry); } - /* * dumpEncoding: put the correct encoding into the archive */ --- 2453,2458 ---- *************** getBlobs(Archive *fout) *** 2629,2635 **** * dump the definition (metadata) of the given large object */ static void ! dumpBlob(Archive *fout, BlobInfo *binfo) { PQExpBuffer cquery = createPQExpBuffer(); PQExpBuffer dquery = createPQExpBuffer(); --- 2592,2598 ---- * 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) *** 2656,2673 **** 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); --- 2619,2636 ---- 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) *** 2680,2686 **** * dump the data contents of all large objects */ static int ! dumpBlobs(Archive *fout, void *arg) { const char *blobQry; const char *blobFetchQry; --- 2643,2649 ---- * 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, *** 3091,3097 **** * numExtensions is set to the number of extensions read in */ ExtensionInfo * ! getExtensions(Archive *fout, int *numExtensions) { PGresult *res; int ntups; --- 3054,3060 ---- * 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 *** 3155,3161 **** extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition)); /* Decide whether we want to dump it */ ! selectDumpableExtension(&(extinfo[i])); } PQclear(res); --- 3118,3124 ---- extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition)); /* Decide whether we want to dump it */ ! selectDumpableExtension(dopt, &(extinfo[i])); } PQclear(res); *************** getFuncs(Archive *fout, int *numFuncs) *** 4268,4274 **** * numTables is set to the number of tables read in */ TableInfo * ! getTables(Archive *fout, int *numTables) { PGresult *res; int ntups; --- 4231,4237 ---- * 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) *** 4765,4771 **** 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. --- 4728,4734 ---- 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) *** 4776,4782 **** */ resetPQExpBuffer(query); appendPQExpBufferStr(query, "SET statement_timeout = "); ! appendStringLiteralConn(query, lockWaitTimeout, GetConnection(fout)); ExecuteSqlStatement(fout, query->data); } --- 4739,4745 ---- */ resetPQExpBuffer(query); appendPQExpBufferStr(query, "SET statement_timeout = "); ! appendStringLiteralConn(query, dopt->lockWaitTimeout, GetConnection(fout)); ExecuteSqlStatement(fout, query->data); } *************** getTables(Archive *fout, int *numTables) *** 4871,4877 **** tblinfo[i].dobj.name); } ! if (lockWaitTimeout && fout->remoteVersion >= 70300) { ExecuteSqlStatement(fout, "SET statement_timeout = 0"); } --- 4834,4840 ---- tblinfo[i].dobj.name); } ! if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300) { ExecuteSqlStatement(fout, "SET statement_timeout = 0"); } *************** getForeignServers(Archive *fout, int *nu *** 7396,7402 **** * numDefaultACLs is set to the number of ACLs read in */ DefaultACLInfo * ! getDefaultACLs(Archive *fout, int *numDefaultACLs) { DefaultACLInfo *daclinfo; PQExpBuffer query; --- 7359,7365 ---- * 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 *** 7465,7471 **** daclinfo[i].defaclacl = pg_strdup(PQgetvalue(res, i, i_defaclacl)); /* Decide whether we want to dump it */ ! selectDumpableDefaultACL(&(daclinfo[i])); } PQclear(res); --- 7428,7434 ---- 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 *** 7494,7500 **** * 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) { --- 7457,7463 ---- * 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 *** 7504,7515 **** /* Comments are schema not data ... except blob comments are data */ if (strncmp(target, "LARGE OBJECT ", 13) != 0) { ! if (dataOnly) return; } else { ! if (schemaOnly) return; } --- 7467,7478 ---- /* 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 *** 7558,7564 **** * and its columns. */ static void ! dumpTableComment(Archive *fout, TableInfo *tbinfo, const char *reltypename) { CommentItem *comments; --- 7521,7527 ---- * and its columns. */ static void ! dumpTableComment(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, const char *reltypename) { CommentItem *comments; *************** dumpTableComment(Archive *fout, TableInf *** 7567,7573 **** PQExpBuffer target; /* Comments are SCHEMA not data */ ! if (dataOnly) return; /* Search for comments associated with relation, using table */ --- 7530,7536 ---- PQExpBuffer target; /* Comments are SCHEMA not data */ ! if (dopt->dataOnly) return; /* Search for comments associated with relation, using table */ *************** collectComments(Archive *fout, CommentIt *** 7812,7919 **** * 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, --- 7775,7882 ---- * 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 *** 7935,7941 **** * writes out to fout the queries to recreate a user-defined namespace */ static void ! dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) { PQExpBuffer q; PQExpBuffer delq; --- 7898,7904 ---- * 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 *** 7943,7949 **** char *qnspname; /* Skip if not to be dumped */ ! if (!nspinfo->dobj.dump || dataOnly) return; /* don't dump dummy namespace from pre-7.3 source */ --- 7906,7912 ---- 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 *** 7975,7988 **** 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); --- 7938,7951 ---- 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 *** 7998,8004 **** * writes out to fout the queries to recreate an extension */ static void ! dumpExtension(Archive *fout, ExtensionInfo *extinfo) { PQExpBuffer q; PQExpBuffer delq; --- 7961,7967 ---- * 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 *** 8006,8012 **** char *qextname; /* Skip if not to be dumped */ ! if (!extinfo->dobj.dump || dataOnly) return; q = createPQExpBuffer(); --- 7969,7975 ---- char *qextname; /* Skip if not to be dumped */ ! if (!extinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpExtension(Archive *fout, ExtensionIn *** 8103,8112 **** 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); --- 8066,8075 ---- 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 *** 8122,8144 **** * 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); --- 8085,8107 ---- * 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 *** 8149,8155 **** * 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(); --- 8112,8118 ---- * 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 *** 8254,8267 **** 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); --- 8217,8230 ---- 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 *** 8278,8284 **** * 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(); --- 8241,8247 ---- * 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 *** 8386,8399 **** 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); --- 8349,8362 ---- 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 *** 8410,8416 **** * 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(); --- 8373,8379 ---- * 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 *** 8776,8789 **** 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); --- 8739,8752 ---- 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 *** 8800,8806 **** * 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(); --- 8763,8769 ---- * 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 *** 8938,8951 **** 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); --- 8901,8914 ---- 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 *** 8962,8968 **** * composite type */ static void ! dumpCompositeType(Archive *fout, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer dropped = createPQExpBuffer(); --- 8925,8931 ---- * composite type */ static void ! dumpCompositeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer dropped = createPQExpBuffer(); *************** dumpCompositeType(Archive *fout, TypeInf *** 9153,9166 **** /* 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); --- 9116,9129 ---- /* 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 *** 9291,9302 **** * 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(); --- 9254,9265 ---- * 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 *** 9346,9357 **** * 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; } --- 9309,9320 ---- * 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) *** 9362,9368 **** * procedural language */ static void ! dumpProcLang(Archive *fout, ProcLangInfo *plang) { PQExpBuffer defqry; PQExpBuffer delqry; --- 9325,9331 ---- * procedural language */ static void ! dumpProcLang(Archive *fout, DumpOptions* dopt, ProcLangInfo *plang) { PQExpBuffer defqry; PQExpBuffer delqry; *************** dumpProcLang(Archive *fout, ProcLangInfo *** 9375,9381 **** FuncInfo *validatorInfo = NULL; /* Skip if not to be dumped */ ! if (!plang->dobj.dump || dataOnly) return; /* --- 9338,9344 ---- FuncInfo *validatorInfo = NULL; /* Skip if not to be dumped */ ! if (!plang->dobj.dump || dopt->dataOnly) return; /* *************** dumpProcLang(Archive *fout, ProcLangInfo *** 9421,9427 **** if (!plang->dobj.ext_member) { ! if (!useParams && !shouldDumpProcLangs()) return; } --- 9384,9390 ---- if (!plang->dobj.ext_member) { ! if (!useParams && !shouldDumpProcLangs(dopt)) return; } *************** dumpProcLang(Archive *fout, ProcLangInfo *** 9500,9514 **** 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); --- 9463,9477 ---- 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, *** 9655,9661 **** * dump out one function */ static void ! dumpFunc(Archive *fout, FuncInfo *finfo) { PQExpBuffer query; PQExpBuffer q; --- 9618,9624 ---- * dump out one function */ static void ! dumpFunc(Archive *fout, DumpOptions* dopt, FuncInfo *finfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpFunc(Archive *fout, FuncInfo *finfo) *** 9694,9700 **** int i; /* Skip if not to be dumped */ ! if (!finfo->dobj.dump || dataOnly) return; query = createPQExpBuffer(); --- 9657,9663 ---- int i; /* Skip if not to be dumped */ ! if (!finfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); *************** dumpFunc(Archive *fout, FuncInfo *finfo) *** 9887,9893 **** * 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 --- 9850,9856 ---- * 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) *** 9900,9906 **** { 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); --- 9863,9869 ---- { 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) *** 10090,10103 **** 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); --- 10053,10066 ---- 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) *** 10128,10134 **** * Dump a user-defined cast */ static void ! dumpCast(Archive *fout, CastInfo *cast) { PQExpBuffer defqry; PQExpBuffer delqry; --- 10091,10097 ---- * Dump a user-defined cast */ static void ! dumpCast(Archive *fout, DumpOptions* dopt, CastInfo *cast) { PQExpBuffer defqry; PQExpBuffer delqry; *************** dumpCast(Archive *fout, CastInfo *cast) *** 10136,10142 **** 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 */ --- 10099,10105 ---- 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) *** 10262,10268 **** NULL, NULL); /* Dump Cast Comments */ ! dumpComment(fout, labelq->data, NULL, "", cast->dobj.catId, 0, cast->dobj.dumpId); --- 10225,10231 ---- NULL, NULL); /* Dump Cast Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, "", cast->dobj.catId, 0, cast->dobj.dumpId); *************** dumpCast(Archive *fout, CastInfo *cast) *** 10276,10282 **** * write out a single operator definition */ static void ! dumpOpr(Archive *fout, OprInfo *oprinfo) { PQExpBuffer query; PQExpBuffer q; --- 10239,10245 ---- * write out a single operator definition */ static void ! dumpOpr(Archive *fout, DumpOptions* dopt, OprInfo *oprinfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpOpr(Archive *fout, OprInfo *oprinfo) *** 10310,10316 **** char *oprref; /* Skip if not to be dumped */ ! if (!oprinfo->dobj.dump || dataOnly) return; /* --- 10273,10279 ---- char *oprref; /* Skip if not to be dumped */ ! if (!oprinfo->dobj.dump || dopt->dataOnly) return; /* *************** dumpOpr(Archive *fout, OprInfo *oprinfo) *** 10514,10520 **** NULL, NULL); /* Dump Operator Comments */ ! dumpComment(fout, labelq->data, oprinfo->dobj.namespace->dobj.name, oprinfo->rolname, oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId); --- 10477,10483 ---- 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 *** 10664,10670 **** * write out a single operator class definition */ static void ! dumpOpclass(Archive *fout, OpclassInfo *opcinfo) { PQExpBuffer query; PQExpBuffer q; --- 10627,10633 ---- * write out a single operator class definition */ static void ! dumpOpclass(Archive *fout, DumpOptions* dopt, OpclassInfo *opcinfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpOpclass(Archive *fout, OpclassInfo * *** 10708,10714 **** int i; /* Skip if not to be dumped */ ! if (!opcinfo->dobj.dump || dataOnly) return; /* --- 10671,10677 ---- int i; /* Skip if not to be dumped */ ! if (!opcinfo->dobj.dump || dopt->dataOnly) return; /* *************** dumpOpclass(Archive *fout, OpclassInfo * *** 11022,11028 **** NULL, NULL); /* Dump Operator Class Comments */ ! dumpComment(fout, labelq->data, NULL, opcinfo->rolname, opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId); --- 10985,10991 ---- 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 * *** 11041,11047 **** * specific opclass within the opfamily. */ static void ! dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo) { PQExpBuffer query; PQExpBuffer q; --- 11004,11010 ---- * specific opclass within the opfamily. */ static void ! dumpOpfamily(Archive *fout, DumpOptions* dopt, OpfamilyInfo *opfinfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpOpfamily(Archive *fout, OpfamilyInfo *** 11075,11081 **** int i; /* Skip if not to be dumped */ ! if (!opfinfo->dobj.dump || dataOnly) return; /* --- 11038,11044 ---- int i; /* Skip if not to be dumped */ ! if (!opfinfo->dobj.dump || dopt->dataOnly) return; /* *************** dumpOpfamily(Archive *fout, OpfamilyInfo *** 11335,11341 **** NULL, NULL); /* Dump Operator Family Comments */ ! dumpComment(fout, labelq->data, NULL, opfinfo->rolname, opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId); --- 11298,11304 ---- 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 *** 11353,11359 **** * write out a single collation definition */ static void ! dumpCollation(Archive *fout, CollInfo *collinfo) { PQExpBuffer query; PQExpBuffer q; --- 11316,11322 ---- * write out a single collation definition */ static void ! dumpCollation(Archive *fout, DumpOptions* dopt, CollInfo *collinfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpCollation(Archive *fout, CollInfo *c *** 11366,11372 **** const char *collctype; /* Skip if not to be dumped */ ! if (!collinfo->dobj.dump || dataOnly) return; query = createPQExpBuffer(); --- 11329,11335 ---- const char *collctype; /* Skip if not to be dumped */ ! if (!collinfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); *************** dumpCollation(Archive *fout, CollInfo *c *** 11424,11430 **** NULL, NULL); /* Dump Collation Comments */ ! dumpComment(fout, labelq->data, collinfo->dobj.namespace->dobj.name, collinfo->rolname, collinfo->dobj.catId, 0, collinfo->dobj.dumpId); --- 11387,11393 ---- 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 *** 11441,11447 **** * write out a single conversion definition */ static void ! dumpConversion(Archive *fout, ConvInfo *convinfo) { PQExpBuffer query; PQExpBuffer q; --- 11404,11410 ---- * write out a single conversion definition */ static void ! dumpConversion(Archive *fout, DumpOptions* dopt, ConvInfo *convinfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpConversion(Archive *fout, ConvInfo * *** 11458,11464 **** bool condefault; /* Skip if not to be dumped */ ! if (!convinfo->dobj.dump || dataOnly) return; query = createPQExpBuffer(); --- 11421,11427 ---- bool condefault; /* Skip if not to be dumped */ ! if (!convinfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); *************** dumpConversion(Archive *fout, ConvInfo * *** 11523,11529 **** NULL, NULL); /* Dump Conversion Comments */ ! dumpComment(fout, labelq->data, convinfo->dobj.namespace->dobj.name, convinfo->rolname, convinfo->dobj.catId, 0, convinfo->dobj.dumpId); --- 11486,11492 ---- 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 *** 11580,11586 **** * write out a single aggregate definition */ static void ! dumpAgg(Archive *fout, AggInfo *agginfo) { PQExpBuffer query; PQExpBuffer q; --- 11543,11549 ---- * write out a single aggregate definition */ static void ! dumpAgg(Archive *fout, DumpOptions* dopt, AggInfo *agginfo) { PQExpBuffer query; PQExpBuffer q; *************** dumpAgg(Archive *fout, AggInfo *agginfo) *** 11626,11632 **** bool convertok; /* Skip if not to be dumped */ ! if (!agginfo->aggfn.dobj.dump || dataOnly) return; query = createPQExpBuffer(); --- 11589,11595 ---- bool convertok; /* Skip if not to be dumped */ ! if (!agginfo->aggfn.dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); *************** dumpAgg(Archive *fout, AggInfo *agginfo) *** 11919,11928 **** 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); --- 11882,11891 ---- 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) *** 11937,11943 **** 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, --- 11900,11906 ---- 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) *** 11962,11975 **** * 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(); --- 11925,11938 ---- * 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 *** 12019,12025 **** NULL, NULL); /* Dump Parser Comments */ ! dumpComment(fout, labelq->data, NULL, "", prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId); --- 11982,11988 ---- NULL, NULL); /* Dump Parser Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, "", prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId); *************** dumpTSParser(Archive *fout, TSParserInfo *** 12033,12039 **** * write out a single text search dictionary */ static void ! dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo) { PQExpBuffer q; PQExpBuffer delq; --- 11996,12002 ---- * write out a single text search dictionary */ static void ! dumpTSDictionary(Archive *fout, DumpOptions* dopt, TSDictInfo *dictinfo) { PQExpBuffer q; PQExpBuffer delq; *************** dumpTSDictionary(Archive *fout, TSDictIn *** 12044,12050 **** char *tmplname; /* Skip if not to be dumped */ ! if (!dictinfo->dobj.dump || dataOnly) return; q = createPQExpBuffer(); --- 12007,12013 ---- char *tmplname; /* Skip if not to be dumped */ ! if (!dictinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpTSDictionary(Archive *fout, TSDictIn *** 12106,12112 **** NULL, NULL); /* Dump Dictionary Comments */ ! dumpComment(fout, labelq->data, NULL, dictinfo->rolname, dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId); --- 12069,12075 ---- NULL, NULL); /* Dump Dictionary Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, dictinfo->rolname, dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId); *************** dumpTSDictionary(Archive *fout, TSDictIn *** 12121,12134 **** * 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(); --- 12084,12097 ---- * 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 *** 12172,12178 **** NULL, NULL); /* Dump Template Comments */ ! dumpComment(fout, labelq->data, NULL, "", tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId); --- 12135,12141 ---- NULL, NULL); /* Dump Template Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, "", tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId); *************** dumpTSTemplate(Archive *fout, TSTemplate *** 12186,12192 **** * write out a single text search configuration */ static void ! dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo) { PQExpBuffer q; PQExpBuffer delq; --- 12149,12155 ---- * write out a single text search configuration */ static void ! dumpTSConfig(Archive *fout, DumpOptions* dopt, TSConfigInfo *cfginfo) { PQExpBuffer q; PQExpBuffer delq; *************** dumpTSConfig(Archive *fout, TSConfigInfo *** 12201,12207 **** int i_dictname; /* Skip if not to be dumped */ ! if (!cfginfo->dobj.dump || dataOnly) return; q = createPQExpBuffer(); --- 12164,12170 ---- int i_dictname; /* Skip if not to be dumped */ ! if (!cfginfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpTSConfig(Archive *fout, TSConfigInfo *** 12300,12306 **** NULL, NULL); /* Dump Configuration Comments */ ! dumpComment(fout, labelq->data, NULL, cfginfo->rolname, cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId); --- 12263,12269 ---- NULL, NULL); /* Dump Configuration Comments */ ! dumpComment(fout, dopt, labelq->data, NULL, cfginfo->rolname, cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId); *************** dumpTSConfig(Archive *fout, TSConfigInfo *** 12315,12321 **** * write out a single foreign-data wrapper definition */ static void ! dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo) { PQExpBuffer q; PQExpBuffer delq; --- 12278,12284 ---- * 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 *** 12323,12329 **** char *qfdwname; /* Skip if not to be dumped */ ! if (!fdwinfo->dobj.dump || dataOnly) return; /* --- 12286,12292 ---- char *qfdwname; /* Skip if not to be dumped */ ! if (!fdwinfo->dobj.dump || dopt->dataOnly) return; /* *************** dumpForeignDataWrapper(Archive *fout, Fd *** 12331,12337 **** * field. Otherwise omit them if we are only dumping some specific object. */ if (!fdwinfo->dobj.ext_member) ! if (!include_everything) return; q = createPQExpBuffer(); --- 12294,12300 ---- * 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 *** 12374,12387 **** 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); --- 12337,12350 ---- 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 *** 12397,12403 **** * write out a foreign server definition */ static void ! dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo) { PQExpBuffer q; PQExpBuffer delq; --- 12360,12366 ---- * write out a foreign server definition */ static void ! dumpForeignServer(Archive *fout, DumpOptions* dopt, ForeignServerInfo *srvinfo) { PQExpBuffer q; PQExpBuffer delq; *************** dumpForeignServer(Archive *fout, Foreign *** 12408,12414 **** char *fdwname; /* Skip if not to be dumped */ ! if (!srvinfo->dobj.dump || dataOnly || !include_everything) return; q = createPQExpBuffer(); --- 12371,12377 ---- char *fdwname; /* Skip if not to be dumped */ ! if (!srvinfo->dobj.dump || dopt->dataOnly || !dopt->include_everything) return; q = createPQExpBuffer(); *************** dumpForeignServer(Archive *fout, Foreign *** 12466,12472 **** NULL, NULL); /* Handle the ACL */ ! dumpACL(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId, "FOREIGN SERVER", qsrvname, NULL, srvinfo->dobj.name, NULL, srvinfo->rolname, --- 12429,12435 ---- 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 *** 12479,12485 **** srvinfo->dobj.catId, srvinfo->dobj.dumpId); /* Dump Foreign Server Comments */ ! dumpComment(fout, labelq->data, NULL, srvinfo->rolname, srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId); --- 12442,12448 ---- 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, *** 12595,12608 **** * 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(); --- 12558,12571 ---- * 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 *** 12675,12681 **** *---------- */ 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) --- 12638,12644 ---- *---------- */ 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 *** 12683,12693 **** 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(); --- 12646,12656 ---- 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 *** 12730,12736 **** * 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) { --- 12693,12699 ---- * 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 * *** 12740,12757 **** 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; } --- 12703,12720 ---- 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 * *** 12794,12800 **** * and its columns. */ static void ! dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename) { SecLabelItem *labels; int nlabels; --- 12757,12763 ---- * and its columns. */ static void ! dumpTableSecLabel(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, const char *reltypename) { SecLabelItem *labels; int nlabels; *************** dumpTableSecLabel(Archive *fout, TableIn *** 12803,12813 **** 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 */ --- 12766,12776 ---- 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 *** 13015,13034 **** * 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, --- 12978,12997 ---- * 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 *** 13063,13069 **** 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); --- 13026,13032 ---- 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 *** 13140,13146 **** * 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(); --- 13103,13109 ---- * 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 *** 13753,13762 **** /* 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++) --- 13716,13725 ---- /* 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 *** 13766,13772 **** if (constr->separate || !constr->conislocal) continue; ! dumpTableConstraintComment(fout, constr); } destroyPQExpBuffer(q); --- 13729,13735 ---- if (constr->separate || !constr->conislocal) continue; ! dumpTableConstraintComment(fout, dopt, constr); } destroyPQExpBuffer(q); *************** dumpTableSchema(Archive *fout, TableInfo *** 13778,13784 **** * dumpAttrDef --- dump an attribute's default-value declaration */ static void ! dumpAttrDef(Archive *fout, AttrDefInfo *adinfo) { TableInfo *tbinfo = adinfo->adtable; int adnum = adinfo->adnum; --- 13741,13747 ---- * 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 * *** 13786,13792 **** 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 */ --- 13749,13755 ---- 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 *** 13865,13871 **** * 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); --- 13828,13834 ---- * 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 *** 13873,13879 **** PQExpBuffer delq; PQExpBuffer labelq; ! if (dataOnly) return; q = createPQExpBuffer(); --- 13836,13842 ---- PQExpBuffer delq; PQExpBuffer labelq; ! if (dopt->dataOnly) return; q = createPQExpBuffer(); *************** dumpIndex(Archive *fout, IndxInfo *indxi *** 13938,13944 **** } /* Dump Index Comments */ ! dumpComment(fout, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, indxinfo->dobj.catId, 0, --- 13901,13907 ---- } /* Dump Index Comments */ ! dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, indxinfo->dobj.catId, 0, *************** dumpIndex(Archive *fout, IndxInfo *indxi *** 13955,13968 **** * 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(); --- 13918,13931 ---- * 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 *** 14172,14178 **** /* Dump Constraint Comments --- only works for table constraints */ if (tbinfo && coninfo->separate) ! dumpTableConstraintComment(fout, coninfo); destroyPQExpBuffer(q); destroyPQExpBuffer(delq); --- 14135,14141 ---- /* Dump Constraint Comments --- only works for table constraints */ if (tbinfo && coninfo->separate) ! dumpTableConstraintComment(fout, dopt, coninfo); destroyPQExpBuffer(q); destroyPQExpBuffer(delq); *************** dumpConstraint(Archive *fout, Constraint *** 14186,14192 **** * or as a separate ALTER command. */ static void ! dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo) { TableInfo *tbinfo = coninfo->contable; PQExpBuffer labelq = createPQExpBuffer(); --- 14149,14155 ---- * 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 *** 14195,14201 **** 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, --- 14158,14164 ---- 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) *** 14255,14261 **** * write the declaration (not data) of one user-defined sequence */ static void ! dumpSequence(Archive *fout, TableInfo *tbinfo) { PGresult *res; char *startv, --- 14218,14224 ---- * 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 *** 14441,14450 **** } /* 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); --- 14404,14413 ---- } /* 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 *** 14515,14521 **** * write the declaration of one user-defined table trigger */ static void ! dumpTrigger(Archive *fout, TriggerInfo *tginfo) { TableInfo *tbinfo = tginfo->tgtable; PQExpBuffer query; --- 14478,14484 ---- * 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 * *** 14530,14536 **** * 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(); --- 14493,14499 ---- * 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 * *** 14711,14717 **** NULL, 0, NULL, NULL); ! dumpComment(fout, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tginfo->dobj.catId, 0, tginfo->dobj.dumpId); --- 14674,14680 ---- 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 * *** 14725,14737 **** * 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(); --- 14688,14700 ---- * 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 *** 14783,14789 **** "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); --- 14746,14752 ---- "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 *** 14796,14802 **** * Dump a rule */ static void ! dumpRule(Archive *fout, RuleInfo *rinfo) { TableInfo *tbinfo = rinfo->ruletable; PQExpBuffer query; --- 14759,14765 ---- * Dump a rule */ static void ! dumpRule(Archive *fout, DumpOptions *dopt, RuleInfo *rinfo) { TableInfo *tbinfo = rinfo->ruletable; PQExpBuffer query; *************** dumpRule(Archive *fout, RuleInfo *rinfo) *** 14806,14812 **** PGresult *res; /* Skip if not to be dumped */ ! if (!rinfo->dobj.dump || dataOnly) return; /* --- 14769,14775 ---- PGresult *res; /* Skip if not to be dumped */ ! if (!rinfo->dobj.dump || dopt->dataOnly) return; /* *************** dumpRule(Archive *fout, RuleInfo *rinfo) *** 14911,14917 **** NULL, NULL); /* Dump rule comments */ ! dumpComment(fout, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, rinfo->dobj.catId, 0, rinfo->dobj.dumpId); --- 14874,14880 ---- 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) *** 14928,14934 **** * getExtensionMembership --- obtain extension membership data */ void ! getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], int numExtensions) { PQExpBuffer query; --- 14891,14897 ---- * getExtensionMembership --- obtain extension membership data */ void ! getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[], int numExtensions) { PQExpBuffer query; *************** getExtensionMembership(Archive *fout, Ex *** 15104,15110 **** * 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) --- 15067,15073 ---- * 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..da1ceee *** 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,512 ---- struct Archive; typedef struct Archive Archive; ! struct _dumpOptions; ! typedef struct _dumpOptions DumpOptions; ! ! extern TableInfo *getSchemaData(Archive *, DumpOptions *dopt, int *numTablesPtr); typedef enum _OidOptions { *************** extern void sortDataAndIndexObjectsBySiz *** 545,551 **** * 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); --- 548,554 ---- * version specific routines */ extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces); ! extern ExtensionInfo *getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions); extern TypeInfo *getTypes(Archive *fout, int *numTypes); extern FuncInfo *getFuncs(Archive *fout, int *numFuncs); extern AggInfo *getAggregates(Archive *fout, int *numAggregates); *************** extern OpclassInfo *getOpclasses(Archive *** 554,560 **** 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); --- 557,563 ---- 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, 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 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); --- 576,583 ---- int *numForeignDataWrappers); extern ForeignServerInfo *getForeignServers(Archive *fout, int *numForeignServers); ! extern DefaultACLInfo *getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs); ! extern void getExtensionMembership(Archive *fout, DumpOptions* dopt, ExtensionInfo extinfo[], int numExtensions); extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers); diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c new file mode 100644 index 4050091..73448b1 *** a/src/bin/pg_dump/pg_dumpall.c --- b/src/bin/pg_dump/pg_dumpall.c *************** static bool verbose = false; *** 72,77 **** --- 72,78 ---- static int binary_upgrade = 0; static int column_inserts = 0; static int disable_dollar_quoting = 0; + static int quote_all_identifiers = 0; static int disable_triggers = 0; static int if_exists = 0; static int inserts = 0; diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c new file mode 100644 index dcb5109..ef2cdd1 *** 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; }