diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 94e9147..41792e8 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -64,7 +64,7 @@ static DumpableObject **nspinfoindex; static void flagInhTables(TableInfo *tbinfo, int numTables, InhInfo *inhinfo, int numInherits); -static void flagInhAttrs(TableInfo *tblinfo, int numTables); +static void flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables); static DumpableObject **buildIndexArray(void *objArray, int numObjs, Size objSize); static int DOCatalogIdCompare(const void *p1, const void *p2); @@ -78,7 +78,7 @@ static int strInArray(const char *pattern, char **arr, int arr_size); * Collect information about all potentially dumpable objects */ TableInfo * -getSchemaData(Archive *fout, int *numTablesPtr) +getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr) { ExtensionInfo *extinfo; InhInfo *inhinfo; @@ -114,7 +114,7 @@ getSchemaData(Archive *fout, int *numTablesPtr) */ if (g_verbose) write_msg(NULL, "reading user-defined tables\n"); - tblinfo = getTables(fout, &numTables); + tblinfo = getTables(fout, dopt, &numTables); tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo)); /* Do this after we've built tblinfoindex */ @@ -122,11 +122,11 @@ getSchemaData(Archive *fout, int *numTablesPtr) if (g_verbose) write_msg(NULL, "reading extensions\n"); - extinfo = getExtensions(fout, &numExtensions); + extinfo = getExtensions(fout, dopt, &numExtensions); if (g_verbose) write_msg(NULL, "reading user-defined functions\n"); - funinfo = getFuncs(fout, &numFuncs); + funinfo = getFuncs(fout, dopt, &numFuncs); funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo)); /* this must be after getTables and getFuncs */ @@ -142,7 +142,7 @@ getSchemaData(Archive *fout, int *numTablesPtr) if (g_verbose) write_msg(NULL, "reading user-defined aggregate functions\n"); - getAggregates(fout, &numAggregates); + getAggregates(fout, dopt, &numAggregates); if (g_verbose) write_msg(NULL, "reading user-defined operators\n"); @@ -183,7 +183,7 @@ getSchemaData(Archive *fout, int *numTablesPtr) if (g_verbose) write_msg(NULL, "reading default privileges\n"); - getDefaultACLs(fout, &numDefaultACLs); + getDefaultACLs(fout, dopt, &numDefaultACLs); if (g_verbose) write_msg(NULL, "reading user-defined collations\n"); @@ -213,7 +213,7 @@ getSchemaData(Archive *fout, int *numTablesPtr) */ if (g_verbose) write_msg(NULL, "finding extension members\n"); - getExtensionMembership(fout, extinfo, numExtensions); + getExtensionMembership(fout, dopt, extinfo, numExtensions); /* Link tables to parents, mark parents of target tables interesting */ if (g_verbose) @@ -222,11 +222,11 @@ getSchemaData(Archive *fout, int *numTablesPtr) if (g_verbose) write_msg(NULL, "reading column info for interesting tables\n"); - getTableAttrs(fout, tblinfo, numTables); + getTableAttrs(fout, dopt, tblinfo, numTables); if (g_verbose) write_msg(NULL, "flagging inherited columns in subtables\n"); - flagInhAttrs(tblinfo, numTables); + flagInhAttrs(dopt, tblinfo, numTables); if (g_verbose) write_msg(NULL, "reading indexes\n"); @@ -303,7 +303,7 @@ flagInhTables(TableInfo *tblinfo, int numTables, * modifies tblinfo */ static void -flagInhAttrs(TableInfo *tblinfo, int numTables) +flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables) { int i, j, @@ -380,7 +380,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables) attrDef->adef_expr = pg_strdup("NULL"); /* Will column be dumped explicitly? */ - if (shouldPrintColumn(tbinfo, j)) + if (shouldPrintColumn(dopt, tbinfo, j)) { attrDef->separate = false; /* No dependency needed: NULL cannot have dependencies */ diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h index b387aa1..0f6c88a 100644 --- a/src/bin/pg_dump/dumputils.h +++ b/src/bin/pg_dump/dumputils.h @@ -31,8 +31,6 @@ typedef struct SimpleStringList SimpleStringListCell *tail; } SimpleStringList; - -extern int quote_all_identifiers; extern PQExpBuffer (*getLocalPQExpBuffer) (void); extern const char *fmtId(const char *identifier); diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c index e50dd8b..ceed115 100644 --- a/src/bin/pg_dump/parallel.c +++ b/src/bin/pg_dump/parallel.c @@ -89,11 +89,12 @@ static void WaitForTerminatingWorkers(ParallelState *pstate); 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, int pipefd[2]); +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); @@ -436,6 +437,7 @@ sigTermHandler(int signum) */ static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker, + DumpOptions *dopt, RestoreOptions *ropt) { /* @@ -445,11 +447,11 @@ SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker, * properly when we shut down. This happens only that way when it is * brought down because of an error. */ - (AH->SetupWorkerPtr) ((Archive *) AH, ropt); + (AH->SetupWorkerPtr) ((Archive *) AH, dopt, ropt); Assert(AH->connection != NULL); - WaitForCommands(AH, pipefd); + WaitForCommands(AH, dopt, pipefd); closesocket(pipefd[PIPE_READ]); closesocket(pipefd[PIPE_WRITE]); @@ -481,7 +483,7 @@ init_spawned_worker_win32(WorkerInfo *wi) * of threads while it does a fork() on Unix. */ ParallelState * -ParallelBackupStart(ArchiveHandle *AH, RestoreOptions *ropt) +ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt) { ParallelState *pstate; int i; @@ -598,7 +600,7 @@ ParallelBackupStart(ArchiveHandle *AH, RestoreOptions *ropt) closesocket(pstate->parallelSlot[j].pipeWrite); } - SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, ropt); + SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, dopt, ropt); exit(0); } @@ -856,7 +858,7 @@ lockTableNoWait(ArchiveHandle *AH, TocEntry *te) * exit. */ static void -WaitForCommands(ArchiveHandle *AH, int pipefd[2]) +WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]) { char *command; DumpId dumpId; @@ -896,7 +898,7 @@ WaitForCommands(ArchiveHandle *AH, int pipefd[2]) * The message we return here has been pg_malloc()ed and we are * responsible for free()ing it. */ - str = (AH->WorkerJobDumpPtr) (AH, te); + 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 index 7a32a9b..81a823d 100644 --- a/src/bin/pg_dump/parallel.h +++ b/src/bin/pg_dump/parallel.h @@ -80,6 +80,7 @@ extern void EnsureIdleWorker(struct _archiveHandle * AH, ParallelState *pstate); 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 index 25780cf..4e3cfad 100644 --- a/src/bin/pg_dump/pg_backup.h +++ b/src/bin/pg_dump/pg_backup.h @@ -98,8 +98,6 @@ struct Archive /* The rest is private */ }; -typedef int (*DataDumperPtr) (Archive *AH, void *userArg); - typedef struct _restoreOptions { int createDB; /* Issue commands to create the database */ @@ -109,17 +107,24 @@ typedef struct _restoreOptions * 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 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; @@ -152,7 +157,61 @@ typedef struct _restoreOptions bool *idWanted; /* array showing which dump IDs to emit */ } RestoreOptions; -typedef void (*SetupWorkerPtr) (Archive *AH, RestoreOptions *ropt); +typedef struct _dumpOptions +{ + const char *dbname; + const char *pghost; + const char *pgport; + const char *username; + const char *dumpencoding; + bool oids; + + int binary_upgrade; + + /* various user-settable parameters */ + bool schemaOnly; + bool dataOnly; + int dumpSections; /* bitmask of chosen sections */ + bool aclsSkip; + const char *lockWaitTimeout; + + /* flags for various command-line long options */ + int disable_dollar_quoting; + int dump_inserts; + int column_inserts; + int if_exists; + int no_security_labels; + int no_synchronized_snapshots; + int no_unlogged_table_data; + int serializable_deferrable; + int quote_all_identifiers; + + /* default, if no "inclusion" switches appear, is to dump everything */ + bool include_everything; + + int 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 int (*DataDumperPtr) (Archive *AH, DumpOptions *dopt, void *userArg); + +typedef void (*SetupWorkerPtr) (Archive *AH, DumpOptions *dopt, RestoreOptions *ropt); /* * Main archiver interface. @@ -185,7 +244,7 @@ extern void WriteData(Archive *AH, const void *data, size_t dLen); extern int StartBlob(Archive *AH, Oid oid); extern int EndBlob(Archive *AH, Oid oid); -extern void CloseArchive(Archive *AH); +extern void CloseArchive(Archive *AH, DumpOptions *dopt); extern void SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt); @@ -204,6 +263,9 @@ extern void PrintTOCSummary(Archive *AH, RestoreOptions *ropt); extern RestoreOptions *NewRestoreOptions(void); +extern DumpOptions* NewDumpOptions(void); +extern DumpOptions* dumpOptionsFromRestoreOptions(RestoreOptions *ropt); + /* Rearrange and filter TOC entries */ extern void SortTocFromFile(Archive *AHX, RestoreOptions *ropt); diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 0018720..17c5f61 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -107,6 +107,64 @@ static void mark_create_done(ArchiveHandle *AH, TocEntry *te); 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 = NewDumpOptions(); + + /* this is the inverse of what's at the end of pg_dump.c's main() */ + dopt->outputClean = ropt->dropSchema; + dopt->dataOnly = ropt->dataOnly; + dopt->schemaOnly = ropt->schemaOnly; + dopt->if_exists = ropt->if_exists; + dopt->column_inserts = ropt->column_inserts; + dopt->dumpSections = ropt->dumpSections; + dopt->aclsSkip = ropt->aclsSkip; + dopt->outputSuperuser = ropt->superuser; + dopt->outputCreateDB = ropt->createDB; + dopt->outputNoOwner = ropt->noOwner; + dopt->outputNoTablespaces = ropt->noTablespace; + dopt->disable_triggers = ropt->disable_triggers; + dopt->use_setsessauth = ropt->use_setsessauth; + + dopt->disable_dollar_quoting = ropt->disable_dollar_quoting; + dopt->dump_inserts = ropt->dump_inserts; + dopt->no_security_labels = ropt->no_security_labels; + dopt->lockWaitTimeout = ropt->lockWaitTimeout; + dopt->include_everything = ropt->include_everything; + + return dopt; +} + + +/* * Wrapper functions. * * The objective it to make writing new formats and dumpers as simple @@ -120,7 +178,7 @@ static void inhibit_data_for_failed_table(ArchiveHandle *AH, TocEntry *te); * setup doesn't need to know anything much, so it's defined here. */ static void -setupRestoreWorker(Archive *AHX, RestoreOptions *ropt) +setupRestoreWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt) { ArchiveHandle *AH = (ArchiveHandle *) AHX; @@ -152,12 +210,12 @@ OpenArchive(const char *FileSpec, const ArchiveFormat fmt) /* Public */ void -CloseArchive(Archive *AHX) +CloseArchive(Archive *AHX, DumpOptions *dopt) { int res = 0; ArchiveHandle *AH = (ArchiveHandle *) AHX; - (*AH->ClosePtr) (AH); + (*AH->ClosePtr) (AH, dopt); /* Close the output */ if (AH->gzOut) @@ -522,7 +580,7 @@ RestoreArchive(Archive *AHX) Assert(AH->connection == NULL); /* ParallelBackupStart() will actually fork the processes */ - pstate = ParallelBackupStart(AH, ropt); + pstate = ParallelBackupStart(AH, NULL, ropt); restore_toc_entries_parallel(AH, pstate, &pending_list); ParallelBackupEnd(AH, pstate); @@ -2211,7 +2269,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt, } void -WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate) +WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate) { TocEntry *te; @@ -2234,13 +2292,13 @@ WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate) DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP); } else - WriteDataChunksForTocEntry(AH, te); + WriteDataChunksForTocEntry(AH, dopt, te); } EnsureWorkersFinished(AH, pstate); } void -WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te) +WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te) { StartDataPtr startPtr; EndDataPtr endPtr; @@ -2264,7 +2322,7 @@ WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te) /* * The user-provided DataDumper routine needs to call AH->WriteData */ - (*te->dataDumper) ((Archive *) AH, te->dataDumperArg); + (*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 index c163f29..2dac52c 100644 --- a/src/bin/pg_dump/pg_backup_archiver.h +++ b/src/bin/pg_dump/pg_backup_archiver.h @@ -139,7 +139,7 @@ typedef enum T_Action ACT_RESTORE } T_Action; -typedef void (*ClosePtr) (struct _archiveHandle * AH); +typedef void (*ClosePtr) (struct _archiveHandle * AH, DumpOptions *dopt); typedef void (*ReopenPtr) (struct _archiveHandle * AH); typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te); @@ -166,7 +166,7 @@ typedef void (*ClonePtr) (struct _archiveHandle * AH); 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 *(*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, @@ -389,8 +389,8 @@ extern void WriteHead(ArchiveHandle *AH); 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 void WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, struct ParallelState *pstate); +extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te); extern ArchiveHandle *CloneArchive(ArchiveHandle *AH); extern void DeCloneArchive(ArchiveHandle *AH); diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c index 06cd0a7..d6bb471 100644 --- a/src/bin/pg_dump/pg_backup_custom.c +++ b/src/bin/pg_dump/pg_backup_custom.c @@ -41,7 +41,7 @@ static int _WriteByte(ArchiveHandle *AH, const int i); 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 _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); @@ -694,7 +694,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len) * */ static void -_CloseArchive(ArchiveHandle *AH) +_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) { lclContext *ctx = (lclContext *) AH->formatData; pgoff_t tpos; @@ -709,7 +709,7 @@ _CloseArchive(ArchiveHandle *AH) strerror(errno)); WriteToc(AH); ctx->dataStart = _getFilePos(AH, ctx); - WriteDataChunks(AH, NULL); + 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 index 39e29d8..01b0e97 100644 --- a/src/bin/pg_dump/pg_backup_directory.c +++ b/src/bin/pg_dump/pg_backup_directory.c @@ -71,7 +71,7 @@ static int _WriteByte(ArchiveHandle *AH, const int i); 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 _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt); static void _ReopenArchive(ArchiveHandle *AH); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); @@ -92,7 +92,7 @@ static char *_MasterStartParallelItem(ArchiveHandle *AH, TocEntry *te, T_Action 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 char *_WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te); static void setFilePath(ArchiveHandle *AH, char *buf, const char *relativeFilename); @@ -566,7 +566,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len) * WriteDataChunks to save all DATA & BLOBs. */ static void -_CloseArchive(ArchiveHandle *AH) +_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) { lclContext *ctx = (lclContext *) AH->formatData; @@ -578,7 +578,7 @@ _CloseArchive(ArchiveHandle *AH) setFilePath(AH, fname, "toc.dat"); /* this will actually fork the processes for a parallel backup */ - ctx->pstate = ParallelBackupStart(AH, NULL); + ctx->pstate = ParallelBackupStart(AH, dopt, NULL); /* The TOC is always created uncompressed */ tocFH = cfopen_write(fname, PG_BINARY_W, 0); @@ -599,7 +599,7 @@ _CloseArchive(ArchiveHandle *AH) if (cfclose(tocFH) != 0) exit_horribly(modulename, "could not close TOC file: %s\n", strerror(errno)); - WriteDataChunks(AH, ctx->pstate); + WriteDataChunks(AH, dopt, ctx->pstate); ParallelBackupEnd(AH, ctx->pstate); } @@ -790,7 +790,7 @@ _MasterStartParallelItem(ArchiveHandle *AH, TocEntry *te, T_Action act) * function of the respective dump format. */ static char * -_WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te) +_WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te) { /* * short fixed-size string + some ID so far, this needs to be malloc'ed @@ -809,7 +809,7 @@ _WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te) * succeed... A failure will be detected by the parent when the child dies * unexpectedly. */ - WriteDataChunksForTocEntry(AH, te); + 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 index 3bce588..b1c28c1 100644 --- a/src/bin/pg_dump/pg_backup_null.c +++ b/src/bin/pg_dump/pg_backup_null.c @@ -35,7 +35,7 @@ static void _WriteBlobData(ArchiveHandle *AH, const void *data, size_t dLen); 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 _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); @@ -198,12 +198,15 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) { if (te->dataDumper) { + DumpOptions *dopt; AH->currToc = te; if (strcmp(te->desc, "BLOBS") == 0) _StartBlobs(AH, te); - (*te->dataDumper) ((Archive *) AH, te->dataDumperArg); + dopt = dumpOptionsFromRestoreOptions(ropt); + (*te->dataDumper) ((Archive *) AH, dopt, te->dataDumperArg); + free(dopt); if (strcmp(te->desc, "BLOBS") == 0) _EndBlobs(AH, te); @@ -227,7 +230,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len) } static void -_CloseArchive(ArchiveHandle *AH) +_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 index 457b742..1c5056c 100644 --- a/src/bin/pg_dump/pg_backup_tar.c +++ b/src/bin/pg_dump/pg_backup_tar.c @@ -48,7 +48,7 @@ static int _WriteByte(ArchiveHandle *AH, const int i); 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 _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); @@ -827,7 +827,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len) } static void -_CloseArchive(ArchiveHandle *AH) +_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) { lclContext *ctx = (lclContext *) AH->formatData; TAR_MEMBER *th; @@ -850,7 +850,7 @@ _CloseArchive(ArchiveHandle *AH) /* * Now send the data (tables & blobs) */ - WriteDataChunks(AH, NULL); + 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 index c084ee9..e2befe5 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -85,13 +85,6 @@ typedef struct 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; @@ -116,8 +109,6 @@ static SimpleOidList table_exclude_oids = {NULL, NULL}; 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 */ @@ -125,23 +116,12 @@ char g_opaque_type[10]; /* name for the opaque type */ 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; +extern int quote_all_identifiers; +static const CatalogId nilCatalogId = {0, 0}; static void help(const char *progname); -static void setup_connection(Archive *AH, const char *dumpencoding, - char *use_role); +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, @@ -150,64 +130,64 @@ static void expand_table_name_patterns(Archive *fout, SimpleStringList *patterns, SimpleOidList *oids); static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid); -static void dumpTableData(Archive *fout, TableDataInfo *tdinfo); +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, const char *target, +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, const char *target, +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, 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 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, 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 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, 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 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, DefaultACLInfo *daclinfo); +static void dumpDefaultACL(Archive *fout, DumpOptions* dopt, DefaultACLInfo *daclinfo); -static void dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId, +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); @@ -222,8 +202,8 @@ static void addBoundaryDependencies(DumpableObject **dobjs, int numObjs, 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 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, @@ -245,9 +225,9 @@ static void selectSourceSchema(Archive *fout, const char *schemaName); 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 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, @@ -264,7 +244,7 @@ static const char *getAttrName(int attrnum, TableInfo *tblInfo); 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); +static void setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt); int @@ -273,39 +253,19 @@ main(int argc, char **argv) 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; + DumpOptions *dopt = NewDumpOptions(); - static struct option long_options[] = { + struct option long_options[] = { {"data-only", no_argument, NULL, 'a'}, {"blobs", no_argument, NULL, 'b'}, {"clean", no_argument, NULL, 'c'}, @@ -340,24 +300,24 @@ main(int argc, char **argv) /* * 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}, + {"attribute-inserts", no_argument, &dopt->column_inserts, 1}, + {"binary-upgrade", no_argument, &dopt->binary_upgrade, 1}, + {"column-inserts", no_argument, &dopt->column_inserts, 1}, + {"disable-dollar-quoting", no_argument, &dopt->disable_dollar_quoting, 1}, + {"disable-triggers", no_argument, &dopt->disable_triggers, 1}, {"exclude-table-data", required_argument, NULL, 4}, - {"if-exists", no_argument, &if_exists, 1}, - {"inserts", no_argument, &dump_inserts, 1}, + {"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, &outputNoTablespaces, 1}, + {"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, &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}, + {"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} }; @@ -376,10 +336,6 @@ main(int argc, char **argv) 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 */ @@ -406,27 +362,27 @@ main(int argc, char **argv) switch (c) { case 'a': /* Dump data only */ - dataOnly = true; + dopt->dataOnly = true; break; case 'b': /* Dump blobs */ - outputBlobs = true; + dopt->outputBlobs = true; break; case 'c': /* clean (i.e., drop) schema prior to create */ - outputClean = 1; + dopt->outputClean = 1; break; case 'C': /* Create DB */ - outputCreateDB = 1; + dopt->outputCreateDB = 1; break; case 'd': /* database name */ - dbname = pg_strdup(optarg); + dopt->dbname = pg_strdup(optarg); break; case 'E': /* Dump encoding */ - dumpencoding = pg_strdup(optarg); + dopt->dumpencoding = pg_strdup(optarg); break; case 'f': @@ -438,7 +394,7 @@ main(int argc, char **argv) break; case 'h': /* server host */ - pghost = pg_strdup(optarg); + dopt->pghost = pg_strdup(optarg); break; case 'i': @@ -446,12 +402,12 @@ main(int argc, char **argv) break; case 'j': /* number of dump jobs */ - numWorkers = atoi(optarg); + dopt->numWorkers = atoi(optarg); break; case 'n': /* include schema(s) */ simple_string_list_append(&schema_include_patterns, optarg); - include_everything = false; + dopt->include_everything = false; break; case 'N': /* exclude schema(s) */ @@ -459,15 +415,15 @@ main(int argc, char **argv) break; case 'o': /* Dump oids */ - oids = true; + dopt->oids = true; break; case 'O': /* Don't reconnect to match owner */ - outputNoOwner = 1; + dopt->outputNoOwner = 1; break; case 'p': /* server port */ - pgport = pg_strdup(optarg); + dopt->pgport = pg_strdup(optarg); break; case 'R': @@ -475,16 +431,16 @@ main(int argc, char **argv) break; case 's': /* dump schema only */ - schemaOnly = true; + dopt->schemaOnly = true; break; case 'S': /* Username for superuser in plain text output */ - outputSuperuser = pg_strdup(optarg); + dopt->outputSuperuser = pg_strdup(optarg); break; case 't': /* include table(s) */ simple_string_list_append(&table_include_patterns, optarg); - include_everything = false; + dopt->include_everything = false; break; case 'T': /* exclude table(s) */ @@ -492,7 +448,7 @@ main(int argc, char **argv) break; case 'U': - username = pg_strdup(optarg); + dopt->username = pg_strdup(optarg); break; case 'v': /* verbose */ @@ -500,19 +456,19 @@ main(int argc, char **argv) break; case 'w': - prompt_password = TRI_NO; + dopt->prompt_password = TRI_NO; break; case 'W': - prompt_password = TRI_YES; + dopt->prompt_password = TRI_YES; break; case 'x': /* skip ACL dump */ - aclsSkip = true; + dopt->aclsSkip = true; break; case 'Z': /* Compression Level */ - compressLevel = atoi(optarg); + dopt->compressLevel = atoi(optarg); break; case 0: @@ -520,11 +476,11 @@ main(int argc, char **argv) break; case 2: /* lock-wait-timeout */ - lockWaitTimeout = pg_strdup(optarg); + dopt->lockWaitTimeout = pg_strdup(optarg); break; case 3: /* SET ROLE */ - use_role = pg_strdup(optarg); + dopt->use_role = pg_strdup(optarg); break; case 4: /* exclude table(s) data */ @@ -532,7 +488,7 @@ main(int argc, char **argv) break; case 5: /* section */ - set_dump_section(optarg, &dumpSections); + set_dump_section(optarg, &dopt->dumpSections); break; default: @@ -545,8 +501,8 @@ main(int argc, char **argv) * 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++]; + if (optind < argc && dopt->dbname == NULL) + dopt->dbname = argv[optind++]; /* Complain if any arguments remain */ if (optind < argc) @@ -559,45 +515,45 @@ main(int argc, char **argv) } /* --column-inserts implies --inserts */ - if (column_inserts) - dump_inserts = 1; + if (dopt->column_inserts) + dopt->dump_inserts = 1; - if (dataOnly && schemaOnly) + 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 (dataOnly && outputClean) + if (dopt->dataOnly && dopt->outputClean) { write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n"); exit_nicely(1); } - if (dump_inserts && oids) + 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 (if_exists && !outputClean) + if (dopt->if_exists && !dopt->outputClean) exit_horribly(NULL, "option --if-exists requires option -c/--clean\n"); /* Identify archive format to emit */ - archiveFormat = parseArchiveFormat(format, &archiveMode); + dopt->archiveFormat = parseArchiveFormat(format, &dopt->archiveMode); /* archiveFormat specific setup */ - if (archiveFormat == archNull) - plainText = 1; + if (dopt->archiveFormat == archNull) + dopt->plainText = 1; /* Custom and directory formats are compressed by default, others not */ - if (compressLevel == -1) + if (dopt->compressLevel == -1) { - if (archiveFormat == archCustom || archiveFormat == archDirectory) - compressLevel = Z_DEFAULT_COMPRESSION; + if (dopt->archiveFormat == archCustom || dopt->archiveFormat == archDirectory) + dopt->compressLevel = Z_DEFAULT_COMPRESSION; else - compressLevel = 0; + dopt->compressLevel = 0; } /* @@ -605,19 +561,19 @@ main(int argc, char **argv) * parallel jobs because that's the maximum limit for the * WaitForMultipleObjects() call. */ - if (numWorkers <= 0 + if (dopt->numWorkers <= 0 #ifdef WIN32 - || numWorkers > MAXIMUM_WAIT_OBJECTS + || 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 (archiveFormat != archDirectory && numWorkers > 1) + 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, archiveFormat, compressLevel, archiveMode, + fout = CreateArchive(filename, dopt->archiveFormat, dopt->compressLevel, dopt->archiveMode, setupDumpWorker); /* Register the cleanup hook */ @@ -636,21 +592,21 @@ main(int argc, char **argv) fout->minRemoteVersion = 70000; fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99; - fout->numWorkers = numWorkers; + fout->numWorkers = dopt->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); + 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) - no_security_labels = 1; + dopt->no_security_labels = 1; /* * When running against 9.0 or later, check if we are in recovery mode, @@ -666,7 +622,7 @@ main(int argc, char **argv) * On hot standby slaves, never try to dump unlogged table data, * since it will just throw an error. */ - no_unlogged_table_data = true; + dopt->no_unlogged_table_data = true; } PQclear(res); } @@ -680,8 +636,8 @@ main(int argc, char **argv) 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) + 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" @@ -731,27 +687,27 @@ main(int argc, char **argv) * 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; + 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, &numTables); + tblinfo = getSchemaData(fout, dopt, &numTables); if (fout->remoteVersion < 80400) guessConstraintInheritance(tblinfo, numTables); - if (!schemaOnly) + if (!dopt->schemaOnly) { - getTableData(tblinfo, numTables, oids); + getTableData(dopt, tblinfo, numTables, dopt->oids); buildMatViewRefreshDependencies(fout); - if (dataOnly) + if (dopt->dataOnly) getTableDataFKConstraints(); } - if (outputBlobs) + if (dopt->outputBlobs) getBlobs(fout); /* @@ -785,7 +741,7 @@ main(int argc, char **argv) sortDumpableObjectsByTypeOid(dobjs, numObjs); /* If we do a parallel dump, we want the largest tables to go first */ - if (archiveFormat == archDirectory && numWorkers > 1) + if (dopt->archiveFormat == archDirectory && dopt->numWorkers > 1) sortDataAndIndexObjectsBySize(dobjs, numObjs); sortDumpableObjects(dobjs, numObjs, @@ -801,35 +757,41 @@ main(int argc, char **argv) dumpStdStrings(fout); /* The database item is always next, unless we don't want it at all */ - if (include_everything && !dataOnly) - dumpDatabase(fout); + if (dopt->include_everything && !dopt->dataOnly) + dumpDatabase(fout, dopt); /* Now the rearrangeable objects. */ for (i = 0; i < numObjs; i++) - dumpDumpableObject(fout, dobjs[i]); + dumpDumpableObject(fout, dopt, 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->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 = compressLevel; + ropt->compression = dopt->compressLevel; ropt->suppressDumpWarnings = true; /* We've already shown them */ @@ -840,7 +802,7 @@ main(int argc, char **argv) * be output, so we can set up their dependency lists properly. This isn't * necessary for plain-text output, though. */ - if (!plainText) + if (!dopt->plainText) BuildArchiveDependencies(fout); /* @@ -850,10 +812,10 @@ main(int argc, char **argv) * inside CloseArchive(). This is, um, bizarre; but not worth changing * right now. */ - if (plainText) + if (dopt->plainText) RestoreArchive(fout); - CloseArchive(fout); + CloseArchive(fout, dopt); exit_nicely(0); } @@ -926,7 +888,7 @@ help(const char *progname) } static void -setup_connection(Archive *AH, const char *dumpencoding, char *use_role) +setup_connection(Archive *AH, DumpOptions *dopt) { PGconn *conn = GetConnection(AH); const char *std_strings; @@ -937,11 +899,11 @@ setup_connection(Archive *AH, const char *dumpencoding, char *use_role) * this has already been set in CloneArchive according to the original * connection encoding. */ - if (dumpencoding) + if (dopt->dumpencoding) { - if (PQsetClientEncoding(conn, dumpencoding) < 0) + if (PQsetClientEncoding(conn, dopt->dumpencoding) < 0) exit_horribly(NULL, "invalid client encoding \"%s\" specified\n", - dumpencoding); + dopt->dumpencoding); } /* @@ -954,21 +916,21 @@ setup_connection(Archive *AH, const char *dumpencoding, char *use_role) 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; + if (!dopt->use_role && AH->use_role) + dopt->use_role = AH->use_role; /* Set the role if requested */ - if (use_role && AH->remoteVersion >= 80100) + if (dopt->use_role && AH->remoteVersion >= 80100) { PQExpBuffer query = createPQExpBuffer(); - appendPQExpBuffer(query, "SET ROLE %s", fmtId(use_role)); + 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(use_role); + AH->use_role = strdup(dopt->use_role); } /* Set the datestyle to ISO to ensure the dump's portability */ @@ -1014,7 +976,7 @@ setup_connection(Archive *AH, const char *dumpencoding, char *use_role) ExecuteSqlStatement(AH, "BEGIN"); if (AH->remoteVersion >= 90100) { - if (serializable_deferrable) + if (dopt->serializable_deferrable) ExecuteSqlStatement(AH, "SET TRANSACTION ISOLATION LEVEL " "SERIALIZABLE, READ ONLY, DEFERRABLE"); @@ -1036,7 +998,7 @@ setup_connection(Archive *AH, const char *dumpencoding, char *use_role) - if (AH->numWorkers > 1 && AH->remoteVersion >= 90200 && !no_synchronized_snapshots) + if (AH->numWorkers > 1 && AH->remoteVersion >= 90200 && !dopt->no_synchronized_snapshots) { if (AH->sync_snapshot_id) { @@ -1053,9 +1015,9 @@ setup_connection(Archive *AH, const char *dumpencoding, char *use_role) } static void -setupDumpWorker(Archive *AHX, RestoreOptions *ropt) +setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt) { - setup_connection(AHX, NULL, NULL); + setup_connection(AHX, dopt); } static char * @@ -1326,12 +1288,12 @@ selectDumpableType(TypeInfo *tyinfo) * and aclsSkip are checked separately. */ static void -selectDumpableDefaultACL(DefaultACLInfo *dinfo) +selectDumpableDefaultACL(DumpOptions *dopt, DefaultACLInfo *dinfo) { if (dinfo->dobj.namespace) dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump; else - dinfo->dobj.dump = include_everything; + dinfo->dobj.dump = dopt->include_everything; } /* @@ -1345,12 +1307,12 @@ selectDumpableDefaultACL(DefaultACLInfo *dinfo) * such extensions by their having OIDs in the range reserved for initdb. */ static void -selectDumpableExtension(ExtensionInfo *extinfo) +selectDumpableExtension(DumpOptions *dopt, ExtensionInfo *extinfo) { - if (binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId) + if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId) extinfo->dobj.dump = false; else - extinfo->dobj.dump = include_everything; + extinfo->dobj.dump = dopt->include_everything; } /* @@ -1379,7 +1341,7 @@ selectDumpableObject(DumpableObject *dobj) */ static int -dumpTableData_copy(Archive *fout, void *dcontext) +dumpTableData_copy(Archive *fout, DumpOptions *dopt, void *dcontext) { TableDataInfo *tdinfo = (TableDataInfo *) dcontext; TableInfo *tbinfo = tdinfo->tdtable; @@ -1554,7 +1516,7 @@ dumpTableData_copy(Archive *fout, void *dcontext) * E'' strings, or dollar-quoted strings. So don't emit anything like that. */ static int -dumpTableData_insert(Archive *fout, void *dcontext) +dumpTableData_insert(Archive *fout, DumpOptions *dopt, void *dcontext) { TableDataInfo *tdinfo = (TableDataInfo *) dcontext; TableInfo *tbinfo = tdinfo->tdtable; @@ -1623,7 +1585,7 @@ dumpTableData_insert(Archive *fout, void *dcontext) else { /* append the list of column names if required */ - if (column_inserts) + if (dopt->column_inserts) { appendPQExpBufferStr(insertStmt, "("); for (field = 0; field < nfields; field++) @@ -1740,7 +1702,7 @@ dumpTableData_insert(Archive *fout, void *dcontext) * Actually, this just makes an ArchiveEntry for the table contents. */ static void -dumpTableData(Archive *fout, TableDataInfo *tdinfo) +dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo) { TableInfo *tbinfo = tdinfo->tdtable; PQExpBuffer copyBuf = createPQExpBuffer(); @@ -1748,7 +1710,7 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo) DataDumperPtr dumpFn; char *copyStmt; - if (!dump_inserts) + if (!dopt->dump_inserts) { /* Dump/restore using COPY */ dumpFn = dumpTableData_copy; @@ -1832,14 +1794,14 @@ refreshMatViewData(Archive *fout, TableDataInfo *tdinfo) * set up dumpable objects representing the contents of tables */ static void -getTableData(TableInfo *tblinfo, int numTables, bool oids) +getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids) { int i; for (i = 0; i < numTables; i++) { if (tblinfo[i].dobj.dump) - makeTableDataInfo(&(tblinfo[i]), oids); + makeTableDataInfo(dopt, &(tblinfo[i]), oids); } } @@ -1850,7 +1812,7 @@ getTableData(TableInfo *tblinfo, int numTables, bool oids) * table data; the "dump" flag in such objects isn't used. */ static void -makeTableDataInfo(TableInfo *tbinfo, bool oids) +makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids) { TableDataInfo *tdinfo; @@ -1870,7 +1832,7 @@ makeTableDataInfo(TableInfo *tbinfo, bool oids) /* Don't dump data in unlogged tables, if so requested */ if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED && - no_unlogged_table_data) + dopt->no_unlogged_table_data) return; /* Check that the data is not explicitly excluded */ @@ -2143,7 +2105,7 @@ guessConstraintInheritance(TableInfo *tblinfo, int numTables) * dump the database definition */ static void -dumpDatabase(Archive *fout) +dumpDatabase(Archive *fout, DumpOptions *dopt) { PQExpBuffer dbQry = createPQExpBuffer(); PQExpBuffer delQry = createPQExpBuffer(); @@ -2305,7 +2267,7 @@ dumpDatabase(Archive *fout) fmtId(tablespace)); appendPQExpBufferStr(creaQry, ";\n"); - if (binary_upgrade) + if (dopt->binary_upgrade) { appendPQExpBufferStr(creaQry, "\n-- For binary upgrade, set datfrozenxid and datminmxid.\n"); appendPQExpBuffer(creaQry, "UPDATE pg_catalog.pg_database\n" @@ -2344,7 +2306,7 @@ dumpDatabase(Archive *fout) * pg_largeobject and pg_largeobject_metadata come from the old system * intact, so set their relfrozenxids and relminmxids. */ - if (binary_upgrade) + if (dopt->binary_upgrade) { PGresult *lo_res; PQExpBuffer loFrozenQry = createPQExpBuffer(); @@ -2462,14 +2424,14 @@ dumpDatabase(Archive *fout) { resetPQExpBuffer(dbQry); appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname)); - dumpComment(fout, dbQry->data, NULL, "", + dumpComment(fout, dopt, dbQry->data, NULL, "", dbCatId, 0, dbDumpId); } PQclear(res); /* Dump shared security label. */ - if (!no_security_labels && fout->remoteVersion >= 90200) + if (!dopt->no_security_labels && fout->remoteVersion >= 90200) { PQExpBuffer seclabelQry = createPQExpBuffer(); @@ -2490,7 +2452,6 @@ dumpDatabase(Archive *fout) destroyPQExpBuffer(creaQry); } - /* * dumpEncoding: put the correct encoding into the archive */ @@ -2630,7 +2591,7 @@ getBlobs(Archive *fout) * dump the definition (metadata) of the given large object */ static void -dumpBlob(Archive *fout, BlobInfo *binfo) +dumpBlob(Archive *fout, DumpOptions* dopt, BlobInfo *binfo) { PQExpBuffer cquery = createPQExpBuffer(); PQExpBuffer dquery = createPQExpBuffer(); @@ -2657,18 +2618,18 @@ dumpBlob(Archive *fout, BlobInfo *binfo) appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name); /* Dump comment if any */ - dumpComment(fout, cquery->data, + dumpComment(fout, dopt, cquery->data, NULL, binfo->rolname, binfo->dobj.catId, 0, binfo->dobj.dumpId); /* Dump security label if any */ - dumpSecLabel(fout, cquery->data, + dumpSecLabel(fout, dopt, 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", + dumpACL(fout, dopt, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT", binfo->dobj.name, NULL, cquery->data, NULL, binfo->rolname, binfo->blobacl); @@ -2681,7 +2642,7 @@ dumpBlob(Archive *fout, BlobInfo *binfo) * dump the data contents of all large objects */ static int -dumpBlobs(Archive *fout, void *arg) +dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg) { const char *blobQry; const char *blobFetchQry; @@ -3092,7 +3053,7 @@ findNamespace(Archive *fout, Oid nsoid, Oid objoid) * numExtensions is set to the number of extensions read in */ ExtensionInfo * -getExtensions(Archive *fout, int *numExtensions) +getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions) { PGresult *res; int ntups; @@ -3156,7 +3117,7 @@ getExtensions(Archive *fout, int *numExtensions) extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition)); /* Decide whether we want to dump it */ - selectDumpableExtension(&(extinfo[i])); + selectDumpableExtension(dopt, &(extinfo[i])); } PQclear(res); @@ -3907,7 +3868,7 @@ getOpfamilies(Archive *fout, int *numOpfamilies) * numAggs is set to the number of aggregates read in */ AggInfo * -getAggregates(Archive *fout, int *numAggs) +getAggregates(Archive *fout, DumpOptions *dopt, int *numAggs) { PGresult *res; int ntups; @@ -3946,7 +3907,7 @@ getAggregates(Archive *fout, int *numAggs) "(SELECT oid FROM pg_namespace " "WHERE nspname = 'pg_catalog')", username_subquery); - if (binary_upgrade && fout->remoteVersion >= 90100) + if (dopt->binary_upgrade && fout->remoteVersion >= 90100) appendPQExpBufferStr(query, " OR EXISTS(SELECT 1 FROM pg_depend WHERE " "classid = 'pg_proc'::regclass AND " @@ -4086,7 +4047,7 @@ getAggregates(Archive *fout, int *numAggs) * numFuncs is set to the number of functions read in */ FuncInfo * -getFuncs(Archive *fout, int *numFuncs) +getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs) { PGresult *res; int ntups; @@ -4143,7 +4104,7 @@ getFuncs(Archive *fout, int *numFuncs) "\n AND NOT EXISTS (SELECT 1 FROM pg_depend " "WHERE classid = 'pg_proc'::regclass AND " "objid = p.oid AND deptype = 'i')"); - if (binary_upgrade && fout->remoteVersion >= 90100) + if (dopt->binary_upgrade && fout->remoteVersion >= 90100) appendPQExpBufferStr(query, "\n OR EXISTS(SELECT 1 FROM pg_depend WHERE " "classid = 'pg_proc'::regclass AND " @@ -4269,7 +4230,7 @@ getFuncs(Archive *fout, int *numFuncs) * numTables is set to the number of tables read in */ TableInfo * -getTables(Archive *fout, int *numTables) +getTables(Archive *fout, DumpOptions *dopt, int *numTables) { PGresult *res; int ntups; @@ -4766,7 +4727,7 @@ getTables(Archive *fout, int *numTables) i_toastreloptions = PQfnumber(res, "toast_reloptions"); i_reloftype = PQfnumber(res, "reloftype"); - if (lockWaitTimeout && fout->remoteVersion >= 70300) + if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300) { /* * Arrange to fail instead of waiting forever for a table lock. @@ -4777,7 +4738,7 @@ getTables(Archive *fout, int *numTables) */ resetPQExpBuffer(query); appendPQExpBufferStr(query, "SET statement_timeout = "); - appendStringLiteralConn(query, lockWaitTimeout, GetConnection(fout)); + appendStringLiteralConn(query, dopt->lockWaitTimeout, GetConnection(fout)); ExecuteSqlStatement(fout, query->data); } @@ -4872,7 +4833,7 @@ getTables(Archive *fout, int *numTables) tblinfo[i].dobj.name); } - if (lockWaitTimeout && fout->remoteVersion >= 70300) + if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300) { ExecuteSqlStatement(fout, "SET statement_timeout = 0"); } @@ -6287,7 +6248,7 @@ getCasts(Archive *fout, int *numCasts) * modifies tblinfo */ void -getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) +getTableAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tblinfo, int numTables) { int i, j; @@ -6642,7 +6603,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) addObjectDependency(&attrdefs[j].dobj, tbinfo->dobj.dumpId); } - else if (!shouldPrintColumn(tbinfo, adnum - 1)) + else if (!shouldPrintColumn(dopt, tbinfo, adnum - 1)) { /* column will be suppressed, print default separately */ attrdefs[j].separate = true; @@ -6855,9 +6816,9 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) * must be kept in sync with this decision. */ bool -shouldPrintColumn(TableInfo *tbinfo, int colno) +shouldPrintColumn(DumpOptions *dopt, TableInfo *tbinfo, int colno) { - if (binary_upgrade) + if (dopt->binary_upgrade) return true; return (tbinfo->attislocal[colno] && !tbinfo->attisdropped[colno]); } @@ -7403,7 +7364,7 @@ getForeignServers(Archive *fout, int *numForeignServers) * numDefaultACLs is set to the number of ACLs read in */ DefaultACLInfo * -getDefaultACLs(Archive *fout, int *numDefaultACLs) +getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs) { DefaultACLInfo *daclinfo; PQExpBuffer query; @@ -7472,7 +7433,7 @@ getDefaultACLs(Archive *fout, int *numDefaultACLs) daclinfo[i].defaclacl = pg_strdup(PQgetvalue(res, i, i_defaclacl)); /* Decide whether we want to dump it */ - selectDumpableDefaultACL(&(daclinfo[i])); + selectDumpableDefaultACL(dopt, &(daclinfo[i])); } PQclear(res); @@ -7501,7 +7462,7 @@ getDefaultACLs(Archive *fout, int *numDefaultACLs) * calling ArchiveEntry() for the specified object. */ static void -dumpComment(Archive *fout, const char *target, +dumpComment(Archive *fout, DumpOptions *dopt, const char *target, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId) { @@ -7511,12 +7472,12 @@ dumpComment(Archive *fout, const char *target, /* Comments are schema not data ... except blob comments are data */ if (strncmp(target, "LARGE OBJECT ", 13) != 0) { - if (dataOnly) + if (dopt->dataOnly) return; } else { - if (schemaOnly) + if (dopt->schemaOnly) return; } @@ -7565,7 +7526,7 @@ dumpComment(Archive *fout, const char *target, * and its columns. */ static void -dumpTableComment(Archive *fout, TableInfo *tbinfo, +dumpTableComment(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, const char *reltypename) { CommentItem *comments; @@ -7574,7 +7535,7 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo, PQExpBuffer target; /* Comments are SCHEMA not data */ - if (dataOnly) + if (dopt->dataOnly) return; /* Search for comments associated with relation, using table */ @@ -7819,108 +7780,108 @@ collectComments(Archive *fout, CommentItem **items) * ArchiveEntries (TOC objects) for each object to be dumped. */ static void -dumpDumpableObject(Archive *fout, DumpableObject *dobj) +dumpDumpableObject(Archive *fout, DumpOptions *dopt, DumpableObject *dobj) { switch (dobj->objType) { case DO_NAMESPACE: - dumpNamespace(fout, (NamespaceInfo *) dobj); + dumpNamespace(fout, dopt, (NamespaceInfo *) dobj); break; case DO_EXTENSION: - dumpExtension(fout, (ExtensionInfo *) dobj); + dumpExtension(fout, dopt, (ExtensionInfo *) dobj); break; case DO_TYPE: - dumpType(fout, (TypeInfo *) dobj); + dumpType(fout, dopt, (TypeInfo *) dobj); break; case DO_SHELL_TYPE: - dumpShellType(fout, (ShellTypeInfo *) dobj); + dumpShellType(fout, dopt, (ShellTypeInfo *) dobj); break; case DO_FUNC: - dumpFunc(fout, (FuncInfo *) dobj); + dumpFunc(fout, dopt, (FuncInfo *) dobj); break; case DO_AGG: - dumpAgg(fout, (AggInfo *) dobj); + dumpAgg(fout, dopt, (AggInfo *) dobj); break; case DO_OPERATOR: - dumpOpr(fout, (OprInfo *) dobj); + dumpOpr(fout, dopt, (OprInfo *) dobj); break; case DO_OPCLASS: - dumpOpclass(fout, (OpclassInfo *) dobj); + dumpOpclass(fout, dopt, (OpclassInfo *) dobj); break; case DO_OPFAMILY: - dumpOpfamily(fout, (OpfamilyInfo *) dobj); + dumpOpfamily(fout, dopt, (OpfamilyInfo *) dobj); break; case DO_COLLATION: - dumpCollation(fout, (CollInfo *) dobj); + dumpCollation(fout, dopt, (CollInfo *) dobj); break; case DO_CONVERSION: - dumpConversion(fout, (ConvInfo *) dobj); + dumpConversion(fout, dopt, (ConvInfo *) dobj); break; case DO_TABLE: - dumpTable(fout, (TableInfo *) dobj); + dumpTable(fout, dopt, (TableInfo *) dobj); break; case DO_ATTRDEF: - dumpAttrDef(fout, (AttrDefInfo *) dobj); + dumpAttrDef(fout, dopt, (AttrDefInfo *) dobj); break; case DO_INDEX: - dumpIndex(fout, (IndxInfo *) dobj); + dumpIndex(fout, dopt, (IndxInfo *) dobj); break; case DO_REFRESH_MATVIEW: refreshMatViewData(fout, (TableDataInfo *) dobj); break; case DO_RULE: - dumpRule(fout, (RuleInfo *) dobj); + dumpRule(fout, dopt, (RuleInfo *) dobj); break; case DO_TRIGGER: - dumpTrigger(fout, (TriggerInfo *) dobj); + dumpTrigger(fout, dopt, (TriggerInfo *) dobj); break; case DO_EVENT_TRIGGER: - dumpEventTrigger(fout, (EventTriggerInfo *) dobj); + dumpEventTrigger(fout, dopt, (EventTriggerInfo *) dobj); break; case DO_CONSTRAINT: - dumpConstraint(fout, (ConstraintInfo *) dobj); + dumpConstraint(fout, dopt, (ConstraintInfo *) dobj); break; case DO_FK_CONSTRAINT: - dumpConstraint(fout, (ConstraintInfo *) dobj); + dumpConstraint(fout, dopt, (ConstraintInfo *) dobj); break; case DO_PROCLANG: - dumpProcLang(fout, (ProcLangInfo *) dobj); + dumpProcLang(fout, dopt, (ProcLangInfo *) dobj); break; case DO_CAST: - dumpCast(fout, (CastInfo *) dobj); + dumpCast(fout, dopt, (CastInfo *) dobj); break; case DO_TABLE_DATA: if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE) dumpSequenceData(fout, (TableDataInfo *) dobj); else - dumpTableData(fout, (TableDataInfo *) dobj); + 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, (TSParserInfo *) dobj); + dumpTSParser(fout, dopt, (TSParserInfo *) dobj); break; case DO_TSDICT: - dumpTSDictionary(fout, (TSDictInfo *) dobj); + dumpTSDictionary(fout, dopt, (TSDictInfo *) dobj); break; case DO_TSTEMPLATE: - dumpTSTemplate(fout, (TSTemplateInfo *) dobj); + dumpTSTemplate(fout, dopt, (TSTemplateInfo *) dobj); break; case DO_TSCONFIG: - dumpTSConfig(fout, (TSConfigInfo *) dobj); + dumpTSConfig(fout, dopt, (TSConfigInfo *) dobj); break; case DO_FDW: - dumpForeignDataWrapper(fout, (FdwInfo *) dobj); + dumpForeignDataWrapper(fout, dopt, (FdwInfo *) dobj); break; case DO_FOREIGN_SERVER: - dumpForeignServer(fout, (ForeignServerInfo *) dobj); + dumpForeignServer(fout, dopt, (ForeignServerInfo *) dobj); break; case DO_DEFAULT_ACL: - dumpDefaultACL(fout, (DefaultACLInfo *) dobj); + dumpDefaultACL(fout, dopt, (DefaultACLInfo *) dobj); break; case DO_BLOB: - dumpBlob(fout, (BlobInfo *) dobj); + dumpBlob(fout, dopt, (BlobInfo *) dobj); break; case DO_BLOB_DATA: ArchiveEntry(fout, dobj->catId, dobj->dumpId, @@ -7942,7 +7903,7 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj) * writes out to fout the queries to recreate a user-defined namespace */ static void -dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) +dumpNamespace(Archive *fout, DumpOptions *dopt, NamespaceInfo *nspinfo) { PQExpBuffer q; PQExpBuffer delq; @@ -7950,7 +7911,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) char *qnspname; /* Skip if not to be dumped */ - if (!nspinfo->dobj.dump || dataOnly) + if (!nspinfo->dobj.dump || dopt->dataOnly) return; /* don't dump dummy namespace from pre-7.3 source */ @@ -7969,7 +7930,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) appendPQExpBuffer(labelq, "SCHEMA %s", qnspname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &nspinfo->dobj, labelq->data); ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, @@ -7982,14 +7943,14 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) NULL, NULL); /* Dump Schema Comments and Security Labels */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, nspinfo->rolname, nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId); - dumpSecLabel(fout, labelq->data, + dumpSecLabel(fout, dopt, labelq->data, NULL, nspinfo->rolname, nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId); - dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA", + dumpACL(fout, dopt, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA", qnspname, NULL, nspinfo->dobj.name, NULL, nspinfo->rolname, nspinfo->nspacl); @@ -8005,7 +7966,7 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo) * writes out to fout the queries to recreate an extension */ static void -dumpExtension(Archive *fout, ExtensionInfo *extinfo) +dumpExtension(Archive *fout, DumpOptions *dopt, ExtensionInfo *extinfo) { PQExpBuffer q; PQExpBuffer delq; @@ -8013,7 +7974,7 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo) char *qextname; /* Skip if not to be dumped */ - if (!extinfo->dobj.dump || dataOnly) + if (!extinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); @@ -8024,7 +7985,7 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo) appendPQExpBuffer(delq, "DROP EXTENSION %s;\n", qextname); - if (!binary_upgrade) + if (!dopt->binary_upgrade) { /* * In a regular dump, we use IF NOT EXISTS so that there isn't a @@ -8110,10 +8071,10 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo) NULL, NULL); /* Dump Extension Comments and Security Labels */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, "", extinfo->dobj.catId, 0, extinfo->dobj.dumpId); - dumpSecLabel(fout, labelq->data, + dumpSecLabel(fout, dopt, labelq->data, NULL, "", extinfo->dobj.catId, 0, extinfo->dobj.dumpId); @@ -8129,23 +8090,23 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo) * writes out to fout the queries to recreate a user-defined type */ static void -dumpType(Archive *fout, TypeInfo *tyinfo) +dumpType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo) { /* Skip if not to be dumped */ - if (!tyinfo->dobj.dump || dataOnly) + if (!tyinfo->dobj.dump || dopt->dataOnly) return; /* Dump out in proper style */ if (tyinfo->typtype == TYPTYPE_BASE) - dumpBaseType(fout, tyinfo); + dumpBaseType(fout, dopt, tyinfo); else if (tyinfo->typtype == TYPTYPE_DOMAIN) - dumpDomain(fout, tyinfo); + dumpDomain(fout, dopt, tyinfo); else if (tyinfo->typtype == TYPTYPE_COMPOSITE) - dumpCompositeType(fout, tyinfo); + dumpCompositeType(fout, dopt, tyinfo); else if (tyinfo->typtype == TYPTYPE_ENUM) - dumpEnumType(fout, tyinfo); + dumpEnumType(fout, dopt, tyinfo); else if (tyinfo->typtype == TYPTYPE_RANGE) - dumpRangeType(fout, tyinfo); + dumpRangeType(fout, dopt, tyinfo); else write_msg(NULL, "WARNING: typtype of data type \"%s\" appears to be invalid\n", tyinfo->dobj.name); @@ -8156,7 +8117,7 @@ dumpType(Archive *fout, TypeInfo *tyinfo) * writes out to fout the queries to recreate a user-defined enum type */ static void -dumpEnumType(Archive *fout, TypeInfo *tyinfo) +dumpEnumType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); @@ -8201,14 +8162,14 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo) appendPQExpBuffer(delq, "%s;\n", qtypname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); appendPQExpBuffer(q, "CREATE TYPE %s AS ENUM (", qtypname); - if (!binary_upgrade) + if (!dopt->binary_upgrade) { /* Labels with server-assigned oids */ for (i = 0; i < num; i++) @@ -8223,7 +8184,7 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo) appendPQExpBufferStr(q, "\n);\n"); - if (binary_upgrade) + if (dopt->binary_upgrade) { /* Labels with dump-assigned (preserved) oids */ for (i = 0; i < num; i++) @@ -8247,7 +8208,7 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo) appendPQExpBuffer(labelq, "TYPE %s", qtypname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, @@ -8261,14 +8222,14 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo) NULL, NULL); /* Dump Type Comments and Security Labels */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); - dumpSecLabel(fout, labelq->data, + dumpSecLabel(fout, dopt, 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", + dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); @@ -8285,7 +8246,7 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo) * writes out to fout the queries to recreate a user-defined range type */ static void -dumpRangeType(Archive *fout, TypeInfo *tyinfo) +dumpRangeType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); @@ -8331,7 +8292,7 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo) appendPQExpBuffer(delq, "%s;\n", qtypname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); @@ -8379,7 +8340,7 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo) appendPQExpBuffer(labelq, "TYPE %s", qtypname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, @@ -8393,14 +8354,14 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo) NULL, NULL); /* Dump Type Comments and Security Labels */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); - dumpSecLabel(fout, labelq->data, + dumpSecLabel(fout, dopt, 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", + dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); @@ -8417,7 +8378,7 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo) * writes out to fout the queries to recreate a user-defined base type */ static void -dumpBaseType(Archive *fout, TypeInfo *tyinfo) +dumpBaseType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); @@ -8671,7 +8632,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) qtypname); /* We might already have a shell type, but setting pg_type_oid is harmless */ - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); @@ -8769,7 +8730,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) appendPQExpBuffer(labelq, "TYPE %s", qtypname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, @@ -8783,14 +8744,14 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) NULL, NULL); /* Dump Type Comments and Security Labels */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); - dumpSecLabel(fout, labelq->data, + dumpSecLabel(fout, dopt, 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", + dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); @@ -8807,7 +8768,7 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo) * writes out to fout the queries to recreate a user-defined domain */ static void -dumpDomain(Archive *fout, TypeInfo *tyinfo) +dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); @@ -8867,7 +8828,7 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo) typdefault = NULL; typcollation = atooid(PQgetvalue(res, 0, PQfnumber(res, "typcollation"))); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, tyinfo->dobj.catId.oid); @@ -8931,7 +8892,7 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo) appendPQExpBuffer(labelq, "DOMAIN %s", qtypname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, @@ -8945,14 +8906,14 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo) NULL, NULL); /* Dump Domain Comments and Security Labels */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); - dumpSecLabel(fout, labelq->data, + dumpSecLabel(fout, dopt, 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", + dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); @@ -8969,7 +8930,7 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo) * composite type */ static void -dumpCompositeType(Archive *fout, TypeInfo *tyinfo) +dumpCompositeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer dropped = createPQExpBuffer(); @@ -9046,7 +9007,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) i_attcollation = PQfnumber(res, "attcollation"); i_typrelid = PQfnumber(res, "typrelid"); - if (binary_upgrade) + if (dopt->binary_upgrade) { Oid typrelid = atooid(PQgetvalue(res, 0, i_typrelid)); @@ -9077,7 +9038,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) attisdropped = (PQgetvalue(res, i, i_attisdropped)[0] == 't'); attcollation = atooid(PQgetvalue(res, i, i_attcollation)); - if (attisdropped && !binary_upgrade) + if (attisdropped && !dopt->binary_upgrade) continue; /* Format properly if not first attr */ @@ -9145,7 +9106,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) appendPQExpBuffer(labelq, "TYPE %s", qtypname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data); ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, @@ -9160,14 +9121,14 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo) /* Dump Type Comments and Security Labels */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId); - dumpSecLabel(fout, labelq->data, + dumpSecLabel(fout, dopt, 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", + dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE", qtypname, NULL, tyinfo->dobj.name, tyinfo->dobj.namespace->dobj.name, tyinfo->rolname, tyinfo->typacl); @@ -9298,12 +9259,12 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo) * We dump a shell definition in advance of the I/O functions for the type. */ static void -dumpShellType(Archive *fout, ShellTypeInfo *stinfo) +dumpShellType(Archive *fout, DumpOptions *dopt, ShellTypeInfo *stinfo) { PQExpBuffer q; /* Skip if not to be dumped */ - if (!stinfo->dobj.dump || dataOnly) + if (!stinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); @@ -9317,7 +9278,7 @@ dumpShellType(Archive *fout, ShellTypeInfo *stinfo) * after it's filled in, otherwise the backend complains. */ - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_type_oid(fout, q, stinfo->baseType->dobj.catId.oid); @@ -9353,12 +9314,12 @@ dumpShellType(Archive *fout, ShellTypeInfo *stinfo) * That case isn't checked here either. */ static bool -shouldDumpProcLangs(void) +shouldDumpProcLangs(DumpOptions *dopt) { - if (!include_everything) + if (!dopt->include_everything) return false; /* And they're schema not data */ - if (dataOnly) + if (dopt->dataOnly) return false; return true; } @@ -9369,7 +9330,7 @@ shouldDumpProcLangs(void) * procedural language */ static void -dumpProcLang(Archive *fout, ProcLangInfo *plang) +dumpProcLang(Archive *fout, DumpOptions* dopt, ProcLangInfo *plang) { PQExpBuffer defqry; PQExpBuffer delqry; @@ -9382,7 +9343,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) FuncInfo *validatorInfo = NULL; /* Skip if not to be dumped */ - if (!plang->dobj.dump || dataOnly) + if (!plang->dobj.dump || dopt->dataOnly) return; /* @@ -9428,7 +9389,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) if (!plang->dobj.ext_member) { - if (!useParams && !shouldDumpProcLangs()) + if (!useParams && !shouldDumpProcLangs(dopt)) return; } @@ -9495,7 +9456,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) appendPQExpBuffer(labelq, "LANGUAGE %s", qlanname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(defqry, &plang->dobj, labelq->data); ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId, @@ -9507,15 +9468,15 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang) NULL, NULL); /* Dump Proc Lang Comments and Security Labels */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, "", plang->dobj.catId, 0, plang->dobj.dumpId); - dumpSecLabel(fout, labelq->data, + dumpSecLabel(fout, dopt, labelq->data, NULL, "", plang->dobj.catId, 0, plang->dobj.dumpId); if (plang->lanpltrusted) - dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE", + dumpACL(fout, dopt, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE", qlanname, NULL, plang->dobj.name, lanschema, plang->lanowner, plang->lanacl); @@ -9662,7 +9623,7 @@ format_function_signature(Archive *fout, FuncInfo *finfo, bool honor_quotes) * dump out one function */ static void -dumpFunc(Archive *fout, FuncInfo *finfo) +dumpFunc(Archive *fout, DumpOptions* dopt, FuncInfo *finfo) { PQExpBuffer query; PQExpBuffer q; @@ -9701,7 +9662,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) int i; /* Skip if not to be dumped */ - if (!finfo->dobj.dump || dataOnly) + if (!finfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); @@ -9894,7 +9855,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) * where we have bin, use dollar quoting if allowed and src * contains quote or backslash; else use regular quoting. */ - if (disable_dollar_quoting || + if (dopt->disable_dollar_quoting || (strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL)) appendStringLiteralAH(asPart, prosrc, fout); else @@ -9907,7 +9868,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) { appendPQExpBufferStr(asPart, "AS "); /* with no bin, dollar quote src unconditionally if allowed */ - if (disable_dollar_quoting) + if (dopt->disable_dollar_quoting) appendStringLiteralAH(asPart, prosrc, fout); else appendStringLiteralDQ(asPart, prosrc, NULL); @@ -10083,7 +10044,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) appendPQExpBuffer(labelq, "FUNCTION %s", funcsig); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &finfo->dobj, labelq->data); ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId, @@ -10097,14 +10058,14 @@ dumpFunc(Archive *fout, FuncInfo *finfo) NULL, NULL); /* Dump Function Comments and Security Labels */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, finfo->dobj.namespace->dobj.name, finfo->rolname, finfo->dobj.catId, 0, finfo->dobj.dumpId); - dumpSecLabel(fout, labelq->data, + dumpSecLabel(fout, dopt, 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", + dumpACL(fout, dopt, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION", funcsig, NULL, funcsig_tag, finfo->dobj.namespace->dobj.name, finfo->rolname, finfo->proacl); @@ -10135,7 +10096,7 @@ dumpFunc(Archive *fout, FuncInfo *finfo) * Dump a user-defined cast */ static void -dumpCast(Archive *fout, CastInfo *cast) +dumpCast(Archive *fout, DumpOptions* dopt, CastInfo *cast) { PQExpBuffer defqry; PQExpBuffer delqry; @@ -10143,7 +10104,7 @@ dumpCast(Archive *fout, CastInfo *cast) FuncInfo *funcInfo = NULL; /* Skip if not to be dumped */ - if (!cast->dobj.dump || dataOnly) + if (!cast->dobj.dump || dopt->dataOnly) return; /* Cannot dump if we don't have the cast function's info */ @@ -10257,7 +10218,7 @@ dumpCast(Archive *fout, CastInfo *cast) getFormattedTypeName(fout, cast->castsource, zeroAsNone), getFormattedTypeName(fout, cast->casttarget, zeroAsNone)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(defqry, &cast->dobj, labelq->data); ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId, @@ -10269,7 +10230,7 @@ dumpCast(Archive *fout, CastInfo *cast) NULL, NULL); /* Dump Cast Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, "", cast->dobj.catId, 0, cast->dobj.dumpId); @@ -10283,7 +10244,7 @@ dumpCast(Archive *fout, CastInfo *cast) * write out a single operator definition */ static void -dumpOpr(Archive *fout, OprInfo *oprinfo) +dumpOpr(Archive *fout, DumpOptions* dopt, OprInfo *oprinfo) { PQExpBuffer query; PQExpBuffer q; @@ -10317,7 +10278,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) char *oprref; /* Skip if not to be dumped */ - if (!oprinfo->dobj.dump || dataOnly) + if (!oprinfo->dobj.dump || dopt->dataOnly) return; /* @@ -10507,7 +10468,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) appendPQExpBuffer(labelq, "OPERATOR %s", oprid->data); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &oprinfo->dobj, labelq->data); ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId, @@ -10521,7 +10482,7 @@ dumpOpr(Archive *fout, OprInfo *oprinfo) NULL, NULL); /* Dump Operator Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, oprinfo->dobj.namespace->dobj.name, oprinfo->rolname, oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId); @@ -10671,7 +10632,7 @@ convertTSFunction(Archive *fout, Oid funcOid) * write out a single operator class definition */ static void -dumpOpclass(Archive *fout, OpclassInfo *opcinfo) +dumpOpclass(Archive *fout, DumpOptions* dopt, OpclassInfo *opcinfo) { PQExpBuffer query; PQExpBuffer q; @@ -10715,7 +10676,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) int i; /* Skip if not to be dumped */ - if (!opcinfo->dobj.dump || dataOnly) + if (!opcinfo->dobj.dump || dopt->dataOnly) return; /* @@ -11015,7 +10976,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) appendPQExpBuffer(labelq, " USING %s", fmtId(amname)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &opcinfo->dobj, labelq->data); ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId, @@ -11029,7 +10990,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) NULL, NULL); /* Dump Operator Class Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, opcinfo->rolname, opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId); @@ -11048,7 +11009,7 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo) * specific opclass within the opfamily. */ static void -dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo) +dumpOpfamily(Archive *fout, DumpOptions* dopt, OpfamilyInfo *opfinfo) { PQExpBuffer query; PQExpBuffer q; @@ -11082,7 +11043,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo) int i; /* Skip if not to be dumped */ - if (!opfinfo->dobj.dump || dataOnly) + if (!opfinfo->dobj.dump || dopt->dataOnly) return; /* @@ -11328,7 +11289,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo) appendPQExpBuffer(labelq, " USING %s", fmtId(amname)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &opfinfo->dobj, labelq->data); ArchiveEntry(fout, opfinfo->dobj.catId, opfinfo->dobj.dumpId, @@ -11342,7 +11303,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo) NULL, NULL); /* Dump Operator Family Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, opfinfo->rolname, opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId); @@ -11360,7 +11321,7 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo) * write out a single collation definition */ static void -dumpCollation(Archive *fout, CollInfo *collinfo) +dumpCollation(Archive *fout, DumpOptions* dopt, CollInfo *collinfo) { PQExpBuffer query; PQExpBuffer q; @@ -11373,7 +11334,7 @@ dumpCollation(Archive *fout, CollInfo *collinfo) const char *collctype; /* Skip if not to be dumped */ - if (!collinfo->dobj.dump || dataOnly) + if (!collinfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); @@ -11417,7 +11378,7 @@ dumpCollation(Archive *fout, CollInfo *collinfo) appendPQExpBuffer(labelq, "COLLATION %s", fmtId(collinfo->dobj.name)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &collinfo->dobj, labelq->data); ArchiveEntry(fout, collinfo->dobj.catId, collinfo->dobj.dumpId, @@ -11431,7 +11392,7 @@ dumpCollation(Archive *fout, CollInfo *collinfo) NULL, NULL); /* Dump Collation Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, collinfo->dobj.namespace->dobj.name, collinfo->rolname, collinfo->dobj.catId, 0, collinfo->dobj.dumpId); @@ -11448,7 +11409,7 @@ dumpCollation(Archive *fout, CollInfo *collinfo) * write out a single conversion definition */ static void -dumpConversion(Archive *fout, ConvInfo *convinfo) +dumpConversion(Archive *fout, DumpOptions* dopt, ConvInfo *convinfo) { PQExpBuffer query; PQExpBuffer q; @@ -11465,7 +11426,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) bool condefault; /* Skip if not to be dumped */ - if (!convinfo->dobj.dump || dataOnly) + if (!convinfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); @@ -11516,7 +11477,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) appendPQExpBuffer(labelq, "CONVERSION %s", fmtId(convinfo->dobj.name)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &convinfo->dobj, labelq->data); ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId, @@ -11530,7 +11491,7 @@ dumpConversion(Archive *fout, ConvInfo *convinfo) NULL, NULL); /* Dump Conversion Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, convinfo->dobj.namespace->dobj.name, convinfo->rolname, convinfo->dobj.catId, 0, convinfo->dobj.dumpId); @@ -11587,7 +11548,7 @@ format_aggregate_signature(AggInfo *agginfo, Archive *fout, bool honor_quotes) * write out a single aggregate definition */ static void -dumpAgg(Archive *fout, AggInfo *agginfo) +dumpAgg(Archive *fout, DumpOptions* dopt, AggInfo *agginfo) { PQExpBuffer query; PQExpBuffer q; @@ -11633,7 +11594,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) bool convertok; /* Skip if not to be dumped */ - if (!agginfo->aggfn.dobj.dump || dataOnly) + if (!agginfo->aggfn.dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); @@ -11912,7 +11873,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) appendPQExpBuffer(labelq, "AGGREGATE %s", aggsig); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &agginfo->aggfn.dobj, labelq->data); ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId, @@ -11926,10 +11887,10 @@ dumpAgg(Archive *fout, AggInfo *agginfo) NULL, NULL); /* Dump Aggregate Comments */ - dumpComment(fout, labelq->data, + 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, labelq->data, + dumpSecLabel(fout, dopt, labelq->data, agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname, agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId); @@ -11944,7 +11905,7 @@ dumpAgg(Archive *fout, AggInfo *agginfo) 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, + dumpACL(fout, dopt, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId, "FUNCTION", aggsig, NULL, aggsig_tag, agginfo->aggfn.dobj.namespace->dobj.name, @@ -11969,14 +11930,14 @@ dumpAgg(Archive *fout, AggInfo *agginfo) * write out a single text search parser */ static void -dumpTSParser(Archive *fout, TSParserInfo *prsinfo) +dumpTSParser(Archive *fout, DumpOptions* dopt, TSParserInfo *prsinfo) { PQExpBuffer q; PQExpBuffer delq; PQExpBuffer labelq; /* Skip if not to be dumped */ - if (!prsinfo->dobj.dump || dataOnly) + if (!prsinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); @@ -12012,7 +11973,7 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo) appendPQExpBuffer(labelq, "TEXT SEARCH PARSER %s", fmtId(prsinfo->dobj.name)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &prsinfo->dobj, labelq->data); ArchiveEntry(fout, prsinfo->dobj.catId, prsinfo->dobj.dumpId, @@ -12026,7 +11987,7 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo) NULL, NULL); /* Dump Parser Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, "", prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId); @@ -12040,7 +12001,7 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo) * write out a single text search dictionary */ static void -dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo) +dumpTSDictionary(Archive *fout, DumpOptions* dopt, TSDictInfo *dictinfo) { PQExpBuffer q; PQExpBuffer delq; @@ -12051,7 +12012,7 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo) char *tmplname; /* Skip if not to be dumped */ - if (!dictinfo->dobj.dump || dataOnly) + if (!dictinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); @@ -12099,7 +12060,7 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo) appendPQExpBuffer(labelq, "TEXT SEARCH DICTIONARY %s", fmtId(dictinfo->dobj.name)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &dictinfo->dobj, labelq->data); ArchiveEntry(fout, dictinfo->dobj.catId, dictinfo->dobj.dumpId, @@ -12113,7 +12074,7 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo) NULL, NULL); /* Dump Dictionary Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, dictinfo->rolname, dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId); @@ -12128,14 +12089,14 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo) * write out a single text search template */ static void -dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo) +dumpTSTemplate(Archive *fout, DumpOptions* dopt, TSTemplateInfo *tmplinfo) { PQExpBuffer q; PQExpBuffer delq; PQExpBuffer labelq; /* Skip if not to be dumped */ - if (!tmplinfo->dobj.dump || dataOnly) + if (!tmplinfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); @@ -12165,7 +12126,7 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo) appendPQExpBuffer(labelq, "TEXT SEARCH TEMPLATE %s", fmtId(tmplinfo->dobj.name)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tmplinfo->dobj, labelq->data); ArchiveEntry(fout, tmplinfo->dobj.catId, tmplinfo->dobj.dumpId, @@ -12179,7 +12140,7 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo) NULL, NULL); /* Dump Template Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, "", tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId); @@ -12193,7 +12154,7 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo) * write out a single text search configuration */ static void -dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo) +dumpTSConfig(Archive *fout, DumpOptions* dopt, TSConfigInfo *cfginfo) { PQExpBuffer q; PQExpBuffer delq; @@ -12208,7 +12169,7 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo) int i_dictname; /* Skip if not to be dumped */ - if (!cfginfo->dobj.dump || dataOnly) + if (!cfginfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); @@ -12293,7 +12254,7 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo) appendPQExpBuffer(labelq, "TEXT SEARCH CONFIGURATION %s", fmtId(cfginfo->dobj.name)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &cfginfo->dobj, labelq->data); ArchiveEntry(fout, cfginfo->dobj.catId, cfginfo->dobj.dumpId, @@ -12307,7 +12268,7 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo) NULL, NULL); /* Dump Configuration Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, cfginfo->rolname, cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId); @@ -12322,7 +12283,7 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo) * write out a single foreign-data wrapper definition */ static void -dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo) +dumpForeignDataWrapper(Archive *fout, DumpOptions* dopt, FdwInfo *fdwinfo) { PQExpBuffer q; PQExpBuffer delq; @@ -12330,7 +12291,7 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo) char *qfdwname; /* Skip if not to be dumped */ - if (!fdwinfo->dobj.dump || dataOnly) + if (!fdwinfo->dobj.dump || dopt->dataOnly) return; /* @@ -12338,7 +12299,7 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo) * field. Otherwise omit them if we are only dumping some specific object. */ if (!fdwinfo->dobj.ext_member) - if (!include_everything) + if (!dopt->include_everything) return; q = createPQExpBuffer(); @@ -12367,7 +12328,7 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo) appendPQExpBuffer(labelq, "FOREIGN DATA WRAPPER %s", qfdwname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &fdwinfo->dobj, labelq->data); ArchiveEntry(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId, @@ -12381,14 +12342,14 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo) NULL, NULL); /* Handle the ACL */ - dumpACL(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId, + 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, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, fdwinfo->rolname, fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId); @@ -12404,7 +12365,7 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo) * write out a foreign server definition */ static void -dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo) +dumpForeignServer(Archive *fout, DumpOptions* dopt, ForeignServerInfo *srvinfo) { PQExpBuffer q; PQExpBuffer delq; @@ -12415,7 +12376,7 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo) char *fdwname; /* Skip if not to be dumped */ - if (!srvinfo->dobj.dump || dataOnly || !include_everything) + if (!srvinfo->dobj.dump || dopt->dataOnly || !dopt->include_everything) return; q = createPQExpBuffer(); @@ -12459,7 +12420,7 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo) appendPQExpBuffer(labelq, "SERVER %s", qsrvname); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &srvinfo->dobj, labelq->data); ArchiveEntry(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId, @@ -12473,7 +12434,7 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo) NULL, NULL); /* Handle the ACL */ - dumpACL(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId, + dumpACL(fout, dopt, srvinfo->dobj.catId, srvinfo->dobj.dumpId, "FOREIGN SERVER", qsrvname, NULL, srvinfo->dobj.name, NULL, srvinfo->rolname, @@ -12486,7 +12447,7 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo) srvinfo->dobj.catId, srvinfo->dobj.dumpId); /* Dump Foreign Server Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, srvinfo->rolname, srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId); @@ -12602,14 +12563,14 @@ dumpUserMappings(Archive *fout, * Write out default privileges information */ static void -dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo) +dumpDefaultACL(Archive *fout, DumpOptions *dopt, DefaultACLInfo *daclinfo) { PQExpBuffer q; PQExpBuffer tag; const char *type; /* Skip if not to be dumped */ - if (!daclinfo->dobj.dump || dataOnly || aclsSkip) + if (!daclinfo->dobj.dump || dopt->dataOnly || dopt->aclsSkip) return; q = createPQExpBuffer(); @@ -12682,7 +12643,7 @@ dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo) *---------- */ static void -dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId, +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) @@ -12690,11 +12651,11 @@ dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId, PQExpBuffer sql; /* Do nothing if ACL dump is not enabled */ - if (aclsSkip) + if (dopt->aclsSkip) return; /* --data-only skips ACLs *except* BLOB ACLs */ - if (dataOnly && strcmp(type, "LARGE OBJECT") != 0) + if (dopt->dataOnly && strcmp(type, "LARGE OBJECT") != 0) return; sql = createPQExpBuffer(); @@ -12737,7 +12698,7 @@ dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId, * calling ArchiveEntry() for the specified object. */ static void -dumpSecLabel(Archive *fout, const char *target, +dumpSecLabel(Archive *fout, DumpOptions* dopt, const char *target, const char *namespace, const char *owner, CatalogId catalogId, int subid, DumpId dumpId) { @@ -12747,18 +12708,18 @@ dumpSecLabel(Archive *fout, const char *target, PQExpBuffer query; /* do nothing, if --no-security-labels is supplied */ - if (no_security_labels) + if (dopt->no_security_labels) return; /* Comments are schema not data ... except blob comments are data */ if (strncmp(target, "LARGE OBJECT ", 13) != 0) { - if (dataOnly) + if (dopt->dataOnly) return; } else { - if (schemaOnly) + if (dopt->schemaOnly) return; } @@ -12801,7 +12762,7 @@ dumpSecLabel(Archive *fout, const char *target, * and its columns. */ static void -dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename) +dumpTableSecLabel(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, const char *reltypename) { SecLabelItem *labels; int nlabels; @@ -12810,11 +12771,11 @@ dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename) PQExpBuffer target; /* do nothing, if --no-security-labels is supplied */ - if (no_security_labels) + if (dopt->no_security_labels) return; /* SecLabel are SCHEMA not data */ - if (dataOnly) + if (dopt->dataOnly) return; /* Search for comments associated with relation, using table */ @@ -13022,20 +12983,20 @@ collectSecLabels(Archive *fout, SecLabelItem **items) * write out to fout the declarations (not data) of a user-defined table */ static void -dumpTable(Archive *fout, TableInfo *tbinfo) +dumpTable(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo) { - if (tbinfo->dobj.dump && !dataOnly) + if (tbinfo->dobj.dump && !dopt->dataOnly) { char *namecopy; if (tbinfo->relkind == RELKIND_SEQUENCE) - dumpSequence(fout, tbinfo); + dumpSequence(fout, dopt, tbinfo); else - dumpTableSchema(fout, tbinfo); + dumpTableSchema(fout, dopt, tbinfo); /* Handle the ACL here */ namecopy = pg_strdup(fmtId(tbinfo->dobj.name)); - dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, + dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId, (tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" : "TABLE", namecopy, NULL, tbinfo->dobj.name, @@ -13070,7 +13031,7 @@ dumpTable(Archive *fout, TableInfo *tbinfo) 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", + dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE", namecopy, attnamecopy, acltag, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, attacl); @@ -13147,7 +13108,7 @@ createViewAsClause(Archive *fout, TableInfo *tbinfo) * write the declaration (not data) of one user-defined table or view */ static void -dumpTableSchema(Archive *fout, TableInfo *tbinfo) +dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo) { PQExpBuffer q = createPQExpBuffer(); PQExpBuffer delq = createPQExpBuffer(); @@ -13165,7 +13126,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) /* Make sure we are in proper schema */ selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_set_type_oids_by_rel_oid(fout, q, tbinfo->dobj.catId.oid); @@ -13185,7 +13146,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) appendPQExpBuffer(delq, "%s;\n", fmtId(tbinfo->dobj.name)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, tbinfo->dobj.catId.oid, false); @@ -13265,7 +13226,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) appendPQExpBuffer(labelq, "%s %s", reltypename, fmtId(tbinfo->dobj.name)); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, tbinfo->dobj.catId.oid, false); @@ -13279,7 +13240,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) * Attach to type, if reloftype; except in case of a binary upgrade, * we dump the table normally and attach it to the type afterward. */ - if (tbinfo->reloftype && !binary_upgrade) + if (tbinfo->reloftype && !dopt->binary_upgrade) appendPQExpBuffer(q, " OF %s", tbinfo->reloftype); if (tbinfo->relkind != RELKIND_MATVIEW) @@ -13294,7 +13255,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) * columns, and then fix up the dropped and nonlocal cases * below. */ - if (shouldPrintColumn(tbinfo, j)) + if (shouldPrintColumn(dopt, tbinfo, j)) { /* * Default value --- suppress if to be printed separately. @@ -13308,11 +13269,11 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) */ bool has_notnull = (tbinfo->notnull[j] && (!tbinfo->inhNotNull[j] || - binary_upgrade)); + dopt->binary_upgrade)); /* Skip column if fully defined by reloftype */ if (tbinfo->reloftype && - !has_default && !has_notnull && !binary_upgrade) + !has_default && !has_notnull && !dopt->binary_upgrade) continue; /* Format properly if not first attr */ @@ -13340,7 +13301,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) } /* Attribute type */ - if (tbinfo->reloftype && !binary_upgrade) + if (tbinfo->reloftype && !dopt->binary_upgrade) { appendPQExpBufferStr(q, " WITH OPTIONS"); } @@ -13405,7 +13366,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) if (actual_atts) appendPQExpBufferStr(q, "\n)"); - else if (!(tbinfo->reloftype && !binary_upgrade)) + else if (!(tbinfo->reloftype && !dopt->binary_upgrade)) { /* * We must have a parenthesized attribute list, even though @@ -13414,7 +13375,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) appendPQExpBufferStr(q, " (\n)"); } - if (numParents > 0 && !binary_upgrade) + if (numParents > 0 && !dopt->binary_upgrade) { appendPQExpBufferStr(q, "\nINHERITS ("); for (k = 0; k < numParents; k++) @@ -13487,7 +13448,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) * attislocal correctly, plus fix up any inherited CHECK constraints. * Analogously, we set up typed tables using ALTER TABLE / OF here. */ - if (binary_upgrade && (tbinfo->relkind == RELKIND_RELATION || + if (dopt->binary_upgrade && (tbinfo->relkind == RELKIND_RELATION || tbinfo->relkind == RELKIND_FOREIGN_TABLE)) { for (j = 0; j < tbinfo->numatts; j++) @@ -13603,7 +13564,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) * REFRESH MATERIALIZED VIEW since it's possible that some underlying * matview is not populated even though this matview is. */ - if (binary_upgrade && tbinfo->relkind == RELKIND_MATVIEW && + if (dopt->binary_upgrade && tbinfo->relkind == RELKIND_MATVIEW && tbinfo->relispopulated) { appendPQExpBufferStr(q, "\n-- For binary upgrade, mark materialized view as populated\n"); @@ -13629,7 +13590,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) * it is NOT NULL and did not inherit that property from a parent, * we have to mark it separately. */ - if (!shouldPrintColumn(tbinfo, j) && + if (!shouldPrintColumn(dopt, tbinfo, j) && tbinfo->notnull[j] && !tbinfo->inhNotNull[j]) { appendPQExpBuffer(q, "ALTER TABLE ONLY %s ", @@ -13743,7 +13704,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) } } - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(q, &tbinfo->dobj, labelq->data); ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, @@ -13760,10 +13721,10 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) /* Dump Table Comments */ - dumpTableComment(fout, tbinfo, reltypename); + dumpTableComment(fout, dopt, tbinfo, reltypename); /* Dump Table Security Labels */ - dumpTableSecLabel(fout, tbinfo, reltypename); + dumpTableSecLabel(fout, dopt, tbinfo, reltypename); /* Dump comments on inlined table constraints */ for (j = 0; j < tbinfo->ncheck; j++) @@ -13773,7 +13734,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) if (constr->separate || !constr->conislocal) continue; - dumpTableConstraintComment(fout, constr); + dumpTableConstraintComment(fout, dopt, constr); } destroyPQExpBuffer(q); @@ -13785,7 +13746,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) * dumpAttrDef --- dump an attribute's default-value declaration */ static void -dumpAttrDef(Archive *fout, AttrDefInfo *adinfo) +dumpAttrDef(Archive *fout, DumpOptions *dopt, AttrDefInfo *adinfo) { TableInfo *tbinfo = adinfo->adtable; int adnum = adinfo->adnum; @@ -13793,7 +13754,7 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo) PQExpBuffer delq; /* Skip if table definition not to be dumped */ - if (!tbinfo->dobj.dump || dataOnly) + if (!tbinfo->dobj.dump || dopt->dataOnly) return; /* Skip if not "separate"; it was dumped in the table's definition */ @@ -13872,7 +13833,7 @@ getAttrName(int attrnum, TableInfo *tblInfo) * write out to fout a user-defined index */ static void -dumpIndex(Archive *fout, IndxInfo *indxinfo) +dumpIndex(Archive *fout, DumpOptions* dopt, IndxInfo *indxinfo) { TableInfo *tbinfo = indxinfo->indextable; bool is_constraint = (indxinfo->indexconstraint != 0); @@ -13880,7 +13841,7 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo) PQExpBuffer delq; PQExpBuffer labelq; - if (dataOnly) + if (dopt->dataOnly) return; q = createPQExpBuffer(); @@ -13899,7 +13860,7 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo) */ if (!is_constraint) { - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, indxinfo->dobj.catId.oid, true); @@ -13945,7 +13906,7 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo) } /* Dump Index Comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, indxinfo->dobj.catId, 0, @@ -13962,14 +13923,14 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo) * write out to fout a user-defined constraint */ static void -dumpConstraint(Archive *fout, ConstraintInfo *coninfo) +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 || dataOnly) + if (!coninfo->dobj.dump || dopt->dataOnly) return; q = createPQExpBuffer(); @@ -13989,7 +13950,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) exit_horribly(NULL, "missing index for constraint \"%s\"\n", coninfo->dobj.name); - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_set_pg_class_oids(fout, q, indxinfo->dobj.catId.oid, true); @@ -14179,7 +14140,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) /* Dump Constraint Comments --- only works for table constraints */ if (tbinfo && coninfo->separate) - dumpTableConstraintComment(fout, coninfo); + dumpTableConstraintComment(fout, dopt, coninfo); destroyPQExpBuffer(q); destroyPQExpBuffer(delq); @@ -14193,7 +14154,7 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo) * or as a separate ALTER command. */ static void -dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo) +dumpTableConstraintComment(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo) { TableInfo *tbinfo = coninfo->contable; PQExpBuffer labelq = createPQExpBuffer(); @@ -14202,7 +14163,7 @@ dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo) fmtId(coninfo->dobj.name)); appendPQExpBuffer(labelq, "ON %s", fmtId(tbinfo->dobj.name)); - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, coninfo->dobj.catId, 0, @@ -14262,7 +14223,7 @@ findLastBuiltinOid_V70(Archive *fout) * write the declaration (not data) of one user-defined sequence */ static void -dumpSequence(Archive *fout, TableInfo *tbinfo) +dumpSequence(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo) { PGresult *res; char *startv, @@ -14358,7 +14319,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) resetPQExpBuffer(query); - if (binary_upgrade) + if (dopt->binary_upgrade) { binary_upgrade_set_pg_class_oids(fout, query, tbinfo->dobj.catId.oid, false); @@ -14395,7 +14356,7 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) /* binary_upgrade: no need to clear TOAST table oid */ - if (binary_upgrade) + if (dopt->binary_upgrade) binary_upgrade_extension_member(query, &tbinfo->dobj, labelq->data); @@ -14448,10 +14409,10 @@ dumpSequence(Archive *fout, TableInfo *tbinfo) } /* Dump Sequence Comments and Security Labels */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); - dumpSecLabel(fout, labelq->data, + dumpSecLabel(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId); @@ -14522,7 +14483,7 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo) * write the declaration of one user-defined table trigger */ static void -dumpTrigger(Archive *fout, TriggerInfo *tginfo) +dumpTrigger(Archive *fout, DumpOptions* dopt, TriggerInfo *tginfo) { TableInfo *tbinfo = tginfo->tgtable; PQExpBuffer query; @@ -14537,7 +14498,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) * we needn't check dobj.dump because TriggerInfo wouldn't have been * created in the first place for non-dumpable triggers */ - if (dataOnly) + if (dopt->dataOnly) return; query = createPQExpBuffer(); @@ -14718,7 +14679,7 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) NULL, 0, NULL, NULL); - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, tginfo->dobj.catId, 0, tginfo->dobj.dumpId); @@ -14732,13 +14693,13 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo) * write the declaration of one user-defined event trigger */ static void -dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo) +dumpEventTrigger(Archive *fout, DumpOptions* dopt, EventTriggerInfo *evtinfo) { PQExpBuffer query; PQExpBuffer labelq; /* Skip if not to be dumped */ - if (!evtinfo->dobj.dump || dataOnly) + if (!evtinfo->dobj.dump || dopt->dataOnly) return; query = createPQExpBuffer(); @@ -14790,7 +14751,7 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo) "EVENT TRIGGER", SECTION_POST_DATA, query->data, "", NULL, NULL, 0, NULL, NULL); - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, NULL, NULL, evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId); @@ -14803,7 +14764,7 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo) * Dump a rule */ static void -dumpRule(Archive *fout, RuleInfo *rinfo) +dumpRule(Archive *fout, DumpOptions *dopt, RuleInfo *rinfo) { TableInfo *tbinfo = rinfo->ruletable; PQExpBuffer query; @@ -14813,7 +14774,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo) PGresult *res; /* Skip if not to be dumped */ - if (!rinfo->dobj.dump || dataOnly) + if (!rinfo->dobj.dump || dopt->dataOnly) return; /* @@ -14918,7 +14879,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo) NULL, NULL); /* Dump rule comments */ - dumpComment(fout, labelq->data, + dumpComment(fout, dopt, labelq->data, tbinfo->dobj.namespace->dobj.name, tbinfo->rolname, rinfo->dobj.catId, 0, rinfo->dobj.dumpId); @@ -14935,7 +14896,7 @@ dumpRule(Archive *fout, RuleInfo *rinfo) * getExtensionMembership --- obtain extension membership data */ void -getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], +getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[], int numExtensions) { PQExpBuffer query; @@ -15032,7 +14993,7 @@ getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], * idea is to exactly reproduce the database contents rather than * replace the extension contents with something different. */ - if (!binary_upgrade) + if (!dopt->binary_upgrade) dobj->dump = false; else dobj->dump = refdobj->dump; @@ -15111,7 +15072,7 @@ getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], * of the --oids setting. This is because row filtering * conditions aren't compatible with dumping OIDs. */ - makeTableDataInfo(configtbl, false); + 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 index d184187..c8864a0 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -503,7 +503,9 @@ extern char g_opaque_type[10]; /* name for the opaque type */ struct Archive; typedef struct Archive Archive; -extern TableInfo *getSchemaData(Archive *, int *numTablesPtr); +struct _dumpOptions; + +extern TableInfo *getSchemaData(Archive *, struct _dumpOptions *dopt, int *numTablesPtr); typedef enum _OidOptions { @@ -545,16 +547,16 @@ extern void sortDataAndIndexObjectsBySize(DumpableObject **objs, int numObjs); * version specific routines */ extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces); -extern ExtensionInfo *getExtensions(Archive *fout, int *numExtensions); +extern ExtensionInfo *getExtensions(Archive *fout, struct _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 FuncInfo *getFuncs(Archive *fout, struct _dumpOptions *dopt, int *numFuncs); +extern AggInfo *getAggregates(Archive *fout, struct _dumpOptions *dopt, int *numAggregates); extern OprInfo *getOperators(Archive *fout, int *numOperators); extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses); extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies); extern CollInfo *getCollations(Archive *fout, int *numCollations); extern ConvInfo *getConversions(Archive *fout, int *numConversions); -extern TableInfo *getTables(Archive *fout, int *numTables); +extern TableInfo *getTables(Archive *fout, struct _dumpOptions *dopt, int *numTables); extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables); extern InhInfo *getInherits(Archive *fout, int *numInherits); extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables); @@ -563,8 +565,8 @@ extern RuleInfo *getRules(Archive *fout, int *numRules); extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables); extern ProcLangInfo *getProcLangs(Archive *fout, int *numProcLangs); extern CastInfo *getCasts(Archive *fout, int *numCasts); -extern void getTableAttrs(Archive *fout, TableInfo *tbinfo, int numTables); -extern bool shouldPrintColumn(TableInfo *tbinfo, int colno); +extern void getTableAttrs(Archive *fout, struct _dumpOptions *dopt, TableInfo *tbinfo, int numTables); +extern bool shouldPrintColumn(struct _dumpOptions *dopt, TableInfo *tbinfo, int colno); extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers); extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts); extern TSTemplateInfo *getTSTemplates(Archive *fout, int *numTSTemplates); @@ -573,8 +575,8 @@ extern FdwInfo *getForeignDataWrappers(Archive *fout, int *numForeignDataWrappers); extern ForeignServerInfo *getForeignServers(Archive *fout, int *numForeignServers); -extern DefaultACLInfo *getDefaultACLs(Archive *fout, int *numDefaultACLs); -extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], +extern DefaultACLInfo *getDefaultACLs(Archive *fout, struct _dumpOptions *dopt, int *numDefaultACLs); +extern void getExtensionMembership(Archive *fout, struct _dumpOptions *dopt, ExtensionInfo extinfo[], int numExtensions); extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers); diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 4050091..73448b1 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -72,6 +72,7 @@ static bool verbose = false; 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 index fdfdc19..514615b 100644 --- a/src/bin/pg_dump/pg_restore.c +++ b/src/bin/pg_dump/pg_restore.c @@ -420,7 +420,7 @@ main(int argc, char **argv) /* AH may be freed in CloseArchive? */ exit_code = AH->n_errors ? 1 : 0; - CloseArchive(AH); + CloseArchive(AH, NULL); return exit_code; }