pg_dump refactor patch to remove global variables
Attached is a patch that doesn't add any new functionality or
features, all it does is get rid of the global variables that
pg_dump.c is full of.
The patch introduces a DumpOptions struct, analogous to the existing
RestoreOptions. This struct then holds the globals but also variables
like dbname, hostname and so on that are currently declared in
pg_dump's main().
Then it passes a pointer to this DumpOptions struct to all functions
that need it.
Motivation for this patch is to a) clean up the globals just because
it's a sane thing to do, b) facilitate future refactoring and c) my
own private objective is to introduce a parallel version of what you
can currently do with "pg_dump | psql" in a later commitfest, where
pg_dump dumps a database in parallel and restores it in parallel
without saving any data on disk. For this, pg_dump needs to handle
more than one database connection which isn't possible with the
current globals and the variables that are declared in main().
One thing I haven't done yet and I'm not sure if it's a good idea to
do, is getting rid of dumputils.c's quote_all_identifiers variable.
This is used by fmtId() which is called in hundreds of places. I don't
need it for my use case but for a proper cleanup of globals one could
make the point that it needs refactoring, too. I didn't want to blow
up the patch size unnecessarily without previous discussion however so
I left it out for now.
There's also more potential refactoring with respect to
DumpOptions/RestoreOptions, they share common fields now which could
be combined and for example a dump in the plain format in pg_dump is
implemented as a restore operation (and goes through the restore
code). This requires access to both dump and restore options. Here as
well, we could do more but for this patch I tried to minimize the
impact for now and kept it close to how it is implemented now.
Attachments:
pg_dump_refactor_globals.difftext/plain; charset=US-ASCII; name=pg_dump_refactor_globals.diffDownload
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
new file mode 100644
index 94e9147..d01035b
*** a/src/bin/pg_dump/common.c
--- b/src/bin/pg_dump/common.c
*************** static int strInArray(const char *patter
*** 78,84 ****
* Collect information about all potentially dumpable objects
*/
TableInfo *
! getSchemaData(Archive *fout, int *numTablesPtr)
{
ExtensionInfo *extinfo;
InhInfo *inhinfo;
--- 78,84 ----
* Collect information about all potentially dumpable objects
*/
TableInfo *
! getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
{
ExtensionInfo *extinfo;
InhInfo *inhinfo;
*************** getSchemaData(Archive *fout, int *numTab
*** 114,120 ****
*/
if (g_verbose)
write_msg(NULL, "reading user-defined tables\n");
! tblinfo = getTables(fout, &numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
/* Do this after we've built tblinfoindex */
--- 114,120 ----
*/
if (g_verbose)
write_msg(NULL, "reading user-defined tables\n");
! tblinfo = getTables(fout, dopt, &numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
/* Do this after we've built tblinfoindex */
*************** getSchemaData(Archive *fout, int *numTab
*** 122,128 ****
if (g_verbose)
write_msg(NULL, "reading extensions\n");
! extinfo = getExtensions(fout, &numExtensions);
if (g_verbose)
write_msg(NULL, "reading user-defined functions\n");
--- 122,128 ----
if (g_verbose)
write_msg(NULL, "reading extensions\n");
! extinfo = getExtensions(fout, dopt, &numExtensions);
if (g_verbose)
write_msg(NULL, "reading user-defined functions\n");
*************** getSchemaData(Archive *fout, int *numTab
*** 183,189 ****
if (g_verbose)
write_msg(NULL, "reading default privileges\n");
! getDefaultACLs(fout, &numDefaultACLs);
if (g_verbose)
write_msg(NULL, "reading user-defined collations\n");
--- 183,189 ----
if (g_verbose)
write_msg(NULL, "reading default privileges\n");
! getDefaultACLs(fout, dopt, &numDefaultACLs);
if (g_verbose)
write_msg(NULL, "reading user-defined collations\n");
*************** getSchemaData(Archive *fout, int *numTab
*** 213,219 ****
*/
if (g_verbose)
write_msg(NULL, "finding extension members\n");
! getExtensionMembership(fout, extinfo, numExtensions);
/* Link tables to parents, mark parents of target tables interesting */
if (g_verbose)
--- 213,219 ----
*/
if (g_verbose)
write_msg(NULL, "finding extension members\n");
! getExtensionMembership(fout, dopt, extinfo, numExtensions);
/* Link tables to parents, mark parents of target tables interesting */
if (g_verbose)
diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h
new file mode 100644
index b387aa1..0f6c88a
*** a/src/bin/pg_dump/dumputils.h
--- b/src/bin/pg_dump/dumputils.h
*************** typedef struct SimpleStringList
*** 31,38 ****
SimpleStringListCell *tail;
} SimpleStringList;
-
- extern int quote_all_identifiers;
extern PQExpBuffer (*getLocalPQExpBuffer) (void);
extern const char *fmtId(const char *identifier);
--- 31,36 ----
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
new file mode 100644
index e50dd8b..ceed115
*** a/src/bin/pg_dump/parallel.c
--- b/src/bin/pg_dump/parallel.c
*************** static void WaitForTerminatingWorkers(Pa
*** 89,99 ****
static void sigTermHandler(int signum);
#endif
static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
RestoreOptions *ropt);
static bool HasEveryWorkerTerminated(ParallelState *pstate);
static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te);
! static void WaitForCommands(ArchiveHandle *AH, int pipefd[2]);
static char *getMessageFromMaster(int pipefd[2]);
static void sendMessageToMaster(int pipefd[2], const char *str);
static int select_loop(int maxFd, fd_set *workerset);
--- 89,100 ----
static void sigTermHandler(int signum);
#endif
static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
+ DumpOptions *dopt,
RestoreOptions *ropt);
static bool HasEveryWorkerTerminated(ParallelState *pstate);
static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te);
! static void WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]);
static char *getMessageFromMaster(int pipefd[2]);
static void sendMessageToMaster(int pipefd[2], const char *str);
static int select_loop(int maxFd, fd_set *workerset);
*************** sigTermHandler(int signum)
*** 436,441 ****
--- 437,443 ----
*/
static void
SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
+ DumpOptions *dopt,
RestoreOptions *ropt)
{
/*
*************** SetupWorker(ArchiveHandle *AH, int pipef
*** 445,455 ****
* properly when we shut down. This happens only that way when it is
* brought down because of an error.
*/
! (AH->SetupWorkerPtr) ((Archive *) AH, ropt);
Assert(AH->connection != NULL);
! WaitForCommands(AH, pipefd);
closesocket(pipefd[PIPE_READ]);
closesocket(pipefd[PIPE_WRITE]);
--- 447,457 ----
* properly when we shut down. This happens only that way when it is
* brought down because of an error.
*/
! (AH->SetupWorkerPtr) ((Archive *) AH, dopt, ropt);
Assert(AH->connection != NULL);
! WaitForCommands(AH, dopt, pipefd);
closesocket(pipefd[PIPE_READ]);
closesocket(pipefd[PIPE_WRITE]);
*************** init_spawned_worker_win32(WorkerInfo *wi
*** 481,487 ****
* of threads while it does a fork() on Unix.
*/
ParallelState *
! ParallelBackupStart(ArchiveHandle *AH, RestoreOptions *ropt)
{
ParallelState *pstate;
int i;
--- 483,489 ----
* of threads while it does a fork() on Unix.
*/
ParallelState *
! ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt)
{
ParallelState *pstate;
int i;
*************** ParallelBackupStart(ArchiveHandle *AH, R
*** 598,604 ****
closesocket(pstate->parallelSlot[j].pipeWrite);
}
! SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, ropt);
exit(0);
}
--- 600,606 ----
closesocket(pstate->parallelSlot[j].pipeWrite);
}
! SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, dopt, ropt);
exit(0);
}
*************** lockTableNoWait(ArchiveHandle *AH, TocEn
*** 856,862 ****
* exit.
*/
static void
! WaitForCommands(ArchiveHandle *AH, int pipefd[2])
{
char *command;
DumpId dumpId;
--- 858,864 ----
* exit.
*/
static void
! WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2])
{
char *command;
DumpId dumpId;
*************** WaitForCommands(ArchiveHandle *AH, int p
*** 896,902 ****
* The message we return here has been pg_malloc()ed and we are
* responsible for free()ing it.
*/
! str = (AH->WorkerJobDumpPtr) (AH, te);
Assert(AH->connection != NULL);
sendMessageToMaster(pipefd, str);
free(str);
--- 898,904 ----
* The message we return here has been pg_malloc()ed and we are
* responsible for free()ing it.
*/
! str = (AH->WorkerJobDumpPtr) (AH, dopt, te);
Assert(AH->connection != NULL);
sendMessageToMaster(pipefd, str);
free(str);
diff --git a/src/bin/pg_dump/parallel.h b/src/bin/pg_dump/parallel.h
new file mode 100644
index 7a32a9b..81a823d
*** a/src/bin/pg_dump/parallel.h
--- b/src/bin/pg_dump/parallel.h
*************** extern void EnsureIdleWorker(struct _arc
*** 80,85 ****
--- 80,86 ----
extern void EnsureWorkersFinished(struct _archiveHandle * AH, ParallelState *pstate);
extern ParallelState *ParallelBackupStart(struct _archiveHandle * AH,
+ DumpOptions *dopt,
RestoreOptions *ropt);
extern void DispatchJobForTocEntry(struct _archiveHandle * AH,
ParallelState *pstate,
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
new file mode 100644
index 25780cf..d8c9f69
*** a/src/bin/pg_dump/pg_backup.h
--- b/src/bin/pg_dump/pg_backup.h
*************** struct Archive
*** 98,104 ****
/* The rest is private */
};
! typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
typedef struct _restoreOptions
{
--- 98,106 ----
/* The rest is private */
};
! struct _dumpOptions;
!
! typedef int (*DataDumperPtr) (Archive *AH, struct _dumpOptions *dopt, void *userArg);
typedef struct _restoreOptions
{
*************** typedef struct _restoreOptions
*** 109,125 ****
* restore */
int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
* instead of OWNER TO */
- int no_security_labels; /* Skip security label entries */
char *superuser; /* Username to use as superuser */
char *use_role; /* Issue SET ROLE to this */
int dropSchema;
int if_exists;
const char *filename;
int dataOnly;
int schemaOnly;
int dumpSections;
int verbose;
int aclsSkip;
int tocSummary;
char *tocFile;
int format;
--- 111,134 ----
* restore */
int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
* instead of OWNER TO */
char *superuser; /* Username to use as superuser */
char *use_role; /* Issue SET ROLE to this */
int dropSchema;
+ int disable_dollar_quoting;
+ int dump_inserts;
+ int column_inserts;
int if_exists;
+ int no_security_labels; /* Skip security label entries */
+
const char *filename;
int dataOnly;
int schemaOnly;
int dumpSections;
int verbose;
int aclsSkip;
+ const char *lockWaitTimeout;
+ int include_everything;
+
int tocSummary;
char *tocFile;
int format;
*************** typedef struct _restoreOptions
*** 152,158 ****
bool *idWanted; /* array showing which dump IDs to emit */
} RestoreOptions;
! typedef void (*SetupWorkerPtr) (Archive *AH, RestoreOptions *ropt);
/*
* Main archiver interface.
--- 161,217 ----
bool *idWanted; /* array showing which dump IDs to emit */
} RestoreOptions;
! typedef struct _dumpOptions
! {
! const char *dbname;
! const char *pghost;
! const char *pgport;
! const char *username;
! const char *dumpencoding;
! bool oids;
!
! /* various user-settable parameters */
! bool schemaOnly;
! bool dataOnly;
! int dumpSections; /* bitmask of chosen sections */
! bool aclsSkip;
! const char *lockWaitTimeout;
!
! /* flags for various command-line long options */
! int disable_dollar_quoting;
! int dump_inserts;
! int column_inserts;
! int if_exists;
! int no_security_labels;
! int no_synchronized_snapshots;
! int no_unlogged_table_data;
! int serializable_deferrable;
! int quote_all_identifiers;
!
! /* default, if no "inclusion" switches appear, is to dump everything */
! bool include_everything;
!
! int numWorkers;
! enum trivalue prompt_password;
! int compressLevel;
! int plainText;
! int outputClean;
! int outputCreateDB;
! bool outputBlobs;
! int outputNoOwner;
! char *outputSuperuser;
! char *use_role;
!
! ArchiveFormat archiveFormat;
! ArchiveMode archiveMode;
!
! int disable_triggers;
! int outputNoTablespaces;
! int use_setsessauth;
!
! } DumpOptions;
!
! typedef void (*SetupWorkerPtr) (Archive *AH, DumpOptions *dopt, RestoreOptions *ropt);
/*
* Main archiver interface.
*************** extern void WriteData(Archive *AH, const
*** 185,191 ****
extern int StartBlob(Archive *AH, Oid oid);
extern int EndBlob(Archive *AH, Oid oid);
! extern void CloseArchive(Archive *AH);
extern void SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt);
--- 244,250 ----
extern int StartBlob(Archive *AH, Oid oid);
extern int EndBlob(Archive *AH, Oid oid);
! extern void CloseArchive(Archive *AH, DumpOptions *dopt);
extern void SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt);
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
new file mode 100644
index 3aebac8..b378265
*** a/src/bin/pg_dump/pg_backup_archiver.c
--- b/src/bin/pg_dump/pg_backup_archiver.c
*************** static void mark_create_done(ArchiveHand
*** 107,112 ****
--- 107,170 ----
static void inhibit_data_for_failed_table(ArchiveHandle *AH, TocEntry *te);
/*
+ * Allocate a new DumpOptions block.
+ * This is mainly so we can initialize it, but also for future expansion.
+ * We pg_malloc0 the structure, so we don't need to initialize whatever is
+ * 0, NULL or false anyway.
+ */
+ DumpOptions*
+ NewDumpOptions(void)
+ {
+ DumpOptions *opts;
+
+ opts = (DumpOptions *) pg_malloc0(sizeof(DumpOptions));
+
+ /* set any fields that shouldn't default to zeroes */
+ opts->include_everything = true;
+ opts->prompt_password = TRI_DEFAULT;
+ opts->compressLevel = -1;
+ opts->archiveFormat = archUnknown;
+ opts->numWorkers = 1;
+ opts->dumpSections = DUMP_UNSECTIONED;
+
+ return opts;
+ }
+
+ /*
+ * We do a plaintext dump by printing out the restore command that would create
+ * a certain object. Since in those functions we only have RestoreOptions, we
+ * crate ad-hoc DumpOptions.
+ */
+ DumpOptions
+ dumpOptionsFromRestoreOptions(RestoreOptions *ropt) {
+ DumpOptions dopt;
+
+ /* this is the inverse of what's at the end of pg_dump.c's main() */
+ dopt.outputClean = ropt->dropSchema;
+ dopt.dataOnly = ropt->dataOnly;
+ dopt.schemaOnly = ropt->schemaOnly;
+ dopt.if_exists = ropt->if_exists;
+ dopt.column_inserts = ropt->column_inserts;
+ dopt.dumpSections = ropt->dumpSections;
+ dopt.aclsSkip = ropt->aclsSkip;
+ dopt.outputSuperuser = ropt->superuser;
+ dopt.outputCreateDB = ropt->createDB;
+ dopt.outputNoOwner = ropt->noOwner;
+ dopt.outputNoTablespaces = ropt->noTablespace;
+ dopt.disable_triggers = ropt->disable_triggers;
+ dopt.use_setsessauth = ropt->use_setsessauth;
+
+ dopt.disable_dollar_quoting = ropt->disable_dollar_quoting;
+ dopt.dump_inserts = ropt->dump_inserts;
+ dopt.no_security_labels = ropt->no_security_labels;
+ dopt.lockWaitTimeout = ropt->lockWaitTimeout;
+ dopt.include_everything = ropt->include_everything;
+
+ return dopt;
+ }
+
+
+ /*
* Wrapper functions.
*
* The objective it to make writing new formats and dumpers as simple
*************** static void inhibit_data_for_failed_tabl
*** 120,126 ****
* setup doesn't need to know anything much, so it's defined here.
*/
static void
! setupRestoreWorker(Archive *AHX, RestoreOptions *ropt)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
--- 178,184 ----
* setup doesn't need to know anything much, so it's defined here.
*/
static void
! setupRestoreWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
*************** OpenArchive(const char *FileSpec, const
*** 152,163 ****
/* Public */
void
! CloseArchive(Archive *AHX)
{
int res = 0;
ArchiveHandle *AH = (ArchiveHandle *) AHX;
! (*AH->ClosePtr) (AH);
/* Close the output */
if (AH->gzOut)
--- 210,221 ----
/* Public */
void
! CloseArchive(Archive *AHX, DumpOptions *dopt)
{
int res = 0;
ArchiveHandle *AH = (ArchiveHandle *) AHX;
! (*AH->ClosePtr) (AH, dopt);
/* Close the output */
if (AH->gzOut)
*************** RestoreArchive(Archive *AHX)
*** 522,528 ****
Assert(AH->connection == NULL);
/* ParallelBackupStart() will actually fork the processes */
! pstate = ParallelBackupStart(AH, ropt);
restore_toc_entries_parallel(AH, pstate, &pending_list);
ParallelBackupEnd(AH, pstate);
--- 580,586 ----
Assert(AH->connection == NULL);
/* ParallelBackupStart() will actually fork the processes */
! pstate = ParallelBackupStart(AH, NULL, ropt);
restore_toc_entries_parallel(AH, pstate, &pending_list);
ParallelBackupEnd(AH, pstate);
*************** _allocAH(const char *FileSpec, const Arc
*** 2200,2206 ****
}
void
! WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
{
TocEntry *te;
--- 2258,2264 ----
}
void
! WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate)
{
TocEntry *te;
*************** WriteDataChunks(ArchiveHandle *AH, Paral
*** 2223,2235 ****
DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP);
}
else
! WriteDataChunksForTocEntry(AH, te);
}
EnsureWorkersFinished(AH, pstate);
}
void
! WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
{
StartDataPtr startPtr;
EndDataPtr endPtr;
--- 2281,2293 ----
DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP);
}
else
! WriteDataChunksForTocEntry(AH, dopt, te);
}
EnsureWorkersFinished(AH, pstate);
}
void
! WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
{
StartDataPtr startPtr;
EndDataPtr endPtr;
*************** WriteDataChunksForTocEntry(ArchiveHandle
*** 2253,2259 ****
/*
* The user-provided DataDumper routine needs to call AH->WriteData
*/
! (*te->dataDumper) ((Archive *) AH, te->dataDumperArg);
if (endPtr != NULL)
(*endPtr) (AH, te);
--- 2311,2317 ----
/*
* The user-provided DataDumper routine needs to call AH->WriteData
*/
! (*te->dataDumper) ((Archive *) AH, dopt, te->dataDumperArg);
if (endPtr != NULL)
(*endPtr) (AH, te);
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
new file mode 100644
index c163f29..0f80045
*** a/src/bin/pg_dump/pg_backup_archiver.h
--- b/src/bin/pg_dump/pg_backup_archiver.h
*************** typedef enum T_Action
*** 139,145 ****
ACT_RESTORE
} T_Action;
! typedef void (*ClosePtr) (struct _archiveHandle * AH);
typedef void (*ReopenPtr) (struct _archiveHandle * AH);
typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
--- 139,145 ----
ACT_RESTORE
} T_Action;
! typedef void (*ClosePtr) (struct _archiveHandle * AH, DumpOptions *dopt);
typedef void (*ReopenPtr) (struct _archiveHandle * AH);
typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
*************** typedef void (*ClonePtr) (struct _archiv
*** 166,172 ****
typedef void (*DeClonePtr) (struct _archiveHandle * AH);
typedef char *(*WorkerJobRestorePtr) (struct _archiveHandle * AH, struct _tocEntry * te);
! typedef char *(*WorkerJobDumpPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef char *(*MasterStartParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
T_Action act);
typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
--- 166,172 ----
typedef void (*DeClonePtr) (struct _archiveHandle * AH);
typedef char *(*WorkerJobRestorePtr) (struct _archiveHandle * AH, struct _tocEntry * te);
! typedef char *(*WorkerJobDumpPtr) (struct _archiveHandle * AH, DumpOptions *dopt, struct _tocEntry * te);
typedef char *(*MasterStartParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
T_Action act);
typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
*************** extern void WriteHead(ArchiveHandle *AH)
*** 389,396 ****
extern void ReadHead(ArchiveHandle *AH);
extern void WriteToc(ArchiveHandle *AH);
extern void ReadToc(ArchiveHandle *AH);
! extern void WriteDataChunks(ArchiveHandle *AH, struct ParallelState *pstate);
! extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te);
extern ArchiveHandle *CloneArchive(ArchiveHandle *AH);
extern void DeCloneArchive(ArchiveHandle *AH);
--- 389,396 ----
extern void ReadHead(ArchiveHandle *AH);
extern void WriteToc(ArchiveHandle *AH);
extern void ReadToc(ArchiveHandle *AH);
! extern void WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, struct ParallelState *pstate);
! extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te);
extern ArchiveHandle *CloneArchive(ArchiveHandle *AH);
extern void DeCloneArchive(ArchiveHandle *AH);
*************** int ahprintf(ArchiveHandle *AH, const
*** 436,439 ****
--- 436,442 ----
void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
+ extern DumpOptions* NewDumpOptions(void);
+ extern DumpOptions dumpOptionsFromRestoreOptions(RestoreOptions *ropt);
+
#endif
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
new file mode 100644
index 06cd0a7..d6bb471
*** a/src/bin/pg_dump/pg_backup_custom.c
--- b/src/bin/pg_dump/pg_backup_custom.c
*************** static int _WriteByte(ArchiveHandle *AH,
*** 41,47 ****
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
--- 41,47 ----
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
*************** _ReadBuf(ArchiveHandle *AH, void *buf, s
*** 694,700 ****
*
*/
static void
! _CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
pgoff_t tpos;
--- 694,700 ----
*
*/
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
lclContext *ctx = (lclContext *) AH->formatData;
pgoff_t tpos;
*************** _CloseArchive(ArchiveHandle *AH)
*** 709,715 ****
strerror(errno));
WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx);
! WriteDataChunks(AH, NULL);
/*
* If possible, re-write the TOC in order to update the data offset
--- 709,715 ----
strerror(errno));
WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx);
! WriteDataChunks(AH, dopt, NULL);
/*
* If possible, re-write the TOC in order to update the data offset
diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c
new file mode 100644
index 39e29d8..01b0e97
*** a/src/bin/pg_dump/pg_backup_directory.c
--- b/src/bin/pg_dump/pg_backup_directory.c
*************** static int _WriteByte(ArchiveHandle *AH,
*** 71,77 ****
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
--- 71,77 ----
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
*************** static char *_MasterStartParallelItem(Ar
*** 92,98 ****
static int _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te,
const char *str, T_Action act);
static char *_WorkerJobRestoreDirectory(ArchiveHandle *AH, TocEntry *te);
! static char *_WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te);
static void setFilePath(ArchiveHandle *AH, char *buf,
const char *relativeFilename);
--- 92,98 ----
static int _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te,
const char *str, T_Action act);
static char *_WorkerJobRestoreDirectory(ArchiveHandle *AH, TocEntry *te);
! static char *_WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te);
static void setFilePath(ArchiveHandle *AH, char *buf,
const char *relativeFilename);
*************** _ReadBuf(ArchiveHandle *AH, void *buf, s
*** 566,572 ****
* WriteDataChunks to save all DATA & BLOBs.
*/
static void
! _CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
--- 566,572 ----
* WriteDataChunks to save all DATA & BLOBs.
*/
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
lclContext *ctx = (lclContext *) AH->formatData;
*************** _CloseArchive(ArchiveHandle *AH)
*** 578,584 ****
setFilePath(AH, fname, "toc.dat");
/* this will actually fork the processes for a parallel backup */
! ctx->pstate = ParallelBackupStart(AH, NULL);
/* The TOC is always created uncompressed */
tocFH = cfopen_write(fname, PG_BINARY_W, 0);
--- 578,584 ----
setFilePath(AH, fname, "toc.dat");
/* this will actually fork the processes for a parallel backup */
! ctx->pstate = ParallelBackupStart(AH, dopt, NULL);
/* The TOC is always created uncompressed */
tocFH = cfopen_write(fname, PG_BINARY_W, 0);
*************** _CloseArchive(ArchiveHandle *AH)
*** 599,605 ****
if (cfclose(tocFH) != 0)
exit_horribly(modulename, "could not close TOC file: %s\n",
strerror(errno));
! WriteDataChunks(AH, ctx->pstate);
ParallelBackupEnd(AH, ctx->pstate);
}
--- 599,605 ----
if (cfclose(tocFH) != 0)
exit_horribly(modulename, "could not close TOC file: %s\n",
strerror(errno));
! WriteDataChunks(AH, dopt, ctx->pstate);
ParallelBackupEnd(AH, ctx->pstate);
}
*************** _MasterStartParallelItem(ArchiveHandle *
*** 790,796 ****
* function of the respective dump format.
*/
static char *
! _WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te)
{
/*
* short fixed-size string + some ID so far, this needs to be malloc'ed
--- 790,796 ----
* function of the respective dump format.
*/
static char *
! _WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
{
/*
* short fixed-size string + some ID so far, this needs to be malloc'ed
*************** _WorkerJobDumpDirectory(ArchiveHandle *A
*** 809,815 ****
* succeed... A failure will be detected by the parent when the child dies
* unexpectedly.
*/
! WriteDataChunksForTocEntry(AH, te);
snprintf(buf, buflen, "OK DUMP %d", te->dumpId);
--- 809,815 ----
* succeed... A failure will be detected by the parent when the child dies
* unexpectedly.
*/
! WriteDataChunksForTocEntry(AH, dopt, te);
snprintf(buf, buflen, "OK DUMP %d", te->dumpId);
diff --git a/src/bin/pg_dump/pg_backup_null.c b/src/bin/pg_dump/pg_backup_null.c
new file mode 100644
index 3bce588..77b1eda
*** a/src/bin/pg_dump/pg_backup_null.c
--- b/src/bin/pg_dump/pg_backup_null.c
*************** static void _WriteBlobData(ArchiveHandle
*** 35,41 ****
static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
--- 35,41 ----
static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
*************** _PrintTocData(ArchiveHandle *AH, TocEntr
*** 198,209 ****
{
if (te->dataDumper)
{
AH->currToc = te;
if (strcmp(te->desc, "BLOBS") == 0)
_StartBlobs(AH, te);
! (*te->dataDumper) ((Archive *) AH, te->dataDumperArg);
if (strcmp(te->desc, "BLOBS") == 0)
_EndBlobs(AH, te);
--- 198,210 ----
{
if (te->dataDumper)
{
+ DumpOptions dopt = dumpOptionsFromRestoreOptions(ropt);
AH->currToc = te;
if (strcmp(te->desc, "BLOBS") == 0)
_StartBlobs(AH, te);
! (*te->dataDumper) ((Archive *) AH, &dopt, te->dataDumperArg);
if (strcmp(te->desc, "BLOBS") == 0)
_EndBlobs(AH, te);
*************** _WriteBuf(ArchiveHandle *AH, const void
*** 227,233 ****
}
static void
! _CloseArchive(ArchiveHandle *AH)
{
/* Nothing to do */
}
--- 228,234 ----
}
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
/* Nothing to do */
}
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
new file mode 100644
index 457b742..1c5056c
*** a/src/bin/pg_dump/pg_backup_tar.c
--- b/src/bin/pg_dump/pg_backup_tar.c
*************** static int _WriteByte(ArchiveHandle *AH,
*** 48,54 ****
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
--- 48,54 ----
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
*************** _ReadBuf(ArchiveHandle *AH, void *buf, s
*** 827,833 ****
}
static void
! _CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
TAR_MEMBER *th;
--- 827,833 ----
}
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
lclContext *ctx = (lclContext *) AH->formatData;
TAR_MEMBER *th;
*************** _CloseArchive(ArchiveHandle *AH)
*** 850,856 ****
/*
* Now send the data (tables & blobs)
*/
! WriteDataChunks(AH, NULL);
/*
* Now this format wants to append a script which does a full restore
--- 850,856 ----
/*
* Now send the data (tables & blobs)
*/
! WriteDataChunks(AH, dopt, NULL);
/*
* Now this format wants to append a script which does a full restore
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
new file mode 100644
index 5c0f95f..95f1e5a
*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
*************** typedef struct
*** 85,97 ****
bool g_verbose; /* User wants verbose narration of our
* activities. */
- /* various user-settable parameters */
- static bool schemaOnly;
- static bool dataOnly;
- static int dumpSections; /* bitmask of chosen sections */
- static bool aclsSkip;
- static const char *lockWaitTimeout;
-
/* subquery used to convert user ID (eg, datdba) to user name */
static const char *username_subquery;
--- 85,90 ----
*************** static SimpleOidList table_exclude_oids
*** 116,123 ****
static SimpleStringList tabledata_exclude_patterns = {NULL, NULL};
static SimpleOidList tabledata_exclude_oids = {NULL, NULL};
- /* default, if no "inclusion" switches appear, is to dump everything */
- static bool include_everything = true;
char g_opaque_type[10]; /* name for the opaque type */
--- 109,114 ----
*************** char g_opaque_type[10]; /* name for the
*** 125,147 ****
char g_comment_start[10];
char g_comment_end[10];
static const CatalogId nilCatalogId = {0, 0};
- /* flags for various command-line long options */
static int binary_upgrade = 0;
- static int disable_dollar_quoting = 0;
- static int dump_inserts = 0;
- static int column_inserts = 0;
- static int if_exists = 0;
- static int no_security_labels = 0;
- static int no_synchronized_snapshots = 0;
- static int no_unlogged_table_data = 0;
- static int serializable_deferrable = 0;
-
static void help(const char *progname);
! static void setup_connection(Archive *AH, const char *dumpencoding,
! char *use_role);
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
static void expand_schema_name_patterns(Archive *fout,
SimpleStringList *patterns,
--- 116,129 ----
char g_comment_start[10];
char g_comment_end[10];
+ extern int quote_all_identifiers;
+
static const CatalogId nilCatalogId = {0, 0};
static int binary_upgrade = 0;
static void help(const char *progname);
! static void setup_connection(Archive *AH, DumpOptions *dopt);
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
static void expand_schema_name_patterns(Archive *fout,
SimpleStringList *patterns,
*************** static void expand_table_name_patterns(A
*** 150,213 ****
SimpleStringList *patterns,
SimpleOidList *oids);
static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid);
! static void dumpTableData(Archive *fout, TableDataInfo *tdinfo);
static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo);
static void guessConstraintInheritance(TableInfo *tblinfo, int numTables);
! static void dumpComment(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findComments(Archive *fout, Oid classoid, Oid objoid,
CommentItem **items);
static int collectComments(Archive *fout, CommentItem **items);
! static void dumpSecLabel(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findSecLabels(Archive *fout, Oid classoid, Oid objoid,
SecLabelItem **items);
static int collectSecLabels(Archive *fout, SecLabelItem **items);
! static void dumpDumpableObject(Archive *fout, DumpableObject *dobj);
! static void dumpNamespace(Archive *fout, NamespaceInfo *nspinfo);
! static void dumpExtension(Archive *fout, ExtensionInfo *extinfo);
! static void dumpType(Archive *fout, TypeInfo *tyinfo);
! static void dumpBaseType(Archive *fout, TypeInfo *tyinfo);
! static void dumpEnumType(Archive *fout, TypeInfo *tyinfo);
! static void dumpRangeType(Archive *fout, TypeInfo *tyinfo);
! static void dumpDomain(Archive *fout, TypeInfo *tyinfo);
! static void dumpCompositeType(Archive *fout, TypeInfo *tyinfo);
static void dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo);
! static void dumpShellType(Archive *fout, ShellTypeInfo *stinfo);
! static void dumpProcLang(Archive *fout, ProcLangInfo *plang);
! static void dumpFunc(Archive *fout, FuncInfo *finfo);
! static void dumpCast(Archive *fout, CastInfo *cast);
! static void dumpOpr(Archive *fout, OprInfo *oprinfo);
! static void dumpOpclass(Archive *fout, OpclassInfo *opcinfo);
! static void dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo);
! static void dumpCollation(Archive *fout, CollInfo *convinfo);
! static void dumpConversion(Archive *fout, ConvInfo *convinfo);
! static void dumpRule(Archive *fout, RuleInfo *rinfo);
! static void dumpAgg(Archive *fout, AggInfo *agginfo);
! static void dumpTrigger(Archive *fout, TriggerInfo *tginfo);
! static void dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo);
! static void dumpTable(Archive *fout, TableInfo *tbinfo);
! static void dumpTableSchema(Archive *fout, TableInfo *tbinfo);
! static void dumpAttrDef(Archive *fout, AttrDefInfo *adinfo);
! static void dumpSequence(Archive *fout, TableInfo *tbinfo);
static void dumpSequenceData(Archive *fout, TableDataInfo *tdinfo);
! static void dumpIndex(Archive *fout, IndxInfo *indxinfo);
! static void dumpConstraint(Archive *fout, ConstraintInfo *coninfo);
! static void dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo);
! static void dumpTSParser(Archive *fout, TSParserInfo *prsinfo);
! static void dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo);
! static void dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo);
! static void dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo);
! static void dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo);
! static void dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo);
static void dumpUserMappings(Archive *fout,
const char *servername, const char *namespace,
const char *owner, CatalogId catalogId, DumpId dumpId);
! static void dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo);
! static void dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls);
--- 132,195 ----
SimpleStringList *patterns,
SimpleOidList *oids);
static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid);
! static void dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo);
static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo);
static void guessConstraintInheritance(TableInfo *tblinfo, int numTables);
! static void dumpComment(Archive *fout, DumpOptions* dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findComments(Archive *fout, Oid classoid, Oid objoid,
CommentItem **items);
static int collectComments(Archive *fout, CommentItem **items);
! static void dumpSecLabel(Archive *fout, DumpOptions* dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findSecLabels(Archive *fout, Oid classoid, Oid objoid,
SecLabelItem **items);
static int collectSecLabels(Archive *fout, SecLabelItem **items);
! static void dumpDumpableObject(Archive *fout, DumpOptions* dopt, DumpableObject *dobj);
! static void dumpNamespace(Archive *fout, DumpOptions* dopt, NamespaceInfo *nspinfo);
! static void dumpExtension(Archive *fout, DumpOptions* dopt, ExtensionInfo *extinfo);
! static void dumpType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpBaseType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpEnumType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpRangeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpDomain(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpCompositeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
static void dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo);
! static void dumpShellType(Archive *fout, DumpOptions* dopt, ShellTypeInfo *stinfo);
! static void dumpProcLang(Archive *fout, DumpOptions* dopt, ProcLangInfo *plang);
! static void dumpFunc(Archive *fout, DumpOptions* dopt, FuncInfo *finfo);
! static void dumpCast(Archive *fout, DumpOptions* dopt, CastInfo *cast);
! static void dumpOpr(Archive *fout, DumpOptions* dopt, OprInfo *oprinfo);
! static void dumpOpclass(Archive *fout, DumpOptions* dopt, OpclassInfo *opcinfo);
! static void dumpOpfamily(Archive *fout, DumpOptions* dopt, OpfamilyInfo *opfinfo);
! static void dumpCollation(Archive *fout, DumpOptions* dopt, CollInfo *convinfo);
! static void dumpConversion(Archive *fout, DumpOptions* dopt, ConvInfo *convinfo);
! static void dumpRule(Archive *fout, DumpOptions* dopt, RuleInfo *rinfo);
! static void dumpAgg(Archive *fout, DumpOptions* dopt, AggInfo *agginfo);
! static void dumpTrigger(Archive *fout, DumpOptions* dopt, TriggerInfo *tginfo);
! static void dumpEventTrigger(Archive *fout, DumpOptions* dopt, EventTriggerInfo *evtinfo);
! static void dumpTable(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo);
! static void dumpTableSchema(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo);
! static void dumpAttrDef(Archive *fout, DumpOptions* dopt, AttrDefInfo *adinfo);
! static void dumpSequence(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo);
static void dumpSequenceData(Archive *fout, TableDataInfo *tdinfo);
! static void dumpIndex(Archive *fout, DumpOptions* dopt, IndxInfo *indxinfo);
! static void dumpConstraint(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo);
! static void dumpTableConstraintComment(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo);
! static void dumpTSParser(Archive *fout, DumpOptions* dopt, TSParserInfo *prsinfo);
! static void dumpTSDictionary(Archive *fout, DumpOptions* dopt, TSDictInfo *dictinfo);
! static void dumpTSTemplate(Archive *fout, DumpOptions* dopt, TSTemplateInfo *tmplinfo);
! static void dumpTSConfig(Archive *fout, DumpOptions* dopt, TSConfigInfo *cfginfo);
! static void dumpForeignDataWrapper(Archive *fout, DumpOptions* dopt, FdwInfo *fdwinfo);
! static void dumpForeignServer(Archive *fout, DumpOptions* dopt, ForeignServerInfo *srvinfo);
static void dumpUserMappings(Archive *fout,
const char *servername, const char *namespace,
const char *owner, CatalogId catalogId, DumpId dumpId);
! static void dumpDefaultACL(Archive *fout, DumpOptions* dopt, DefaultACLInfo *daclinfo);
! static void dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls);
*************** static void addBoundaryDependencies(Dump
*** 222,229 ****
DumpableObject *boundaryObjs);
static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo);
! static void getTableData(TableInfo *tblinfo, int numTables, bool oids);
! static void makeTableDataInfo(TableInfo *tbinfo, bool oids);
static void buildMatViewRefreshDependencies(Archive *fout);
static void getTableDataFKConstraints(void);
static char *format_function_arguments(FuncInfo *finfo, char *funcargs,
--- 204,211 ----
DumpableObject *boundaryObjs);
static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo);
! static void getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids);
! static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids);
static void buildMatViewRefreshDependencies(Archive *fout);
static void getTableDataFKConstraints(void);
static char *format_function_arguments(FuncInfo *finfo, char *funcargs,
*************** static void selectSourceSchema(Archive *
*** 245,253 ****
static char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts);
static char *myFormatType(const char *typname, int32 typmod);
static void getBlobs(Archive *fout);
! static void dumpBlob(Archive *fout, BlobInfo *binfo);
! static int dumpBlobs(Archive *fout, void *arg);
! static void dumpDatabase(Archive *AH);
static void dumpEncoding(Archive *AH);
static void dumpStdStrings(Archive *AH);
static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout,
--- 227,235 ----
static char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts);
static char *myFormatType(const char *typname, int32 typmod);
static void getBlobs(Archive *fout);
! static void dumpBlob(Archive *fout, DumpOptions *dopt, BlobInfo *binfo);
! static int dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg);
! static void dumpDatabase(Archive *AH, DumpOptions *dopt);
static void dumpEncoding(Archive *AH);
static void dumpStdStrings(Archive *AH);
static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout,
*************** static const char *getAttrName(int attrn
*** 264,270 ****
static const char *fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer);
static char *get_synchronized_snapshot(Archive *fout);
static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query);
! static void setupDumpWorker(Archive *AHX, RestoreOptions *ropt);
int
--- 246,252 ----
static const char *fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer);
static char *get_synchronized_snapshot(Archive *fout);
static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query);
! static void setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt);
int
*************** main(int argc, char **argv)
*** 273,311 ****
int c;
const char *filename = NULL;
const char *format = "p";
- const char *dbname = NULL;
- const char *pghost = NULL;
- const char *pgport = NULL;
- const char *username = NULL;
- const char *dumpencoding = NULL;
- bool oids = false;
TableInfo *tblinfo;
int numTables;
DumpableObject **dobjs;
int numObjs;
DumpableObject *boundaryObjs;
int i;
- int numWorkers = 1;
- enum trivalue prompt_password = TRI_DEFAULT;
- int compressLevel = -1;
- int plainText = 0;
- int outputClean = 0;
- int outputCreateDB = 0;
- bool outputBlobs = false;
- int outputNoOwner = 0;
- char *outputSuperuser = NULL;
- char *use_role = NULL;
int optindex;
RestoreOptions *ropt;
- ArchiveFormat archiveFormat = archUnknown;
- ArchiveMode archiveMode;
Archive *fout; /* the script file */
! static int disable_triggers = 0;
! static int outputNoTablespaces = 0;
! static int use_setsessauth = 0;
! static struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
{"blobs", no_argument, NULL, 'b'},
{"clean", no_argument, NULL, 'c'},
--- 255,273 ----
int c;
const char *filename = NULL;
const char *format = "p";
TableInfo *tblinfo;
int numTables;
DumpableObject **dobjs;
int numObjs;
DumpableObject *boundaryObjs;
int i;
int optindex;
RestoreOptions *ropt;
Archive *fout; /* the script file */
! DumpOptions *dopt = NewDumpOptions();
! struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
{"blobs", no_argument, NULL, 'b'},
{"clean", no_argument, NULL, 'c'},
*************** main(int argc, char **argv)
*** 340,363 ****
/*
* the following options don't have an equivalent short option letter
*/
! {"attribute-inserts", no_argument, &column_inserts, 1},
{"binary-upgrade", no_argument, &binary_upgrade, 1},
! {"column-inserts", no_argument, &column_inserts, 1},
! {"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1},
! {"disable-triggers", no_argument, &disable_triggers, 1},
{"exclude-table-data", required_argument, NULL, 4},
! {"if-exists", no_argument, &if_exists, 1},
! {"inserts", no_argument, &dump_inserts, 1},
{"lock-wait-timeout", required_argument, NULL, 2},
! {"no-tablespaces", no_argument, &outputNoTablespaces, 1},
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
{"role", required_argument, NULL, 3},
{"section", required_argument, NULL, 5},
! {"serializable-deferrable", no_argument, &serializable_deferrable, 1},
! {"use-set-session-authorization", no_argument, &use_setsessauth, 1},
! {"no-security-labels", no_argument, &no_security_labels, 1},
! {"no-synchronized-snapshots", no_argument, &no_synchronized_snapshots, 1},
! {"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1},
{NULL, 0, NULL, 0}
};
--- 302,325 ----
/*
* the following options don't have an equivalent short option letter
*/
! {"attribute-inserts", no_argument, &dopt->column_inserts, 1},
{"binary-upgrade", no_argument, &binary_upgrade, 1},
! {"column-inserts", no_argument, &dopt->column_inserts, 1},
! {"disable-dollar-quoting", no_argument, &dopt->disable_dollar_quoting, 1},
! {"disable-triggers", no_argument, &dopt->disable_triggers, 1},
{"exclude-table-data", required_argument, NULL, 4},
! {"if-exists", no_argument, &dopt->if_exists, 1},
! {"inserts", no_argument, &dopt->dump_inserts, 1},
{"lock-wait-timeout", required_argument, NULL, 2},
! {"no-tablespaces", no_argument, &dopt->outputNoTablespaces, 1},
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
{"role", required_argument, NULL, 3},
{"section", required_argument, NULL, 5},
! {"serializable-deferrable", no_argument, &dopt->serializable_deferrable, 1},
! {"use-set-session-authorization", no_argument, &dopt->use_setsessauth, 1},
! {"no-security-labels", no_argument, &dopt->no_security_labels, 1},
! {"no-synchronized-snapshots", no_argument, &dopt->no_synchronized_snapshots, 1},
! {"no-unlogged-table-data", no_argument, &dopt->no_unlogged_table_data, 1},
{NULL, 0, NULL, 0}
};
*************** main(int argc, char **argv)
*** 376,385 ****
g_comment_end[0] = '\0';
strcpy(g_opaque_type, "opaque");
- dataOnly = schemaOnly = false;
- dumpSections = DUMP_UNSECTIONED;
- lockWaitTimeout = NULL;
-
progname = get_progname(argv[0]);
/* Set default options based on progname */
--- 338,343 ----
*************** main(int argc, char **argv)
*** 406,432 ****
switch (c)
{
case 'a': /* Dump data only */
! dataOnly = true;
break;
case 'b': /* Dump blobs */
! outputBlobs = true;
break;
case 'c': /* clean (i.e., drop) schema prior to create */
! outputClean = 1;
break;
case 'C': /* Create DB */
! outputCreateDB = 1;
break;
case 'd': /* database name */
! dbname = pg_strdup(optarg);
break;
case 'E': /* Dump encoding */
! dumpencoding = pg_strdup(optarg);
break;
case 'f':
--- 364,390 ----
switch (c)
{
case 'a': /* Dump data only */
! dopt->dataOnly = true;
break;
case 'b': /* Dump blobs */
! dopt->outputBlobs = true;
break;
case 'c': /* clean (i.e., drop) schema prior to create */
! dopt->outputClean = 1;
break;
case 'C': /* Create DB */
! dopt->outputCreateDB = 1;
break;
case 'd': /* database name */
! dopt->dbname = pg_strdup(optarg);
break;
case 'E': /* Dump encoding */
! dopt->dumpencoding = pg_strdup(optarg);
break;
case 'f':
*************** main(int argc, char **argv)
*** 438,444 ****
break;
case 'h': /* server host */
! pghost = pg_strdup(optarg);
break;
case 'i':
--- 396,402 ----
break;
case 'h': /* server host */
! dopt->pghost = pg_strdup(optarg);
break;
case 'i':
*************** main(int argc, char **argv)
*** 446,457 ****
break;
case 'j': /* number of dump jobs */
! numWorkers = atoi(optarg);
break;
case 'n': /* include schema(s) */
simple_string_list_append(&schema_include_patterns, optarg);
! include_everything = false;
break;
case 'N': /* exclude schema(s) */
--- 404,415 ----
break;
case 'j': /* number of dump jobs */
! dopt->numWorkers = atoi(optarg);
break;
case 'n': /* include schema(s) */
simple_string_list_append(&schema_include_patterns, optarg);
! dopt->include_everything = false;
break;
case 'N': /* exclude schema(s) */
*************** main(int argc, char **argv)
*** 459,473 ****
break;
case 'o': /* Dump oids */
! oids = true;
break;
case 'O': /* Don't reconnect to match owner */
! outputNoOwner = 1;
break;
case 'p': /* server port */
! pgport = pg_strdup(optarg);
break;
case 'R':
--- 417,431 ----
break;
case 'o': /* Dump oids */
! dopt->oids = true;
break;
case 'O': /* Don't reconnect to match owner */
! dopt->outputNoOwner = 1;
break;
case 'p': /* server port */
! dopt->pgport = pg_strdup(optarg);
break;
case 'R':
*************** main(int argc, char **argv)
*** 475,490 ****
break;
case 's': /* dump schema only */
! schemaOnly = true;
break;
case 'S': /* Username for superuser in plain text output */
! outputSuperuser = pg_strdup(optarg);
break;
case 't': /* include table(s) */
simple_string_list_append(&table_include_patterns, optarg);
! include_everything = false;
break;
case 'T': /* exclude table(s) */
--- 433,448 ----
break;
case 's': /* dump schema only */
! dopt->schemaOnly = true;
break;
case 'S': /* Username for superuser in plain text output */
! dopt->outputSuperuser = pg_strdup(optarg);
break;
case 't': /* include table(s) */
simple_string_list_append(&table_include_patterns, optarg);
! dopt->include_everything = false;
break;
case 'T': /* exclude table(s) */
*************** main(int argc, char **argv)
*** 492,498 ****
break;
case 'U':
! username = pg_strdup(optarg);
break;
case 'v': /* verbose */
--- 450,456 ----
break;
case 'U':
! dopt->username = pg_strdup(optarg);
break;
case 'v': /* verbose */
*************** main(int argc, char **argv)
*** 500,518 ****
break;
case 'w':
! prompt_password = TRI_NO;
break;
case 'W':
! prompt_password = TRI_YES;
break;
case 'x': /* skip ACL dump */
! aclsSkip = true;
break;
case 'Z': /* Compression Level */
! compressLevel = atoi(optarg);
break;
case 0:
--- 458,476 ----
break;
case 'w':
! dopt->prompt_password = TRI_NO;
break;
case 'W':
! dopt->prompt_password = TRI_YES;
break;
case 'x': /* skip ACL dump */
! dopt->aclsSkip = true;
break;
case 'Z': /* Compression Level */
! dopt->compressLevel = atoi(optarg);
break;
case 0:
*************** main(int argc, char **argv)
*** 520,530 ****
break;
case 2: /* lock-wait-timeout */
! lockWaitTimeout = pg_strdup(optarg);
break;
case 3: /* SET ROLE */
! use_role = pg_strdup(optarg);
break;
case 4: /* exclude table(s) data */
--- 478,488 ----
break;
case 2: /* lock-wait-timeout */
! dopt->lockWaitTimeout = pg_strdup(optarg);
break;
case 3: /* SET ROLE */
! dopt->use_role = pg_strdup(optarg);
break;
case 4: /* exclude table(s) data */
*************** main(int argc, char **argv)
*** 532,538 ****
break;
case 5: /* section */
! set_dump_section(optarg, &dumpSections);
break;
default:
--- 490,496 ----
break;
case 5: /* section */
! set_dump_section(optarg, &dopt->dumpSections);
break;
default:
*************** main(int argc, char **argv)
*** 545,552 ****
* Non-option argument specifies database name as long as it wasn't
* already specified with -d / --dbname
*/
! if (optind < argc && dbname == NULL)
! dbname = argv[optind++];
/* Complain if any arguments remain */
if (optind < argc)
--- 503,510 ----
* Non-option argument specifies database name as long as it wasn't
* already specified with -d / --dbname
*/
! if (optind < argc && dopt->dbname == NULL)
! dopt->dbname = argv[optind++];
/* Complain if any arguments remain */
if (optind < argc)
*************** main(int argc, char **argv)
*** 559,603 ****
}
/* --column-inserts implies --inserts */
! if (column_inserts)
! dump_inserts = 1;
! if (dataOnly && schemaOnly)
{
write_msg(NULL, "options -s/--schema-only and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dataOnly && outputClean)
{
write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dump_inserts && oids)
{
write_msg(NULL, "options --inserts/--column-inserts and -o/--oids cannot be used together\n");
write_msg(NULL, "(The INSERT command cannot set OIDs.)\n");
exit_nicely(1);
}
! if (if_exists && !outputClean)
exit_horribly(NULL, "option --if-exists requires option -c/--clean\n");
/* Identify archive format to emit */
! archiveFormat = parseArchiveFormat(format, &archiveMode);
/* archiveFormat specific setup */
! if (archiveFormat == archNull)
! plainText = 1;
/* Custom and directory formats are compressed by default, others not */
! if (compressLevel == -1)
{
! if (archiveFormat == archCustom || archiveFormat == archDirectory)
! compressLevel = Z_DEFAULT_COMPRESSION;
else
! compressLevel = 0;
}
/*
--- 517,561 ----
}
/* --column-inserts implies --inserts */
! if (dopt->column_inserts)
! dopt->dump_inserts = 1;
! if (dopt->dataOnly && dopt->schemaOnly)
{
write_msg(NULL, "options -s/--schema-only and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dopt->dataOnly && dopt->outputClean)
{
write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dopt->dump_inserts && dopt->oids)
{
write_msg(NULL, "options --inserts/--column-inserts and -o/--oids cannot be used together\n");
write_msg(NULL, "(The INSERT command cannot set OIDs.)\n");
exit_nicely(1);
}
! if (dopt->if_exists && !dopt->outputClean)
exit_horribly(NULL, "option --if-exists requires option -c/--clean\n");
/* Identify archive format to emit */
! dopt->archiveFormat = parseArchiveFormat(format, &dopt->archiveMode);
/* archiveFormat specific setup */
! if (dopt->archiveFormat == archNull)
! dopt->plainText = 1;
/* Custom and directory formats are compressed by default, others not */
! if (dopt->compressLevel == -1)
{
! if (dopt->archiveFormat == archCustom || dopt->archiveFormat == archDirectory)
! dopt->compressLevel = Z_DEFAULT_COMPRESSION;
else
! dopt->compressLevel = 0;
}
/*
*************** main(int argc, char **argv)
*** 605,623 ****
* parallel jobs because that's the maximum limit for the
* WaitForMultipleObjects() call.
*/
! if (numWorkers <= 0
#ifdef WIN32
! || numWorkers > MAXIMUM_WAIT_OBJECTS
#endif
)
exit_horribly(NULL, "%s: invalid number of parallel jobs\n", progname);
/* Parallel backup only in the directory archive format so far */
! if (archiveFormat != archDirectory && numWorkers > 1)
exit_horribly(NULL, "parallel backup only supported by the directory format\n");
/* Open the output file */
! fout = CreateArchive(filename, archiveFormat, compressLevel, archiveMode,
setupDumpWorker);
/* Register the cleanup hook */
--- 563,581 ----
* parallel jobs because that's the maximum limit for the
* WaitForMultipleObjects() call.
*/
! if (dopt->numWorkers <= 0
#ifdef WIN32
! || dopt->numWorkers > MAXIMUM_WAIT_OBJECTS
#endif
)
exit_horribly(NULL, "%s: invalid number of parallel jobs\n", progname);
/* Parallel backup only in the directory archive format so far */
! if (dopt->archiveFormat != archDirectory && dopt->numWorkers > 1)
exit_horribly(NULL, "parallel backup only supported by the directory format\n");
/* Open the output file */
! fout = CreateArchive(filename, dopt->archiveFormat, dopt->compressLevel, dopt->archiveMode,
setupDumpWorker);
/* Register the cleanup hook */
*************** main(int argc, char **argv)
*** 636,656 ****
fout->minRemoteVersion = 70000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
! fout->numWorkers = numWorkers;
/*
* Open the database using the Archiver, so it knows about it. Errors mean
* death.
*/
! ConnectDatabase(fout, dbname, pghost, pgport, username, prompt_password);
! setup_connection(fout, dumpencoding, use_role);
/*
* Disable security label support if server version < v9.1.x (prevents
* access to nonexistent pg_seclabel catalog)
*/
if (fout->remoteVersion < 90100)
! no_security_labels = 1;
/*
* When running against 9.0 or later, check if we are in recovery mode,
--- 594,614 ----
fout->minRemoteVersion = 70000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
! fout->numWorkers = dopt->numWorkers;
/*
* Open the database using the Archiver, so it knows about it. Errors mean
* death.
*/
! ConnectDatabase(fout, dopt->dbname, dopt->pghost, dopt->pgport, dopt->username, dopt->prompt_password);
! setup_connection(fout, dopt);
/*
* Disable security label support if server version < v9.1.x (prevents
* access to nonexistent pg_seclabel catalog)
*/
if (fout->remoteVersion < 90100)
! dopt->no_security_labels = 1;
/*
* When running against 9.0 or later, check if we are in recovery mode,
*************** main(int argc, char **argv)
*** 666,672 ****
* On hot standby slaves, never try to dump unlogged table data,
* since it will just throw an error.
*/
! no_unlogged_table_data = true;
}
PQclear(res);
}
--- 624,630 ----
* On hot standby slaves, never try to dump unlogged table data,
* since it will just throw an error.
*/
! dopt->no_unlogged_table_data = true;
}
PQclear(res);
}
*************** main(int argc, char **argv)
*** 680,687 ****
username_subquery = "SELECT usename FROM pg_user WHERE usesysid =";
/* check the version for the synchronized snapshots feature */
! if (numWorkers > 1 && fout->remoteVersion < 90200
! && !no_synchronized_snapshots)
exit_horribly(NULL,
"Synchronized snapshots are not supported by this server version.\n"
"Run with --no-synchronized-snapshots instead if you do not need\n"
--- 638,645 ----
username_subquery = "SELECT usename FROM pg_user WHERE usesysid =";
/* check the version for the synchronized snapshots feature */
! if (dopt->numWorkers > 1 && fout->remoteVersion < 90200
! && !dopt->no_synchronized_snapshots)
exit_horribly(NULL,
"Synchronized snapshots are not supported by this server version.\n"
"Run with --no-synchronized-snapshots instead if you do not need\n"
*************** main(int argc, char **argv)
*** 731,757 ****
* Dumping blobs is now default unless we saw an inclusion switch or -s
* ... but even if we did see one of these, -b turns it back on.
*/
! if (include_everything && !schemaOnly)
! outputBlobs = true;
/*
* Now scan the database and create DumpableObject structs for all the
* objects we intend to dump.
*/
! tblinfo = getSchemaData(fout, &numTables);
if (fout->remoteVersion < 80400)
guessConstraintInheritance(tblinfo, numTables);
! if (!schemaOnly)
{
! getTableData(tblinfo, numTables, oids);
buildMatViewRefreshDependencies(fout);
! if (dataOnly)
getTableDataFKConstraints();
}
! if (outputBlobs)
getBlobs(fout);
/*
--- 689,715 ----
* Dumping blobs is now default unless we saw an inclusion switch or -s
* ... but even if we did see one of these, -b turns it back on.
*/
! if (dopt->include_everything && !dopt->schemaOnly)
! dopt->outputBlobs = true;
/*
* Now scan the database and create DumpableObject structs for all the
* objects we intend to dump.
*/
! tblinfo = getSchemaData(fout, dopt, &numTables);
if (fout->remoteVersion < 80400)
guessConstraintInheritance(tblinfo, numTables);
! if (!dopt->schemaOnly)
{
! getTableData(dopt, tblinfo, numTables, dopt->oids);
buildMatViewRefreshDependencies(fout);
! if (dopt->dataOnly)
getTableDataFKConstraints();
}
! if (dopt->outputBlobs)
getBlobs(fout);
/*
*************** main(int argc, char **argv)
*** 785,791 ****
sortDumpableObjectsByTypeOid(dobjs, numObjs);
/* If we do a parallel dump, we want the largest tables to go first */
! if (archiveFormat == archDirectory && numWorkers > 1)
sortDataAndIndexObjectsBySize(dobjs, numObjs);
sortDumpableObjects(dobjs, numObjs,
--- 743,749 ----
sortDumpableObjectsByTypeOid(dobjs, numObjs);
/* If we do a parallel dump, we want the largest tables to go first */
! if (dopt->archiveFormat == archDirectory && dopt->numWorkers > 1)
sortDataAndIndexObjectsBySize(dobjs, numObjs);
sortDumpableObjects(dobjs, numObjs,
*************** main(int argc, char **argv)
*** 801,835 ****
dumpStdStrings(fout);
/* The database item is always next, unless we don't want it at all */
! if (include_everything && !dataOnly)
! dumpDatabase(fout);
/* Now the rearrangeable objects. */
for (i = 0; i < numObjs; i++)
! dumpDumpableObject(fout, dobjs[i]);
/*
* Set up options info to ensure we dump what we want.
*/
ropt = NewRestoreOptions();
ropt->filename = filename;
! ropt->dropSchema = outputClean;
! ropt->dataOnly = dataOnly;
! ropt->schemaOnly = schemaOnly;
! ropt->if_exists = if_exists;
! ropt->dumpSections = dumpSections;
! ropt->aclsSkip = aclsSkip;
! ropt->superuser = outputSuperuser;
! ropt->createDB = outputCreateDB;
! ropt->noOwner = outputNoOwner;
! ropt->noTablespace = outputNoTablespaces;
! ropt->disable_triggers = disable_triggers;
! ropt->use_setsessauth = use_setsessauth;
! if (compressLevel == -1)
ropt->compression = 0;
else
! ropt->compression = compressLevel;
ropt->suppressDumpWarnings = true; /* We've already shown them */
--- 759,799 ----
dumpStdStrings(fout);
/* The database item is always next, unless we don't want it at all */
! if (dopt->include_everything && !dopt->dataOnly)
! dumpDatabase(fout, dopt);
/* Now the rearrangeable objects. */
for (i = 0; i < numObjs; i++)
! dumpDumpableObject(fout, dopt, dobjs[i]);
/*
* Set up options info to ensure we dump what we want.
*/
ropt = NewRestoreOptions();
ropt->filename = filename;
! ropt->dropSchema = dopt->outputClean;
! ropt->dataOnly = dopt->dataOnly;
! ropt->schemaOnly = dopt->schemaOnly;
! ropt->if_exists = dopt->if_exists;
! ropt->column_inserts = dopt->column_inserts;
! ropt->dumpSections = dopt->dumpSections;
! ropt->aclsSkip = dopt->aclsSkip;
! ropt->superuser = dopt->outputSuperuser;
! ropt->createDB = dopt->outputCreateDB;
! ropt->noOwner = dopt->outputNoOwner;
! ropt->noTablespace = dopt->outputNoTablespaces;
! ropt->disable_triggers = dopt->disable_triggers;
! ropt->use_setsessauth = dopt->use_setsessauth;
! ropt->disable_dollar_quoting = dopt->disable_dollar_quoting;
! ropt->dump_inserts = dopt->dump_inserts;
! ropt->no_security_labels = dopt->no_security_labels;
! ropt->lockWaitTimeout = dopt->lockWaitTimeout;
! ropt->include_everything = dopt->include_everything;
! if (dopt->compressLevel == -1)
ropt->compression = 0;
else
! ropt->compression = dopt->compressLevel;
ropt->suppressDumpWarnings = true; /* We've already shown them */
*************** main(int argc, char **argv)
*** 840,846 ****
* be output, so we can set up their dependency lists properly. This isn't
* necessary for plain-text output, though.
*/
! if (!plainText)
BuildArchiveDependencies(fout);
/*
--- 804,810 ----
* be output, so we can set up their dependency lists properly. This isn't
* necessary for plain-text output, though.
*/
! if (!dopt->plainText)
BuildArchiveDependencies(fout);
/*
*************** main(int argc, char **argv)
*** 850,859 ****
* inside CloseArchive(). This is, um, bizarre; but not worth changing
* right now.
*/
! if (plainText)
RestoreArchive(fout);
! CloseArchive(fout);
exit_nicely(0);
}
--- 814,823 ----
* inside CloseArchive(). This is, um, bizarre; but not worth changing
* right now.
*/
! if (dopt->plainText)
RestoreArchive(fout);
! CloseArchive(fout, dopt);
exit_nicely(0);
}
*************** help(const char *progname)
*** 926,932 ****
}
static void
! setup_connection(Archive *AH, const char *dumpencoding, char *use_role)
{
PGconn *conn = GetConnection(AH);
const char *std_strings;
--- 890,896 ----
}
static void
! setup_connection(Archive *AH, DumpOptions *dopt)
{
PGconn *conn = GetConnection(AH);
const char *std_strings;
*************** setup_connection(Archive *AH, const char
*** 937,947 ****
* this has already been set in CloneArchive according to the original
* connection encoding.
*/
! if (dumpencoding)
{
! if (PQsetClientEncoding(conn, dumpencoding) < 0)
exit_horribly(NULL, "invalid client encoding \"%s\" specified\n",
! dumpencoding);
}
/*
--- 901,911 ----
* this has already been set in CloneArchive according to the original
* connection encoding.
*/
! if (dopt->dumpencoding)
{
! if (PQsetClientEncoding(conn, dopt->dumpencoding) < 0)
exit_horribly(NULL, "invalid client encoding \"%s\" specified\n",
! dopt->dumpencoding);
}
/*
*************** setup_connection(Archive *AH, const char
*** 954,974 ****
AH->std_strings = (std_strings && strcmp(std_strings, "on") == 0);
/* Set the role if requested */
! if (!use_role && AH->use_role)
! use_role = AH->use_role;
/* Set the role if requested */
! if (use_role && AH->remoteVersion >= 80100)
{
PQExpBuffer query = createPQExpBuffer();
! appendPQExpBuffer(query, "SET ROLE %s", fmtId(use_role));
ExecuteSqlStatement(AH, query->data);
destroyPQExpBuffer(query);
/* save this for later use on parallel connections */
if (!AH->use_role)
! AH->use_role = strdup(use_role);
}
/* Set the datestyle to ISO to ensure the dump's portability */
--- 918,938 ----
AH->std_strings = (std_strings && strcmp(std_strings, "on") == 0);
/* Set the role if requested */
! if (!dopt->use_role && AH->use_role)
! dopt->use_role = AH->use_role;
/* Set the role if requested */
! if (dopt->use_role && AH->remoteVersion >= 80100)
{
PQExpBuffer query = createPQExpBuffer();
! appendPQExpBuffer(query, "SET ROLE %s", fmtId(dopt->use_role));
ExecuteSqlStatement(AH, query->data);
destroyPQExpBuffer(query);
/* save this for later use on parallel connections */
if (!AH->use_role)
! AH->use_role = strdup(dopt->use_role);
}
/* Set the datestyle to ISO to ensure the dump's portability */
*************** setup_connection(Archive *AH, const char
*** 1014,1020 ****
ExecuteSqlStatement(AH, "BEGIN");
if (AH->remoteVersion >= 90100)
{
! if (serializable_deferrable)
ExecuteSqlStatement(AH,
"SET TRANSACTION ISOLATION LEVEL "
"SERIALIZABLE, READ ONLY, DEFERRABLE");
--- 978,984 ----
ExecuteSqlStatement(AH, "BEGIN");
if (AH->remoteVersion >= 90100)
{
! if (dopt->serializable_deferrable)
ExecuteSqlStatement(AH,
"SET TRANSACTION ISOLATION LEVEL "
"SERIALIZABLE, READ ONLY, DEFERRABLE");
*************** setup_connection(Archive *AH, const char
*** 1036,1042 ****
! if (AH->numWorkers > 1 && AH->remoteVersion >= 90200 && !no_synchronized_snapshots)
{
if (AH->sync_snapshot_id)
{
--- 1000,1006 ----
! if (AH->numWorkers > 1 && AH->remoteVersion >= 90200 && !dopt->no_synchronized_snapshots)
{
if (AH->sync_snapshot_id)
{
*************** setup_connection(Archive *AH, const char
*** 1053,1061 ****
}
static void
! setupDumpWorker(Archive *AHX, RestoreOptions *ropt)
{
! setup_connection(AHX, NULL, NULL);
}
static char *
--- 1017,1025 ----
}
static void
! setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt)
{
! setup_connection(AHX, dopt);
}
static char *
*************** selectDumpableType(TypeInfo *tyinfo)
*** 1326,1337 ****
* and aclsSkip are checked separately.
*/
static void
! selectDumpableDefaultACL(DefaultACLInfo *dinfo)
{
if (dinfo->dobj.namespace)
dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump;
else
! dinfo->dobj.dump = include_everything;
}
/*
--- 1290,1301 ----
* and aclsSkip are checked separately.
*/
static void
! selectDumpableDefaultACL(DumpOptions *dopt, DefaultACLInfo *dinfo)
{
if (dinfo->dobj.namespace)
dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump;
else
! dinfo->dobj.dump = dopt->include_everything;
}
/*
*************** selectDumpableDefaultACL(DefaultACLInfo
*** 1345,1356 ****
* such extensions by their having OIDs in the range reserved for initdb.
*/
static void
! selectDumpableExtension(ExtensionInfo *extinfo)
{
if (binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
extinfo->dobj.dump = false;
else
! extinfo->dobj.dump = include_everything;
}
/*
--- 1309,1320 ----
* such extensions by their having OIDs in the range reserved for initdb.
*/
static void
! selectDumpableExtension(DumpOptions *dopt, ExtensionInfo *extinfo)
{
if (binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
extinfo->dobj.dump = false;
else
! extinfo->dobj.dump = dopt->include_everything;
}
/*
*************** selectDumpableObject(DumpableObject *dob
*** 1379,1385 ****
*/
static int
! dumpTableData_copy(Archive *fout, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
--- 1343,1349 ----
*/
static int
! dumpTableData_copy(Archive *fout, DumpOptions *dopt, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
*************** dumpTableData_copy(Archive *fout, void *
*** 1553,1559 ****
* E'' strings, or dollar-quoted strings. So don't emit anything like that.
*/
static int
! dumpTableData_insert(Archive *fout, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
--- 1517,1523 ----
* E'' strings, or dollar-quoted strings. So don't emit anything like that.
*/
static int
! dumpTableData_insert(Archive *fout, DumpOptions *dopt, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
*************** dumpTableData_insert(Archive *fout, void
*** 1622,1628 ****
else
{
/* append the list of column names if required */
! if (column_inserts)
{
appendPQExpBufferStr(insertStmt, "(");
for (field = 0; field < nfields; field++)
--- 1586,1592 ----
else
{
/* append the list of column names if required */
! if (dopt->column_inserts)
{
appendPQExpBufferStr(insertStmt, "(");
for (field = 0; field < nfields; field++)
*************** dumpTableData_insert(Archive *fout, void
*** 1739,1745 ****
* Actually, this just makes an ArchiveEntry for the table contents.
*/
static void
! dumpTableData(Archive *fout, TableDataInfo *tdinfo)
{
TableInfo *tbinfo = tdinfo->tdtable;
PQExpBuffer copyBuf = createPQExpBuffer();
--- 1703,1709 ----
* Actually, this just makes an ArchiveEntry for the table contents.
*/
static void
! dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo)
{
TableInfo *tbinfo = tdinfo->tdtable;
PQExpBuffer copyBuf = createPQExpBuffer();
*************** dumpTableData(Archive *fout, TableDataIn
*** 1747,1753 ****
DataDumperPtr dumpFn;
char *copyStmt;
! if (!dump_inserts)
{
/* Dump/restore using COPY */
dumpFn = dumpTableData_copy;
--- 1711,1717 ----
DataDumperPtr dumpFn;
char *copyStmt;
! if (!dopt->dump_inserts)
{
/* Dump/restore using COPY */
dumpFn = dumpTableData_copy;
*************** refreshMatViewData(Archive *fout, TableD
*** 1831,1844 ****
* set up dumpable objects representing the contents of tables
*/
static void
! getTableData(TableInfo *tblinfo, int numTables, bool oids)
{
int i;
for (i = 0; i < numTables; i++)
{
if (tblinfo[i].dobj.dump)
! makeTableDataInfo(&(tblinfo[i]), oids);
}
}
--- 1795,1808 ----
* set up dumpable objects representing the contents of tables
*/
static void
! getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids)
{
int i;
for (i = 0; i < numTables; i++)
{
if (tblinfo[i].dobj.dump)
! makeTableDataInfo(dopt, &(tblinfo[i]), oids);
}
}
*************** getTableData(TableInfo *tblinfo, int num
*** 1849,1855 ****
* table data; the "dump" flag in such objects isn't used.
*/
static void
! makeTableDataInfo(TableInfo *tbinfo, bool oids)
{
TableDataInfo *tdinfo;
--- 1813,1819 ----
* table data; the "dump" flag in such objects isn't used.
*/
static void
! makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids)
{
TableDataInfo *tdinfo;
*************** makeTableDataInfo(TableInfo *tbinfo, boo
*** 1869,1875 ****
/* Don't dump data in unlogged tables, if so requested */
if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED &&
! no_unlogged_table_data)
return;
/* Check that the data is not explicitly excluded */
--- 1833,1839 ----
/* Don't dump data in unlogged tables, if so requested */
if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED &&
! dopt->no_unlogged_table_data)
return;
/* Check that the data is not explicitly excluded */
*************** guessConstraintInheritance(TableInfo *tb
*** 2142,2148 ****
* dump the database definition
*/
static void
! dumpDatabase(Archive *fout)
{
PQExpBuffer dbQry = createPQExpBuffer();
PQExpBuffer delQry = createPQExpBuffer();
--- 2106,2112 ----
* dump the database definition
*/
static void
! dumpDatabase(Archive *fout, DumpOptions *dopt)
{
PQExpBuffer dbQry = createPQExpBuffer();
PQExpBuffer delQry = createPQExpBuffer();
*************** dumpDatabase(Archive *fout)
*** 2461,2474 ****
{
resetPQExpBuffer(dbQry);
appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname));
! dumpComment(fout, dbQry->data, NULL, "",
dbCatId, 0, dbDumpId);
}
PQclear(res);
/* Dump shared security label. */
! if (!no_security_labels && fout->remoteVersion >= 90200)
{
PQExpBuffer seclabelQry = createPQExpBuffer();
--- 2425,2438 ----
{
resetPQExpBuffer(dbQry);
appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname));
! dumpComment(fout, dopt, dbQry->data, NULL, "",
dbCatId, 0, dbDumpId);
}
PQclear(res);
/* Dump shared security label. */
! if (!dopt->no_security_labels && fout->remoteVersion >= 90200)
{
PQExpBuffer seclabelQry = createPQExpBuffer();
*************** dumpDatabase(Archive *fout)
*** 2489,2495 ****
destroyPQExpBuffer(creaQry);
}
-
/*
* dumpEncoding: put the correct encoding into the archive
*/
--- 2453,2458 ----
*************** getBlobs(Archive *fout)
*** 2629,2635 ****
* dump the definition (metadata) of the given large object
*/
static void
! dumpBlob(Archive *fout, BlobInfo *binfo)
{
PQExpBuffer cquery = createPQExpBuffer();
PQExpBuffer dquery = createPQExpBuffer();
--- 2592,2598 ----
* dump the definition (metadata) of the given large object
*/
static void
! dumpBlob(Archive *fout, DumpOptions* dopt, BlobInfo *binfo)
{
PQExpBuffer cquery = createPQExpBuffer();
PQExpBuffer dquery = createPQExpBuffer();
*************** dumpBlob(Archive *fout, BlobInfo *binfo)
*** 2656,2673 ****
appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name);
/* Dump comment if any */
! dumpComment(fout, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump security label if any */
! dumpSecLabel(fout, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump ACL if any */
if (binfo->blobacl)
! dumpACL(fout, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT",
binfo->dobj.name, NULL, cquery->data,
NULL, binfo->rolname, binfo->blobacl);
--- 2619,2636 ----
appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name);
/* Dump comment if any */
! dumpComment(fout, dopt, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump security label if any */
! dumpSecLabel(fout, dopt, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump ACL if any */
if (binfo->blobacl)
! dumpACL(fout, dopt, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT",
binfo->dobj.name, NULL, cquery->data,
NULL, binfo->rolname, binfo->blobacl);
*************** dumpBlob(Archive *fout, BlobInfo *binfo)
*** 2680,2686 ****
* dump the data contents of all large objects
*/
static int
! dumpBlobs(Archive *fout, void *arg)
{
const char *blobQry;
const char *blobFetchQry;
--- 2643,2649 ----
* dump the data contents of all large objects
*/
static int
! dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg)
{
const char *blobQry;
const char *blobFetchQry;
*************** findNamespace(Archive *fout, Oid nsoid,
*** 3091,3097 ****
* numExtensions is set to the number of extensions read in
*/
ExtensionInfo *
! getExtensions(Archive *fout, int *numExtensions)
{
PGresult *res;
int ntups;
--- 3054,3060 ----
* numExtensions is set to the number of extensions read in
*/
ExtensionInfo *
! getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions)
{
PGresult *res;
int ntups;
*************** getExtensions(Archive *fout, int *numExt
*** 3155,3161 ****
extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition));
/* Decide whether we want to dump it */
! selectDumpableExtension(&(extinfo[i]));
}
PQclear(res);
--- 3118,3124 ----
extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition));
/* Decide whether we want to dump it */
! selectDumpableExtension(dopt, &(extinfo[i]));
}
PQclear(res);
*************** getFuncs(Archive *fout, int *numFuncs)
*** 4268,4274 ****
* numTables is set to the number of tables read in
*/
TableInfo *
! getTables(Archive *fout, int *numTables)
{
PGresult *res;
int ntups;
--- 4231,4237 ----
* numTables is set to the number of tables read in
*/
TableInfo *
! getTables(Archive *fout, DumpOptions *dopt, int *numTables)
{
PGresult *res;
int ntups;
*************** getTables(Archive *fout, int *numTables)
*** 4765,4771 ****
i_toastreloptions = PQfnumber(res, "toast_reloptions");
i_reloftype = PQfnumber(res, "reloftype");
! if (lockWaitTimeout && fout->remoteVersion >= 70300)
{
/*
* Arrange to fail instead of waiting forever for a table lock.
--- 4728,4734 ----
i_toastreloptions = PQfnumber(res, "toast_reloptions");
i_reloftype = PQfnumber(res, "reloftype");
! if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300)
{
/*
* Arrange to fail instead of waiting forever for a table lock.
*************** getTables(Archive *fout, int *numTables)
*** 4776,4782 ****
*/
resetPQExpBuffer(query);
appendPQExpBufferStr(query, "SET statement_timeout = ");
! appendStringLiteralConn(query, lockWaitTimeout, GetConnection(fout));
ExecuteSqlStatement(fout, query->data);
}
--- 4739,4745 ----
*/
resetPQExpBuffer(query);
appendPQExpBufferStr(query, "SET statement_timeout = ");
! appendStringLiteralConn(query, dopt->lockWaitTimeout, GetConnection(fout));
ExecuteSqlStatement(fout, query->data);
}
*************** getTables(Archive *fout, int *numTables)
*** 4871,4877 ****
tblinfo[i].dobj.name);
}
! if (lockWaitTimeout && fout->remoteVersion >= 70300)
{
ExecuteSqlStatement(fout, "SET statement_timeout = 0");
}
--- 4834,4840 ----
tblinfo[i].dobj.name);
}
! if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300)
{
ExecuteSqlStatement(fout, "SET statement_timeout = 0");
}
*************** getForeignServers(Archive *fout, int *nu
*** 7396,7402 ****
* numDefaultACLs is set to the number of ACLs read in
*/
DefaultACLInfo *
! getDefaultACLs(Archive *fout, int *numDefaultACLs)
{
DefaultACLInfo *daclinfo;
PQExpBuffer query;
--- 7359,7365 ----
* numDefaultACLs is set to the number of ACLs read in
*/
DefaultACLInfo *
! getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs)
{
DefaultACLInfo *daclinfo;
PQExpBuffer query;
*************** getDefaultACLs(Archive *fout, int *numDe
*** 7465,7471 ****
daclinfo[i].defaclacl = pg_strdup(PQgetvalue(res, i, i_defaclacl));
/* Decide whether we want to dump it */
! selectDumpableDefaultACL(&(daclinfo[i]));
}
PQclear(res);
--- 7428,7434 ----
daclinfo[i].defaclacl = pg_strdup(PQgetvalue(res, i, i_defaclacl));
/* Decide whether we want to dump it */
! selectDumpableDefaultACL(dopt, &(daclinfo[i]));
}
PQclear(res);
*************** getDefaultACLs(Archive *fout, int *numDe
*** 7494,7500 ****
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpComment(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
--- 7457,7463 ----
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpComment(Archive *fout, DumpOptions *dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
*************** dumpComment(Archive *fout, const char *t
*** 7504,7515 ****
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dataOnly)
return;
}
else
{
! if (schemaOnly)
return;
}
--- 7467,7478 ----
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dopt->dataOnly)
return;
}
else
{
! if (dopt->schemaOnly)
return;
}
*************** dumpComment(Archive *fout, const char *t
*** 7558,7564 ****
* and its columns.
*/
static void
! dumpTableComment(Archive *fout, TableInfo *tbinfo,
const char *reltypename)
{
CommentItem *comments;
--- 7521,7527 ----
* and its columns.
*/
static void
! dumpTableComment(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo,
const char *reltypename)
{
CommentItem *comments;
*************** dumpTableComment(Archive *fout, TableInf
*** 7567,7573 ****
PQExpBuffer target;
/* Comments are SCHEMA not data */
! if (dataOnly)
return;
/* Search for comments associated with relation, using table */
--- 7530,7536 ----
PQExpBuffer target;
/* Comments are SCHEMA not data */
! if (dopt->dataOnly)
return;
/* Search for comments associated with relation, using table */
*************** collectComments(Archive *fout, CommentIt
*** 7812,7919 ****
* ArchiveEntries (TOC objects) for each object to be dumped.
*/
static void
! dumpDumpableObject(Archive *fout, DumpableObject *dobj)
{
switch (dobj->objType)
{
case DO_NAMESPACE:
! dumpNamespace(fout, (NamespaceInfo *) dobj);
break;
case DO_EXTENSION:
! dumpExtension(fout, (ExtensionInfo *) dobj);
break;
case DO_TYPE:
! dumpType(fout, (TypeInfo *) dobj);
break;
case DO_SHELL_TYPE:
! dumpShellType(fout, (ShellTypeInfo *) dobj);
break;
case DO_FUNC:
! dumpFunc(fout, (FuncInfo *) dobj);
break;
case DO_AGG:
! dumpAgg(fout, (AggInfo *) dobj);
break;
case DO_OPERATOR:
! dumpOpr(fout, (OprInfo *) dobj);
break;
case DO_OPCLASS:
! dumpOpclass(fout, (OpclassInfo *) dobj);
break;
case DO_OPFAMILY:
! dumpOpfamily(fout, (OpfamilyInfo *) dobj);
break;
case DO_COLLATION:
! dumpCollation(fout, (CollInfo *) dobj);
break;
case DO_CONVERSION:
! dumpConversion(fout, (ConvInfo *) dobj);
break;
case DO_TABLE:
! dumpTable(fout, (TableInfo *) dobj);
break;
case DO_ATTRDEF:
! dumpAttrDef(fout, (AttrDefInfo *) dobj);
break;
case DO_INDEX:
! dumpIndex(fout, (IndxInfo *) dobj);
break;
case DO_REFRESH_MATVIEW:
refreshMatViewData(fout, (TableDataInfo *) dobj);
break;
case DO_RULE:
! dumpRule(fout, (RuleInfo *) dobj);
break;
case DO_TRIGGER:
! dumpTrigger(fout, (TriggerInfo *) dobj);
break;
case DO_EVENT_TRIGGER:
! dumpEventTrigger(fout, (EventTriggerInfo *) dobj);
break;
case DO_CONSTRAINT:
! dumpConstraint(fout, (ConstraintInfo *) dobj);
break;
case DO_FK_CONSTRAINT:
! dumpConstraint(fout, (ConstraintInfo *) dobj);
break;
case DO_PROCLANG:
! dumpProcLang(fout, (ProcLangInfo *) dobj);
break;
case DO_CAST:
! dumpCast(fout, (CastInfo *) dobj);
break;
case DO_TABLE_DATA:
if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE)
dumpSequenceData(fout, (TableDataInfo *) dobj);
else
! dumpTableData(fout, (TableDataInfo *) dobj);
break;
case DO_DUMMY_TYPE:
/* table rowtypes and array types are never dumped separately */
break;
case DO_TSPARSER:
! dumpTSParser(fout, (TSParserInfo *) dobj);
break;
case DO_TSDICT:
! dumpTSDictionary(fout, (TSDictInfo *) dobj);
break;
case DO_TSTEMPLATE:
! dumpTSTemplate(fout, (TSTemplateInfo *) dobj);
break;
case DO_TSCONFIG:
! dumpTSConfig(fout, (TSConfigInfo *) dobj);
break;
case DO_FDW:
! dumpForeignDataWrapper(fout, (FdwInfo *) dobj);
break;
case DO_FOREIGN_SERVER:
! dumpForeignServer(fout, (ForeignServerInfo *) dobj);
break;
case DO_DEFAULT_ACL:
! dumpDefaultACL(fout, (DefaultACLInfo *) dobj);
break;
case DO_BLOB:
! dumpBlob(fout, (BlobInfo *) dobj);
break;
case DO_BLOB_DATA:
ArchiveEntry(fout, dobj->catId, dobj->dumpId,
--- 7775,7882 ----
* ArchiveEntries (TOC objects) for each object to be dumped.
*/
static void
! dumpDumpableObject(Archive *fout, DumpOptions *dopt, DumpableObject *dobj)
{
switch (dobj->objType)
{
case DO_NAMESPACE:
! dumpNamespace(fout, dopt, (NamespaceInfo *) dobj);
break;
case DO_EXTENSION:
! dumpExtension(fout, dopt, (ExtensionInfo *) dobj);
break;
case DO_TYPE:
! dumpType(fout, dopt, (TypeInfo *) dobj);
break;
case DO_SHELL_TYPE:
! dumpShellType(fout, dopt, (ShellTypeInfo *) dobj);
break;
case DO_FUNC:
! dumpFunc(fout, dopt, (FuncInfo *) dobj);
break;
case DO_AGG:
! dumpAgg(fout, dopt, (AggInfo *) dobj);
break;
case DO_OPERATOR:
! dumpOpr(fout, dopt, (OprInfo *) dobj);
break;
case DO_OPCLASS:
! dumpOpclass(fout, dopt, (OpclassInfo *) dobj);
break;
case DO_OPFAMILY:
! dumpOpfamily(fout, dopt, (OpfamilyInfo *) dobj);
break;
case DO_COLLATION:
! dumpCollation(fout, dopt, (CollInfo *) dobj);
break;
case DO_CONVERSION:
! dumpConversion(fout, dopt, (ConvInfo *) dobj);
break;
case DO_TABLE:
! dumpTable(fout, dopt, (TableInfo *) dobj);
break;
case DO_ATTRDEF:
! dumpAttrDef(fout, dopt, (AttrDefInfo *) dobj);
break;
case DO_INDEX:
! dumpIndex(fout, dopt, (IndxInfo *) dobj);
break;
case DO_REFRESH_MATVIEW:
refreshMatViewData(fout, (TableDataInfo *) dobj);
break;
case DO_RULE:
! dumpRule(fout, dopt, (RuleInfo *) dobj);
break;
case DO_TRIGGER:
! dumpTrigger(fout, dopt, (TriggerInfo *) dobj);
break;
case DO_EVENT_TRIGGER:
! dumpEventTrigger(fout, dopt, (EventTriggerInfo *) dobj);
break;
case DO_CONSTRAINT:
! dumpConstraint(fout, dopt, (ConstraintInfo *) dobj);
break;
case DO_FK_CONSTRAINT:
! dumpConstraint(fout, dopt, (ConstraintInfo *) dobj);
break;
case DO_PROCLANG:
! dumpProcLang(fout, dopt, (ProcLangInfo *) dobj);
break;
case DO_CAST:
! dumpCast(fout, dopt, (CastInfo *) dobj);
break;
case DO_TABLE_DATA:
if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE)
dumpSequenceData(fout, (TableDataInfo *) dobj);
else
! dumpTableData(fout, dopt, (TableDataInfo *) dobj);
break;
case DO_DUMMY_TYPE:
/* table rowtypes and array types are never dumped separately */
break;
case DO_TSPARSER:
! dumpTSParser(fout, dopt, (TSParserInfo *) dobj);
break;
case DO_TSDICT:
! dumpTSDictionary(fout, dopt, (TSDictInfo *) dobj);
break;
case DO_TSTEMPLATE:
! dumpTSTemplate(fout, dopt, (TSTemplateInfo *) dobj);
break;
case DO_TSCONFIG:
! dumpTSConfig(fout, dopt, (TSConfigInfo *) dobj);
break;
case DO_FDW:
! dumpForeignDataWrapper(fout, dopt, (FdwInfo *) dobj);
break;
case DO_FOREIGN_SERVER:
! dumpForeignServer(fout, dopt, (ForeignServerInfo *) dobj);
break;
case DO_DEFAULT_ACL:
! dumpDefaultACL(fout, dopt, (DefaultACLInfo *) dobj);
break;
case DO_BLOB:
! dumpBlob(fout, dopt, (BlobInfo *) dobj);
break;
case DO_BLOB_DATA:
ArchiveEntry(fout, dobj->catId, dobj->dumpId,
*************** dumpDumpableObject(Archive *fout, Dumpab
*** 7935,7941 ****
* writes out to fout the queries to recreate a user-defined namespace
*/
static void
! dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 7898,7904 ----
* writes out to fout the queries to recreate a user-defined namespace
*/
static void
! dumpNamespace(Archive *fout, DumpOptions *dopt, NamespaceInfo *nspinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpNamespace(Archive *fout, NamespaceIn
*** 7943,7949 ****
char *qnspname;
/* Skip if not to be dumped */
! if (!nspinfo->dobj.dump || dataOnly)
return;
/* don't dump dummy namespace from pre-7.3 source */
--- 7906,7912 ----
char *qnspname;
/* Skip if not to be dumped */
! if (!nspinfo->dobj.dump || dopt->dataOnly)
return;
/* don't dump dummy namespace from pre-7.3 source */
*************** dumpNamespace(Archive *fout, NamespaceIn
*** 7975,7988 ****
NULL, NULL);
/* Dump Schema Comments and Security Labels */
! dumpComment(fout, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
qnspname, NULL, nspinfo->dobj.name, NULL,
nspinfo->rolname, nspinfo->nspacl);
--- 7938,7951 ----
NULL, NULL);
/* Dump Schema Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpACL(fout, dopt, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
qnspname, NULL, nspinfo->dobj.name, NULL,
nspinfo->rolname, nspinfo->nspacl);
*************** dumpNamespace(Archive *fout, NamespaceIn
*** 7998,8004 ****
* writes out to fout the queries to recreate an extension
*/
static void
! dumpExtension(Archive *fout, ExtensionInfo *extinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 7961,7967 ----
* writes out to fout the queries to recreate an extension
*/
static void
! dumpExtension(Archive *fout, DumpOptions *dopt, ExtensionInfo *extinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpExtension(Archive *fout, ExtensionIn
*** 8006,8012 ****
char *qextname;
/* Skip if not to be dumped */
! if (!extinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 7969,7975 ----
char *qextname;
/* Skip if not to be dumped */
! if (!extinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpExtension(Archive *fout, ExtensionIn
*** 8103,8112 ****
NULL, NULL);
/* Dump Extension Comments and Security Labels */
! dumpComment(fout, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
--- 8066,8075 ----
NULL, NULL);
/* Dump Extension Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
*************** dumpExtension(Archive *fout, ExtensionIn
*** 8122,8144 ****
* writes out to fout the queries to recreate a user-defined type
*/
static void
! dumpType(Archive *fout, TypeInfo *tyinfo)
{
/* Skip if not to be dumped */
! if (!tyinfo->dobj.dump || dataOnly)
return;
/* Dump out in proper style */
if (tyinfo->typtype == TYPTYPE_BASE)
! dumpBaseType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_DOMAIN)
! dumpDomain(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_COMPOSITE)
! dumpCompositeType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_ENUM)
! dumpEnumType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_RANGE)
! dumpRangeType(fout, tyinfo);
else
write_msg(NULL, "WARNING: typtype of data type \"%s\" appears to be invalid\n",
tyinfo->dobj.name);
--- 8085,8107 ----
* writes out to fout the queries to recreate a user-defined type
*/
static void
! dumpType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
/* Skip if not to be dumped */
! if (!tyinfo->dobj.dump || dopt->dataOnly)
return;
/* Dump out in proper style */
if (tyinfo->typtype == TYPTYPE_BASE)
! dumpBaseType(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_DOMAIN)
! dumpDomain(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_COMPOSITE)
! dumpCompositeType(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_ENUM)
! dumpEnumType(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_RANGE)
! dumpRangeType(fout, dopt, tyinfo);
else
write_msg(NULL, "WARNING: typtype of data type \"%s\" appears to be invalid\n",
tyinfo->dobj.name);
*************** dumpType(Archive *fout, TypeInfo *tyinfo
*** 8149,8155 ****
* writes out to fout the queries to recreate a user-defined enum type
*/
static void
! dumpEnumType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8112,8118 ----
* writes out to fout the queries to recreate a user-defined enum type
*/
static void
! dumpEnumType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpEnumType(Archive *fout, TypeInfo *ty
*** 8254,8267 ****
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8217,8230 ----
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpEnumType(Archive *fout, TypeInfo *ty
*** 8278,8284 ****
* writes out to fout the queries to recreate a user-defined range type
*/
static void
! dumpRangeType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8241,8247 ----
* writes out to fout the queries to recreate a user-defined range type
*/
static void
! dumpRangeType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpRangeType(Archive *fout, TypeInfo *t
*** 8386,8399 ****
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8349,8362 ----
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpRangeType(Archive *fout, TypeInfo *t
*** 8410,8416 ****
* writes out to fout the queries to recreate a user-defined base type
*/
static void
! dumpBaseType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8373,8379 ----
* writes out to fout the queries to recreate a user-defined base type
*/
static void
! dumpBaseType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpBaseType(Archive *fout, TypeInfo *ty
*** 8776,8789 ****
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8739,8752 ----
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpBaseType(Archive *fout, TypeInfo *ty
*** 8800,8806 ****
* writes out to fout the queries to recreate a user-defined domain
*/
static void
! dumpDomain(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8763,8769 ----
* writes out to fout the queries to recreate a user-defined domain
*/
static void
! dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpDomain(Archive *fout, TypeInfo *tyin
*** 8938,8951 ****
NULL, NULL);
/* Dump Domain Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8901,8914 ----
NULL, NULL);
/* Dump Domain Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpDomain(Archive *fout, TypeInfo *tyin
*** 8962,8968 ****
* composite type
*/
static void
! dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer dropped = createPQExpBuffer();
--- 8925,8931 ----
* composite type
*/
static void
! dumpCompositeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer dropped = createPQExpBuffer();
*************** dumpCompositeType(Archive *fout, TypeInf
*** 9153,9166 ****
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 9116,9129 ----
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpCompositeTypeColComments(Archive *fo
*** 9291,9302 ****
* We dump a shell definition in advance of the I/O functions for the type.
*/
static void
! dumpShellType(Archive *fout, ShellTypeInfo *stinfo)
{
PQExpBuffer q;
/* Skip if not to be dumped */
! if (!stinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 9254,9265 ----
* We dump a shell definition in advance of the I/O functions for the type.
*/
static void
! dumpShellType(Archive *fout, DumpOptions *dopt, ShellTypeInfo *stinfo)
{
PQExpBuffer q;
/* Skip if not to be dumped */
! if (!stinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpShellType(Archive *fout, ShellTypeIn
*** 9346,9357 ****
* That case isn't checked here either.
*/
static bool
! shouldDumpProcLangs(void)
{
! if (!include_everything)
return false;
/* And they're schema not data */
! if (dataOnly)
return false;
return true;
}
--- 9309,9320 ----
* That case isn't checked here either.
*/
static bool
! shouldDumpProcLangs(DumpOptions *dopt)
{
! if (!dopt->include_everything)
return false;
/* And they're schema not data */
! if (dopt->dataOnly)
return false;
return true;
}
*************** shouldDumpProcLangs(void)
*** 9362,9368 ****
* procedural language
*/
static void
! dumpProcLang(Archive *fout, ProcLangInfo *plang)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
--- 9325,9331 ----
* procedural language
*/
static void
! dumpProcLang(Archive *fout, DumpOptions* dopt, ProcLangInfo *plang)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
*************** dumpProcLang(Archive *fout, ProcLangInfo
*** 9375,9381 ****
FuncInfo *validatorInfo = NULL;
/* Skip if not to be dumped */
! if (!plang->dobj.dump || dataOnly)
return;
/*
--- 9338,9344 ----
FuncInfo *validatorInfo = NULL;
/* Skip if not to be dumped */
! if (!plang->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpProcLang(Archive *fout, ProcLangInfo
*** 9421,9427 ****
if (!plang->dobj.ext_member)
{
! if (!useParams && !shouldDumpProcLangs())
return;
}
--- 9384,9390 ----
if (!plang->dobj.ext_member)
{
! if (!useParams && !shouldDumpProcLangs(dopt))
return;
}
*************** dumpProcLang(Archive *fout, ProcLangInfo
*** 9500,9514 ****
NULL, NULL);
/* Dump Proc Lang Comments and Security Labels */
! dumpComment(fout, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
if (plang->lanpltrusted)
! dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
qlanname, NULL, plang->dobj.name,
lanschema,
plang->lanowner, plang->lanacl);
--- 9463,9477 ----
NULL, NULL);
/* Dump Proc Lang Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
if (plang->lanpltrusted)
! dumpACL(fout, dopt, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
qlanname, NULL, plang->dobj.name,
lanschema,
plang->lanowner, plang->lanacl);
*************** format_function_signature(Archive *fout,
*** 9655,9661 ****
* dump out one function
*/
static void
! dumpFunc(Archive *fout, FuncInfo *finfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 9618,9624 ----
* dump out one function
*/
static void
! dumpFunc(Archive *fout, DumpOptions* dopt, FuncInfo *finfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 9694,9700 ****
int i;
/* Skip if not to be dumped */
! if (!finfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 9657,9663 ----
int i;
/* Skip if not to be dumped */
! if (!finfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 9887,9893 ****
* where we have bin, use dollar quoting if allowed and src
* contains quote or backslash; else use regular quoting.
*/
! if (disable_dollar_quoting ||
(strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL))
appendStringLiteralAH(asPart, prosrc, fout);
else
--- 9850,9856 ----
* where we have bin, use dollar quoting if allowed and src
* contains quote or backslash; else use regular quoting.
*/
! if (dopt->disable_dollar_quoting ||
(strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL))
appendStringLiteralAH(asPart, prosrc, fout);
else
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 9900,9906 ****
{
appendPQExpBufferStr(asPart, "AS ");
/* with no bin, dollar quote src unconditionally if allowed */
! if (disable_dollar_quoting)
appendStringLiteralAH(asPart, prosrc, fout);
else
appendStringLiteralDQ(asPart, prosrc, NULL);
--- 9863,9869 ----
{
appendPQExpBufferStr(asPart, "AS ");
/* with no bin, dollar quote src unconditionally if allowed */
! if (dopt->disable_dollar_quoting)
appendStringLiteralAH(asPart, prosrc, fout);
else
appendStringLiteralDQ(asPart, prosrc, NULL);
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 10090,10103 ****
NULL, NULL);
/* Dump Function Comments and Security Labels */
! dumpComment(fout, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, NULL, funcsig_tag,
finfo->dobj.namespace->dobj.name,
finfo->rolname, finfo->proacl);
--- 10053,10066 ----
NULL, NULL);
/* Dump Function Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpACL(fout, dopt, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, NULL, funcsig_tag,
finfo->dobj.namespace->dobj.name,
finfo->rolname, finfo->proacl);
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 10128,10134 ****
* Dump a user-defined cast
*/
static void
! dumpCast(Archive *fout, CastInfo *cast)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
--- 10091,10097 ----
* Dump a user-defined cast
*/
static void
! dumpCast(Archive *fout, DumpOptions* dopt, CastInfo *cast)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
*************** dumpCast(Archive *fout, CastInfo *cast)
*** 10136,10142 ****
FuncInfo *funcInfo = NULL;
/* Skip if not to be dumped */
! if (!cast->dobj.dump || dataOnly)
return;
/* Cannot dump if we don't have the cast function's info */
--- 10099,10105 ----
FuncInfo *funcInfo = NULL;
/* Skip if not to be dumped */
! if (!cast->dobj.dump || dopt->dataOnly)
return;
/* Cannot dump if we don't have the cast function's info */
*************** dumpCast(Archive *fout, CastInfo *cast)
*** 10262,10268 ****
NULL, NULL);
/* Dump Cast Comments */
! dumpComment(fout, labelq->data,
NULL, "",
cast->dobj.catId, 0, cast->dobj.dumpId);
--- 10225,10231 ----
NULL, NULL);
/* Dump Cast Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
cast->dobj.catId, 0, cast->dobj.dumpId);
*************** dumpCast(Archive *fout, CastInfo *cast)
*** 10276,10282 ****
* write out a single operator definition
*/
static void
! dumpOpr(Archive *fout, OprInfo *oprinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 10239,10245 ----
* write out a single operator definition
*/
static void
! dumpOpr(Archive *fout, DumpOptions* dopt, OprInfo *oprinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpOpr(Archive *fout, OprInfo *oprinfo)
*** 10310,10316 ****
char *oprref;
/* Skip if not to be dumped */
! if (!oprinfo->dobj.dump || dataOnly)
return;
/*
--- 10273,10279 ----
char *oprref;
/* Skip if not to be dumped */
! if (!oprinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpOpr(Archive *fout, OprInfo *oprinfo)
*** 10514,10520 ****
NULL, NULL);
/* Dump Operator Comments */
! dumpComment(fout, labelq->data,
oprinfo->dobj.namespace->dobj.name, oprinfo->rolname,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
--- 10477,10483 ----
NULL, NULL);
/* Dump Operator Comments */
! dumpComment(fout, dopt, labelq->data,
oprinfo->dobj.namespace->dobj.name, oprinfo->rolname,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
*************** convertTSFunction(Archive *fout, Oid fun
*** 10664,10670 ****
* write out a single operator class definition
*/
static void
! dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 10627,10633 ----
* write out a single operator class definition
*/
static void
! dumpOpclass(Archive *fout, DumpOptions* dopt, OpclassInfo *opcinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpOpclass(Archive *fout, OpclassInfo *
*** 10708,10714 ****
int i;
/* Skip if not to be dumped */
! if (!opcinfo->dobj.dump || dataOnly)
return;
/*
--- 10671,10677 ----
int i;
/* Skip if not to be dumped */
! if (!opcinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpOpclass(Archive *fout, OpclassInfo *
*** 11022,11028 ****
NULL, NULL);
/* Dump Operator Class Comments */
! dumpComment(fout, labelq->data,
NULL, opcinfo->rolname,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
--- 10985,10991 ----
NULL, NULL);
/* Dump Operator Class Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, opcinfo->rolname,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
*************** dumpOpclass(Archive *fout, OpclassInfo *
*** 11041,11047 ****
* specific opclass within the opfamily.
*/
static void
! dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11004,11010 ----
* specific opclass within the opfamily.
*/
static void
! dumpOpfamily(Archive *fout, DumpOptions* dopt, OpfamilyInfo *opfinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpOpfamily(Archive *fout, OpfamilyInfo
*** 11075,11081 ****
int i;
/* Skip if not to be dumped */
! if (!opfinfo->dobj.dump || dataOnly)
return;
/*
--- 11038,11044 ----
int i;
/* Skip if not to be dumped */
! if (!opfinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpOpfamily(Archive *fout, OpfamilyInfo
*** 11335,11341 ****
NULL, NULL);
/* Dump Operator Family Comments */
! dumpComment(fout, labelq->data,
NULL, opfinfo->rolname,
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
--- 11298,11304 ----
NULL, NULL);
/* Dump Operator Family Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, opfinfo->rolname,
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
*************** dumpOpfamily(Archive *fout, OpfamilyInfo
*** 11353,11359 ****
* write out a single collation definition
*/
static void
! dumpCollation(Archive *fout, CollInfo *collinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11316,11322 ----
* write out a single collation definition
*/
static void
! dumpCollation(Archive *fout, DumpOptions* dopt, CollInfo *collinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpCollation(Archive *fout, CollInfo *c
*** 11366,11372 ****
const char *collctype;
/* Skip if not to be dumped */
! if (!collinfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 11329,11335 ----
const char *collctype;
/* Skip if not to be dumped */
! if (!collinfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpCollation(Archive *fout, CollInfo *c
*** 11424,11430 ****
NULL, NULL);
/* Dump Collation Comments */
! dumpComment(fout, labelq->data,
collinfo->dobj.namespace->dobj.name, collinfo->rolname,
collinfo->dobj.catId, 0, collinfo->dobj.dumpId);
--- 11387,11393 ----
NULL, NULL);
/* Dump Collation Comments */
! dumpComment(fout, dopt, labelq->data,
collinfo->dobj.namespace->dobj.name, collinfo->rolname,
collinfo->dobj.catId, 0, collinfo->dobj.dumpId);
*************** dumpCollation(Archive *fout, CollInfo *c
*** 11441,11447 ****
* write out a single conversion definition
*/
static void
! dumpConversion(Archive *fout, ConvInfo *convinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11404,11410 ----
* write out a single conversion definition
*/
static void
! dumpConversion(Archive *fout, DumpOptions* dopt, ConvInfo *convinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpConversion(Archive *fout, ConvInfo *
*** 11458,11464 ****
bool condefault;
/* Skip if not to be dumped */
! if (!convinfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 11421,11427 ----
bool condefault;
/* Skip if not to be dumped */
! if (!convinfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpConversion(Archive *fout, ConvInfo *
*** 11523,11529 ****
NULL, NULL);
/* Dump Conversion Comments */
! dumpComment(fout, labelq->data,
convinfo->dobj.namespace->dobj.name, convinfo->rolname,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
--- 11486,11492 ----
NULL, NULL);
/* Dump Conversion Comments */
! dumpComment(fout, dopt, labelq->data,
convinfo->dobj.namespace->dobj.name, convinfo->rolname,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
*************** format_aggregate_signature(AggInfo *aggi
*** 11580,11586 ****
* write out a single aggregate definition
*/
static void
! dumpAgg(Archive *fout, AggInfo *agginfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11543,11549 ----
* write out a single aggregate definition
*/
static void
! dumpAgg(Archive *fout, DumpOptions* dopt, AggInfo *agginfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11626,11632 ****
bool convertok;
/* Skip if not to be dumped */
! if (!agginfo->aggfn.dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 11589,11595 ----
bool convertok;
/* Skip if not to be dumped */
! if (!agginfo->aggfn.dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11919,11928 ****
NULL, NULL);
/* Dump Aggregate Comments */
! dumpComment(fout, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
--- 11882,11891 ----
NULL, NULL);
/* Dump Aggregate Comments */
! dumpComment(fout, dopt, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11937,11943 ****
aggsig = format_function_signature(fout, &agginfo->aggfn, true);
aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false);
! dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
"FUNCTION",
aggsig, NULL, aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
--- 11900,11906 ----
aggsig = format_function_signature(fout, &agginfo->aggfn, true);
aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false);
! dumpACL(fout, dopt, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
"FUNCTION",
aggsig, NULL, aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11962,11975 ****
* write out a single text search parser
*/
static void
! dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!prsinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 11925,11938 ----
* write out a single text search parser
*/
static void
! dumpTSParser(Archive *fout, DumpOptions* dopt, TSParserInfo *prsinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!prsinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSParser(Archive *fout, TSParserInfo
*** 12019,12025 ****
NULL, NULL);
/* Dump Parser Comments */
! dumpComment(fout, labelq->data,
NULL, "",
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
--- 11982,11988 ----
NULL, NULL);
/* Dump Parser Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
*************** dumpTSParser(Archive *fout, TSParserInfo
*** 12033,12039 ****
* write out a single text search dictionary
*/
static void
! dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 11996,12002 ----
* write out a single text search dictionary
*/
static void
! dumpTSDictionary(Archive *fout, DumpOptions* dopt, TSDictInfo *dictinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpTSDictionary(Archive *fout, TSDictIn
*** 12044,12050 ****
char *tmplname;
/* Skip if not to be dumped */
! if (!dictinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 12007,12013 ----
char *tmplname;
/* Skip if not to be dumped */
! if (!dictinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSDictionary(Archive *fout, TSDictIn
*** 12106,12112 ****
NULL, NULL);
/* Dump Dictionary Comments */
! dumpComment(fout, labelq->data,
NULL, dictinfo->rolname,
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
--- 12069,12075 ----
NULL, NULL);
/* Dump Dictionary Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, dictinfo->rolname,
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
*************** dumpTSDictionary(Archive *fout, TSDictIn
*** 12121,12134 ****
* write out a single text search template
*/
static void
! dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!tmplinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 12084,12097 ----
* write out a single text search template
*/
static void
! dumpTSTemplate(Archive *fout, DumpOptions* dopt, TSTemplateInfo *tmplinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!tmplinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSTemplate(Archive *fout, TSTemplate
*** 12172,12178 ****
NULL, NULL);
/* Dump Template Comments */
! dumpComment(fout, labelq->data,
NULL, "",
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
--- 12135,12141 ----
NULL, NULL);
/* Dump Template Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
*************** dumpTSTemplate(Archive *fout, TSTemplate
*** 12186,12192 ****
* write out a single text search configuration
*/
static void
! dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12149,12155 ----
* write out a single text search configuration
*/
static void
! dumpTSConfig(Archive *fout, DumpOptions* dopt, TSConfigInfo *cfginfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpTSConfig(Archive *fout, TSConfigInfo
*** 12201,12207 ****
int i_dictname;
/* Skip if not to be dumped */
! if (!cfginfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 12164,12170 ----
int i_dictname;
/* Skip if not to be dumped */
! if (!cfginfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSConfig(Archive *fout, TSConfigInfo
*** 12300,12306 ****
NULL, NULL);
/* Dump Configuration Comments */
! dumpComment(fout, labelq->data,
NULL, cfginfo->rolname,
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
--- 12263,12269 ----
NULL, NULL);
/* Dump Configuration Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, cfginfo->rolname,
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
*************** dumpTSConfig(Archive *fout, TSConfigInfo
*** 12315,12321 ****
* write out a single foreign-data wrapper definition
*/
static void
! dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12278,12284 ----
* write out a single foreign-data wrapper definition
*/
static void
! dumpForeignDataWrapper(Archive *fout, DumpOptions* dopt, FdwInfo *fdwinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12323,12329 ****
char *qfdwname;
/* Skip if not to be dumped */
! if (!fdwinfo->dobj.dump || dataOnly)
return;
/*
--- 12286,12292 ----
char *qfdwname;
/* Skip if not to be dumped */
! if (!fdwinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12331,12337 ****
* field. Otherwise omit them if we are only dumping some specific object.
*/
if (!fdwinfo->dobj.ext_member)
! if (!include_everything)
return;
q = createPQExpBuffer();
--- 12294,12300 ----
* field. Otherwise omit them if we are only dumping some specific object.
*/
if (!fdwinfo->dobj.ext_member)
! if (!dopt->include_everything)
return;
q = createPQExpBuffer();
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12374,12387 ****
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
"FOREIGN DATA WRAPPER",
qfdwname, NULL, fdwinfo->dobj.name,
NULL, fdwinfo->rolname,
fdwinfo->fdwacl);
/* Dump Foreign Data Wrapper Comments */
! dumpComment(fout, labelq->data,
NULL, fdwinfo->rolname,
fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId);
--- 12337,12350 ----
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, dopt, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
"FOREIGN DATA WRAPPER",
qfdwname, NULL, fdwinfo->dobj.name,
NULL, fdwinfo->rolname,
fdwinfo->fdwacl);
/* Dump Foreign Data Wrapper Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, fdwinfo->rolname,
fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId);
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12397,12403 ****
* write out a foreign server definition
*/
static void
! dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12360,12366 ----
* write out a foreign server definition
*/
static void
! dumpForeignServer(Archive *fout, DumpOptions* dopt, ForeignServerInfo *srvinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpForeignServer(Archive *fout, Foreign
*** 12408,12414 ****
char *fdwname;
/* Skip if not to be dumped */
! if (!srvinfo->dobj.dump || dataOnly || !include_everything)
return;
q = createPQExpBuffer();
--- 12371,12377 ----
char *fdwname;
/* Skip if not to be dumped */
! if (!srvinfo->dobj.dump || dopt->dataOnly || !dopt->include_everything)
return;
q = createPQExpBuffer();
*************** dumpForeignServer(Archive *fout, Foreign
*** 12466,12472 ****
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
"FOREIGN SERVER",
qsrvname, NULL, srvinfo->dobj.name,
NULL, srvinfo->rolname,
--- 12429,12435 ----
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, dopt, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
"FOREIGN SERVER",
qsrvname, NULL, srvinfo->dobj.name,
NULL, srvinfo->rolname,
*************** dumpForeignServer(Archive *fout, Foreign
*** 12479,12485 ****
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
/* Dump Foreign Server Comments */
! dumpComment(fout, labelq->data,
NULL, srvinfo->rolname,
srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId);
--- 12442,12448 ----
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
/* Dump Foreign Server Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, srvinfo->rolname,
srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId);
*************** dumpUserMappings(Archive *fout,
*** 12595,12608 ****
* Write out default privileges information
*/
static void
! dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo)
{
PQExpBuffer q;
PQExpBuffer tag;
const char *type;
/* Skip if not to be dumped */
! if (!daclinfo->dobj.dump || dataOnly || aclsSkip)
return;
q = createPQExpBuffer();
--- 12558,12571 ----
* Write out default privileges information
*/
static void
! dumpDefaultACL(Archive *fout, DumpOptions *dopt, DefaultACLInfo *daclinfo)
{
PQExpBuffer q;
PQExpBuffer tag;
const char *type;
/* Skip if not to be dumped */
! if (!daclinfo->dobj.dump || dopt->dataOnly || dopt->aclsSkip)
return;
q = createPQExpBuffer();
*************** dumpDefaultACL(Archive *fout, DefaultACL
*** 12675,12681 ****
*----------
*/
static void
! dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls)
--- 12638,12644 ----
*----------
*/
static void
! dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls)
*************** dumpACL(Archive *fout, CatalogId objCatI
*** 12683,12693 ****
PQExpBuffer sql;
/* Do nothing if ACL dump is not enabled */
! if (aclsSkip)
return;
/* --data-only skips ACLs *except* BLOB ACLs */
! if (dataOnly && strcmp(type, "LARGE OBJECT") != 0)
return;
sql = createPQExpBuffer();
--- 12646,12656 ----
PQExpBuffer sql;
/* Do nothing if ACL dump is not enabled */
! if (dopt->aclsSkip)
return;
/* --data-only skips ACLs *except* BLOB ACLs */
! if (dopt->dataOnly && strcmp(type, "LARGE OBJECT") != 0)
return;
sql = createPQExpBuffer();
*************** dumpACL(Archive *fout, CatalogId objCatI
*** 12730,12736 ****
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpSecLabel(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
--- 12693,12699 ----
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpSecLabel(Archive *fout, DumpOptions* dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
*************** dumpSecLabel(Archive *fout, const char *
*** 12740,12757 ****
PQExpBuffer query;
/* do nothing, if --no-security-labels is supplied */
! if (no_security_labels)
return;
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dataOnly)
return;
}
else
{
! if (schemaOnly)
return;
}
--- 12703,12720 ----
PQExpBuffer query;
/* do nothing, if --no-security-labels is supplied */
! if (dopt->no_security_labels)
return;
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dopt->dataOnly)
return;
}
else
{
! if (dopt->schemaOnly)
return;
}
*************** dumpSecLabel(Archive *fout, const char *
*** 12794,12800 ****
* and its columns.
*/
static void
! dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename)
{
SecLabelItem *labels;
int nlabels;
--- 12757,12763 ----
* and its columns.
*/
static void
! dumpTableSecLabel(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, const char *reltypename)
{
SecLabelItem *labels;
int nlabels;
*************** dumpTableSecLabel(Archive *fout, TableIn
*** 12803,12813 ****
PQExpBuffer target;
/* do nothing, if --no-security-labels is supplied */
! if (no_security_labels)
return;
/* SecLabel are SCHEMA not data */
! if (dataOnly)
return;
/* Search for comments associated with relation, using table */
--- 12766,12776 ----
PQExpBuffer target;
/* do nothing, if --no-security-labels is supplied */
! if (dopt->no_security_labels)
return;
/* SecLabel are SCHEMA not data */
! if (dopt->dataOnly)
return;
/* Search for comments associated with relation, using table */
*************** collectSecLabels(Archive *fout, SecLabel
*** 13015,13034 ****
* write out to fout the declarations (not data) of a user-defined table
*/
static void
! dumpTable(Archive *fout, TableInfo *tbinfo)
{
! if (tbinfo->dobj.dump && !dataOnly)
{
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
! dumpSequence(fout, tbinfo);
else
! dumpTableSchema(fout, tbinfo);
/* Handle the ACL here */
namecopy = pg_strdup(fmtId(tbinfo->dobj.name));
! dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
(tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" :
"TABLE",
namecopy, NULL, tbinfo->dobj.name,
--- 12978,12997 ----
* write out to fout the declarations (not data) of a user-defined table
*/
static void
! dumpTable(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
{
! if (tbinfo->dobj.dump && !dopt->dataOnly)
{
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
! dumpSequence(fout, dopt, tbinfo);
else
! dumpTableSchema(fout, dopt, tbinfo);
/* Handle the ACL here */
namecopy = pg_strdup(fmtId(tbinfo->dobj.name));
! dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
(tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" :
"TABLE",
namecopy, NULL, tbinfo->dobj.name,
*************** dumpTable(Archive *fout, TableInfo *tbin
*** 13063,13069 ****
attnamecopy = pg_strdup(fmtId(attname));
acltag = psprintf("%s.%s", tbinfo->dobj.name, attname);
/* Column's GRANT type is always TABLE */
! dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
namecopy, attnamecopy, acltag,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
attacl);
--- 13026,13032 ----
attnamecopy = pg_strdup(fmtId(attname));
acltag = psprintf("%s.%s", tbinfo->dobj.name, attname);
/* Column's GRANT type is always TABLE */
! dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
namecopy, attnamecopy, acltag,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
attacl);
*************** createViewAsClause(Archive *fout, TableI
*** 13140,13146 ****
* write the declaration (not data) of one user-defined table or view
*/
static void
! dumpTableSchema(Archive *fout, TableInfo *tbinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 13103,13109 ----
* write the declaration (not data) of one user-defined table or view
*/
static void
! dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13753,13762 ****
/* Dump Table Comments */
! dumpTableComment(fout, tbinfo, reltypename);
/* Dump Table Security Labels */
! dumpTableSecLabel(fout, tbinfo, reltypename);
/* Dump comments on inlined table constraints */
for (j = 0; j < tbinfo->ncheck; j++)
--- 13716,13725 ----
/* Dump Table Comments */
! dumpTableComment(fout, dopt, tbinfo, reltypename);
/* Dump Table Security Labels */
! dumpTableSecLabel(fout, dopt, tbinfo, reltypename);
/* Dump comments on inlined table constraints */
for (j = 0; j < tbinfo->ncheck; j++)
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13766,13772 ****
if (constr->separate || !constr->conislocal)
continue;
! dumpTableConstraintComment(fout, constr);
}
destroyPQExpBuffer(q);
--- 13729,13735 ----
if (constr->separate || !constr->conislocal)
continue;
! dumpTableConstraintComment(fout, dopt, constr);
}
destroyPQExpBuffer(q);
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13778,13784 ****
* dumpAttrDef --- dump an attribute's default-value declaration
*/
static void
! dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
{
TableInfo *tbinfo = adinfo->adtable;
int adnum = adinfo->adnum;
--- 13741,13747 ----
* dumpAttrDef --- dump an attribute's default-value declaration
*/
static void
! dumpAttrDef(Archive *fout, DumpOptions *dopt, AttrDefInfo *adinfo)
{
TableInfo *tbinfo = adinfo->adtable;
int adnum = adinfo->adnum;
*************** dumpAttrDef(Archive *fout, AttrDefInfo *
*** 13786,13792 ****
PQExpBuffer delq;
/* Skip if table definition not to be dumped */
! if (!tbinfo->dobj.dump || dataOnly)
return;
/* Skip if not "separate"; it was dumped in the table's definition */
--- 13749,13755 ----
PQExpBuffer delq;
/* Skip if table definition not to be dumped */
! if (!tbinfo->dobj.dump || dopt->dataOnly)
return;
/* Skip if not "separate"; it was dumped in the table's definition */
*************** getAttrName(int attrnum, TableInfo *tblI
*** 13865,13871 ****
* write out to fout a user-defined index
*/
static void
! dumpIndex(Archive *fout, IndxInfo *indxinfo)
{
TableInfo *tbinfo = indxinfo->indextable;
bool is_constraint = (indxinfo->indexconstraint != 0);
--- 13828,13834 ----
* write out to fout a user-defined index
*/
static void
! dumpIndex(Archive *fout, DumpOptions* dopt, IndxInfo *indxinfo)
{
TableInfo *tbinfo = indxinfo->indextable;
bool is_constraint = (indxinfo->indexconstraint != 0);
*************** dumpIndex(Archive *fout, IndxInfo *indxi
*** 13873,13879 ****
PQExpBuffer delq;
PQExpBuffer labelq;
! if (dataOnly)
return;
q = createPQExpBuffer();
--- 13836,13842 ----
PQExpBuffer delq;
PQExpBuffer labelq;
! if (dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpIndex(Archive *fout, IndxInfo *indxi
*** 13938,13944 ****
}
/* Dump Index Comments */
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
indxinfo->dobj.catId, 0,
--- 13901,13907 ----
}
/* Dump Index Comments */
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
indxinfo->dobj.catId, 0,
*************** dumpIndex(Archive *fout, IndxInfo *indxi
*** 13955,13968 ****
* write out to fout a user-defined constraint
*/
static void
! dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer q;
PQExpBuffer delq;
/* Skip if not to be dumped */
! if (!coninfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 13918,13931 ----
* write out to fout a user-defined constraint
*/
static void
! dumpConstraint(Archive *fout, DumpOptions *dopt, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer q;
PQExpBuffer delq;
/* Skip if not to be dumped */
! if (!coninfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpConstraint(Archive *fout, Constraint
*** 14172,14178 ****
/* Dump Constraint Comments --- only works for table constraints */
if (tbinfo && coninfo->separate)
! dumpTableConstraintComment(fout, coninfo);
destroyPQExpBuffer(q);
destroyPQExpBuffer(delq);
--- 14135,14141 ----
/* Dump Constraint Comments --- only works for table constraints */
if (tbinfo && coninfo->separate)
! dumpTableConstraintComment(fout, dopt, coninfo);
destroyPQExpBuffer(q);
destroyPQExpBuffer(delq);
*************** dumpConstraint(Archive *fout, Constraint
*** 14186,14192 ****
* or as a separate ALTER command.
*/
static void
! dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer labelq = createPQExpBuffer();
--- 14149,14155 ----
* or as a separate ALTER command.
*/
static void
! dumpTableConstraintComment(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer labelq = createPQExpBuffer();
*************** dumpTableConstraintComment(Archive *fout
*** 14195,14201 ****
fmtId(coninfo->dobj.name));
appendPQExpBuffer(labelq, "ON %s",
fmtId(tbinfo->dobj.name));
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
coninfo->dobj.catId, 0,
--- 14158,14164 ----
fmtId(coninfo->dobj.name));
appendPQExpBuffer(labelq, "ON %s",
fmtId(tbinfo->dobj.name));
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
coninfo->dobj.catId, 0,
*************** findLastBuiltinOid_V70(Archive *fout)
*** 14255,14261 ****
* write the declaration (not data) of one user-defined sequence
*/
static void
! dumpSequence(Archive *fout, TableInfo *tbinfo)
{
PGresult *res;
char *startv,
--- 14218,14224 ----
* write the declaration (not data) of one user-defined sequence
*/
static void
! dumpSequence(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo)
{
PGresult *res;
char *startv,
*************** dumpSequence(Archive *fout, TableInfo *t
*** 14441,14450 ****
}
/* Dump Sequence Comments and Security Labels */
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
--- 14404,14413 ----
}
/* Dump Sequence Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
*************** dumpSequenceData(Archive *fout, TableDat
*** 14515,14521 ****
* write the declaration of one user-defined table trigger
*/
static void
! dumpTrigger(Archive *fout, TriggerInfo *tginfo)
{
TableInfo *tbinfo = tginfo->tgtable;
PQExpBuffer query;
--- 14478,14484 ----
* write the declaration of one user-defined table trigger
*/
static void
! dumpTrigger(Archive *fout, DumpOptions* dopt, TriggerInfo *tginfo)
{
TableInfo *tbinfo = tginfo->tgtable;
PQExpBuffer query;
*************** dumpTrigger(Archive *fout, TriggerInfo *
*** 14530,14536 ****
* we needn't check dobj.dump because TriggerInfo wouldn't have been
* created in the first place for non-dumpable triggers
*/
! if (dataOnly)
return;
query = createPQExpBuffer();
--- 14493,14499 ----
* we needn't check dobj.dump because TriggerInfo wouldn't have been
* created in the first place for non-dumpable triggers
*/
! if (dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpTrigger(Archive *fout, TriggerInfo *
*** 14711,14717 ****
NULL, 0,
NULL, NULL);
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
--- 14674,14680 ----
NULL, 0,
NULL, NULL);
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
*************** dumpTrigger(Archive *fout, TriggerInfo *
*** 14725,14737 ****
* write the declaration of one user-defined event trigger
*/
static void
! dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
{
PQExpBuffer query;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!evtinfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 14688,14700 ----
* write the declaration of one user-defined event trigger
*/
static void
! dumpEventTrigger(Archive *fout, DumpOptions* dopt, EventTriggerInfo *evtinfo)
{
PQExpBuffer query;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!evtinfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpEventTrigger(Archive *fout, EventTri
*** 14783,14789 ****
"EVENT TRIGGER", SECTION_POST_DATA,
query->data, "", NULL, NULL, 0, NULL, NULL);
! dumpComment(fout, labelq->data,
NULL, NULL,
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
--- 14746,14752 ----
"EVENT TRIGGER", SECTION_POST_DATA,
query->data, "", NULL, NULL, 0, NULL, NULL);
! dumpComment(fout, dopt, labelq->data,
NULL, NULL,
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
*************** dumpEventTrigger(Archive *fout, EventTri
*** 14796,14802 ****
* Dump a rule
*/
static void
! dumpRule(Archive *fout, RuleInfo *rinfo)
{
TableInfo *tbinfo = rinfo->ruletable;
PQExpBuffer query;
--- 14759,14765 ----
* Dump a rule
*/
static void
! dumpRule(Archive *fout, DumpOptions *dopt, RuleInfo *rinfo)
{
TableInfo *tbinfo = rinfo->ruletable;
PQExpBuffer query;
*************** dumpRule(Archive *fout, RuleInfo *rinfo)
*** 14806,14812 ****
PGresult *res;
/* Skip if not to be dumped */
! if (!rinfo->dobj.dump || dataOnly)
return;
/*
--- 14769,14775 ----
PGresult *res;
/* Skip if not to be dumped */
! if (!rinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpRule(Archive *fout, RuleInfo *rinfo)
*** 14911,14917 ****
NULL, NULL);
/* Dump rule comments */
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId);
--- 14874,14880 ----
NULL, NULL);
/* Dump rule comments */
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId);
*************** dumpRule(Archive *fout, RuleInfo *rinfo)
*** 14928,14934 ****
* getExtensionMembership --- obtain extension membership data
*/
void
! getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
int numExtensions)
{
PQExpBuffer query;
--- 14891,14897 ----
* getExtensionMembership --- obtain extension membership data
*/
void
! getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[],
int numExtensions)
{
PQExpBuffer query;
*************** getExtensionMembership(Archive *fout, Ex
*** 15104,15110 ****
* of the --oids setting. This is because row filtering
* conditions aren't compatible with dumping OIDs.
*/
! makeTableDataInfo(configtbl, false);
if (configtbl->dataObj != NULL)
{
if (strlen(extconditionarray[j]) > 0)
--- 15067,15073 ----
* of the --oids setting. This is because row filtering
* conditions aren't compatible with dumping OIDs.
*/
! makeTableDataInfo(dopt, configtbl, false);
if (configtbl->dataObj != NULL)
{
if (strlen(extconditionarray[j]) > 0)
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
new file mode 100644
index d184187..da1ceee
*** a/src/bin/pg_dump/pg_dump.h
--- b/src/bin/pg_dump/pg_dump.h
*************** extern char g_opaque_type[10]; /* name f
*** 503,509 ****
struct Archive;
typedef struct Archive Archive;
! extern TableInfo *getSchemaData(Archive *, int *numTablesPtr);
typedef enum _OidOptions
{
--- 503,512 ----
struct Archive;
typedef struct Archive Archive;
! struct _dumpOptions;
! typedef struct _dumpOptions DumpOptions;
!
! extern TableInfo *getSchemaData(Archive *, DumpOptions *dopt, int *numTablesPtr);
typedef enum _OidOptions
{
*************** extern void sortDataAndIndexObjectsBySiz
*** 545,551 ****
* version specific routines
*/
extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
! extern ExtensionInfo *getExtensions(Archive *fout, int *numExtensions);
extern TypeInfo *getTypes(Archive *fout, int *numTypes);
extern FuncInfo *getFuncs(Archive *fout, int *numFuncs);
extern AggInfo *getAggregates(Archive *fout, int *numAggregates);
--- 548,554 ----
* version specific routines
*/
extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
! extern ExtensionInfo *getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions);
extern TypeInfo *getTypes(Archive *fout, int *numTypes);
extern FuncInfo *getFuncs(Archive *fout, int *numFuncs);
extern AggInfo *getAggregates(Archive *fout, int *numAggregates);
*************** extern OpclassInfo *getOpclasses(Archive
*** 554,560 ****
extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(Archive *fout, int *numConversions);
! extern TableInfo *getTables(Archive *fout, int *numTables);
extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
--- 557,563 ----
extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(Archive *fout, int *numConversions);
! extern TableInfo *getTables(Archive *fout, DumpOptions *dopt, int *numTables);
extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
*************** extern FdwInfo *getForeignDataWrappers(A
*** 573,580 ****
int *numForeignDataWrappers);
extern ForeignServerInfo *getForeignServers(Archive *fout,
int *numForeignServers);
! extern DefaultACLInfo *getDefaultACLs(Archive *fout, int *numDefaultACLs);
! extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
int numExtensions);
extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
--- 576,583 ----
int *numForeignDataWrappers);
extern ForeignServerInfo *getForeignServers(Archive *fout,
int *numForeignServers);
! extern DefaultACLInfo *getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs);
! extern void getExtensionMembership(Archive *fout, DumpOptions* dopt, ExtensionInfo extinfo[],
int numExtensions);
extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
new file mode 100644
index 4050091..73448b1
*** a/src/bin/pg_dump/pg_dumpall.c
--- b/src/bin/pg_dump/pg_dumpall.c
*************** static bool verbose = false;
*** 72,77 ****
--- 72,78 ----
static int binary_upgrade = 0;
static int column_inserts = 0;
static int disable_dollar_quoting = 0;
+ static int quote_all_identifiers = 0;
static int disable_triggers = 0;
static int if_exists = 0;
static int inserts = 0;
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
new file mode 100644
index dcb5109..ef2cdd1
*** a/src/bin/pg_dump/pg_restore.c
--- b/src/bin/pg_dump/pg_restore.c
*************** main(int argc, char **argv)
*** 420,426 ****
/* AH may be freed in CloseArchive? */
exit_code = AH->n_errors ? 1 : 0;
! CloseArchive(AH);
return exit_code;
}
--- 420,426 ----
/* AH may be freed in CloseArchive? */
exit_code = AH->n_errors ? 1 : 0;
! CloseArchive(AH, NULL);
return exit_code;
}
On Fri, Aug 15, 2014 at 7:30 PM, Joachim Wieland <joe@mcknight.de> wrote:
Attached is a patch that doesn't add any new functionality or
features, all it does is get rid of the global variables that
pg_dump.c is full of.
I think this is an excellent idea.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 08/19/2014 01:40 AM, Robert Haas wrote:
Attached is a patch that doesn't add any new functionality or
features, all it does is get rid of the global variables that
pg_dump.c is full of.I think this is an excellent idea.
It's also one small step toward library-ifying pg_dump.
Huge +1.
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 8/15/14 7:30 PM, Joachim Wieland wrote:
Attached is a patch that doesn't add any new functionality or
features, all it does is get rid of the global variables that
pg_dump.c is full of.
I'm getting a compiler error:
In file included from pg_dump.c:60:
In file included from ./pg_backup_archiver.h:32:
./pg_backup.h:212:3: error: redefinition of typedef 'DumpOptions' is a
C11 feature [-Werror,-Wtypedef-redefinition]
} DumpOptions;
^
./pg_dump.h:507:29: note: previous definition is here
typedef struct _dumpOptions DumpOptions;
^
1 error generated.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Fixed and rebased patch attached.
Show quoted text
On Tue, Aug 26, 2014 at 11:40 AM, Peter Eisentraut <peter_e@gmx.net> wrote:
On 8/15/14 7:30 PM, Joachim Wieland wrote:
Attached is a patch that doesn't add any new functionality or
features, all it does is get rid of the global variables that
pg_dump.c is full of.I'm getting a compiler error:
In file included from pg_dump.c:60:
In file included from ./pg_backup_archiver.h:32:
./pg_backup.h:212:3: error: redefinition of typedef 'DumpOptions' is a
C11 feature [-Werror,-Wtypedef-redefinition]
} DumpOptions;
^
./pg_dump.h:507:29: note: previous definition is here
typedef struct _dumpOptions DumpOptions;
^
1 error generated.
Attachments:
pg_dump_refactor_globals.2.difftext/plain; charset=US-ASCII; name=pg_dump_refactor_globals.2.diffDownload
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
new file mode 100644
index 94e9147..d01035b
*** a/src/bin/pg_dump/common.c
--- b/src/bin/pg_dump/common.c
*************** static int strInArray(const char *patter
*** 78,84 ****
* Collect information about all potentially dumpable objects
*/
TableInfo *
! getSchemaData(Archive *fout, int *numTablesPtr)
{
ExtensionInfo *extinfo;
InhInfo *inhinfo;
--- 78,84 ----
* Collect information about all potentially dumpable objects
*/
TableInfo *
! getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
{
ExtensionInfo *extinfo;
InhInfo *inhinfo;
*************** getSchemaData(Archive *fout, int *numTab
*** 114,120 ****
*/
if (g_verbose)
write_msg(NULL, "reading user-defined tables\n");
! tblinfo = getTables(fout, &numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
/* Do this after we've built tblinfoindex */
--- 114,120 ----
*/
if (g_verbose)
write_msg(NULL, "reading user-defined tables\n");
! tblinfo = getTables(fout, dopt, &numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
/* Do this after we've built tblinfoindex */
*************** getSchemaData(Archive *fout, int *numTab
*** 122,128 ****
if (g_verbose)
write_msg(NULL, "reading extensions\n");
! extinfo = getExtensions(fout, &numExtensions);
if (g_verbose)
write_msg(NULL, "reading user-defined functions\n");
--- 122,128 ----
if (g_verbose)
write_msg(NULL, "reading extensions\n");
! extinfo = getExtensions(fout, dopt, &numExtensions);
if (g_verbose)
write_msg(NULL, "reading user-defined functions\n");
*************** getSchemaData(Archive *fout, int *numTab
*** 183,189 ****
if (g_verbose)
write_msg(NULL, "reading default privileges\n");
! getDefaultACLs(fout, &numDefaultACLs);
if (g_verbose)
write_msg(NULL, "reading user-defined collations\n");
--- 183,189 ----
if (g_verbose)
write_msg(NULL, "reading default privileges\n");
! getDefaultACLs(fout, dopt, &numDefaultACLs);
if (g_verbose)
write_msg(NULL, "reading user-defined collations\n");
*************** getSchemaData(Archive *fout, int *numTab
*** 213,219 ****
*/
if (g_verbose)
write_msg(NULL, "finding extension members\n");
! getExtensionMembership(fout, extinfo, numExtensions);
/* Link tables to parents, mark parents of target tables interesting */
if (g_verbose)
--- 213,219 ----
*/
if (g_verbose)
write_msg(NULL, "finding extension members\n");
! getExtensionMembership(fout, dopt, extinfo, numExtensions);
/* Link tables to parents, mark parents of target tables interesting */
if (g_verbose)
diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h
new file mode 100644
index b387aa1..0f6c88a
*** a/src/bin/pg_dump/dumputils.h
--- b/src/bin/pg_dump/dumputils.h
*************** typedef struct SimpleStringList
*** 31,38 ****
SimpleStringListCell *tail;
} SimpleStringList;
-
- extern int quote_all_identifiers;
extern PQExpBuffer (*getLocalPQExpBuffer) (void);
extern const char *fmtId(const char *identifier);
--- 31,36 ----
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
new file mode 100644
index e50dd8b..ceed115
*** a/src/bin/pg_dump/parallel.c
--- b/src/bin/pg_dump/parallel.c
*************** static void WaitForTerminatingWorkers(Pa
*** 89,99 ****
static void sigTermHandler(int signum);
#endif
static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
RestoreOptions *ropt);
static bool HasEveryWorkerTerminated(ParallelState *pstate);
static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te);
! static void WaitForCommands(ArchiveHandle *AH, int pipefd[2]);
static char *getMessageFromMaster(int pipefd[2]);
static void sendMessageToMaster(int pipefd[2], const char *str);
static int select_loop(int maxFd, fd_set *workerset);
--- 89,100 ----
static void sigTermHandler(int signum);
#endif
static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
+ DumpOptions *dopt,
RestoreOptions *ropt);
static bool HasEveryWorkerTerminated(ParallelState *pstate);
static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te);
! static void WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]);
static char *getMessageFromMaster(int pipefd[2]);
static void sendMessageToMaster(int pipefd[2], const char *str);
static int select_loop(int maxFd, fd_set *workerset);
*************** sigTermHandler(int signum)
*** 436,441 ****
--- 437,443 ----
*/
static void
SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
+ DumpOptions *dopt,
RestoreOptions *ropt)
{
/*
*************** SetupWorker(ArchiveHandle *AH, int pipef
*** 445,455 ****
* properly when we shut down. This happens only that way when it is
* brought down because of an error.
*/
! (AH->SetupWorkerPtr) ((Archive *) AH, ropt);
Assert(AH->connection != NULL);
! WaitForCommands(AH, pipefd);
closesocket(pipefd[PIPE_READ]);
closesocket(pipefd[PIPE_WRITE]);
--- 447,457 ----
* properly when we shut down. This happens only that way when it is
* brought down because of an error.
*/
! (AH->SetupWorkerPtr) ((Archive *) AH, dopt, ropt);
Assert(AH->connection != NULL);
! WaitForCommands(AH, dopt, pipefd);
closesocket(pipefd[PIPE_READ]);
closesocket(pipefd[PIPE_WRITE]);
*************** init_spawned_worker_win32(WorkerInfo *wi
*** 481,487 ****
* of threads while it does a fork() on Unix.
*/
ParallelState *
! ParallelBackupStart(ArchiveHandle *AH, RestoreOptions *ropt)
{
ParallelState *pstate;
int i;
--- 483,489 ----
* of threads while it does a fork() on Unix.
*/
ParallelState *
! ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt)
{
ParallelState *pstate;
int i;
*************** ParallelBackupStart(ArchiveHandle *AH, R
*** 598,604 ****
closesocket(pstate->parallelSlot[j].pipeWrite);
}
! SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, ropt);
exit(0);
}
--- 600,606 ----
closesocket(pstate->parallelSlot[j].pipeWrite);
}
! SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, dopt, ropt);
exit(0);
}
*************** lockTableNoWait(ArchiveHandle *AH, TocEn
*** 856,862 ****
* exit.
*/
static void
! WaitForCommands(ArchiveHandle *AH, int pipefd[2])
{
char *command;
DumpId dumpId;
--- 858,864 ----
* exit.
*/
static void
! WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2])
{
char *command;
DumpId dumpId;
*************** WaitForCommands(ArchiveHandle *AH, int p
*** 896,902 ****
* The message we return here has been pg_malloc()ed and we are
* responsible for free()ing it.
*/
! str = (AH->WorkerJobDumpPtr) (AH, te);
Assert(AH->connection != NULL);
sendMessageToMaster(pipefd, str);
free(str);
--- 898,904 ----
* The message we return here has been pg_malloc()ed and we are
* responsible for free()ing it.
*/
! str = (AH->WorkerJobDumpPtr) (AH, dopt, te);
Assert(AH->connection != NULL);
sendMessageToMaster(pipefd, str);
free(str);
diff --git a/src/bin/pg_dump/parallel.h b/src/bin/pg_dump/parallel.h
new file mode 100644
index 7a32a9b..81a823d
*** a/src/bin/pg_dump/parallel.h
--- b/src/bin/pg_dump/parallel.h
*************** extern void EnsureIdleWorker(struct _arc
*** 80,85 ****
--- 80,86 ----
extern void EnsureWorkersFinished(struct _archiveHandle * AH, ParallelState *pstate);
extern ParallelState *ParallelBackupStart(struct _archiveHandle * AH,
+ DumpOptions *dopt,
RestoreOptions *ropt);
extern void DispatchJobForTocEntry(struct _archiveHandle * AH,
ParallelState *pstate,
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
new file mode 100644
index 25780cf..d8c9f69
*** a/src/bin/pg_dump/pg_backup.h
--- b/src/bin/pg_dump/pg_backup.h
*************** struct Archive
*** 98,104 ****
/* The rest is private */
};
! typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
typedef struct _restoreOptions
{
--- 98,106 ----
/* The rest is private */
};
! struct _dumpOptions;
!
! typedef int (*DataDumperPtr) (Archive *AH, struct _dumpOptions *dopt, void *userArg);
typedef struct _restoreOptions
{
*************** typedef struct _restoreOptions
*** 109,125 ****
* restore */
int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
* instead of OWNER TO */
- int no_security_labels; /* Skip security label entries */
char *superuser; /* Username to use as superuser */
char *use_role; /* Issue SET ROLE to this */
int dropSchema;
int if_exists;
const char *filename;
int dataOnly;
int schemaOnly;
int dumpSections;
int verbose;
int aclsSkip;
int tocSummary;
char *tocFile;
int format;
--- 111,134 ----
* restore */
int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
* instead of OWNER TO */
char *superuser; /* Username to use as superuser */
char *use_role; /* Issue SET ROLE to this */
int dropSchema;
+ int disable_dollar_quoting;
+ int dump_inserts;
+ int column_inserts;
int if_exists;
+ int no_security_labels; /* Skip security label entries */
+
const char *filename;
int dataOnly;
int schemaOnly;
int dumpSections;
int verbose;
int aclsSkip;
+ const char *lockWaitTimeout;
+ int include_everything;
+
int tocSummary;
char *tocFile;
int format;
*************** typedef struct _restoreOptions
*** 152,158 ****
bool *idWanted; /* array showing which dump IDs to emit */
} RestoreOptions;
! typedef void (*SetupWorkerPtr) (Archive *AH, RestoreOptions *ropt);
/*
* Main archiver interface.
--- 161,217 ----
bool *idWanted; /* array showing which dump IDs to emit */
} RestoreOptions;
! typedef struct _dumpOptions
! {
! const char *dbname;
! const char *pghost;
! const char *pgport;
! const char *username;
! const char *dumpencoding;
! bool oids;
!
! /* various user-settable parameters */
! bool schemaOnly;
! bool dataOnly;
! int dumpSections; /* bitmask of chosen sections */
! bool aclsSkip;
! const char *lockWaitTimeout;
!
! /* flags for various command-line long options */
! int disable_dollar_quoting;
! int dump_inserts;
! int column_inserts;
! int if_exists;
! int no_security_labels;
! int no_synchronized_snapshots;
! int no_unlogged_table_data;
! int serializable_deferrable;
! int quote_all_identifiers;
!
! /* default, if no "inclusion" switches appear, is to dump everything */
! bool include_everything;
!
! int numWorkers;
! enum trivalue prompt_password;
! int compressLevel;
! int plainText;
! int outputClean;
! int outputCreateDB;
! bool outputBlobs;
! int outputNoOwner;
! char *outputSuperuser;
! char *use_role;
!
! ArchiveFormat archiveFormat;
! ArchiveMode archiveMode;
!
! int disable_triggers;
! int outputNoTablespaces;
! int use_setsessauth;
!
! } DumpOptions;
!
! typedef void (*SetupWorkerPtr) (Archive *AH, DumpOptions *dopt, RestoreOptions *ropt);
/*
* Main archiver interface.
*************** extern void WriteData(Archive *AH, const
*** 185,191 ****
extern int StartBlob(Archive *AH, Oid oid);
extern int EndBlob(Archive *AH, Oid oid);
! extern void CloseArchive(Archive *AH);
extern void SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt);
--- 244,250 ----
extern int StartBlob(Archive *AH, Oid oid);
extern int EndBlob(Archive *AH, Oid oid);
! extern void CloseArchive(Archive *AH, DumpOptions *dopt);
extern void SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt);
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
new file mode 100644
index 0018720..07cf26e
*** a/src/bin/pg_dump/pg_backup_archiver.c
--- b/src/bin/pg_dump/pg_backup_archiver.c
*************** static void mark_create_done(ArchiveHand
*** 107,112 ****
--- 107,170 ----
static void inhibit_data_for_failed_table(ArchiveHandle *AH, TocEntry *te);
/*
+ * Allocate a new DumpOptions block.
+ * This is mainly so we can initialize it, but also for future expansion.
+ * We pg_malloc0 the structure, so we don't need to initialize whatever is
+ * 0, NULL or false anyway.
+ */
+ DumpOptions*
+ NewDumpOptions(void)
+ {
+ DumpOptions *opts;
+
+ opts = (DumpOptions *) pg_malloc0(sizeof(DumpOptions));
+
+ /* set any fields that shouldn't default to zeroes */
+ opts->include_everything = true;
+ opts->prompt_password = TRI_DEFAULT;
+ opts->compressLevel = -1;
+ opts->archiveFormat = archUnknown;
+ opts->numWorkers = 1;
+ opts->dumpSections = DUMP_UNSECTIONED;
+
+ return opts;
+ }
+
+ /*
+ * We do a plaintext dump by printing out the restore command that would create
+ * a certain object. Since in those functions we only have RestoreOptions, we
+ * crate ad-hoc DumpOptions.
+ */
+ DumpOptions
+ dumpOptionsFromRestoreOptions(RestoreOptions *ropt) {
+ DumpOptions dopt;
+
+ /* this is the inverse of what's at the end of pg_dump.c's main() */
+ dopt.outputClean = ropt->dropSchema;
+ dopt.dataOnly = ropt->dataOnly;
+ dopt.schemaOnly = ropt->schemaOnly;
+ dopt.if_exists = ropt->if_exists;
+ dopt.column_inserts = ropt->column_inserts;
+ dopt.dumpSections = ropt->dumpSections;
+ dopt.aclsSkip = ropt->aclsSkip;
+ dopt.outputSuperuser = ropt->superuser;
+ dopt.outputCreateDB = ropt->createDB;
+ dopt.outputNoOwner = ropt->noOwner;
+ dopt.outputNoTablespaces = ropt->noTablespace;
+ dopt.disable_triggers = ropt->disable_triggers;
+ dopt.use_setsessauth = ropt->use_setsessauth;
+
+ dopt.disable_dollar_quoting = ropt->disable_dollar_quoting;
+ dopt.dump_inserts = ropt->dump_inserts;
+ dopt.no_security_labels = ropt->no_security_labels;
+ dopt.lockWaitTimeout = ropt->lockWaitTimeout;
+ dopt.include_everything = ropt->include_everything;
+
+ return dopt;
+ }
+
+
+ /*
* Wrapper functions.
*
* The objective it to make writing new formats and dumpers as simple
*************** static void inhibit_data_for_failed_tabl
*** 120,126 ****
* setup doesn't need to know anything much, so it's defined here.
*/
static void
! setupRestoreWorker(Archive *AHX, RestoreOptions *ropt)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
--- 178,184 ----
* setup doesn't need to know anything much, so it's defined here.
*/
static void
! setupRestoreWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
*************** OpenArchive(const char *FileSpec, const
*** 152,163 ****
/* Public */
void
! CloseArchive(Archive *AHX)
{
int res = 0;
ArchiveHandle *AH = (ArchiveHandle *) AHX;
! (*AH->ClosePtr) (AH);
/* Close the output */
if (AH->gzOut)
--- 210,221 ----
/* Public */
void
! CloseArchive(Archive *AHX, DumpOptions *dopt)
{
int res = 0;
ArchiveHandle *AH = (ArchiveHandle *) AHX;
! (*AH->ClosePtr) (AH, dopt);
/* Close the output */
if (AH->gzOut)
*************** RestoreArchive(Archive *AHX)
*** 522,528 ****
Assert(AH->connection == NULL);
/* ParallelBackupStart() will actually fork the processes */
! pstate = ParallelBackupStart(AH, ropt);
restore_toc_entries_parallel(AH, pstate, &pending_list);
ParallelBackupEnd(AH, pstate);
--- 580,586 ----
Assert(AH->connection == NULL);
/* ParallelBackupStart() will actually fork the processes */
! pstate = ParallelBackupStart(AH, NULL, ropt);
restore_toc_entries_parallel(AH, pstate, &pending_list);
ParallelBackupEnd(AH, pstate);
*************** _allocAH(const char *FileSpec, const Arc
*** 2211,2217 ****
}
void
! WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
{
TocEntry *te;
--- 2269,2275 ----
}
void
! WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate)
{
TocEntry *te;
*************** WriteDataChunks(ArchiveHandle *AH, Paral
*** 2234,2246 ****
DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP);
}
else
! WriteDataChunksForTocEntry(AH, te);
}
EnsureWorkersFinished(AH, pstate);
}
void
! WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
{
StartDataPtr startPtr;
EndDataPtr endPtr;
--- 2292,2304 ----
DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP);
}
else
! WriteDataChunksForTocEntry(AH, dopt, te);
}
EnsureWorkersFinished(AH, pstate);
}
void
! WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
{
StartDataPtr startPtr;
EndDataPtr endPtr;
*************** WriteDataChunksForTocEntry(ArchiveHandle
*** 2264,2270 ****
/*
* The user-provided DataDumper routine needs to call AH->WriteData
*/
! (*te->dataDumper) ((Archive *) AH, te->dataDumperArg);
if (endPtr != NULL)
(*endPtr) (AH, te);
--- 2322,2328 ----
/*
* The user-provided DataDumper routine needs to call AH->WriteData
*/
! (*te->dataDumper) ((Archive *) AH, dopt, te->dataDumperArg);
if (endPtr != NULL)
(*endPtr) (AH, te);
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
new file mode 100644
index c163f29..0f80045
*** a/src/bin/pg_dump/pg_backup_archiver.h
--- b/src/bin/pg_dump/pg_backup_archiver.h
*************** typedef enum T_Action
*** 139,145 ****
ACT_RESTORE
} T_Action;
! typedef void (*ClosePtr) (struct _archiveHandle * AH);
typedef void (*ReopenPtr) (struct _archiveHandle * AH);
typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
--- 139,145 ----
ACT_RESTORE
} T_Action;
! typedef void (*ClosePtr) (struct _archiveHandle * AH, DumpOptions *dopt);
typedef void (*ReopenPtr) (struct _archiveHandle * AH);
typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
*************** typedef void (*ClonePtr) (struct _archiv
*** 166,172 ****
typedef void (*DeClonePtr) (struct _archiveHandle * AH);
typedef char *(*WorkerJobRestorePtr) (struct _archiveHandle * AH, struct _tocEntry * te);
! typedef char *(*WorkerJobDumpPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef char *(*MasterStartParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
T_Action act);
typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
--- 166,172 ----
typedef void (*DeClonePtr) (struct _archiveHandle * AH);
typedef char *(*WorkerJobRestorePtr) (struct _archiveHandle * AH, struct _tocEntry * te);
! typedef char *(*WorkerJobDumpPtr) (struct _archiveHandle * AH, DumpOptions *dopt, struct _tocEntry * te);
typedef char *(*MasterStartParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
T_Action act);
typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
*************** extern void WriteHead(ArchiveHandle *AH)
*** 389,396 ****
extern void ReadHead(ArchiveHandle *AH);
extern void WriteToc(ArchiveHandle *AH);
extern void ReadToc(ArchiveHandle *AH);
! extern void WriteDataChunks(ArchiveHandle *AH, struct ParallelState *pstate);
! extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te);
extern ArchiveHandle *CloneArchive(ArchiveHandle *AH);
extern void DeCloneArchive(ArchiveHandle *AH);
--- 389,396 ----
extern void ReadHead(ArchiveHandle *AH);
extern void WriteToc(ArchiveHandle *AH);
extern void ReadToc(ArchiveHandle *AH);
! extern void WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, struct ParallelState *pstate);
! extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te);
extern ArchiveHandle *CloneArchive(ArchiveHandle *AH);
extern void DeCloneArchive(ArchiveHandle *AH);
*************** int ahprintf(ArchiveHandle *AH, const
*** 436,439 ****
--- 436,442 ----
void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
+ extern DumpOptions* NewDumpOptions(void);
+ extern DumpOptions dumpOptionsFromRestoreOptions(RestoreOptions *ropt);
+
#endif
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
new file mode 100644
index 06cd0a7..d6bb471
*** a/src/bin/pg_dump/pg_backup_custom.c
--- b/src/bin/pg_dump/pg_backup_custom.c
*************** static int _WriteByte(ArchiveHandle *AH,
*** 41,47 ****
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
--- 41,47 ----
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
*************** _ReadBuf(ArchiveHandle *AH, void *buf, s
*** 694,700 ****
*
*/
static void
! _CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
pgoff_t tpos;
--- 694,700 ----
*
*/
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
lclContext *ctx = (lclContext *) AH->formatData;
pgoff_t tpos;
*************** _CloseArchive(ArchiveHandle *AH)
*** 709,715 ****
strerror(errno));
WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx);
! WriteDataChunks(AH, NULL);
/*
* If possible, re-write the TOC in order to update the data offset
--- 709,715 ----
strerror(errno));
WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx);
! WriteDataChunks(AH, dopt, NULL);
/*
* If possible, re-write the TOC in order to update the data offset
diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c
new file mode 100644
index 39e29d8..01b0e97
*** a/src/bin/pg_dump/pg_backup_directory.c
--- b/src/bin/pg_dump/pg_backup_directory.c
*************** static int _WriteByte(ArchiveHandle *AH,
*** 71,77 ****
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
--- 71,77 ----
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
*************** static char *_MasterStartParallelItem(Ar
*** 92,98 ****
static int _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te,
const char *str, T_Action act);
static char *_WorkerJobRestoreDirectory(ArchiveHandle *AH, TocEntry *te);
! static char *_WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te);
static void setFilePath(ArchiveHandle *AH, char *buf,
const char *relativeFilename);
--- 92,98 ----
static int _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te,
const char *str, T_Action act);
static char *_WorkerJobRestoreDirectory(ArchiveHandle *AH, TocEntry *te);
! static char *_WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te);
static void setFilePath(ArchiveHandle *AH, char *buf,
const char *relativeFilename);
*************** _ReadBuf(ArchiveHandle *AH, void *buf, s
*** 566,572 ****
* WriteDataChunks to save all DATA & BLOBs.
*/
static void
! _CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
--- 566,572 ----
* WriteDataChunks to save all DATA & BLOBs.
*/
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
lclContext *ctx = (lclContext *) AH->formatData;
*************** _CloseArchive(ArchiveHandle *AH)
*** 578,584 ****
setFilePath(AH, fname, "toc.dat");
/* this will actually fork the processes for a parallel backup */
! ctx->pstate = ParallelBackupStart(AH, NULL);
/* The TOC is always created uncompressed */
tocFH = cfopen_write(fname, PG_BINARY_W, 0);
--- 578,584 ----
setFilePath(AH, fname, "toc.dat");
/* this will actually fork the processes for a parallel backup */
! ctx->pstate = ParallelBackupStart(AH, dopt, NULL);
/* The TOC is always created uncompressed */
tocFH = cfopen_write(fname, PG_BINARY_W, 0);
*************** _CloseArchive(ArchiveHandle *AH)
*** 599,605 ****
if (cfclose(tocFH) != 0)
exit_horribly(modulename, "could not close TOC file: %s\n",
strerror(errno));
! WriteDataChunks(AH, ctx->pstate);
ParallelBackupEnd(AH, ctx->pstate);
}
--- 599,605 ----
if (cfclose(tocFH) != 0)
exit_horribly(modulename, "could not close TOC file: %s\n",
strerror(errno));
! WriteDataChunks(AH, dopt, ctx->pstate);
ParallelBackupEnd(AH, ctx->pstate);
}
*************** _MasterStartParallelItem(ArchiveHandle *
*** 790,796 ****
* function of the respective dump format.
*/
static char *
! _WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te)
{
/*
* short fixed-size string + some ID so far, this needs to be malloc'ed
--- 790,796 ----
* function of the respective dump format.
*/
static char *
! _WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
{
/*
* short fixed-size string + some ID so far, this needs to be malloc'ed
*************** _WorkerJobDumpDirectory(ArchiveHandle *A
*** 809,815 ****
* succeed... A failure will be detected by the parent when the child dies
* unexpectedly.
*/
! WriteDataChunksForTocEntry(AH, te);
snprintf(buf, buflen, "OK DUMP %d", te->dumpId);
--- 809,815 ----
* succeed... A failure will be detected by the parent when the child dies
* unexpectedly.
*/
! WriteDataChunksForTocEntry(AH, dopt, te);
snprintf(buf, buflen, "OK DUMP %d", te->dumpId);
diff --git a/src/bin/pg_dump/pg_backup_null.c b/src/bin/pg_dump/pg_backup_null.c
new file mode 100644
index 3bce588..77b1eda
*** a/src/bin/pg_dump/pg_backup_null.c
--- b/src/bin/pg_dump/pg_backup_null.c
*************** static void _WriteBlobData(ArchiveHandle
*** 35,41 ****
static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
--- 35,41 ----
static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
*************** _PrintTocData(ArchiveHandle *AH, TocEntr
*** 198,209 ****
{
if (te->dataDumper)
{
AH->currToc = te;
if (strcmp(te->desc, "BLOBS") == 0)
_StartBlobs(AH, te);
! (*te->dataDumper) ((Archive *) AH, te->dataDumperArg);
if (strcmp(te->desc, "BLOBS") == 0)
_EndBlobs(AH, te);
--- 198,210 ----
{
if (te->dataDumper)
{
+ DumpOptions dopt = dumpOptionsFromRestoreOptions(ropt);
AH->currToc = te;
if (strcmp(te->desc, "BLOBS") == 0)
_StartBlobs(AH, te);
! (*te->dataDumper) ((Archive *) AH, &dopt, te->dataDumperArg);
if (strcmp(te->desc, "BLOBS") == 0)
_EndBlobs(AH, te);
*************** _WriteBuf(ArchiveHandle *AH, const void
*** 227,233 ****
}
static void
! _CloseArchive(ArchiveHandle *AH)
{
/* Nothing to do */
}
--- 228,234 ----
}
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
/* Nothing to do */
}
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
new file mode 100644
index 457b742..1c5056c
*** a/src/bin/pg_dump/pg_backup_tar.c
--- b/src/bin/pg_dump/pg_backup_tar.c
*************** static int _WriteByte(ArchiveHandle *AH,
*** 48,54 ****
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
--- 48,54 ----
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
*************** _ReadBuf(ArchiveHandle *AH, void *buf, s
*** 827,833 ****
}
static void
! _CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
TAR_MEMBER *th;
--- 827,833 ----
}
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
lclContext *ctx = (lclContext *) AH->formatData;
TAR_MEMBER *th;
*************** _CloseArchive(ArchiveHandle *AH)
*** 850,856 ****
/*
* Now send the data (tables & blobs)
*/
! WriteDataChunks(AH, NULL);
/*
* Now this format wants to append a script which does a full restore
--- 850,856 ----
/*
* Now send the data (tables & blobs)
*/
! WriteDataChunks(AH, dopt, NULL);
/*
* Now this format wants to append a script which does a full restore
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
new file mode 100644
index c084ee9..7bdfb2c
*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
*************** typedef struct
*** 85,97 ****
bool g_verbose; /* User wants verbose narration of our
* activities. */
- /* various user-settable parameters */
- static bool schemaOnly;
- static bool dataOnly;
- static int dumpSections; /* bitmask of chosen sections */
- static bool aclsSkip;
- static const char *lockWaitTimeout;
-
/* subquery used to convert user ID (eg, datdba) to user name */
static const char *username_subquery;
--- 85,90 ----
*************** static SimpleOidList table_exclude_oids
*** 116,123 ****
static SimpleStringList tabledata_exclude_patterns = {NULL, NULL};
static SimpleOidList tabledata_exclude_oids = {NULL, NULL};
- /* default, if no "inclusion" switches appear, is to dump everything */
- static bool include_everything = true;
char g_opaque_type[10]; /* name for the opaque type */
--- 109,114 ----
*************** char g_opaque_type[10]; /* name for the
*** 125,147 ****
char g_comment_start[10];
char g_comment_end[10];
static const CatalogId nilCatalogId = {0, 0};
- /* flags for various command-line long options */
static int binary_upgrade = 0;
- static int disable_dollar_quoting = 0;
- static int dump_inserts = 0;
- static int column_inserts = 0;
- static int if_exists = 0;
- static int no_security_labels = 0;
- static int no_synchronized_snapshots = 0;
- static int no_unlogged_table_data = 0;
- static int serializable_deferrable = 0;
-
static void help(const char *progname);
! static void setup_connection(Archive *AH, const char *dumpencoding,
! char *use_role);
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
static void expand_schema_name_patterns(Archive *fout,
SimpleStringList *patterns,
--- 116,129 ----
char g_comment_start[10];
char g_comment_end[10];
+ extern int quote_all_identifiers;
+
static const CatalogId nilCatalogId = {0, 0};
static int binary_upgrade = 0;
static void help(const char *progname);
! static void setup_connection(Archive *AH, DumpOptions *dopt);
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
static void expand_schema_name_patterns(Archive *fout,
SimpleStringList *patterns,
*************** static void expand_table_name_patterns(A
*** 150,213 ****
SimpleStringList *patterns,
SimpleOidList *oids);
static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid);
! static void dumpTableData(Archive *fout, TableDataInfo *tdinfo);
static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo);
static void guessConstraintInheritance(TableInfo *tblinfo, int numTables);
! static void dumpComment(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findComments(Archive *fout, Oid classoid, Oid objoid,
CommentItem **items);
static int collectComments(Archive *fout, CommentItem **items);
! static void dumpSecLabel(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findSecLabels(Archive *fout, Oid classoid, Oid objoid,
SecLabelItem **items);
static int collectSecLabels(Archive *fout, SecLabelItem **items);
! static void dumpDumpableObject(Archive *fout, DumpableObject *dobj);
! static void dumpNamespace(Archive *fout, NamespaceInfo *nspinfo);
! static void dumpExtension(Archive *fout, ExtensionInfo *extinfo);
! static void dumpType(Archive *fout, TypeInfo *tyinfo);
! static void dumpBaseType(Archive *fout, TypeInfo *tyinfo);
! static void dumpEnumType(Archive *fout, TypeInfo *tyinfo);
! static void dumpRangeType(Archive *fout, TypeInfo *tyinfo);
! static void dumpDomain(Archive *fout, TypeInfo *tyinfo);
! static void dumpCompositeType(Archive *fout, TypeInfo *tyinfo);
static void dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo);
! static void dumpShellType(Archive *fout, ShellTypeInfo *stinfo);
! static void dumpProcLang(Archive *fout, ProcLangInfo *plang);
! static void dumpFunc(Archive *fout, FuncInfo *finfo);
! static void dumpCast(Archive *fout, CastInfo *cast);
! static void dumpOpr(Archive *fout, OprInfo *oprinfo);
! static void dumpOpclass(Archive *fout, OpclassInfo *opcinfo);
! static void dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo);
! static void dumpCollation(Archive *fout, CollInfo *convinfo);
! static void dumpConversion(Archive *fout, ConvInfo *convinfo);
! static void dumpRule(Archive *fout, RuleInfo *rinfo);
! static void dumpAgg(Archive *fout, AggInfo *agginfo);
! static void dumpTrigger(Archive *fout, TriggerInfo *tginfo);
! static void dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo);
! static void dumpTable(Archive *fout, TableInfo *tbinfo);
! static void dumpTableSchema(Archive *fout, TableInfo *tbinfo);
! static void dumpAttrDef(Archive *fout, AttrDefInfo *adinfo);
! static void dumpSequence(Archive *fout, TableInfo *tbinfo);
static void dumpSequenceData(Archive *fout, TableDataInfo *tdinfo);
! static void dumpIndex(Archive *fout, IndxInfo *indxinfo);
! static void dumpConstraint(Archive *fout, ConstraintInfo *coninfo);
! static void dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo);
! static void dumpTSParser(Archive *fout, TSParserInfo *prsinfo);
! static void dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo);
! static void dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo);
! static void dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo);
! static void dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo);
! static void dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo);
static void dumpUserMappings(Archive *fout,
const char *servername, const char *namespace,
const char *owner, CatalogId catalogId, DumpId dumpId);
! static void dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo);
! static void dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls);
--- 132,195 ----
SimpleStringList *patterns,
SimpleOidList *oids);
static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid);
! static void dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo);
static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo);
static void guessConstraintInheritance(TableInfo *tblinfo, int numTables);
! static void dumpComment(Archive *fout, DumpOptions* dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findComments(Archive *fout, Oid classoid, Oid objoid,
CommentItem **items);
static int collectComments(Archive *fout, CommentItem **items);
! static void dumpSecLabel(Archive *fout, DumpOptions* dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findSecLabels(Archive *fout, Oid classoid, Oid objoid,
SecLabelItem **items);
static int collectSecLabels(Archive *fout, SecLabelItem **items);
! static void dumpDumpableObject(Archive *fout, DumpOptions* dopt, DumpableObject *dobj);
! static void dumpNamespace(Archive *fout, DumpOptions* dopt, NamespaceInfo *nspinfo);
! static void dumpExtension(Archive *fout, DumpOptions* dopt, ExtensionInfo *extinfo);
! static void dumpType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpBaseType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpEnumType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpRangeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpDomain(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpCompositeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
static void dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo);
! static void dumpShellType(Archive *fout, DumpOptions* dopt, ShellTypeInfo *stinfo);
! static void dumpProcLang(Archive *fout, DumpOptions* dopt, ProcLangInfo *plang);
! static void dumpFunc(Archive *fout, DumpOptions* dopt, FuncInfo *finfo);
! static void dumpCast(Archive *fout, DumpOptions* dopt, CastInfo *cast);
! static void dumpOpr(Archive *fout, DumpOptions* dopt, OprInfo *oprinfo);
! static void dumpOpclass(Archive *fout, DumpOptions* dopt, OpclassInfo *opcinfo);
! static void dumpOpfamily(Archive *fout, DumpOptions* dopt, OpfamilyInfo *opfinfo);
! static void dumpCollation(Archive *fout, DumpOptions* dopt, CollInfo *convinfo);
! static void dumpConversion(Archive *fout, DumpOptions* dopt, ConvInfo *convinfo);
! static void dumpRule(Archive *fout, DumpOptions* dopt, RuleInfo *rinfo);
! static void dumpAgg(Archive *fout, DumpOptions* dopt, AggInfo *agginfo);
! static void dumpTrigger(Archive *fout, DumpOptions* dopt, TriggerInfo *tginfo);
! static void dumpEventTrigger(Archive *fout, DumpOptions* dopt, EventTriggerInfo *evtinfo);
! static void dumpTable(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo);
! static void dumpTableSchema(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo);
! static void dumpAttrDef(Archive *fout, DumpOptions* dopt, AttrDefInfo *adinfo);
! static void dumpSequence(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo);
static void dumpSequenceData(Archive *fout, TableDataInfo *tdinfo);
! static void dumpIndex(Archive *fout, DumpOptions* dopt, IndxInfo *indxinfo);
! static void dumpConstraint(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo);
! static void dumpTableConstraintComment(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo);
! static void dumpTSParser(Archive *fout, DumpOptions* dopt, TSParserInfo *prsinfo);
! static void dumpTSDictionary(Archive *fout, DumpOptions* dopt, TSDictInfo *dictinfo);
! static void dumpTSTemplate(Archive *fout, DumpOptions* dopt, TSTemplateInfo *tmplinfo);
! static void dumpTSConfig(Archive *fout, DumpOptions* dopt, TSConfigInfo *cfginfo);
! static void dumpForeignDataWrapper(Archive *fout, DumpOptions* dopt, FdwInfo *fdwinfo);
! static void dumpForeignServer(Archive *fout, DumpOptions* dopt, ForeignServerInfo *srvinfo);
static void dumpUserMappings(Archive *fout,
const char *servername, const char *namespace,
const char *owner, CatalogId catalogId, DumpId dumpId);
! static void dumpDefaultACL(Archive *fout, DumpOptions* dopt, DefaultACLInfo *daclinfo);
! static void dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls);
*************** static void addBoundaryDependencies(Dump
*** 222,229 ****
DumpableObject *boundaryObjs);
static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo);
! static void getTableData(TableInfo *tblinfo, int numTables, bool oids);
! static void makeTableDataInfo(TableInfo *tbinfo, bool oids);
static void buildMatViewRefreshDependencies(Archive *fout);
static void getTableDataFKConstraints(void);
static char *format_function_arguments(FuncInfo *finfo, char *funcargs,
--- 204,211 ----
DumpableObject *boundaryObjs);
static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo);
! static void getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids);
! static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids);
static void buildMatViewRefreshDependencies(Archive *fout);
static void getTableDataFKConstraints(void);
static char *format_function_arguments(FuncInfo *finfo, char *funcargs,
*************** static void selectSourceSchema(Archive *
*** 245,253 ****
static char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts);
static char *myFormatType(const char *typname, int32 typmod);
static void getBlobs(Archive *fout);
! static void dumpBlob(Archive *fout, BlobInfo *binfo);
! static int dumpBlobs(Archive *fout, void *arg);
! static void dumpDatabase(Archive *AH);
static void dumpEncoding(Archive *AH);
static void dumpStdStrings(Archive *AH);
static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout,
--- 227,235 ----
static char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts);
static char *myFormatType(const char *typname, int32 typmod);
static void getBlobs(Archive *fout);
! static void dumpBlob(Archive *fout, DumpOptions *dopt, BlobInfo *binfo);
! static int dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg);
! static void dumpDatabase(Archive *AH, DumpOptions *dopt);
static void dumpEncoding(Archive *AH);
static void dumpStdStrings(Archive *AH);
static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout,
*************** static const char *getAttrName(int attrn
*** 264,270 ****
static const char *fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer);
static char *get_synchronized_snapshot(Archive *fout);
static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query);
! static void setupDumpWorker(Archive *AHX, RestoreOptions *ropt);
int
--- 246,252 ----
static const char *fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer);
static char *get_synchronized_snapshot(Archive *fout);
static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query);
! static void setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt);
int
*************** main(int argc, char **argv)
*** 273,311 ****
int c;
const char *filename = NULL;
const char *format = "p";
- const char *dbname = NULL;
- const char *pghost = NULL;
- const char *pgport = NULL;
- const char *username = NULL;
- const char *dumpencoding = NULL;
- bool oids = false;
TableInfo *tblinfo;
int numTables;
DumpableObject **dobjs;
int numObjs;
DumpableObject *boundaryObjs;
int i;
- int numWorkers = 1;
- enum trivalue prompt_password = TRI_DEFAULT;
- int compressLevel = -1;
- int plainText = 0;
- int outputClean = 0;
- int outputCreateDB = 0;
- bool outputBlobs = false;
- int outputNoOwner = 0;
- char *outputSuperuser = NULL;
- char *use_role = NULL;
int optindex;
RestoreOptions *ropt;
- ArchiveFormat archiveFormat = archUnknown;
- ArchiveMode archiveMode;
Archive *fout; /* the script file */
! static int disable_triggers = 0;
! static int outputNoTablespaces = 0;
! static int use_setsessauth = 0;
! static struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
{"blobs", no_argument, NULL, 'b'},
{"clean", no_argument, NULL, 'c'},
--- 255,273 ----
int c;
const char *filename = NULL;
const char *format = "p";
TableInfo *tblinfo;
int numTables;
DumpableObject **dobjs;
int numObjs;
DumpableObject *boundaryObjs;
int i;
int optindex;
RestoreOptions *ropt;
Archive *fout; /* the script file */
! DumpOptions *dopt = NewDumpOptions();
! struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
{"blobs", no_argument, NULL, 'b'},
{"clean", no_argument, NULL, 'c'},
*************** main(int argc, char **argv)
*** 340,363 ****
/*
* the following options don't have an equivalent short option letter
*/
! {"attribute-inserts", no_argument, &column_inserts, 1},
{"binary-upgrade", no_argument, &binary_upgrade, 1},
! {"column-inserts", no_argument, &column_inserts, 1},
! {"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1},
! {"disable-triggers", no_argument, &disable_triggers, 1},
{"exclude-table-data", required_argument, NULL, 4},
! {"if-exists", no_argument, &if_exists, 1},
! {"inserts", no_argument, &dump_inserts, 1},
{"lock-wait-timeout", required_argument, NULL, 2},
! {"no-tablespaces", no_argument, &outputNoTablespaces, 1},
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
{"role", required_argument, NULL, 3},
{"section", required_argument, NULL, 5},
! {"serializable-deferrable", no_argument, &serializable_deferrable, 1},
! {"use-set-session-authorization", no_argument, &use_setsessauth, 1},
! {"no-security-labels", no_argument, &no_security_labels, 1},
! {"no-synchronized-snapshots", no_argument, &no_synchronized_snapshots, 1},
! {"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1},
{NULL, 0, NULL, 0}
};
--- 302,325 ----
/*
* the following options don't have an equivalent short option letter
*/
! {"attribute-inserts", no_argument, &dopt->column_inserts, 1},
{"binary-upgrade", no_argument, &binary_upgrade, 1},
! {"column-inserts", no_argument, &dopt->column_inserts, 1},
! {"disable-dollar-quoting", no_argument, &dopt->disable_dollar_quoting, 1},
! {"disable-triggers", no_argument, &dopt->disable_triggers, 1},
{"exclude-table-data", required_argument, NULL, 4},
! {"if-exists", no_argument, &dopt->if_exists, 1},
! {"inserts", no_argument, &dopt->dump_inserts, 1},
{"lock-wait-timeout", required_argument, NULL, 2},
! {"no-tablespaces", no_argument, &dopt->outputNoTablespaces, 1},
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
{"role", required_argument, NULL, 3},
{"section", required_argument, NULL, 5},
! {"serializable-deferrable", no_argument, &dopt->serializable_deferrable, 1},
! {"use-set-session-authorization", no_argument, &dopt->use_setsessauth, 1},
! {"no-security-labels", no_argument, &dopt->no_security_labels, 1},
! {"no-synchronized-snapshots", no_argument, &dopt->no_synchronized_snapshots, 1},
! {"no-unlogged-table-data", no_argument, &dopt->no_unlogged_table_data, 1},
{NULL, 0, NULL, 0}
};
*************** main(int argc, char **argv)
*** 376,385 ****
g_comment_end[0] = '\0';
strcpy(g_opaque_type, "opaque");
- dataOnly = schemaOnly = false;
- dumpSections = DUMP_UNSECTIONED;
- lockWaitTimeout = NULL;
-
progname = get_progname(argv[0]);
/* Set default options based on progname */
--- 338,343 ----
*************** main(int argc, char **argv)
*** 406,432 ****
switch (c)
{
case 'a': /* Dump data only */
! dataOnly = true;
break;
case 'b': /* Dump blobs */
! outputBlobs = true;
break;
case 'c': /* clean (i.e., drop) schema prior to create */
! outputClean = 1;
break;
case 'C': /* Create DB */
! outputCreateDB = 1;
break;
case 'd': /* database name */
! dbname = pg_strdup(optarg);
break;
case 'E': /* Dump encoding */
! dumpencoding = pg_strdup(optarg);
break;
case 'f':
--- 364,390 ----
switch (c)
{
case 'a': /* Dump data only */
! dopt->dataOnly = true;
break;
case 'b': /* Dump blobs */
! dopt->outputBlobs = true;
break;
case 'c': /* clean (i.e., drop) schema prior to create */
! dopt->outputClean = 1;
break;
case 'C': /* Create DB */
! dopt->outputCreateDB = 1;
break;
case 'd': /* database name */
! dopt->dbname = pg_strdup(optarg);
break;
case 'E': /* Dump encoding */
! dopt->dumpencoding = pg_strdup(optarg);
break;
case 'f':
*************** main(int argc, char **argv)
*** 438,444 ****
break;
case 'h': /* server host */
! pghost = pg_strdup(optarg);
break;
case 'i':
--- 396,402 ----
break;
case 'h': /* server host */
! dopt->pghost = pg_strdup(optarg);
break;
case 'i':
*************** main(int argc, char **argv)
*** 446,457 ****
break;
case 'j': /* number of dump jobs */
! numWorkers = atoi(optarg);
break;
case 'n': /* include schema(s) */
simple_string_list_append(&schema_include_patterns, optarg);
! include_everything = false;
break;
case 'N': /* exclude schema(s) */
--- 404,415 ----
break;
case 'j': /* number of dump jobs */
! dopt->numWorkers = atoi(optarg);
break;
case 'n': /* include schema(s) */
simple_string_list_append(&schema_include_patterns, optarg);
! dopt->include_everything = false;
break;
case 'N': /* exclude schema(s) */
*************** main(int argc, char **argv)
*** 459,473 ****
break;
case 'o': /* Dump oids */
! oids = true;
break;
case 'O': /* Don't reconnect to match owner */
! outputNoOwner = 1;
break;
case 'p': /* server port */
! pgport = pg_strdup(optarg);
break;
case 'R':
--- 417,431 ----
break;
case 'o': /* Dump oids */
! dopt->oids = true;
break;
case 'O': /* Don't reconnect to match owner */
! dopt->outputNoOwner = 1;
break;
case 'p': /* server port */
! dopt->pgport = pg_strdup(optarg);
break;
case 'R':
*************** main(int argc, char **argv)
*** 475,490 ****
break;
case 's': /* dump schema only */
! schemaOnly = true;
break;
case 'S': /* Username for superuser in plain text output */
! outputSuperuser = pg_strdup(optarg);
break;
case 't': /* include table(s) */
simple_string_list_append(&table_include_patterns, optarg);
! include_everything = false;
break;
case 'T': /* exclude table(s) */
--- 433,448 ----
break;
case 's': /* dump schema only */
! dopt->schemaOnly = true;
break;
case 'S': /* Username for superuser in plain text output */
! dopt->outputSuperuser = pg_strdup(optarg);
break;
case 't': /* include table(s) */
simple_string_list_append(&table_include_patterns, optarg);
! dopt->include_everything = false;
break;
case 'T': /* exclude table(s) */
*************** main(int argc, char **argv)
*** 492,498 ****
break;
case 'U':
! username = pg_strdup(optarg);
break;
case 'v': /* verbose */
--- 450,456 ----
break;
case 'U':
! dopt->username = pg_strdup(optarg);
break;
case 'v': /* verbose */
*************** main(int argc, char **argv)
*** 500,518 ****
break;
case 'w':
! prompt_password = TRI_NO;
break;
case 'W':
! prompt_password = TRI_YES;
break;
case 'x': /* skip ACL dump */
! aclsSkip = true;
break;
case 'Z': /* Compression Level */
! compressLevel = atoi(optarg);
break;
case 0:
--- 458,476 ----
break;
case 'w':
! dopt->prompt_password = TRI_NO;
break;
case 'W':
! dopt->prompt_password = TRI_YES;
break;
case 'x': /* skip ACL dump */
! dopt->aclsSkip = true;
break;
case 'Z': /* Compression Level */
! dopt->compressLevel = atoi(optarg);
break;
case 0:
*************** main(int argc, char **argv)
*** 520,530 ****
break;
case 2: /* lock-wait-timeout */
! lockWaitTimeout = pg_strdup(optarg);
break;
case 3: /* SET ROLE */
! use_role = pg_strdup(optarg);
break;
case 4: /* exclude table(s) data */
--- 478,488 ----
break;
case 2: /* lock-wait-timeout */
! dopt->lockWaitTimeout = pg_strdup(optarg);
break;
case 3: /* SET ROLE */
! dopt->use_role = pg_strdup(optarg);
break;
case 4: /* exclude table(s) data */
*************** main(int argc, char **argv)
*** 532,538 ****
break;
case 5: /* section */
! set_dump_section(optarg, &dumpSections);
break;
default:
--- 490,496 ----
break;
case 5: /* section */
! set_dump_section(optarg, &dopt->dumpSections);
break;
default:
*************** main(int argc, char **argv)
*** 545,552 ****
* Non-option argument specifies database name as long as it wasn't
* already specified with -d / --dbname
*/
! if (optind < argc && dbname == NULL)
! dbname = argv[optind++];
/* Complain if any arguments remain */
if (optind < argc)
--- 503,510 ----
* Non-option argument specifies database name as long as it wasn't
* already specified with -d / --dbname
*/
! if (optind < argc && dopt->dbname == NULL)
! dopt->dbname = argv[optind++];
/* Complain if any arguments remain */
if (optind < argc)
*************** main(int argc, char **argv)
*** 559,603 ****
}
/* --column-inserts implies --inserts */
! if (column_inserts)
! dump_inserts = 1;
! if (dataOnly && schemaOnly)
{
write_msg(NULL, "options -s/--schema-only and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dataOnly && outputClean)
{
write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dump_inserts && oids)
{
write_msg(NULL, "options --inserts/--column-inserts and -o/--oids cannot be used together\n");
write_msg(NULL, "(The INSERT command cannot set OIDs.)\n");
exit_nicely(1);
}
! if (if_exists && !outputClean)
exit_horribly(NULL, "option --if-exists requires option -c/--clean\n");
/* Identify archive format to emit */
! archiveFormat = parseArchiveFormat(format, &archiveMode);
/* archiveFormat specific setup */
! if (archiveFormat == archNull)
! plainText = 1;
/* Custom and directory formats are compressed by default, others not */
! if (compressLevel == -1)
{
! if (archiveFormat == archCustom || archiveFormat == archDirectory)
! compressLevel = Z_DEFAULT_COMPRESSION;
else
! compressLevel = 0;
}
/*
--- 517,561 ----
}
/* --column-inserts implies --inserts */
! if (dopt->column_inserts)
! dopt->dump_inserts = 1;
! if (dopt->dataOnly && dopt->schemaOnly)
{
write_msg(NULL, "options -s/--schema-only and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dopt->dataOnly && dopt->outputClean)
{
write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dopt->dump_inserts && dopt->oids)
{
write_msg(NULL, "options --inserts/--column-inserts and -o/--oids cannot be used together\n");
write_msg(NULL, "(The INSERT command cannot set OIDs.)\n");
exit_nicely(1);
}
! if (dopt->if_exists && !dopt->outputClean)
exit_horribly(NULL, "option --if-exists requires option -c/--clean\n");
/* Identify archive format to emit */
! dopt->archiveFormat = parseArchiveFormat(format, &dopt->archiveMode);
/* archiveFormat specific setup */
! if (dopt->archiveFormat == archNull)
! dopt->plainText = 1;
/* Custom and directory formats are compressed by default, others not */
! if (dopt->compressLevel == -1)
{
! if (dopt->archiveFormat == archCustom || dopt->archiveFormat == archDirectory)
! dopt->compressLevel = Z_DEFAULT_COMPRESSION;
else
! dopt->compressLevel = 0;
}
/*
*************** main(int argc, char **argv)
*** 605,623 ****
* parallel jobs because that's the maximum limit for the
* WaitForMultipleObjects() call.
*/
! if (numWorkers <= 0
#ifdef WIN32
! || numWorkers > MAXIMUM_WAIT_OBJECTS
#endif
)
exit_horribly(NULL, "%s: invalid number of parallel jobs\n", progname);
/* Parallel backup only in the directory archive format so far */
! if (archiveFormat != archDirectory && numWorkers > 1)
exit_horribly(NULL, "parallel backup only supported by the directory format\n");
/* Open the output file */
! fout = CreateArchive(filename, archiveFormat, compressLevel, archiveMode,
setupDumpWorker);
/* Register the cleanup hook */
--- 563,581 ----
* parallel jobs because that's the maximum limit for the
* WaitForMultipleObjects() call.
*/
! if (dopt->numWorkers <= 0
#ifdef WIN32
! || dopt->numWorkers > MAXIMUM_WAIT_OBJECTS
#endif
)
exit_horribly(NULL, "%s: invalid number of parallel jobs\n", progname);
/* Parallel backup only in the directory archive format so far */
! if (dopt->archiveFormat != archDirectory && dopt->numWorkers > 1)
exit_horribly(NULL, "parallel backup only supported by the directory format\n");
/* Open the output file */
! fout = CreateArchive(filename, dopt->archiveFormat, dopt->compressLevel, dopt->archiveMode,
setupDumpWorker);
/* Register the cleanup hook */
*************** main(int argc, char **argv)
*** 636,656 ****
fout->minRemoteVersion = 70000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
! fout->numWorkers = numWorkers;
/*
* Open the database using the Archiver, so it knows about it. Errors mean
* death.
*/
! ConnectDatabase(fout, dbname, pghost, pgport, username, prompt_password);
! setup_connection(fout, dumpencoding, use_role);
/*
* Disable security label support if server version < v9.1.x (prevents
* access to nonexistent pg_seclabel catalog)
*/
if (fout->remoteVersion < 90100)
! no_security_labels = 1;
/*
* When running against 9.0 or later, check if we are in recovery mode,
--- 594,614 ----
fout->minRemoteVersion = 70000;
fout->maxRemoteVersion = (PG_VERSION_NUM / 100) * 100 + 99;
! fout->numWorkers = dopt->numWorkers;
/*
* Open the database using the Archiver, so it knows about it. Errors mean
* death.
*/
! ConnectDatabase(fout, dopt->dbname, dopt->pghost, dopt->pgport, dopt->username, dopt->prompt_password);
! setup_connection(fout, dopt);
/*
* Disable security label support if server version < v9.1.x (prevents
* access to nonexistent pg_seclabel catalog)
*/
if (fout->remoteVersion < 90100)
! dopt->no_security_labels = 1;
/*
* When running against 9.0 or later, check if we are in recovery mode,
*************** main(int argc, char **argv)
*** 666,672 ****
* On hot standby slaves, never try to dump unlogged table data,
* since it will just throw an error.
*/
! no_unlogged_table_data = true;
}
PQclear(res);
}
--- 624,630 ----
* On hot standby slaves, never try to dump unlogged table data,
* since it will just throw an error.
*/
! dopt->no_unlogged_table_data = true;
}
PQclear(res);
}
*************** main(int argc, char **argv)
*** 680,687 ****
username_subquery = "SELECT usename FROM pg_user WHERE usesysid =";
/* check the version for the synchronized snapshots feature */
! if (numWorkers > 1 && fout->remoteVersion < 90200
! && !no_synchronized_snapshots)
exit_horribly(NULL,
"Synchronized snapshots are not supported by this server version.\n"
"Run with --no-synchronized-snapshots instead if you do not need\n"
--- 638,645 ----
username_subquery = "SELECT usename FROM pg_user WHERE usesysid =";
/* check the version for the synchronized snapshots feature */
! if (dopt->numWorkers > 1 && fout->remoteVersion < 90200
! && !dopt->no_synchronized_snapshots)
exit_horribly(NULL,
"Synchronized snapshots are not supported by this server version.\n"
"Run with --no-synchronized-snapshots instead if you do not need\n"
*************** main(int argc, char **argv)
*** 731,757 ****
* Dumping blobs is now default unless we saw an inclusion switch or -s
* ... but even if we did see one of these, -b turns it back on.
*/
! if (include_everything && !schemaOnly)
! outputBlobs = true;
/*
* Now scan the database and create DumpableObject structs for all the
* objects we intend to dump.
*/
! tblinfo = getSchemaData(fout, &numTables);
if (fout->remoteVersion < 80400)
guessConstraintInheritance(tblinfo, numTables);
! if (!schemaOnly)
{
! getTableData(tblinfo, numTables, oids);
buildMatViewRefreshDependencies(fout);
! if (dataOnly)
getTableDataFKConstraints();
}
! if (outputBlobs)
getBlobs(fout);
/*
--- 689,715 ----
* Dumping blobs is now default unless we saw an inclusion switch or -s
* ... but even if we did see one of these, -b turns it back on.
*/
! if (dopt->include_everything && !dopt->schemaOnly)
! dopt->outputBlobs = true;
/*
* Now scan the database and create DumpableObject structs for all the
* objects we intend to dump.
*/
! tblinfo = getSchemaData(fout, dopt, &numTables);
if (fout->remoteVersion < 80400)
guessConstraintInheritance(tblinfo, numTables);
! if (!dopt->schemaOnly)
{
! getTableData(dopt, tblinfo, numTables, dopt->oids);
buildMatViewRefreshDependencies(fout);
! if (dopt->dataOnly)
getTableDataFKConstraints();
}
! if (dopt->outputBlobs)
getBlobs(fout);
/*
*************** main(int argc, char **argv)
*** 785,791 ****
sortDumpableObjectsByTypeOid(dobjs, numObjs);
/* If we do a parallel dump, we want the largest tables to go first */
! if (archiveFormat == archDirectory && numWorkers > 1)
sortDataAndIndexObjectsBySize(dobjs, numObjs);
sortDumpableObjects(dobjs, numObjs,
--- 743,749 ----
sortDumpableObjectsByTypeOid(dobjs, numObjs);
/* If we do a parallel dump, we want the largest tables to go first */
! if (dopt->archiveFormat == archDirectory && dopt->numWorkers > 1)
sortDataAndIndexObjectsBySize(dobjs, numObjs);
sortDumpableObjects(dobjs, numObjs,
*************** main(int argc, char **argv)
*** 801,835 ****
dumpStdStrings(fout);
/* The database item is always next, unless we don't want it at all */
! if (include_everything && !dataOnly)
! dumpDatabase(fout);
/* Now the rearrangeable objects. */
for (i = 0; i < numObjs; i++)
! dumpDumpableObject(fout, dobjs[i]);
/*
* Set up options info to ensure we dump what we want.
*/
ropt = NewRestoreOptions();
ropt->filename = filename;
! ropt->dropSchema = outputClean;
! ropt->dataOnly = dataOnly;
! ropt->schemaOnly = schemaOnly;
! ropt->if_exists = if_exists;
! ropt->dumpSections = dumpSections;
! ropt->aclsSkip = aclsSkip;
! ropt->superuser = outputSuperuser;
! ropt->createDB = outputCreateDB;
! ropt->noOwner = outputNoOwner;
! ropt->noTablespace = outputNoTablespaces;
! ropt->disable_triggers = disable_triggers;
! ropt->use_setsessauth = use_setsessauth;
! if (compressLevel == -1)
ropt->compression = 0;
else
! ropt->compression = compressLevel;
ropt->suppressDumpWarnings = true; /* We've already shown them */
--- 759,799 ----
dumpStdStrings(fout);
/* The database item is always next, unless we don't want it at all */
! if (dopt->include_everything && !dopt->dataOnly)
! dumpDatabase(fout, dopt);
/* Now the rearrangeable objects. */
for (i = 0; i < numObjs; i++)
! dumpDumpableObject(fout, dopt, dobjs[i]);
/*
* Set up options info to ensure we dump what we want.
*/
ropt = NewRestoreOptions();
ropt->filename = filename;
! ropt->dropSchema = dopt->outputClean;
! ropt->dataOnly = dopt->dataOnly;
! ropt->schemaOnly = dopt->schemaOnly;
! ropt->if_exists = dopt->if_exists;
! ropt->column_inserts = dopt->column_inserts;
! ropt->dumpSections = dopt->dumpSections;
! ropt->aclsSkip = dopt->aclsSkip;
! ropt->superuser = dopt->outputSuperuser;
! ropt->createDB = dopt->outputCreateDB;
! ropt->noOwner = dopt->outputNoOwner;
! ropt->noTablespace = dopt->outputNoTablespaces;
! ropt->disable_triggers = dopt->disable_triggers;
! ropt->use_setsessauth = dopt->use_setsessauth;
! ropt->disable_dollar_quoting = dopt->disable_dollar_quoting;
! ropt->dump_inserts = dopt->dump_inserts;
! ropt->no_security_labels = dopt->no_security_labels;
! ropt->lockWaitTimeout = dopt->lockWaitTimeout;
! ropt->include_everything = dopt->include_everything;
! if (dopt->compressLevel == -1)
ropt->compression = 0;
else
! ropt->compression = dopt->compressLevel;
ropt->suppressDumpWarnings = true; /* We've already shown them */
*************** main(int argc, char **argv)
*** 840,846 ****
* be output, so we can set up their dependency lists properly. This isn't
* necessary for plain-text output, though.
*/
! if (!plainText)
BuildArchiveDependencies(fout);
/*
--- 804,810 ----
* be output, so we can set up their dependency lists properly. This isn't
* necessary for plain-text output, though.
*/
! if (!dopt->plainText)
BuildArchiveDependencies(fout);
/*
*************** main(int argc, char **argv)
*** 850,859 ****
* inside CloseArchive(). This is, um, bizarre; but not worth changing
* right now.
*/
! if (plainText)
RestoreArchive(fout);
! CloseArchive(fout);
exit_nicely(0);
}
--- 814,823 ----
* inside CloseArchive(). This is, um, bizarre; but not worth changing
* right now.
*/
! if (dopt->plainText)
RestoreArchive(fout);
! CloseArchive(fout, dopt);
exit_nicely(0);
}
*************** help(const char *progname)
*** 926,932 ****
}
static void
! setup_connection(Archive *AH, const char *dumpencoding, char *use_role)
{
PGconn *conn = GetConnection(AH);
const char *std_strings;
--- 890,896 ----
}
static void
! setup_connection(Archive *AH, DumpOptions *dopt)
{
PGconn *conn = GetConnection(AH);
const char *std_strings;
*************** setup_connection(Archive *AH, const char
*** 937,947 ****
* this has already been set in CloneArchive according to the original
* connection encoding.
*/
! if (dumpencoding)
{
! if (PQsetClientEncoding(conn, dumpencoding) < 0)
exit_horribly(NULL, "invalid client encoding \"%s\" specified\n",
! dumpencoding);
}
/*
--- 901,911 ----
* this has already been set in CloneArchive according to the original
* connection encoding.
*/
! if (dopt->dumpencoding)
{
! if (PQsetClientEncoding(conn, dopt->dumpencoding) < 0)
exit_horribly(NULL, "invalid client encoding \"%s\" specified\n",
! dopt->dumpencoding);
}
/*
*************** setup_connection(Archive *AH, const char
*** 954,974 ****
AH->std_strings = (std_strings && strcmp(std_strings, "on") == 0);
/* Set the role if requested */
! if (!use_role && AH->use_role)
! use_role = AH->use_role;
/* Set the role if requested */
! if (use_role && AH->remoteVersion >= 80100)
{
PQExpBuffer query = createPQExpBuffer();
! appendPQExpBuffer(query, "SET ROLE %s", fmtId(use_role));
ExecuteSqlStatement(AH, query->data);
destroyPQExpBuffer(query);
/* save this for later use on parallel connections */
if (!AH->use_role)
! AH->use_role = strdup(use_role);
}
/* Set the datestyle to ISO to ensure the dump's portability */
--- 918,938 ----
AH->std_strings = (std_strings && strcmp(std_strings, "on") == 0);
/* Set the role if requested */
! if (!dopt->use_role && AH->use_role)
! dopt->use_role = AH->use_role;
/* Set the role if requested */
! if (dopt->use_role && AH->remoteVersion >= 80100)
{
PQExpBuffer query = createPQExpBuffer();
! appendPQExpBuffer(query, "SET ROLE %s", fmtId(dopt->use_role));
ExecuteSqlStatement(AH, query->data);
destroyPQExpBuffer(query);
/* save this for later use on parallel connections */
if (!AH->use_role)
! AH->use_role = strdup(dopt->use_role);
}
/* Set the datestyle to ISO to ensure the dump's portability */
*************** setup_connection(Archive *AH, const char
*** 1014,1020 ****
ExecuteSqlStatement(AH, "BEGIN");
if (AH->remoteVersion >= 90100)
{
! if (serializable_deferrable)
ExecuteSqlStatement(AH,
"SET TRANSACTION ISOLATION LEVEL "
"SERIALIZABLE, READ ONLY, DEFERRABLE");
--- 978,984 ----
ExecuteSqlStatement(AH, "BEGIN");
if (AH->remoteVersion >= 90100)
{
! if (dopt->serializable_deferrable)
ExecuteSqlStatement(AH,
"SET TRANSACTION ISOLATION LEVEL "
"SERIALIZABLE, READ ONLY, DEFERRABLE");
*************** setup_connection(Archive *AH, const char
*** 1036,1042 ****
! if (AH->numWorkers > 1 && AH->remoteVersion >= 90200 && !no_synchronized_snapshots)
{
if (AH->sync_snapshot_id)
{
--- 1000,1006 ----
! if (AH->numWorkers > 1 && AH->remoteVersion >= 90200 && !dopt->no_synchronized_snapshots)
{
if (AH->sync_snapshot_id)
{
*************** setup_connection(Archive *AH, const char
*** 1053,1061 ****
}
static void
! setupDumpWorker(Archive *AHX, RestoreOptions *ropt)
{
! setup_connection(AHX, NULL, NULL);
}
static char *
--- 1017,1025 ----
}
static void
! setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt)
{
! setup_connection(AHX, dopt);
}
static char *
*************** selectDumpableType(TypeInfo *tyinfo)
*** 1326,1337 ****
* and aclsSkip are checked separately.
*/
static void
! selectDumpableDefaultACL(DefaultACLInfo *dinfo)
{
if (dinfo->dobj.namespace)
dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump;
else
! dinfo->dobj.dump = include_everything;
}
/*
--- 1290,1301 ----
* and aclsSkip are checked separately.
*/
static void
! selectDumpableDefaultACL(DumpOptions *dopt, DefaultACLInfo *dinfo)
{
if (dinfo->dobj.namespace)
dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump;
else
! dinfo->dobj.dump = dopt->include_everything;
}
/*
*************** selectDumpableDefaultACL(DefaultACLInfo
*** 1345,1356 ****
* such extensions by their having OIDs in the range reserved for initdb.
*/
static void
! selectDumpableExtension(ExtensionInfo *extinfo)
{
if (binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
extinfo->dobj.dump = false;
else
! extinfo->dobj.dump = include_everything;
}
/*
--- 1309,1320 ----
* such extensions by their having OIDs in the range reserved for initdb.
*/
static void
! selectDumpableExtension(DumpOptions *dopt, ExtensionInfo *extinfo)
{
if (binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
extinfo->dobj.dump = false;
else
! extinfo->dobj.dump = dopt->include_everything;
}
/*
*************** selectDumpableObject(DumpableObject *dob
*** 1379,1385 ****
*/
static int
! dumpTableData_copy(Archive *fout, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
--- 1343,1349 ----
*/
static int
! dumpTableData_copy(Archive *fout, DumpOptions *dopt, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
*************** dumpTableData_copy(Archive *fout, void *
*** 1554,1560 ****
* E'' strings, or dollar-quoted strings. So don't emit anything like that.
*/
static int
! dumpTableData_insert(Archive *fout, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
--- 1518,1524 ----
* E'' strings, or dollar-quoted strings. So don't emit anything like that.
*/
static int
! dumpTableData_insert(Archive *fout, DumpOptions *dopt, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
*************** dumpTableData_insert(Archive *fout, void
*** 1623,1629 ****
else
{
/* append the list of column names if required */
! if (column_inserts)
{
appendPQExpBufferStr(insertStmt, "(");
for (field = 0; field < nfields; field++)
--- 1587,1593 ----
else
{
/* append the list of column names if required */
! if (dopt->column_inserts)
{
appendPQExpBufferStr(insertStmt, "(");
for (field = 0; field < nfields; field++)
*************** dumpTableData_insert(Archive *fout, void
*** 1740,1746 ****
* Actually, this just makes an ArchiveEntry for the table contents.
*/
static void
! dumpTableData(Archive *fout, TableDataInfo *tdinfo)
{
TableInfo *tbinfo = tdinfo->tdtable;
PQExpBuffer copyBuf = createPQExpBuffer();
--- 1704,1710 ----
* Actually, this just makes an ArchiveEntry for the table contents.
*/
static void
! dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo)
{
TableInfo *tbinfo = tdinfo->tdtable;
PQExpBuffer copyBuf = createPQExpBuffer();
*************** dumpTableData(Archive *fout, TableDataIn
*** 1748,1754 ****
DataDumperPtr dumpFn;
char *copyStmt;
! if (!dump_inserts)
{
/* Dump/restore using COPY */
dumpFn = dumpTableData_copy;
--- 1712,1718 ----
DataDumperPtr dumpFn;
char *copyStmt;
! if (!dopt->dump_inserts)
{
/* Dump/restore using COPY */
dumpFn = dumpTableData_copy;
*************** refreshMatViewData(Archive *fout, TableD
*** 1832,1845 ****
* set up dumpable objects representing the contents of tables
*/
static void
! getTableData(TableInfo *tblinfo, int numTables, bool oids)
{
int i;
for (i = 0; i < numTables; i++)
{
if (tblinfo[i].dobj.dump)
! makeTableDataInfo(&(tblinfo[i]), oids);
}
}
--- 1796,1809 ----
* set up dumpable objects representing the contents of tables
*/
static void
! getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids)
{
int i;
for (i = 0; i < numTables; i++)
{
if (tblinfo[i].dobj.dump)
! makeTableDataInfo(dopt, &(tblinfo[i]), oids);
}
}
*************** getTableData(TableInfo *tblinfo, int num
*** 1850,1856 ****
* table data; the "dump" flag in such objects isn't used.
*/
static void
! makeTableDataInfo(TableInfo *tbinfo, bool oids)
{
TableDataInfo *tdinfo;
--- 1814,1820 ----
* table data; the "dump" flag in such objects isn't used.
*/
static void
! makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids)
{
TableDataInfo *tdinfo;
*************** makeTableDataInfo(TableInfo *tbinfo, boo
*** 1870,1876 ****
/* Don't dump data in unlogged tables, if so requested */
if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED &&
! no_unlogged_table_data)
return;
/* Check that the data is not explicitly excluded */
--- 1834,1840 ----
/* Don't dump data in unlogged tables, if so requested */
if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED &&
! dopt->no_unlogged_table_data)
return;
/* Check that the data is not explicitly excluded */
*************** guessConstraintInheritance(TableInfo *tb
*** 2143,2149 ****
* dump the database definition
*/
static void
! dumpDatabase(Archive *fout)
{
PQExpBuffer dbQry = createPQExpBuffer();
PQExpBuffer delQry = createPQExpBuffer();
--- 2107,2113 ----
* dump the database definition
*/
static void
! dumpDatabase(Archive *fout, DumpOptions *dopt)
{
PQExpBuffer dbQry = createPQExpBuffer();
PQExpBuffer delQry = createPQExpBuffer();
*************** dumpDatabase(Archive *fout)
*** 2462,2475 ****
{
resetPQExpBuffer(dbQry);
appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname));
! dumpComment(fout, dbQry->data, NULL, "",
dbCatId, 0, dbDumpId);
}
PQclear(res);
/* Dump shared security label. */
! if (!no_security_labels && fout->remoteVersion >= 90200)
{
PQExpBuffer seclabelQry = createPQExpBuffer();
--- 2426,2439 ----
{
resetPQExpBuffer(dbQry);
appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname));
! dumpComment(fout, dopt, dbQry->data, NULL, "",
dbCatId, 0, dbDumpId);
}
PQclear(res);
/* Dump shared security label. */
! if (!dopt->no_security_labels && fout->remoteVersion >= 90200)
{
PQExpBuffer seclabelQry = createPQExpBuffer();
*************** dumpDatabase(Archive *fout)
*** 2490,2496 ****
destroyPQExpBuffer(creaQry);
}
-
/*
* dumpEncoding: put the correct encoding into the archive
*/
--- 2454,2459 ----
*************** getBlobs(Archive *fout)
*** 2630,2636 ****
* dump the definition (metadata) of the given large object
*/
static void
! dumpBlob(Archive *fout, BlobInfo *binfo)
{
PQExpBuffer cquery = createPQExpBuffer();
PQExpBuffer dquery = createPQExpBuffer();
--- 2593,2599 ----
* dump the definition (metadata) of the given large object
*/
static void
! dumpBlob(Archive *fout, DumpOptions* dopt, BlobInfo *binfo)
{
PQExpBuffer cquery = createPQExpBuffer();
PQExpBuffer dquery = createPQExpBuffer();
*************** dumpBlob(Archive *fout, BlobInfo *binfo)
*** 2657,2674 ****
appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name);
/* Dump comment if any */
! dumpComment(fout, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump security label if any */
! dumpSecLabel(fout, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump ACL if any */
if (binfo->blobacl)
! dumpACL(fout, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT",
binfo->dobj.name, NULL, cquery->data,
NULL, binfo->rolname, binfo->blobacl);
--- 2620,2637 ----
appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name);
/* Dump comment if any */
! dumpComment(fout, dopt, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump security label if any */
! dumpSecLabel(fout, dopt, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump ACL if any */
if (binfo->blobacl)
! dumpACL(fout, dopt, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT",
binfo->dobj.name, NULL, cquery->data,
NULL, binfo->rolname, binfo->blobacl);
*************** dumpBlob(Archive *fout, BlobInfo *binfo)
*** 2681,2687 ****
* dump the data contents of all large objects
*/
static int
! dumpBlobs(Archive *fout, void *arg)
{
const char *blobQry;
const char *blobFetchQry;
--- 2644,2650 ----
* dump the data contents of all large objects
*/
static int
! dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg)
{
const char *blobQry;
const char *blobFetchQry;
*************** findNamespace(Archive *fout, Oid nsoid,
*** 3092,3098 ****
* numExtensions is set to the number of extensions read in
*/
ExtensionInfo *
! getExtensions(Archive *fout, int *numExtensions)
{
PGresult *res;
int ntups;
--- 3055,3061 ----
* numExtensions is set to the number of extensions read in
*/
ExtensionInfo *
! getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions)
{
PGresult *res;
int ntups;
*************** getExtensions(Archive *fout, int *numExt
*** 3156,3162 ****
extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition));
/* Decide whether we want to dump it */
! selectDumpableExtension(&(extinfo[i]));
}
PQclear(res);
--- 3119,3125 ----
extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition));
/* Decide whether we want to dump it */
! selectDumpableExtension(dopt, &(extinfo[i]));
}
PQclear(res);
*************** getFuncs(Archive *fout, int *numFuncs)
*** 4269,4275 ****
* numTables is set to the number of tables read in
*/
TableInfo *
! getTables(Archive *fout, int *numTables)
{
PGresult *res;
int ntups;
--- 4232,4238 ----
* numTables is set to the number of tables read in
*/
TableInfo *
! getTables(Archive *fout, DumpOptions *dopt, int *numTables)
{
PGresult *res;
int ntups;
*************** getTables(Archive *fout, int *numTables)
*** 4766,4772 ****
i_toastreloptions = PQfnumber(res, "toast_reloptions");
i_reloftype = PQfnumber(res, "reloftype");
! if (lockWaitTimeout && fout->remoteVersion >= 70300)
{
/*
* Arrange to fail instead of waiting forever for a table lock.
--- 4729,4735 ----
i_toastreloptions = PQfnumber(res, "toast_reloptions");
i_reloftype = PQfnumber(res, "reloftype");
! if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300)
{
/*
* Arrange to fail instead of waiting forever for a table lock.
*************** getTables(Archive *fout, int *numTables)
*** 4777,4783 ****
*/
resetPQExpBuffer(query);
appendPQExpBufferStr(query, "SET statement_timeout = ");
! appendStringLiteralConn(query, lockWaitTimeout, GetConnection(fout));
ExecuteSqlStatement(fout, query->data);
}
--- 4740,4746 ----
*/
resetPQExpBuffer(query);
appendPQExpBufferStr(query, "SET statement_timeout = ");
! appendStringLiteralConn(query, dopt->lockWaitTimeout, GetConnection(fout));
ExecuteSqlStatement(fout, query->data);
}
*************** getTables(Archive *fout, int *numTables)
*** 4872,4878 ****
tblinfo[i].dobj.name);
}
! if (lockWaitTimeout && fout->remoteVersion >= 70300)
{
ExecuteSqlStatement(fout, "SET statement_timeout = 0");
}
--- 4835,4841 ----
tblinfo[i].dobj.name);
}
! if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300)
{
ExecuteSqlStatement(fout, "SET statement_timeout = 0");
}
*************** getForeignServers(Archive *fout, int *nu
*** 7403,7409 ****
* numDefaultACLs is set to the number of ACLs read in
*/
DefaultACLInfo *
! getDefaultACLs(Archive *fout, int *numDefaultACLs)
{
DefaultACLInfo *daclinfo;
PQExpBuffer query;
--- 7366,7372 ----
* numDefaultACLs is set to the number of ACLs read in
*/
DefaultACLInfo *
! getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs)
{
DefaultACLInfo *daclinfo;
PQExpBuffer query;
*************** getDefaultACLs(Archive *fout, int *numDe
*** 7472,7478 ****
daclinfo[i].defaclacl = pg_strdup(PQgetvalue(res, i, i_defaclacl));
/* Decide whether we want to dump it */
! selectDumpableDefaultACL(&(daclinfo[i]));
}
PQclear(res);
--- 7435,7441 ----
daclinfo[i].defaclacl = pg_strdup(PQgetvalue(res, i, i_defaclacl));
/* Decide whether we want to dump it */
! selectDumpableDefaultACL(dopt, &(daclinfo[i]));
}
PQclear(res);
*************** getDefaultACLs(Archive *fout, int *numDe
*** 7501,7507 ****
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpComment(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
--- 7464,7470 ----
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpComment(Archive *fout, DumpOptions *dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
*************** dumpComment(Archive *fout, const char *t
*** 7511,7522 ****
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dataOnly)
return;
}
else
{
! if (schemaOnly)
return;
}
--- 7474,7485 ----
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dopt->dataOnly)
return;
}
else
{
! if (dopt->schemaOnly)
return;
}
*************** dumpComment(Archive *fout, const char *t
*** 7565,7571 ****
* and its columns.
*/
static void
! dumpTableComment(Archive *fout, TableInfo *tbinfo,
const char *reltypename)
{
CommentItem *comments;
--- 7528,7534 ----
* and its columns.
*/
static void
! dumpTableComment(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo,
const char *reltypename)
{
CommentItem *comments;
*************** dumpTableComment(Archive *fout, TableInf
*** 7574,7580 ****
PQExpBuffer target;
/* Comments are SCHEMA not data */
! if (dataOnly)
return;
/* Search for comments associated with relation, using table */
--- 7537,7543 ----
PQExpBuffer target;
/* Comments are SCHEMA not data */
! if (dopt->dataOnly)
return;
/* Search for comments associated with relation, using table */
*************** collectComments(Archive *fout, CommentIt
*** 7819,7926 ****
* ArchiveEntries (TOC objects) for each object to be dumped.
*/
static void
! dumpDumpableObject(Archive *fout, DumpableObject *dobj)
{
switch (dobj->objType)
{
case DO_NAMESPACE:
! dumpNamespace(fout, (NamespaceInfo *) dobj);
break;
case DO_EXTENSION:
! dumpExtension(fout, (ExtensionInfo *) dobj);
break;
case DO_TYPE:
! dumpType(fout, (TypeInfo *) dobj);
break;
case DO_SHELL_TYPE:
! dumpShellType(fout, (ShellTypeInfo *) dobj);
break;
case DO_FUNC:
! dumpFunc(fout, (FuncInfo *) dobj);
break;
case DO_AGG:
! dumpAgg(fout, (AggInfo *) dobj);
break;
case DO_OPERATOR:
! dumpOpr(fout, (OprInfo *) dobj);
break;
case DO_OPCLASS:
! dumpOpclass(fout, (OpclassInfo *) dobj);
break;
case DO_OPFAMILY:
! dumpOpfamily(fout, (OpfamilyInfo *) dobj);
break;
case DO_COLLATION:
! dumpCollation(fout, (CollInfo *) dobj);
break;
case DO_CONVERSION:
! dumpConversion(fout, (ConvInfo *) dobj);
break;
case DO_TABLE:
! dumpTable(fout, (TableInfo *) dobj);
break;
case DO_ATTRDEF:
! dumpAttrDef(fout, (AttrDefInfo *) dobj);
break;
case DO_INDEX:
! dumpIndex(fout, (IndxInfo *) dobj);
break;
case DO_REFRESH_MATVIEW:
refreshMatViewData(fout, (TableDataInfo *) dobj);
break;
case DO_RULE:
! dumpRule(fout, (RuleInfo *) dobj);
break;
case DO_TRIGGER:
! dumpTrigger(fout, (TriggerInfo *) dobj);
break;
case DO_EVENT_TRIGGER:
! dumpEventTrigger(fout, (EventTriggerInfo *) dobj);
break;
case DO_CONSTRAINT:
! dumpConstraint(fout, (ConstraintInfo *) dobj);
break;
case DO_FK_CONSTRAINT:
! dumpConstraint(fout, (ConstraintInfo *) dobj);
break;
case DO_PROCLANG:
! dumpProcLang(fout, (ProcLangInfo *) dobj);
break;
case DO_CAST:
! dumpCast(fout, (CastInfo *) dobj);
break;
case DO_TABLE_DATA:
if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE)
dumpSequenceData(fout, (TableDataInfo *) dobj);
else
! dumpTableData(fout, (TableDataInfo *) dobj);
break;
case DO_DUMMY_TYPE:
/* table rowtypes and array types are never dumped separately */
break;
case DO_TSPARSER:
! dumpTSParser(fout, (TSParserInfo *) dobj);
break;
case DO_TSDICT:
! dumpTSDictionary(fout, (TSDictInfo *) dobj);
break;
case DO_TSTEMPLATE:
! dumpTSTemplate(fout, (TSTemplateInfo *) dobj);
break;
case DO_TSCONFIG:
! dumpTSConfig(fout, (TSConfigInfo *) dobj);
break;
case DO_FDW:
! dumpForeignDataWrapper(fout, (FdwInfo *) dobj);
break;
case DO_FOREIGN_SERVER:
! dumpForeignServer(fout, (ForeignServerInfo *) dobj);
break;
case DO_DEFAULT_ACL:
! dumpDefaultACL(fout, (DefaultACLInfo *) dobj);
break;
case DO_BLOB:
! dumpBlob(fout, (BlobInfo *) dobj);
break;
case DO_BLOB_DATA:
ArchiveEntry(fout, dobj->catId, dobj->dumpId,
--- 7782,7889 ----
* ArchiveEntries (TOC objects) for each object to be dumped.
*/
static void
! dumpDumpableObject(Archive *fout, DumpOptions *dopt, DumpableObject *dobj)
{
switch (dobj->objType)
{
case DO_NAMESPACE:
! dumpNamespace(fout, dopt, (NamespaceInfo *) dobj);
break;
case DO_EXTENSION:
! dumpExtension(fout, dopt, (ExtensionInfo *) dobj);
break;
case DO_TYPE:
! dumpType(fout, dopt, (TypeInfo *) dobj);
break;
case DO_SHELL_TYPE:
! dumpShellType(fout, dopt, (ShellTypeInfo *) dobj);
break;
case DO_FUNC:
! dumpFunc(fout, dopt, (FuncInfo *) dobj);
break;
case DO_AGG:
! dumpAgg(fout, dopt, (AggInfo *) dobj);
break;
case DO_OPERATOR:
! dumpOpr(fout, dopt, (OprInfo *) dobj);
break;
case DO_OPCLASS:
! dumpOpclass(fout, dopt, (OpclassInfo *) dobj);
break;
case DO_OPFAMILY:
! dumpOpfamily(fout, dopt, (OpfamilyInfo *) dobj);
break;
case DO_COLLATION:
! dumpCollation(fout, dopt, (CollInfo *) dobj);
break;
case DO_CONVERSION:
! dumpConversion(fout, dopt, (ConvInfo *) dobj);
break;
case DO_TABLE:
! dumpTable(fout, dopt, (TableInfo *) dobj);
break;
case DO_ATTRDEF:
! dumpAttrDef(fout, dopt, (AttrDefInfo *) dobj);
break;
case DO_INDEX:
! dumpIndex(fout, dopt, (IndxInfo *) dobj);
break;
case DO_REFRESH_MATVIEW:
refreshMatViewData(fout, (TableDataInfo *) dobj);
break;
case DO_RULE:
! dumpRule(fout, dopt, (RuleInfo *) dobj);
break;
case DO_TRIGGER:
! dumpTrigger(fout, dopt, (TriggerInfo *) dobj);
break;
case DO_EVENT_TRIGGER:
! dumpEventTrigger(fout, dopt, (EventTriggerInfo *) dobj);
break;
case DO_CONSTRAINT:
! dumpConstraint(fout, dopt, (ConstraintInfo *) dobj);
break;
case DO_FK_CONSTRAINT:
! dumpConstraint(fout, dopt, (ConstraintInfo *) dobj);
break;
case DO_PROCLANG:
! dumpProcLang(fout, dopt, (ProcLangInfo *) dobj);
break;
case DO_CAST:
! dumpCast(fout, dopt, (CastInfo *) dobj);
break;
case DO_TABLE_DATA:
if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE)
dumpSequenceData(fout, (TableDataInfo *) dobj);
else
! dumpTableData(fout, dopt, (TableDataInfo *) dobj);
break;
case DO_DUMMY_TYPE:
/* table rowtypes and array types are never dumped separately */
break;
case DO_TSPARSER:
! dumpTSParser(fout, dopt, (TSParserInfo *) dobj);
break;
case DO_TSDICT:
! dumpTSDictionary(fout, dopt, (TSDictInfo *) dobj);
break;
case DO_TSTEMPLATE:
! dumpTSTemplate(fout, dopt, (TSTemplateInfo *) dobj);
break;
case DO_TSCONFIG:
! dumpTSConfig(fout, dopt, (TSConfigInfo *) dobj);
break;
case DO_FDW:
! dumpForeignDataWrapper(fout, dopt, (FdwInfo *) dobj);
break;
case DO_FOREIGN_SERVER:
! dumpForeignServer(fout, dopt, (ForeignServerInfo *) dobj);
break;
case DO_DEFAULT_ACL:
! dumpDefaultACL(fout, dopt, (DefaultACLInfo *) dobj);
break;
case DO_BLOB:
! dumpBlob(fout, dopt, (BlobInfo *) dobj);
break;
case DO_BLOB_DATA:
ArchiveEntry(fout, dobj->catId, dobj->dumpId,
*************** dumpDumpableObject(Archive *fout, Dumpab
*** 7942,7948 ****
* writes out to fout the queries to recreate a user-defined namespace
*/
static void
! dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 7905,7911 ----
* writes out to fout the queries to recreate a user-defined namespace
*/
static void
! dumpNamespace(Archive *fout, DumpOptions *dopt, NamespaceInfo *nspinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpNamespace(Archive *fout, NamespaceIn
*** 7950,7956 ****
char *qnspname;
/* Skip if not to be dumped */
! if (!nspinfo->dobj.dump || dataOnly)
return;
/* don't dump dummy namespace from pre-7.3 source */
--- 7913,7919 ----
char *qnspname;
/* Skip if not to be dumped */
! if (!nspinfo->dobj.dump || dopt->dataOnly)
return;
/* don't dump dummy namespace from pre-7.3 source */
*************** dumpNamespace(Archive *fout, NamespaceIn
*** 7982,7995 ****
NULL, NULL);
/* Dump Schema Comments and Security Labels */
! dumpComment(fout, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
qnspname, NULL, nspinfo->dobj.name, NULL,
nspinfo->rolname, nspinfo->nspacl);
--- 7945,7958 ----
NULL, NULL);
/* Dump Schema Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpACL(fout, dopt, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
qnspname, NULL, nspinfo->dobj.name, NULL,
nspinfo->rolname, nspinfo->nspacl);
*************** dumpNamespace(Archive *fout, NamespaceIn
*** 8005,8011 ****
* writes out to fout the queries to recreate an extension
*/
static void
! dumpExtension(Archive *fout, ExtensionInfo *extinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 7968,7974 ----
* writes out to fout the queries to recreate an extension
*/
static void
! dumpExtension(Archive *fout, DumpOptions *dopt, ExtensionInfo *extinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpExtension(Archive *fout, ExtensionIn
*** 8013,8019 ****
char *qextname;
/* Skip if not to be dumped */
! if (!extinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 7976,7982 ----
char *qextname;
/* Skip if not to be dumped */
! if (!extinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpExtension(Archive *fout, ExtensionIn
*** 8110,8119 ****
NULL, NULL);
/* Dump Extension Comments and Security Labels */
! dumpComment(fout, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
--- 8073,8082 ----
NULL, NULL);
/* Dump Extension Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
*************** dumpExtension(Archive *fout, ExtensionIn
*** 8129,8151 ****
* writes out to fout the queries to recreate a user-defined type
*/
static void
! dumpType(Archive *fout, TypeInfo *tyinfo)
{
/* Skip if not to be dumped */
! if (!tyinfo->dobj.dump || dataOnly)
return;
/* Dump out in proper style */
if (tyinfo->typtype == TYPTYPE_BASE)
! dumpBaseType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_DOMAIN)
! dumpDomain(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_COMPOSITE)
! dumpCompositeType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_ENUM)
! dumpEnumType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_RANGE)
! dumpRangeType(fout, tyinfo);
else
write_msg(NULL, "WARNING: typtype of data type \"%s\" appears to be invalid\n",
tyinfo->dobj.name);
--- 8092,8114 ----
* writes out to fout the queries to recreate a user-defined type
*/
static void
! dumpType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
/* Skip if not to be dumped */
! if (!tyinfo->dobj.dump || dopt->dataOnly)
return;
/* Dump out in proper style */
if (tyinfo->typtype == TYPTYPE_BASE)
! dumpBaseType(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_DOMAIN)
! dumpDomain(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_COMPOSITE)
! dumpCompositeType(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_ENUM)
! dumpEnumType(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_RANGE)
! dumpRangeType(fout, dopt, tyinfo);
else
write_msg(NULL, "WARNING: typtype of data type \"%s\" appears to be invalid\n",
tyinfo->dobj.name);
*************** dumpType(Archive *fout, TypeInfo *tyinfo
*** 8156,8162 ****
* writes out to fout the queries to recreate a user-defined enum type
*/
static void
! dumpEnumType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8119,8125 ----
* writes out to fout the queries to recreate a user-defined enum type
*/
static void
! dumpEnumType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpEnumType(Archive *fout, TypeInfo *ty
*** 8261,8274 ****
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8224,8237 ----
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpEnumType(Archive *fout, TypeInfo *ty
*** 8285,8291 ****
* writes out to fout the queries to recreate a user-defined range type
*/
static void
! dumpRangeType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8248,8254 ----
* writes out to fout the queries to recreate a user-defined range type
*/
static void
! dumpRangeType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpRangeType(Archive *fout, TypeInfo *t
*** 8393,8406 ****
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8356,8369 ----
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpRangeType(Archive *fout, TypeInfo *t
*** 8417,8423 ****
* writes out to fout the queries to recreate a user-defined base type
*/
static void
! dumpBaseType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8380,8386 ----
* writes out to fout the queries to recreate a user-defined base type
*/
static void
! dumpBaseType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpBaseType(Archive *fout, TypeInfo *ty
*** 8783,8796 ****
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8746,8759 ----
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpBaseType(Archive *fout, TypeInfo *ty
*** 8807,8813 ****
* writes out to fout the queries to recreate a user-defined domain
*/
static void
! dumpDomain(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8770,8776 ----
* writes out to fout the queries to recreate a user-defined domain
*/
static void
! dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpDomain(Archive *fout, TypeInfo *tyin
*** 8945,8958 ****
NULL, NULL);
/* Dump Domain Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8908,8921 ----
NULL, NULL);
/* Dump Domain Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpDomain(Archive *fout, TypeInfo *tyin
*** 8969,8975 ****
* composite type
*/
static void
! dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer dropped = createPQExpBuffer();
--- 8932,8938 ----
* composite type
*/
static void
! dumpCompositeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer dropped = createPQExpBuffer();
*************** dumpCompositeType(Archive *fout, TypeInf
*** 9160,9173 ****
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 9123,9136 ----
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpCompositeTypeColComments(Archive *fo
*** 9298,9309 ****
* We dump a shell definition in advance of the I/O functions for the type.
*/
static void
! dumpShellType(Archive *fout, ShellTypeInfo *stinfo)
{
PQExpBuffer q;
/* Skip if not to be dumped */
! if (!stinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 9261,9272 ----
* We dump a shell definition in advance of the I/O functions for the type.
*/
static void
! dumpShellType(Archive *fout, DumpOptions *dopt, ShellTypeInfo *stinfo)
{
PQExpBuffer q;
/* Skip if not to be dumped */
! if (!stinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpShellType(Archive *fout, ShellTypeIn
*** 9353,9364 ****
* That case isn't checked here either.
*/
static bool
! shouldDumpProcLangs(void)
{
! if (!include_everything)
return false;
/* And they're schema not data */
! if (dataOnly)
return false;
return true;
}
--- 9316,9327 ----
* That case isn't checked here either.
*/
static bool
! shouldDumpProcLangs(DumpOptions *dopt)
{
! if (!dopt->include_everything)
return false;
/* And they're schema not data */
! if (dopt->dataOnly)
return false;
return true;
}
*************** shouldDumpProcLangs(void)
*** 9369,9375 ****
* procedural language
*/
static void
! dumpProcLang(Archive *fout, ProcLangInfo *plang)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
--- 9332,9338 ----
* procedural language
*/
static void
! dumpProcLang(Archive *fout, DumpOptions* dopt, ProcLangInfo *plang)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
*************** dumpProcLang(Archive *fout, ProcLangInfo
*** 9382,9388 ****
FuncInfo *validatorInfo = NULL;
/* Skip if not to be dumped */
! if (!plang->dobj.dump || dataOnly)
return;
/*
--- 9345,9351 ----
FuncInfo *validatorInfo = NULL;
/* Skip if not to be dumped */
! if (!plang->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpProcLang(Archive *fout, ProcLangInfo
*** 9428,9434 ****
if (!plang->dobj.ext_member)
{
! if (!useParams && !shouldDumpProcLangs())
return;
}
--- 9391,9397 ----
if (!plang->dobj.ext_member)
{
! if (!useParams && !shouldDumpProcLangs(dopt))
return;
}
*************** dumpProcLang(Archive *fout, ProcLangInfo
*** 9507,9521 ****
NULL, NULL);
/* Dump Proc Lang Comments and Security Labels */
! dumpComment(fout, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
if (plang->lanpltrusted)
! dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
qlanname, NULL, plang->dobj.name,
lanschema,
plang->lanowner, plang->lanacl);
--- 9470,9484 ----
NULL, NULL);
/* Dump Proc Lang Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
if (plang->lanpltrusted)
! dumpACL(fout, dopt, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
qlanname, NULL, plang->dobj.name,
lanschema,
plang->lanowner, plang->lanacl);
*************** format_function_signature(Archive *fout,
*** 9662,9668 ****
* dump out one function
*/
static void
! dumpFunc(Archive *fout, FuncInfo *finfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 9625,9631 ----
* dump out one function
*/
static void
! dumpFunc(Archive *fout, DumpOptions* dopt, FuncInfo *finfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 9701,9707 ****
int i;
/* Skip if not to be dumped */
! if (!finfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 9664,9670 ----
int i;
/* Skip if not to be dumped */
! if (!finfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 9894,9900 ****
* where we have bin, use dollar quoting if allowed and src
* contains quote or backslash; else use regular quoting.
*/
! if (disable_dollar_quoting ||
(strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL))
appendStringLiteralAH(asPart, prosrc, fout);
else
--- 9857,9863 ----
* where we have bin, use dollar quoting if allowed and src
* contains quote or backslash; else use regular quoting.
*/
! if (dopt->disable_dollar_quoting ||
(strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL))
appendStringLiteralAH(asPart, prosrc, fout);
else
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 9907,9913 ****
{
appendPQExpBufferStr(asPart, "AS ");
/* with no bin, dollar quote src unconditionally if allowed */
! if (disable_dollar_quoting)
appendStringLiteralAH(asPart, prosrc, fout);
else
appendStringLiteralDQ(asPart, prosrc, NULL);
--- 9870,9876 ----
{
appendPQExpBufferStr(asPart, "AS ");
/* with no bin, dollar quote src unconditionally if allowed */
! if (dopt->disable_dollar_quoting)
appendStringLiteralAH(asPart, prosrc, fout);
else
appendStringLiteralDQ(asPart, prosrc, NULL);
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 10097,10110 ****
NULL, NULL);
/* Dump Function Comments and Security Labels */
! dumpComment(fout, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, NULL, funcsig_tag,
finfo->dobj.namespace->dobj.name,
finfo->rolname, finfo->proacl);
--- 10060,10073 ----
NULL, NULL);
/* Dump Function Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpACL(fout, dopt, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, NULL, funcsig_tag,
finfo->dobj.namespace->dobj.name,
finfo->rolname, finfo->proacl);
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 10135,10141 ****
* Dump a user-defined cast
*/
static void
! dumpCast(Archive *fout, CastInfo *cast)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
--- 10098,10104 ----
* Dump a user-defined cast
*/
static void
! dumpCast(Archive *fout, DumpOptions* dopt, CastInfo *cast)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
*************** dumpCast(Archive *fout, CastInfo *cast)
*** 10143,10149 ****
FuncInfo *funcInfo = NULL;
/* Skip if not to be dumped */
! if (!cast->dobj.dump || dataOnly)
return;
/* Cannot dump if we don't have the cast function's info */
--- 10106,10112 ----
FuncInfo *funcInfo = NULL;
/* Skip if not to be dumped */
! if (!cast->dobj.dump || dopt->dataOnly)
return;
/* Cannot dump if we don't have the cast function's info */
*************** dumpCast(Archive *fout, CastInfo *cast)
*** 10269,10275 ****
NULL, NULL);
/* Dump Cast Comments */
! dumpComment(fout, labelq->data,
NULL, "",
cast->dobj.catId, 0, cast->dobj.dumpId);
--- 10232,10238 ----
NULL, NULL);
/* Dump Cast Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
cast->dobj.catId, 0, cast->dobj.dumpId);
*************** dumpCast(Archive *fout, CastInfo *cast)
*** 10283,10289 ****
* write out a single operator definition
*/
static void
! dumpOpr(Archive *fout, OprInfo *oprinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 10246,10252 ----
* write out a single operator definition
*/
static void
! dumpOpr(Archive *fout, DumpOptions* dopt, OprInfo *oprinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpOpr(Archive *fout, OprInfo *oprinfo)
*** 10317,10323 ****
char *oprref;
/* Skip if not to be dumped */
! if (!oprinfo->dobj.dump || dataOnly)
return;
/*
--- 10280,10286 ----
char *oprref;
/* Skip if not to be dumped */
! if (!oprinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpOpr(Archive *fout, OprInfo *oprinfo)
*** 10521,10527 ****
NULL, NULL);
/* Dump Operator Comments */
! dumpComment(fout, labelq->data,
oprinfo->dobj.namespace->dobj.name, oprinfo->rolname,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
--- 10484,10490 ----
NULL, NULL);
/* Dump Operator Comments */
! dumpComment(fout, dopt, labelq->data,
oprinfo->dobj.namespace->dobj.name, oprinfo->rolname,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
*************** convertTSFunction(Archive *fout, Oid fun
*** 10671,10677 ****
* write out a single operator class definition
*/
static void
! dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 10634,10640 ----
* write out a single operator class definition
*/
static void
! dumpOpclass(Archive *fout, DumpOptions* dopt, OpclassInfo *opcinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpOpclass(Archive *fout, OpclassInfo *
*** 10715,10721 ****
int i;
/* Skip if not to be dumped */
! if (!opcinfo->dobj.dump || dataOnly)
return;
/*
--- 10678,10684 ----
int i;
/* Skip if not to be dumped */
! if (!opcinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpOpclass(Archive *fout, OpclassInfo *
*** 11029,11035 ****
NULL, NULL);
/* Dump Operator Class Comments */
! dumpComment(fout, labelq->data,
NULL, opcinfo->rolname,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
--- 10992,10998 ----
NULL, NULL);
/* Dump Operator Class Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, opcinfo->rolname,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
*************** dumpOpclass(Archive *fout, OpclassInfo *
*** 11048,11054 ****
* specific opclass within the opfamily.
*/
static void
! dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11011,11017 ----
* specific opclass within the opfamily.
*/
static void
! dumpOpfamily(Archive *fout, DumpOptions* dopt, OpfamilyInfo *opfinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpOpfamily(Archive *fout, OpfamilyInfo
*** 11082,11088 ****
int i;
/* Skip if not to be dumped */
! if (!opfinfo->dobj.dump || dataOnly)
return;
/*
--- 11045,11051 ----
int i;
/* Skip if not to be dumped */
! if (!opfinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpOpfamily(Archive *fout, OpfamilyInfo
*** 11342,11348 ****
NULL, NULL);
/* Dump Operator Family Comments */
! dumpComment(fout, labelq->data,
NULL, opfinfo->rolname,
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
--- 11305,11311 ----
NULL, NULL);
/* Dump Operator Family Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, opfinfo->rolname,
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
*************** dumpOpfamily(Archive *fout, OpfamilyInfo
*** 11360,11366 ****
* write out a single collation definition
*/
static void
! dumpCollation(Archive *fout, CollInfo *collinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11323,11329 ----
* write out a single collation definition
*/
static void
! dumpCollation(Archive *fout, DumpOptions* dopt, CollInfo *collinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpCollation(Archive *fout, CollInfo *c
*** 11373,11379 ****
const char *collctype;
/* Skip if not to be dumped */
! if (!collinfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 11336,11342 ----
const char *collctype;
/* Skip if not to be dumped */
! if (!collinfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpCollation(Archive *fout, CollInfo *c
*** 11431,11437 ****
NULL, NULL);
/* Dump Collation Comments */
! dumpComment(fout, labelq->data,
collinfo->dobj.namespace->dobj.name, collinfo->rolname,
collinfo->dobj.catId, 0, collinfo->dobj.dumpId);
--- 11394,11400 ----
NULL, NULL);
/* Dump Collation Comments */
! dumpComment(fout, dopt, labelq->data,
collinfo->dobj.namespace->dobj.name, collinfo->rolname,
collinfo->dobj.catId, 0, collinfo->dobj.dumpId);
*************** dumpCollation(Archive *fout, CollInfo *c
*** 11448,11454 ****
* write out a single conversion definition
*/
static void
! dumpConversion(Archive *fout, ConvInfo *convinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11411,11417 ----
* write out a single conversion definition
*/
static void
! dumpConversion(Archive *fout, DumpOptions* dopt, ConvInfo *convinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpConversion(Archive *fout, ConvInfo *
*** 11465,11471 ****
bool condefault;
/* Skip if not to be dumped */
! if (!convinfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 11428,11434 ----
bool condefault;
/* Skip if not to be dumped */
! if (!convinfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpConversion(Archive *fout, ConvInfo *
*** 11530,11536 ****
NULL, NULL);
/* Dump Conversion Comments */
! dumpComment(fout, labelq->data,
convinfo->dobj.namespace->dobj.name, convinfo->rolname,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
--- 11493,11499 ----
NULL, NULL);
/* Dump Conversion Comments */
! dumpComment(fout, dopt, labelq->data,
convinfo->dobj.namespace->dobj.name, convinfo->rolname,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
*************** format_aggregate_signature(AggInfo *aggi
*** 11587,11593 ****
* write out a single aggregate definition
*/
static void
! dumpAgg(Archive *fout, AggInfo *agginfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11550,11556 ----
* write out a single aggregate definition
*/
static void
! dumpAgg(Archive *fout, DumpOptions* dopt, AggInfo *agginfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11633,11639 ****
bool convertok;
/* Skip if not to be dumped */
! if (!agginfo->aggfn.dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 11596,11602 ----
bool convertok;
/* Skip if not to be dumped */
! if (!agginfo->aggfn.dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11926,11935 ****
NULL, NULL);
/* Dump Aggregate Comments */
! dumpComment(fout, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
--- 11889,11898 ----
NULL, NULL);
/* Dump Aggregate Comments */
! dumpComment(fout, dopt, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11944,11950 ****
aggsig = format_function_signature(fout, &agginfo->aggfn, true);
aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false);
! dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
"FUNCTION",
aggsig, NULL, aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
--- 11907,11913 ----
aggsig = format_function_signature(fout, &agginfo->aggfn, true);
aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false);
! dumpACL(fout, dopt, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
"FUNCTION",
aggsig, NULL, aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11969,11982 ****
* write out a single text search parser
*/
static void
! dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!prsinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 11932,11945 ----
* write out a single text search parser
*/
static void
! dumpTSParser(Archive *fout, DumpOptions* dopt, TSParserInfo *prsinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!prsinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSParser(Archive *fout, TSParserInfo
*** 12026,12032 ****
NULL, NULL);
/* Dump Parser Comments */
! dumpComment(fout, labelq->data,
NULL, "",
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
--- 11989,11995 ----
NULL, NULL);
/* Dump Parser Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
*************** dumpTSParser(Archive *fout, TSParserInfo
*** 12040,12046 ****
* write out a single text search dictionary
*/
static void
! dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12003,12009 ----
* write out a single text search dictionary
*/
static void
! dumpTSDictionary(Archive *fout, DumpOptions* dopt, TSDictInfo *dictinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpTSDictionary(Archive *fout, TSDictIn
*** 12051,12057 ****
char *tmplname;
/* Skip if not to be dumped */
! if (!dictinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 12014,12020 ----
char *tmplname;
/* Skip if not to be dumped */
! if (!dictinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSDictionary(Archive *fout, TSDictIn
*** 12113,12119 ****
NULL, NULL);
/* Dump Dictionary Comments */
! dumpComment(fout, labelq->data,
NULL, dictinfo->rolname,
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
--- 12076,12082 ----
NULL, NULL);
/* Dump Dictionary Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, dictinfo->rolname,
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
*************** dumpTSDictionary(Archive *fout, TSDictIn
*** 12128,12141 ****
* write out a single text search template
*/
static void
! dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!tmplinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 12091,12104 ----
* write out a single text search template
*/
static void
! dumpTSTemplate(Archive *fout, DumpOptions* dopt, TSTemplateInfo *tmplinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!tmplinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSTemplate(Archive *fout, TSTemplate
*** 12179,12185 ****
NULL, NULL);
/* Dump Template Comments */
! dumpComment(fout, labelq->data,
NULL, "",
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
--- 12142,12148 ----
NULL, NULL);
/* Dump Template Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
*************** dumpTSTemplate(Archive *fout, TSTemplate
*** 12193,12199 ****
* write out a single text search configuration
*/
static void
! dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12156,12162 ----
* write out a single text search configuration
*/
static void
! dumpTSConfig(Archive *fout, DumpOptions* dopt, TSConfigInfo *cfginfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpTSConfig(Archive *fout, TSConfigInfo
*** 12208,12214 ****
int i_dictname;
/* Skip if not to be dumped */
! if (!cfginfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 12171,12177 ----
int i_dictname;
/* Skip if not to be dumped */
! if (!cfginfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSConfig(Archive *fout, TSConfigInfo
*** 12307,12313 ****
NULL, NULL);
/* Dump Configuration Comments */
! dumpComment(fout, labelq->data,
NULL, cfginfo->rolname,
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
--- 12270,12276 ----
NULL, NULL);
/* Dump Configuration Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, cfginfo->rolname,
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
*************** dumpTSConfig(Archive *fout, TSConfigInfo
*** 12322,12328 ****
* write out a single foreign-data wrapper definition
*/
static void
! dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12285,12291 ----
* write out a single foreign-data wrapper definition
*/
static void
! dumpForeignDataWrapper(Archive *fout, DumpOptions* dopt, FdwInfo *fdwinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12330,12336 ****
char *qfdwname;
/* Skip if not to be dumped */
! if (!fdwinfo->dobj.dump || dataOnly)
return;
/*
--- 12293,12299 ----
char *qfdwname;
/* Skip if not to be dumped */
! if (!fdwinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12338,12344 ****
* field. Otherwise omit them if we are only dumping some specific object.
*/
if (!fdwinfo->dobj.ext_member)
! if (!include_everything)
return;
q = createPQExpBuffer();
--- 12301,12307 ----
* field. Otherwise omit them if we are only dumping some specific object.
*/
if (!fdwinfo->dobj.ext_member)
! if (!dopt->include_everything)
return;
q = createPQExpBuffer();
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12381,12394 ****
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
"FOREIGN DATA WRAPPER",
qfdwname, NULL, fdwinfo->dobj.name,
NULL, fdwinfo->rolname,
fdwinfo->fdwacl);
/* Dump Foreign Data Wrapper Comments */
! dumpComment(fout, labelq->data,
NULL, fdwinfo->rolname,
fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId);
--- 12344,12357 ----
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, dopt, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
"FOREIGN DATA WRAPPER",
qfdwname, NULL, fdwinfo->dobj.name,
NULL, fdwinfo->rolname,
fdwinfo->fdwacl);
/* Dump Foreign Data Wrapper Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, fdwinfo->rolname,
fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId);
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12404,12410 ****
* write out a foreign server definition
*/
static void
! dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12367,12373 ----
* write out a foreign server definition
*/
static void
! dumpForeignServer(Archive *fout, DumpOptions* dopt, ForeignServerInfo *srvinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpForeignServer(Archive *fout, Foreign
*** 12415,12421 ****
char *fdwname;
/* Skip if not to be dumped */
! if (!srvinfo->dobj.dump || dataOnly || !include_everything)
return;
q = createPQExpBuffer();
--- 12378,12384 ----
char *fdwname;
/* Skip if not to be dumped */
! if (!srvinfo->dobj.dump || dopt->dataOnly || !dopt->include_everything)
return;
q = createPQExpBuffer();
*************** dumpForeignServer(Archive *fout, Foreign
*** 12473,12479 ****
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
"FOREIGN SERVER",
qsrvname, NULL, srvinfo->dobj.name,
NULL, srvinfo->rolname,
--- 12436,12442 ----
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, dopt, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
"FOREIGN SERVER",
qsrvname, NULL, srvinfo->dobj.name,
NULL, srvinfo->rolname,
*************** dumpForeignServer(Archive *fout, Foreign
*** 12486,12492 ****
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
/* Dump Foreign Server Comments */
! dumpComment(fout, labelq->data,
NULL, srvinfo->rolname,
srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId);
--- 12449,12455 ----
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
/* Dump Foreign Server Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, srvinfo->rolname,
srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId);
*************** dumpUserMappings(Archive *fout,
*** 12602,12615 ****
* Write out default privileges information
*/
static void
! dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo)
{
PQExpBuffer q;
PQExpBuffer tag;
const char *type;
/* Skip if not to be dumped */
! if (!daclinfo->dobj.dump || dataOnly || aclsSkip)
return;
q = createPQExpBuffer();
--- 12565,12578 ----
* Write out default privileges information
*/
static void
! dumpDefaultACL(Archive *fout, DumpOptions *dopt, DefaultACLInfo *daclinfo)
{
PQExpBuffer q;
PQExpBuffer tag;
const char *type;
/* Skip if not to be dumped */
! if (!daclinfo->dobj.dump || dopt->dataOnly || dopt->aclsSkip)
return;
q = createPQExpBuffer();
*************** dumpDefaultACL(Archive *fout, DefaultACL
*** 12682,12688 ****
*----------
*/
static void
! dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls)
--- 12645,12651 ----
*----------
*/
static void
! dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls)
*************** dumpACL(Archive *fout, CatalogId objCatI
*** 12690,12700 ****
PQExpBuffer sql;
/* Do nothing if ACL dump is not enabled */
! if (aclsSkip)
return;
/* --data-only skips ACLs *except* BLOB ACLs */
! if (dataOnly && strcmp(type, "LARGE OBJECT") != 0)
return;
sql = createPQExpBuffer();
--- 12653,12663 ----
PQExpBuffer sql;
/* Do nothing if ACL dump is not enabled */
! if (dopt->aclsSkip)
return;
/* --data-only skips ACLs *except* BLOB ACLs */
! if (dopt->dataOnly && strcmp(type, "LARGE OBJECT") != 0)
return;
sql = createPQExpBuffer();
*************** dumpACL(Archive *fout, CatalogId objCatI
*** 12737,12743 ****
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpSecLabel(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
--- 12700,12706 ----
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpSecLabel(Archive *fout, DumpOptions* dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
*************** dumpSecLabel(Archive *fout, const char *
*** 12747,12764 ****
PQExpBuffer query;
/* do nothing, if --no-security-labels is supplied */
! if (no_security_labels)
return;
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dataOnly)
return;
}
else
{
! if (schemaOnly)
return;
}
--- 12710,12727 ----
PQExpBuffer query;
/* do nothing, if --no-security-labels is supplied */
! if (dopt->no_security_labels)
return;
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dopt->dataOnly)
return;
}
else
{
! if (dopt->schemaOnly)
return;
}
*************** dumpSecLabel(Archive *fout, const char *
*** 12801,12807 ****
* and its columns.
*/
static void
! dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename)
{
SecLabelItem *labels;
int nlabels;
--- 12764,12770 ----
* and its columns.
*/
static void
! dumpTableSecLabel(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, const char *reltypename)
{
SecLabelItem *labels;
int nlabels;
*************** dumpTableSecLabel(Archive *fout, TableIn
*** 12810,12820 ****
PQExpBuffer target;
/* do nothing, if --no-security-labels is supplied */
! if (no_security_labels)
return;
/* SecLabel are SCHEMA not data */
! if (dataOnly)
return;
/* Search for comments associated with relation, using table */
--- 12773,12783 ----
PQExpBuffer target;
/* do nothing, if --no-security-labels is supplied */
! if (dopt->no_security_labels)
return;
/* SecLabel are SCHEMA not data */
! if (dopt->dataOnly)
return;
/* Search for comments associated with relation, using table */
*************** collectSecLabels(Archive *fout, SecLabel
*** 13022,13041 ****
* write out to fout the declarations (not data) of a user-defined table
*/
static void
! dumpTable(Archive *fout, TableInfo *tbinfo)
{
! if (tbinfo->dobj.dump && !dataOnly)
{
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
! dumpSequence(fout, tbinfo);
else
! dumpTableSchema(fout, tbinfo);
/* Handle the ACL here */
namecopy = pg_strdup(fmtId(tbinfo->dobj.name));
! dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
(tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" :
"TABLE",
namecopy, NULL, tbinfo->dobj.name,
--- 12985,13004 ----
* write out to fout the declarations (not data) of a user-defined table
*/
static void
! dumpTable(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
{
! if (tbinfo->dobj.dump && !dopt->dataOnly)
{
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
! dumpSequence(fout, dopt, tbinfo);
else
! dumpTableSchema(fout, dopt, tbinfo);
/* Handle the ACL here */
namecopy = pg_strdup(fmtId(tbinfo->dobj.name));
! dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
(tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" :
"TABLE",
namecopy, NULL, tbinfo->dobj.name,
*************** dumpTable(Archive *fout, TableInfo *tbin
*** 13070,13076 ****
attnamecopy = pg_strdup(fmtId(attname));
acltag = psprintf("%s.%s", tbinfo->dobj.name, attname);
/* Column's GRANT type is always TABLE */
! dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
namecopy, attnamecopy, acltag,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
attacl);
--- 13033,13039 ----
attnamecopy = pg_strdup(fmtId(attname));
acltag = psprintf("%s.%s", tbinfo->dobj.name, attname);
/* Column's GRANT type is always TABLE */
! dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
namecopy, attnamecopy, acltag,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
attacl);
*************** createViewAsClause(Archive *fout, TableI
*** 13147,13153 ****
* write the declaration (not data) of one user-defined table or view
*/
static void
! dumpTableSchema(Archive *fout, TableInfo *tbinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 13110,13116 ----
* write the declaration (not data) of one user-defined table or view
*/
static void
! dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13760,13769 ****
/* Dump Table Comments */
! dumpTableComment(fout, tbinfo, reltypename);
/* Dump Table Security Labels */
! dumpTableSecLabel(fout, tbinfo, reltypename);
/* Dump comments on inlined table constraints */
for (j = 0; j < tbinfo->ncheck; j++)
--- 13723,13732 ----
/* Dump Table Comments */
! dumpTableComment(fout, dopt, tbinfo, reltypename);
/* Dump Table Security Labels */
! dumpTableSecLabel(fout, dopt, tbinfo, reltypename);
/* Dump comments on inlined table constraints */
for (j = 0; j < tbinfo->ncheck; j++)
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13773,13779 ****
if (constr->separate || !constr->conislocal)
continue;
! dumpTableConstraintComment(fout, constr);
}
destroyPQExpBuffer(q);
--- 13736,13742 ----
if (constr->separate || !constr->conislocal)
continue;
! dumpTableConstraintComment(fout, dopt, constr);
}
destroyPQExpBuffer(q);
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13785,13791 ****
* dumpAttrDef --- dump an attribute's default-value declaration
*/
static void
! dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
{
TableInfo *tbinfo = adinfo->adtable;
int adnum = adinfo->adnum;
--- 13748,13754 ----
* dumpAttrDef --- dump an attribute's default-value declaration
*/
static void
! dumpAttrDef(Archive *fout, DumpOptions *dopt, AttrDefInfo *adinfo)
{
TableInfo *tbinfo = adinfo->adtable;
int adnum = adinfo->adnum;
*************** dumpAttrDef(Archive *fout, AttrDefInfo *
*** 13793,13799 ****
PQExpBuffer delq;
/* Skip if table definition not to be dumped */
! if (!tbinfo->dobj.dump || dataOnly)
return;
/* Skip if not "separate"; it was dumped in the table's definition */
--- 13756,13762 ----
PQExpBuffer delq;
/* Skip if table definition not to be dumped */
! if (!tbinfo->dobj.dump || dopt->dataOnly)
return;
/* Skip if not "separate"; it was dumped in the table's definition */
*************** getAttrName(int attrnum, TableInfo *tblI
*** 13872,13878 ****
* write out to fout a user-defined index
*/
static void
! dumpIndex(Archive *fout, IndxInfo *indxinfo)
{
TableInfo *tbinfo = indxinfo->indextable;
bool is_constraint = (indxinfo->indexconstraint != 0);
--- 13835,13841 ----
* write out to fout a user-defined index
*/
static void
! dumpIndex(Archive *fout, DumpOptions* dopt, IndxInfo *indxinfo)
{
TableInfo *tbinfo = indxinfo->indextable;
bool is_constraint = (indxinfo->indexconstraint != 0);
*************** dumpIndex(Archive *fout, IndxInfo *indxi
*** 13880,13886 ****
PQExpBuffer delq;
PQExpBuffer labelq;
! if (dataOnly)
return;
q = createPQExpBuffer();
--- 13843,13849 ----
PQExpBuffer delq;
PQExpBuffer labelq;
! if (dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpIndex(Archive *fout, IndxInfo *indxi
*** 13945,13951 ****
}
/* Dump Index Comments */
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
indxinfo->dobj.catId, 0,
--- 13908,13914 ----
}
/* Dump Index Comments */
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
indxinfo->dobj.catId, 0,
*************** dumpIndex(Archive *fout, IndxInfo *indxi
*** 13962,13975 ****
* write out to fout a user-defined constraint
*/
static void
! dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer q;
PQExpBuffer delq;
/* Skip if not to be dumped */
! if (!coninfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 13925,13938 ----
* write out to fout a user-defined constraint
*/
static void
! dumpConstraint(Archive *fout, DumpOptions *dopt, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer q;
PQExpBuffer delq;
/* Skip if not to be dumped */
! if (!coninfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpConstraint(Archive *fout, Constraint
*** 14179,14185 ****
/* Dump Constraint Comments --- only works for table constraints */
if (tbinfo && coninfo->separate)
! dumpTableConstraintComment(fout, coninfo);
destroyPQExpBuffer(q);
destroyPQExpBuffer(delq);
--- 14142,14148 ----
/* Dump Constraint Comments --- only works for table constraints */
if (tbinfo && coninfo->separate)
! dumpTableConstraintComment(fout, dopt, coninfo);
destroyPQExpBuffer(q);
destroyPQExpBuffer(delq);
*************** dumpConstraint(Archive *fout, Constraint
*** 14193,14199 ****
* or as a separate ALTER command.
*/
static void
! dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer labelq = createPQExpBuffer();
--- 14156,14162 ----
* or as a separate ALTER command.
*/
static void
! dumpTableConstraintComment(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer labelq = createPQExpBuffer();
*************** dumpTableConstraintComment(Archive *fout
*** 14202,14208 ****
fmtId(coninfo->dobj.name));
appendPQExpBuffer(labelq, "ON %s",
fmtId(tbinfo->dobj.name));
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
coninfo->dobj.catId, 0,
--- 14165,14171 ----
fmtId(coninfo->dobj.name));
appendPQExpBuffer(labelq, "ON %s",
fmtId(tbinfo->dobj.name));
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
coninfo->dobj.catId, 0,
*************** findLastBuiltinOid_V70(Archive *fout)
*** 14262,14268 ****
* write the declaration (not data) of one user-defined sequence
*/
static void
! dumpSequence(Archive *fout, TableInfo *tbinfo)
{
PGresult *res;
char *startv,
--- 14225,14231 ----
* write the declaration (not data) of one user-defined sequence
*/
static void
! dumpSequence(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo)
{
PGresult *res;
char *startv,
*************** dumpSequence(Archive *fout, TableInfo *t
*** 14448,14457 ****
}
/* Dump Sequence Comments and Security Labels */
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
--- 14411,14420 ----
}
/* Dump Sequence Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
*************** dumpSequenceData(Archive *fout, TableDat
*** 14522,14528 ****
* write the declaration of one user-defined table trigger
*/
static void
! dumpTrigger(Archive *fout, TriggerInfo *tginfo)
{
TableInfo *tbinfo = tginfo->tgtable;
PQExpBuffer query;
--- 14485,14491 ----
* write the declaration of one user-defined table trigger
*/
static void
! dumpTrigger(Archive *fout, DumpOptions* dopt, TriggerInfo *tginfo)
{
TableInfo *tbinfo = tginfo->tgtable;
PQExpBuffer query;
*************** dumpTrigger(Archive *fout, TriggerInfo *
*** 14537,14543 ****
* we needn't check dobj.dump because TriggerInfo wouldn't have been
* created in the first place for non-dumpable triggers
*/
! if (dataOnly)
return;
query = createPQExpBuffer();
--- 14500,14506 ----
* we needn't check dobj.dump because TriggerInfo wouldn't have been
* created in the first place for non-dumpable triggers
*/
! if (dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpTrigger(Archive *fout, TriggerInfo *
*** 14718,14724 ****
NULL, 0,
NULL, NULL);
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
--- 14681,14687 ----
NULL, 0,
NULL, NULL);
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
*************** dumpTrigger(Archive *fout, TriggerInfo *
*** 14732,14744 ****
* write the declaration of one user-defined event trigger
*/
static void
! dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
{
PQExpBuffer query;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!evtinfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 14695,14707 ----
* write the declaration of one user-defined event trigger
*/
static void
! dumpEventTrigger(Archive *fout, DumpOptions* dopt, EventTriggerInfo *evtinfo)
{
PQExpBuffer query;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!evtinfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpEventTrigger(Archive *fout, EventTri
*** 14790,14796 ****
"EVENT TRIGGER", SECTION_POST_DATA,
query->data, "", NULL, NULL, 0, NULL, NULL);
! dumpComment(fout, labelq->data,
NULL, NULL,
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
--- 14753,14759 ----
"EVENT TRIGGER", SECTION_POST_DATA,
query->data, "", NULL, NULL, 0, NULL, NULL);
! dumpComment(fout, dopt, labelq->data,
NULL, NULL,
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
*************** dumpEventTrigger(Archive *fout, EventTri
*** 14803,14809 ****
* Dump a rule
*/
static void
! dumpRule(Archive *fout, RuleInfo *rinfo)
{
TableInfo *tbinfo = rinfo->ruletable;
PQExpBuffer query;
--- 14766,14772 ----
* Dump a rule
*/
static void
! dumpRule(Archive *fout, DumpOptions *dopt, RuleInfo *rinfo)
{
TableInfo *tbinfo = rinfo->ruletable;
PQExpBuffer query;
*************** dumpRule(Archive *fout, RuleInfo *rinfo)
*** 14813,14819 ****
PGresult *res;
/* Skip if not to be dumped */
! if (!rinfo->dobj.dump || dataOnly)
return;
/*
--- 14776,14782 ----
PGresult *res;
/* Skip if not to be dumped */
! if (!rinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpRule(Archive *fout, RuleInfo *rinfo)
*** 14918,14924 ****
NULL, NULL);
/* Dump rule comments */
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId);
--- 14881,14887 ----
NULL, NULL);
/* Dump rule comments */
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId);
*************** dumpRule(Archive *fout, RuleInfo *rinfo)
*** 14935,14941 ****
* getExtensionMembership --- obtain extension membership data
*/
void
! getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
int numExtensions)
{
PQExpBuffer query;
--- 14898,14904 ----
* getExtensionMembership --- obtain extension membership data
*/
void
! getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[],
int numExtensions)
{
PQExpBuffer query;
*************** getExtensionMembership(Archive *fout, Ex
*** 15111,15117 ****
* of the --oids setting. This is because row filtering
* conditions aren't compatible with dumping OIDs.
*/
! makeTableDataInfo(configtbl, false);
if (configtbl->dataObj != NULL)
{
if (strlen(extconditionarray[j]) > 0)
--- 15074,15080 ----
* of the --oids setting. This is because row filtering
* conditions aren't compatible with dumping OIDs.
*/
! makeTableDataInfo(dopt, configtbl, false);
if (configtbl->dataObj != NULL)
{
if (strlen(extconditionarray[j]) > 0)
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
new file mode 100644
index d184187..84ea4c3
*** a/src/bin/pg_dump/pg_dump.h
--- b/src/bin/pg_dump/pg_dump.h
*************** extern char g_opaque_type[10]; /* name f
*** 503,509 ****
struct Archive;
typedef struct Archive Archive;
! extern TableInfo *getSchemaData(Archive *, int *numTablesPtr);
typedef enum _OidOptions
{
--- 503,511 ----
struct Archive;
typedef struct Archive Archive;
! struct _dumpOptions;
!
! extern TableInfo *getSchemaData(Archive *, struct _dumpOptions *dopt, int *numTablesPtr);
typedef enum _OidOptions
{
*************** extern void sortDataAndIndexObjectsBySiz
*** 545,551 ****
* version specific routines
*/
extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
! extern ExtensionInfo *getExtensions(Archive *fout, int *numExtensions);
extern TypeInfo *getTypes(Archive *fout, int *numTypes);
extern FuncInfo *getFuncs(Archive *fout, int *numFuncs);
extern AggInfo *getAggregates(Archive *fout, int *numAggregates);
--- 547,553 ----
* version specific routines
*/
extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
! extern ExtensionInfo *getExtensions(Archive *fout, struct _dumpOptions *dopt, int *numExtensions);
extern TypeInfo *getTypes(Archive *fout, int *numTypes);
extern FuncInfo *getFuncs(Archive *fout, int *numFuncs);
extern AggInfo *getAggregates(Archive *fout, int *numAggregates);
*************** extern OpclassInfo *getOpclasses(Archive
*** 554,560 ****
extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(Archive *fout, int *numConversions);
! extern TableInfo *getTables(Archive *fout, int *numTables);
extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
--- 556,562 ----
extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(Archive *fout, int *numConversions);
! extern TableInfo *getTables(Archive *fout, struct _dumpOptions *dopt, int *numTables);
extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
*************** extern FdwInfo *getForeignDataWrappers(A
*** 573,580 ****
int *numForeignDataWrappers);
extern ForeignServerInfo *getForeignServers(Archive *fout,
int *numForeignServers);
! extern DefaultACLInfo *getDefaultACLs(Archive *fout, int *numDefaultACLs);
! extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
int numExtensions);
extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
--- 575,582 ----
int *numForeignDataWrappers);
extern ForeignServerInfo *getForeignServers(Archive *fout,
int *numForeignServers);
! extern DefaultACLInfo *getDefaultACLs(Archive *fout, struct _dumpOptions *dopt, int *numDefaultACLs);
! extern void getExtensionMembership(Archive *fout, struct _dumpOptions *dopt, ExtensionInfo extinfo[],
int numExtensions);
extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
new file mode 100644
index 4050091..73448b1
*** a/src/bin/pg_dump/pg_dumpall.c
--- b/src/bin/pg_dump/pg_dumpall.c
*************** static bool verbose = false;
*** 72,77 ****
--- 72,78 ----
static int binary_upgrade = 0;
static int column_inserts = 0;
static int disable_dollar_quoting = 0;
+ static int quote_all_identifiers = 0;
static int disable_triggers = 0;
static int if_exists = 0;
static int inserts = 0;
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
new file mode 100644
index fdfdc19..514615b
*** a/src/bin/pg_dump/pg_restore.c
--- b/src/bin/pg_dump/pg_restore.c
*************** main(int argc, char **argv)
*** 420,426 ****
/* AH may be freed in CloseArchive? */
exit_code = AH->n_errors ? 1 : 0;
! CloseArchive(AH);
return exit_code;
}
--- 420,426 ----
/* AH may be freed in CloseArchive? */
exit_code = AH->n_errors ? 1 : 0;
! CloseArchive(AH, NULL);
return exit_code;
}
The general idea of this patch is not disputed, I think.
Some concerns about the details:
- Why is quote_all_identifiers left behind as a global variable?
- Shouldn't pg_dumpall also use DumpOptions?
- What about binary_upgrade?
- I think some of the variables in pg_dump's main() don't need to be
moved into DumpOptions. For example, compressLevel is only looked at
once in main() and then forgotten. We don't need to pass that around
everywhere. The same goes for dumpencoding and possibly others.
- The forward declaration of struct _dumpOptions in pg_backup.h seems
kind of useless. You could move some things around so that that's not
necessary.
- NewDumpOptions() and NewRestoreOptions() are both in
pg_backup_archiver.c, but NewRestoreOptions() is in pg_backup.h whereas
NewDumpOptions() is being put into pg_backup_archiver.h. None of that
makes too much sense, but it could be made more consistent.
- In dumpOptionsFromRestoreOptions() you are building the return value
in a local variable that is not zeroed. You should probably use
NewDumpOptions() there.
Also, looking at dumpOptionsFromRestoreOptions() and related code makes
me think that these should perhaps really be the same structure. Have
you investigated that?
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Sat, Aug 30, 2014 at 11:12 PM, Peter Eisentraut <peter_e@gmx.net> wrote:
The general idea of this patch is not disputed, I think.
Ok, that's good news.
- Why is quote_all_identifiers left behind as a global variable?
As I said, it's really used everywhere. I'm not opposed to passing it
around (which would be straightforward) but it would really blow up
the patch size and it would be a rather mechanical patch. I'd rather
do that as a separate patch, otherwise all other changes would get
lost in the noise.
- Shouldn't pg_dumpall also use DumpOptions?
It could, it would mostly be a cosmetic change, since pg_dumpall is
only a wrapper that invokes the pg_dump command. pg_dumpall's argument
handling is isolated from the rest, so it could use DumpOptions or
not...
- What about binary_upgrade?
I thought of the binary upgrade more as a different environment that
the program is run in (as opposed to a traditional user switch) so I
left it aside, but it turns out that it doesn't require that much more
code to support it and definitely it enables more code refactoring if
it's treated like the other flags, so the new patch also removes the
global binary_upgrade.
- I think some of the variables in pg_dump's main() don't need to be
moved into DumpOptions. For example, compressLevel is only looked at
once in main() and then forgotten. We don't need to pass that around
everywhere. The same goes for dumpencoding and possibly others.
That's partly true, there are two groups of variables that we could
remove from the DumpOptions, one is the group of options that are only
used in the huge main() of pg_dump.c and the second group is variables
that go one function further down into setup_connection().
dumpencoding for example goes down into setup_connection(). So do
use_role, no_synchronized_snapshots, serializable_deferrable and
numWorkers.
Previously dumpencoding and use_role were passed as additional
arguments to setup_connection(), being NULL when there was no change
to the encoding (which I found quite ugly). I would say we should
treat all variables of that group the same, so either all of them
become local variables in main() and are passed as parameters to
setup_connection() or we just pass the DumpOptions struct and put them
in there (as is done in my patch now)... Or we create a new struct
ConnectionOpts or so...
Then there's another group of options that is used only in main() but
is then used to populate the RestoreOptions struct. compressLevel is
one of them.
The thing about creating all those different groups is that it makes
refactoring a bit harder. In the end we would group variables not by
their meaning and purpose but by their usage pattern in the code.
- The forward declaration of struct _dumpOptions in pg_backup.h seems
kind of useless. You could move some things around so that that's not
necessary.
Agreed, fixed.
- NewDumpOptions() and NewRestoreOptions() are both in
pg_backup_archiver.c, but NewRestoreOptions() is in pg_backup.h whereas
NewDumpOptions() is being put into pg_backup_archiver.h. None of that
makes too much sense, but it could be made more consistent.
I would have created the prototype in the respective header of the .c
file that holds the function definition, but that's a bit fuzzy around
pg_dump. I have now moved the DumpOptions over to pg_backup.h, because
pg_backup_archiver.h includes pg_backup.h so that makes pg_backup.h
the lower header.
- In dumpOptionsFromRestoreOptions() you are building the return value
in a local variable that is not zeroed. You should probably use
NewDumpOptions() there.
The idea was to avoid malloc()ing and free()ing and to instead just
create those dumpOptions on the stack, because they're only used for a
short time and a small chunk of data, but I assume it's more
consistent to do it as you propose with NewDumpOptions(). So this is
fixed in the new patch.
Also, looking at dumpOptionsFromRestoreOptions() and related code makes
me think that these should perhaps really be the same structure. Have
you investigated that?
I have (as mentioned in my original email about this patch), but that
would be a much larger change than what I had envisioned.
New patch attached.
Joachim
Attachments:
pg_dump_refactor_globals.3.difftext/plain; charset=US-ASCII; name=pg_dump_refactor_globals.3.diffDownload
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;
}
Joachim Wieland wrote:
On Sat, Aug 30, 2014 at 11:12 PM, Peter Eisentraut <peter_e@gmx.net> wrote:
- Why is quote_all_identifiers left behind as a global variable?
As I said, it's really used everywhere. I'm not opposed to passing it
around (which would be straightforward) but it would really blow up
the patch size and it would be a rather mechanical patch. I'd rather
do that as a separate patch, otherwise all other changes would get
lost in the noise.
I don't understand this bit. You have struct _dumpOptions containing a
quote_all_identifiers, which seems to be unused. There's also a static
int quote_all_identifiers in pg_dumpall.c, which I assume hides the
non-static one in dumputils. And we also have an "extern" in pg_dump.c,
which seems misplaced. There was an extern in dumputils.h but your
patch removes it.
Oh, after reading some code, I realize that those two variables are
actually separate and do different things: pg_dumpall has one that can
be set by passing --quote-all-identifiers; if set, it activates passing
--quote-all-identifiers to pg_dump. pg_dump.c misleadingly has an
extern which is enabled by its --quote-all-identifiers switch, and the
effect is to execute "SET quote_all_identifiers=true" to the server.
And finally we have a quote_all_identifiers in dumputils and has a
quoting effect on the fmtId() function.
So the way this works is that pg_dumpall doesn't use the one in
dumputils; and pg_dump.c sets the one in dumputils.c and affects both
the SET command and fmtId(). In other words, unless I miss something,
pg_dumpall would never change the fmtId() behavior, which would be
pretty broken IMHO.
I find this rather odd. Can we find a more sensible arrangement? At
least let's move the extern to dumputils.h, remove it from pg_dump.c.
Not totally sure about the static in pg_dumpall.c -- note that it does
call fmtId(), so we might be doing the wrong thing there; maybe we need
to remove the static from there as well, and let --quote-all-identifiers
set the one in dumputils.
Is there a bug here that should be backpatched? I checked 9.3 and there
is no static in pg_dumpall so it should behave sensibly AFAICT.
- Shouldn't pg_dumpall also use DumpOptions?
It could, it would mostly be a cosmetic change, since pg_dumpall is
only a wrapper that invokes the pg_dump command. pg_dumpall's argument
handling is isolated from the rest, so it could use DumpOptions or
not...
Probably no point, yeah. However if dumputils.c starts using
DumpOptions, it might need to go in that direction as well. Not sure.
Previously dumpencoding and use_role were passed as additional
arguments to setup_connection(), being NULL when there was no change
to the encoding (which I found quite ugly). I would say we should
treat all variables of that group the same, so either all of them
become local variables in main() and are passed as parameters to
setup_connection() or we just pass the DumpOptions struct and put them
in there (as is done in my patch now)... Or we create a new struct
ConnectionOpts or so...
I think I like the idea of ConnectionOpts as separate from DumpOptions,
TBH.
- In dumpOptionsFromRestoreOptions() you are building the return value
in a local variable that is not zeroed. You should probably use
NewDumpOptions() there.The idea was to avoid malloc()ing and free()ing and to instead just
create those dumpOptions on the stack, because they're only used for a
short time and a small chunk of data, but I assume it's more
consistent to do it as you propose with NewDumpOptions(). So this is
fixed in the new patch.
I think putting stuff in the stack is fine, as long as you don't depend
on it being initialized to all zeroes, because that's not guaranteed.
You could memset() the struct in the stack also, but really I think it's
simpler to just allocate it.
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Thu, Sep 11, 2014 at 5:23 PM, Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
I find this rather odd. Can we find a more sensible arrangement? At
least let's move the extern to dumputils.h, remove it from pg_dump.c.
Not totally sure about the static in pg_dumpall.c -- note that it does
call fmtId(), so we might be doing the wrong thing there; maybe we need
to remove the static from there as well, and let --quote-all-identifiers
set the one in dumputils.
I've reverted that as proposed, i.e. moved the extern to dumputils.h
and removed the static in pg_dumpall.c.
I think I like the idea of ConnectionOpts as separate from DumpOptions,
TBH.
Well, in the end it wasn't all that easy and my initial analysis
wasn't correct. So what I did was that I kind of restored the original
behavior wrt dumpencoding and use_role and pass them as arguments to
setup_connection now as they were before. The only difference now is
that the DumpOptions pointer is also passed in (to setup_connection),
but this makes sense because it needs to check variables in there
which used to be global variables before.
In the new patch I've also taken out other variables from the
DumpOptions struct and made them local in pg_dump.c's main(), partly
proposed by Peter before, those are: numWorkers, prompt_password,
compressLevel, plainText, archiveFormat, archiveMode.
Revised patch attached, thanks for the review Alvaro & Peter.
Attachments:
pg_dump_refactor_globals.4.difftext/plain; charset=US-ASCII; name=pg_dump_refactor_globals.4.diffDownload
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
new file mode 100644
index 94e9147..41792e8
*** a/src/bin/pg_dump/common.c
--- b/src/bin/pg_dump/common.c
*************** static DumpableObject **nspinfoindex;
*** 64,70 ****
static void flagInhTables(TableInfo *tbinfo, int numTables,
InhInfo *inhinfo, int numInherits);
! static void flagInhAttrs(TableInfo *tblinfo, int numTables);
static DumpableObject **buildIndexArray(void *objArray, int numObjs,
Size objSize);
static int DOCatalogIdCompare(const void *p1, const void *p2);
--- 64,70 ----
static void flagInhTables(TableInfo *tbinfo, int numTables,
InhInfo *inhinfo, int numInherits);
! static void flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables);
static DumpableObject **buildIndexArray(void *objArray, int numObjs,
Size objSize);
static int DOCatalogIdCompare(const void *p1, const void *p2);
*************** static int strInArray(const char *patter
*** 78,84 ****
* Collect information about all potentially dumpable objects
*/
TableInfo *
! getSchemaData(Archive *fout, int *numTablesPtr)
{
ExtensionInfo *extinfo;
InhInfo *inhinfo;
--- 78,84 ----
* Collect information about all potentially dumpable objects
*/
TableInfo *
! getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
{
ExtensionInfo *extinfo;
InhInfo *inhinfo;
*************** getSchemaData(Archive *fout, int *numTab
*** 114,120 ****
*/
if (g_verbose)
write_msg(NULL, "reading user-defined tables\n");
! tblinfo = getTables(fout, &numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
/* Do this after we've built tblinfoindex */
--- 114,120 ----
*/
if (g_verbose)
write_msg(NULL, "reading user-defined tables\n");
! tblinfo = getTables(fout, dopt, &numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
/* Do this after we've built tblinfoindex */
*************** getSchemaData(Archive *fout, int *numTab
*** 122,132 ****
if (g_verbose)
write_msg(NULL, "reading extensions\n");
! extinfo = getExtensions(fout, &numExtensions);
if (g_verbose)
write_msg(NULL, "reading user-defined functions\n");
! funinfo = getFuncs(fout, &numFuncs);
funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo));
/* this must be after getTables and getFuncs */
--- 122,132 ----
if (g_verbose)
write_msg(NULL, "reading extensions\n");
! extinfo = getExtensions(fout, dopt, &numExtensions);
if (g_verbose)
write_msg(NULL, "reading user-defined functions\n");
! funinfo = getFuncs(fout, dopt, &numFuncs);
funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo));
/* this must be after getTables and getFuncs */
*************** getSchemaData(Archive *fout, int *numTab
*** 142,148 ****
if (g_verbose)
write_msg(NULL, "reading user-defined aggregate functions\n");
! getAggregates(fout, &numAggregates);
if (g_verbose)
write_msg(NULL, "reading user-defined operators\n");
--- 142,148 ----
if (g_verbose)
write_msg(NULL, "reading user-defined aggregate functions\n");
! getAggregates(fout, dopt, &numAggregates);
if (g_verbose)
write_msg(NULL, "reading user-defined operators\n");
*************** getSchemaData(Archive *fout, int *numTab
*** 183,189 ****
if (g_verbose)
write_msg(NULL, "reading default privileges\n");
! getDefaultACLs(fout, &numDefaultACLs);
if (g_verbose)
write_msg(NULL, "reading user-defined collations\n");
--- 183,189 ----
if (g_verbose)
write_msg(NULL, "reading default privileges\n");
! getDefaultACLs(fout, dopt, &numDefaultACLs);
if (g_verbose)
write_msg(NULL, "reading user-defined collations\n");
*************** getSchemaData(Archive *fout, int *numTab
*** 213,219 ****
*/
if (g_verbose)
write_msg(NULL, "finding extension members\n");
! getExtensionMembership(fout, extinfo, numExtensions);
/* Link tables to parents, mark parents of target tables interesting */
if (g_verbose)
--- 213,219 ----
*/
if (g_verbose)
write_msg(NULL, "finding extension members\n");
! getExtensionMembership(fout, dopt, extinfo, numExtensions);
/* Link tables to parents, mark parents of target tables interesting */
if (g_verbose)
*************** getSchemaData(Archive *fout, int *numTab
*** 222,232 ****
if (g_verbose)
write_msg(NULL, "reading column info for interesting tables\n");
! getTableAttrs(fout, tblinfo, numTables);
if (g_verbose)
write_msg(NULL, "flagging inherited columns in subtables\n");
! flagInhAttrs(tblinfo, numTables);
if (g_verbose)
write_msg(NULL, "reading indexes\n");
--- 222,232 ----
if (g_verbose)
write_msg(NULL, "reading column info for interesting tables\n");
! getTableAttrs(fout, dopt, tblinfo, numTables);
if (g_verbose)
write_msg(NULL, "flagging inherited columns in subtables\n");
! flagInhAttrs(dopt, tblinfo, numTables);
if (g_verbose)
write_msg(NULL, "reading indexes\n");
*************** flagInhTables(TableInfo *tblinfo, int nu
*** 303,309 ****
* modifies tblinfo
*/
static void
! flagInhAttrs(TableInfo *tblinfo, int numTables)
{
int i,
j,
--- 303,309 ----
* modifies tblinfo
*/
static void
! flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int numTables)
{
int i,
j,
*************** flagInhAttrs(TableInfo *tblinfo, int num
*** 380,386 ****
attrDef->adef_expr = pg_strdup("NULL");
/* Will column be dumped explicitly? */
! if (shouldPrintColumn(tbinfo, j))
{
attrDef->separate = false;
/* No dependency needed: NULL cannot have dependencies */
--- 380,386 ----
attrDef->adef_expr = pg_strdup("NULL");
/* Will column be dumped explicitly? */
! if (shouldPrintColumn(dopt, tbinfo, j))
{
attrDef->separate = false;
/* No dependency needed: NULL cannot have dependencies */
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
new file mode 100644
index e50dd8b..ceed115
*** a/src/bin/pg_dump/parallel.c
--- b/src/bin/pg_dump/parallel.c
*************** static void WaitForTerminatingWorkers(Pa
*** 89,99 ****
static void sigTermHandler(int signum);
#endif
static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
RestoreOptions *ropt);
static bool HasEveryWorkerTerminated(ParallelState *pstate);
static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te);
! static void WaitForCommands(ArchiveHandle *AH, int pipefd[2]);
static char *getMessageFromMaster(int pipefd[2]);
static void sendMessageToMaster(int pipefd[2], const char *str);
static int select_loop(int maxFd, fd_set *workerset);
--- 89,100 ----
static void sigTermHandler(int signum);
#endif
static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
+ DumpOptions *dopt,
RestoreOptions *ropt);
static bool HasEveryWorkerTerminated(ParallelState *pstate);
static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te);
! static void WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]);
static char *getMessageFromMaster(int pipefd[2]);
static void sendMessageToMaster(int pipefd[2], const char *str);
static int select_loop(int maxFd, fd_set *workerset);
*************** sigTermHandler(int signum)
*** 436,441 ****
--- 437,443 ----
*/
static void
SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
+ DumpOptions *dopt,
RestoreOptions *ropt)
{
/*
*************** SetupWorker(ArchiveHandle *AH, int pipef
*** 445,455 ****
* properly when we shut down. This happens only that way when it is
* brought down because of an error.
*/
! (AH->SetupWorkerPtr) ((Archive *) AH, ropt);
Assert(AH->connection != NULL);
! WaitForCommands(AH, pipefd);
closesocket(pipefd[PIPE_READ]);
closesocket(pipefd[PIPE_WRITE]);
--- 447,457 ----
* properly when we shut down. This happens only that way when it is
* brought down because of an error.
*/
! (AH->SetupWorkerPtr) ((Archive *) AH, dopt, ropt);
Assert(AH->connection != NULL);
! WaitForCommands(AH, dopt, pipefd);
closesocket(pipefd[PIPE_READ]);
closesocket(pipefd[PIPE_WRITE]);
*************** init_spawned_worker_win32(WorkerInfo *wi
*** 481,487 ****
* of threads while it does a fork() on Unix.
*/
ParallelState *
! ParallelBackupStart(ArchiveHandle *AH, RestoreOptions *ropt)
{
ParallelState *pstate;
int i;
--- 483,489 ----
* of threads while it does a fork() on Unix.
*/
ParallelState *
! ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt)
{
ParallelState *pstate;
int i;
*************** ParallelBackupStart(ArchiveHandle *AH, R
*** 598,604 ****
closesocket(pstate->parallelSlot[j].pipeWrite);
}
! SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, ropt);
exit(0);
}
--- 600,606 ----
closesocket(pstate->parallelSlot[j].pipeWrite);
}
! SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, dopt, ropt);
exit(0);
}
*************** lockTableNoWait(ArchiveHandle *AH, TocEn
*** 856,862 ****
* exit.
*/
static void
! WaitForCommands(ArchiveHandle *AH, int pipefd[2])
{
char *command;
DumpId dumpId;
--- 858,864 ----
* exit.
*/
static void
! WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2])
{
char *command;
DumpId dumpId;
*************** WaitForCommands(ArchiveHandle *AH, int p
*** 896,902 ****
* The message we return here has been pg_malloc()ed and we are
* responsible for free()ing it.
*/
! str = (AH->WorkerJobDumpPtr) (AH, te);
Assert(AH->connection != NULL);
sendMessageToMaster(pipefd, str);
free(str);
--- 898,904 ----
* The message we return here has been pg_malloc()ed and we are
* responsible for free()ing it.
*/
! str = (AH->WorkerJobDumpPtr) (AH, dopt, te);
Assert(AH->connection != NULL);
sendMessageToMaster(pipefd, str);
free(str);
diff --git a/src/bin/pg_dump/parallel.h b/src/bin/pg_dump/parallel.h
new file mode 100644
index 7a32a9b..81a823d
*** a/src/bin/pg_dump/parallel.h
--- b/src/bin/pg_dump/parallel.h
*************** extern void EnsureIdleWorker(struct _arc
*** 80,85 ****
--- 80,86 ----
extern void EnsureWorkersFinished(struct _archiveHandle * AH, ParallelState *pstate);
extern ParallelState *ParallelBackupStart(struct _archiveHandle * AH,
+ DumpOptions *dopt,
RestoreOptions *ropt);
extern void DispatchJobForTocEntry(struct _archiveHandle * AH,
ParallelState *pstate,
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
new file mode 100644
index 25780cf..4dc0002
*** a/src/bin/pg_dump/pg_backup.h
--- b/src/bin/pg_dump/pg_backup.h
*************** struct Archive
*** 98,105 ****
/* The rest is private */
};
- typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
-
typedef struct _restoreOptions
{
int createDB; /* Issue commands to create the database */
--- 98,103 ----
*************** typedef struct _restoreOptions
*** 109,125 ****
* restore */
int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
* instead of OWNER TO */
- int no_security_labels; /* Skip security label entries */
char *superuser; /* Username to use as superuser */
char *use_role; /* Issue SET ROLE to this */
int dropSchema;
int if_exists;
const char *filename;
int dataOnly;
int schemaOnly;
int dumpSections;
int verbose;
int aclsSkip;
int tocSummary;
char *tocFile;
int format;
--- 107,130 ----
* restore */
int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
* instead of OWNER TO */
char *superuser; /* Username to use as superuser */
char *use_role; /* Issue SET ROLE to this */
int dropSchema;
+ int disable_dollar_quoting;
+ int dump_inserts;
+ int column_inserts;
int if_exists;
+ int no_security_labels; /* Skip security label entries */
+
const char *filename;
int dataOnly;
int schemaOnly;
int dumpSections;
int verbose;
int aclsSkip;
+ const char *lockWaitTimeout;
+ int include_everything;
+
int tocSummary;
char *tocFile;
int format;
*************** typedef struct _restoreOptions
*** 152,158 ****
bool *idWanted; /* array showing which dump IDs to emit */
} RestoreOptions;
! typedef void (*SetupWorkerPtr) (Archive *AH, RestoreOptions *ropt);
/*
* Main archiver interface.
--- 157,208 ----
bool *idWanted; /* array showing which dump IDs to emit */
} RestoreOptions;
! typedef struct _dumpOptions
! {
! const char *dbname;
! const char *pghost;
! const char *pgport;
! const char *username;
! bool oids;
!
! int binary_upgrade;
!
! /* various user-settable parameters */
! bool schemaOnly;
! bool dataOnly;
! int dumpSections; /* bitmask of chosen sections */
! bool aclsSkip;
! const char *lockWaitTimeout;
!
! /* flags for various command-line long options */
! int disable_dollar_quoting;
! int dump_inserts;
! int column_inserts;
! int if_exists;
! int no_security_labels;
! int no_synchronized_snapshots;
! int no_unlogged_table_data;
! int serializable_deferrable;
! int quote_all_identifiers;
!
! /* default, if no "inclusion" switches appear, is to dump everything */
! bool include_everything;
!
! int outputClean;
! int outputCreateDB;
! bool outputBlobs;
! int outputNoOwner;
! char *outputSuperuser;
!
! int disable_triggers;
! int outputNoTablespaces;
! int use_setsessauth;
!
! } DumpOptions;
!
! typedef int (*DataDumperPtr) (Archive *AH, DumpOptions *dopt, void *userArg);
!
! typedef void (*SetupWorkerPtr) (Archive *AH, DumpOptions *dopt, RestoreOptions *ropt);
/*
* Main archiver interface.
*************** extern void WriteData(Archive *AH, const
*** 185,191 ****
extern int StartBlob(Archive *AH, Oid oid);
extern int EndBlob(Archive *AH, Oid oid);
! extern void CloseArchive(Archive *AH);
extern void SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt);
--- 235,241 ----
extern int StartBlob(Archive *AH, Oid oid);
extern int EndBlob(Archive *AH, Oid oid);
! extern void CloseArchive(Archive *AH, DumpOptions *dopt);
extern void SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt);
*************** extern void PrintTOCSummary(Archive *AH,
*** 204,209 ****
--- 254,262 ----
extern RestoreOptions *NewRestoreOptions(void);
+ extern DumpOptions* NewDumpOptions(void);
+ extern DumpOptions* dumpOptionsFromRestoreOptions(RestoreOptions *ropt);
+
/* Rearrange and filter TOC entries */
extern void SortTocFromFile(Archive *AHX, RestoreOptions *ropt);
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
new file mode 100644
index ded9135..81f7300
*** a/src/bin/pg_dump/pg_backup_archiver.c
--- b/src/bin/pg_dump/pg_backup_archiver.c
*************** static void mark_create_done(ArchiveHand
*** 107,112 ****
--- 107,166 ----
static void inhibit_data_for_failed_table(ArchiveHandle *AH, TocEntry *te);
/*
+ * Allocate a new DumpOptions block.
+ * This is mainly so we can initialize it, but also for future expansion.
+ * We pg_malloc0 the structure, so we don't need to initialize whatever is
+ * 0, NULL or false anyway.
+ */
+ DumpOptions*
+ NewDumpOptions(void)
+ {
+ DumpOptions *opts;
+
+ opts = (DumpOptions *) pg_malloc0(sizeof(DumpOptions));
+
+ /* set any fields that shouldn't default to zeroes */
+ opts->include_everything = true;
+ opts->dumpSections = DUMP_UNSECTIONED;
+
+ return opts;
+ }
+
+ /*
+ * We do a plaintext dump by printing out the restore command that would create
+ * a certain object. Since in those functions we only have RestoreOptions, we
+ * crate ad-hoc DumpOptions.
+ */
+ DumpOptions*
+ dumpOptionsFromRestoreOptions(RestoreOptions *ropt) {
+ DumpOptions* dopt = NewDumpOptions();
+
+ /* this is the inverse of what's at the end of pg_dump.c's main() */
+ dopt->outputClean = ropt->dropSchema;
+ dopt->dataOnly = ropt->dataOnly;
+ dopt->schemaOnly = ropt->schemaOnly;
+ dopt->if_exists = ropt->if_exists;
+ dopt->column_inserts = ropt->column_inserts;
+ dopt->dumpSections = ropt->dumpSections;
+ dopt->aclsSkip = ropt->aclsSkip;
+ dopt->outputSuperuser = ropt->superuser;
+ dopt->outputCreateDB = ropt->createDB;
+ dopt->outputNoOwner = ropt->noOwner;
+ dopt->outputNoTablespaces = ropt->noTablespace;
+ dopt->disable_triggers = ropt->disable_triggers;
+ dopt->use_setsessauth = ropt->use_setsessauth;
+
+ dopt->disable_dollar_quoting = ropt->disable_dollar_quoting;
+ dopt->dump_inserts = ropt->dump_inserts;
+ dopt->no_security_labels = ropt->no_security_labels;
+ dopt->lockWaitTimeout = ropt->lockWaitTimeout;
+ dopt->include_everything = ropt->include_everything;
+
+ return dopt;
+ }
+
+
+ /*
* Wrapper functions.
*
* The objective it to make writing new formats and dumpers as simple
*************** static void inhibit_data_for_failed_tabl
*** 120,126 ****
* setup doesn't need to know anything much, so it's defined here.
*/
static void
! setupRestoreWorker(Archive *AHX, RestoreOptions *ropt)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
--- 174,180 ----
* setup doesn't need to know anything much, so it's defined here.
*/
static void
! setupRestoreWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
*************** OpenArchive(const char *FileSpec, const
*** 152,163 ****
/* Public */
void
! CloseArchive(Archive *AHX)
{
int res = 0;
ArchiveHandle *AH = (ArchiveHandle *) AHX;
! (*AH->ClosePtr) (AH);
/* Close the output */
if (AH->gzOut)
--- 206,217 ----
/* Public */
void
! CloseArchive(Archive *AHX, DumpOptions *dopt)
{
int res = 0;
ArchiveHandle *AH = (ArchiveHandle *) AHX;
! (*AH->ClosePtr) (AH, dopt);
/* Close the output */
if (AH->gzOut)
*************** RestoreArchive(Archive *AHX)
*** 522,528 ****
Assert(AH->connection == NULL);
/* ParallelBackupStart() will actually fork the processes */
! pstate = ParallelBackupStart(AH, ropt);
restore_toc_entries_parallel(AH, pstate, &pending_list);
ParallelBackupEnd(AH, pstate);
--- 576,582 ----
Assert(AH->connection == NULL);
/* ParallelBackupStart() will actually fork the processes */
! pstate = ParallelBackupStart(AH, NULL, ropt);
restore_toc_entries_parallel(AH, pstate, &pending_list);
ParallelBackupEnd(AH, pstate);
*************** _allocAH(const char *FileSpec, const Arc
*** 2214,2220 ****
}
void
! WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
{
TocEntry *te;
--- 2268,2274 ----
}
void
! WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate)
{
TocEntry *te;
*************** WriteDataChunks(ArchiveHandle *AH, Paral
*** 2237,2249 ****
DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP);
}
else
! WriteDataChunksForTocEntry(AH, te);
}
EnsureWorkersFinished(AH, pstate);
}
void
! WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
{
StartDataPtr startPtr;
EndDataPtr endPtr;
--- 2291,2303 ----
DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP);
}
else
! WriteDataChunksForTocEntry(AH, dopt, te);
}
EnsureWorkersFinished(AH, pstate);
}
void
! WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
{
StartDataPtr startPtr;
EndDataPtr endPtr;
*************** WriteDataChunksForTocEntry(ArchiveHandle
*** 2267,2273 ****
/*
* The user-provided DataDumper routine needs to call AH->WriteData
*/
! (*te->dataDumper) ((Archive *) AH, te->dataDumperArg);
if (endPtr != NULL)
(*endPtr) (AH, te);
--- 2321,2327 ----
/*
* The user-provided DataDumper routine needs to call AH->WriteData
*/
! (*te->dataDumper) ((Archive *) AH, dopt, te->dataDumperArg);
if (endPtr != NULL)
(*endPtr) (AH, te);
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
new file mode 100644
index c163f29..2dac52c
*** a/src/bin/pg_dump/pg_backup_archiver.h
--- b/src/bin/pg_dump/pg_backup_archiver.h
*************** typedef enum T_Action
*** 139,145 ****
ACT_RESTORE
} T_Action;
! typedef void (*ClosePtr) (struct _archiveHandle * AH);
typedef void (*ReopenPtr) (struct _archiveHandle * AH);
typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
--- 139,145 ----
ACT_RESTORE
} T_Action;
! typedef void (*ClosePtr) (struct _archiveHandle * AH, DumpOptions *dopt);
typedef void (*ReopenPtr) (struct _archiveHandle * AH);
typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
*************** typedef void (*ClonePtr) (struct _archiv
*** 166,172 ****
typedef void (*DeClonePtr) (struct _archiveHandle * AH);
typedef char *(*WorkerJobRestorePtr) (struct _archiveHandle * AH, struct _tocEntry * te);
! typedef char *(*WorkerJobDumpPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef char *(*MasterStartParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
T_Action act);
typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
--- 166,172 ----
typedef void (*DeClonePtr) (struct _archiveHandle * AH);
typedef char *(*WorkerJobRestorePtr) (struct _archiveHandle * AH, struct _tocEntry * te);
! typedef char *(*WorkerJobDumpPtr) (struct _archiveHandle * AH, DumpOptions *dopt, struct _tocEntry * te);
typedef char *(*MasterStartParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
T_Action act);
typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
*************** extern void WriteHead(ArchiveHandle *AH)
*** 389,396 ****
extern void ReadHead(ArchiveHandle *AH);
extern void WriteToc(ArchiveHandle *AH);
extern void ReadToc(ArchiveHandle *AH);
! extern void WriteDataChunks(ArchiveHandle *AH, struct ParallelState *pstate);
! extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te);
extern ArchiveHandle *CloneArchive(ArchiveHandle *AH);
extern void DeCloneArchive(ArchiveHandle *AH);
--- 389,396 ----
extern void ReadHead(ArchiveHandle *AH);
extern void WriteToc(ArchiveHandle *AH);
extern void ReadToc(ArchiveHandle *AH);
! extern void WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, struct ParallelState *pstate);
! extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te);
extern ArchiveHandle *CloneArchive(ArchiveHandle *AH);
extern void DeCloneArchive(ArchiveHandle *AH);
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
new file mode 100644
index 06cd0a7..d6bb471
*** a/src/bin/pg_dump/pg_backup_custom.c
--- b/src/bin/pg_dump/pg_backup_custom.c
*************** static int _WriteByte(ArchiveHandle *AH,
*** 41,47 ****
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
--- 41,47 ----
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
*************** _ReadBuf(ArchiveHandle *AH, void *buf, s
*** 694,700 ****
*
*/
static void
! _CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
pgoff_t tpos;
--- 694,700 ----
*
*/
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
lclContext *ctx = (lclContext *) AH->formatData;
pgoff_t tpos;
*************** _CloseArchive(ArchiveHandle *AH)
*** 709,715 ****
strerror(errno));
WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx);
! WriteDataChunks(AH, NULL);
/*
* If possible, re-write the TOC in order to update the data offset
--- 709,715 ----
strerror(errno));
WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx);
! WriteDataChunks(AH, dopt, NULL);
/*
* If possible, re-write the TOC in order to update the data offset
diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c
new file mode 100644
index 39e29d8..01b0e97
*** a/src/bin/pg_dump/pg_backup_directory.c
--- b/src/bin/pg_dump/pg_backup_directory.c
*************** static int _WriteByte(ArchiveHandle *AH,
*** 71,77 ****
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
--- 71,77 ----
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
*************** static char *_MasterStartParallelItem(Ar
*** 92,98 ****
static int _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te,
const char *str, T_Action act);
static char *_WorkerJobRestoreDirectory(ArchiveHandle *AH, TocEntry *te);
! static char *_WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te);
static void setFilePath(ArchiveHandle *AH, char *buf,
const char *relativeFilename);
--- 92,98 ----
static int _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te,
const char *str, T_Action act);
static char *_WorkerJobRestoreDirectory(ArchiveHandle *AH, TocEntry *te);
! static char *_WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te);
static void setFilePath(ArchiveHandle *AH, char *buf,
const char *relativeFilename);
*************** _ReadBuf(ArchiveHandle *AH, void *buf, s
*** 566,572 ****
* WriteDataChunks to save all DATA & BLOBs.
*/
static void
! _CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
--- 566,572 ----
* WriteDataChunks to save all DATA & BLOBs.
*/
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
lclContext *ctx = (lclContext *) AH->formatData;
*************** _CloseArchive(ArchiveHandle *AH)
*** 578,584 ****
setFilePath(AH, fname, "toc.dat");
/* this will actually fork the processes for a parallel backup */
! ctx->pstate = ParallelBackupStart(AH, NULL);
/* The TOC is always created uncompressed */
tocFH = cfopen_write(fname, PG_BINARY_W, 0);
--- 578,584 ----
setFilePath(AH, fname, "toc.dat");
/* this will actually fork the processes for a parallel backup */
! ctx->pstate = ParallelBackupStart(AH, dopt, NULL);
/* The TOC is always created uncompressed */
tocFH = cfopen_write(fname, PG_BINARY_W, 0);
*************** _CloseArchive(ArchiveHandle *AH)
*** 599,605 ****
if (cfclose(tocFH) != 0)
exit_horribly(modulename, "could not close TOC file: %s\n",
strerror(errno));
! WriteDataChunks(AH, ctx->pstate);
ParallelBackupEnd(AH, ctx->pstate);
}
--- 599,605 ----
if (cfclose(tocFH) != 0)
exit_horribly(modulename, "could not close TOC file: %s\n",
strerror(errno));
! WriteDataChunks(AH, dopt, ctx->pstate);
ParallelBackupEnd(AH, ctx->pstate);
}
*************** _MasterStartParallelItem(ArchiveHandle *
*** 790,796 ****
* function of the respective dump format.
*/
static char *
! _WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te)
{
/*
* short fixed-size string + some ID so far, this needs to be malloc'ed
--- 790,796 ----
* function of the respective dump format.
*/
static char *
! _WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
{
/*
* short fixed-size string + some ID so far, this needs to be malloc'ed
*************** _WorkerJobDumpDirectory(ArchiveHandle *A
*** 809,815 ****
* succeed... A failure will be detected by the parent when the child dies
* unexpectedly.
*/
! WriteDataChunksForTocEntry(AH, te);
snprintf(buf, buflen, "OK DUMP %d", te->dumpId);
--- 809,815 ----
* succeed... A failure will be detected by the parent when the child dies
* unexpectedly.
*/
! WriteDataChunksForTocEntry(AH, dopt, te);
snprintf(buf, buflen, "OK DUMP %d", te->dumpId);
diff --git a/src/bin/pg_dump/pg_backup_null.c b/src/bin/pg_dump/pg_backup_null.c
new file mode 100644
index 3bce588..b1c28c1
*** a/src/bin/pg_dump/pg_backup_null.c
--- b/src/bin/pg_dump/pg_backup_null.c
*************** static void _WriteBlobData(ArchiveHandle
*** 35,41 ****
static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
--- 35,41 ----
static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
*************** _PrintTocData(ArchiveHandle *AH, TocEntr
*** 198,209 ****
{
if (te->dataDumper)
{
AH->currToc = te;
if (strcmp(te->desc, "BLOBS") == 0)
_StartBlobs(AH, te);
! (*te->dataDumper) ((Archive *) AH, te->dataDumperArg);
if (strcmp(te->desc, "BLOBS") == 0)
_EndBlobs(AH, te);
--- 198,212 ----
{
if (te->dataDumper)
{
+ DumpOptions *dopt;
AH->currToc = te;
if (strcmp(te->desc, "BLOBS") == 0)
_StartBlobs(AH, te);
! dopt = dumpOptionsFromRestoreOptions(ropt);
! (*te->dataDumper) ((Archive *) AH, dopt, te->dataDumperArg);
! free(dopt);
if (strcmp(te->desc, "BLOBS") == 0)
_EndBlobs(AH, te);
*************** _WriteBuf(ArchiveHandle *AH, const void
*** 227,233 ****
}
static void
! _CloseArchive(ArchiveHandle *AH)
{
/* Nothing to do */
}
--- 230,236 ----
}
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
/* Nothing to do */
}
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
new file mode 100644
index 457b742..1c5056c
*** a/src/bin/pg_dump/pg_backup_tar.c
--- b/src/bin/pg_dump/pg_backup_tar.c
*************** static int _WriteByte(ArchiveHandle *AH,
*** 48,54 ****
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
--- 48,54 ----
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
! static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
*************** _ReadBuf(ArchiveHandle *AH, void *buf, s
*** 827,833 ****
}
static void
! _CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
TAR_MEMBER *th;
--- 827,833 ----
}
static void
! _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
lclContext *ctx = (lclContext *) AH->formatData;
TAR_MEMBER *th;
*************** _CloseArchive(ArchiveHandle *AH)
*** 850,856 ****
/*
* Now send the data (tables & blobs)
*/
! WriteDataChunks(AH, NULL);
/*
* Now this format wants to append a script which does a full restore
--- 850,856 ----
/*
* Now send the data (tables & blobs)
*/
! WriteDataChunks(AH, dopt, NULL);
/*
* Now this format wants to append a script which does a full restore
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
new file mode 100644
index c084ee9..76eb64a
*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
*************** typedef struct
*** 85,97 ****
bool g_verbose; /* User wants verbose narration of our
* activities. */
- /* various user-settable parameters */
- static bool schemaOnly;
- static bool dataOnly;
- static int dumpSections; /* bitmask of chosen sections */
- static bool aclsSkip;
- static const char *lockWaitTimeout;
-
/* subquery used to convert user ID (eg, datdba) to user name */
static const char *username_subquery;
--- 85,90 ----
*************** static SimpleOidList table_exclude_oids
*** 116,123 ****
static SimpleStringList tabledata_exclude_patterns = {NULL, NULL};
static SimpleOidList tabledata_exclude_oids = {NULL, NULL};
- /* default, if no "inclusion" switches appear, is to dump everything */
- static bool include_everything = true;
char g_opaque_type[10]; /* name for the opaque type */
--- 109,114 ----
*************** char g_comment_end[10];
*** 127,147 ****
static const CatalogId nilCatalogId = {0, 0};
- /* flags for various command-line long options */
- static int binary_upgrade = 0;
- static int disable_dollar_quoting = 0;
- static int dump_inserts = 0;
- static int column_inserts = 0;
- static int if_exists = 0;
- static int no_security_labels = 0;
- static int no_synchronized_snapshots = 0;
- static int no_unlogged_table_data = 0;
- static int serializable_deferrable = 0;
-
-
static void help(const char *progname);
! static void setup_connection(Archive *AH, const char *dumpencoding,
! char *use_role);
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
static void expand_schema_name_patterns(Archive *fout,
SimpleStringList *patterns,
--- 118,125 ----
static const CatalogId nilCatalogId = {0, 0};
static void help(const char *progname);
! static void setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding, char *use_role);
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
static void expand_schema_name_patterns(Archive *fout,
SimpleStringList *patterns,
*************** static void expand_table_name_patterns(A
*** 150,213 ****
SimpleStringList *patterns,
SimpleOidList *oids);
static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid);
! static void dumpTableData(Archive *fout, TableDataInfo *tdinfo);
static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo);
static void guessConstraintInheritance(TableInfo *tblinfo, int numTables);
! static void dumpComment(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findComments(Archive *fout, Oid classoid, Oid objoid,
CommentItem **items);
static int collectComments(Archive *fout, CommentItem **items);
! static void dumpSecLabel(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findSecLabels(Archive *fout, Oid classoid, Oid objoid,
SecLabelItem **items);
static int collectSecLabels(Archive *fout, SecLabelItem **items);
! static void dumpDumpableObject(Archive *fout, DumpableObject *dobj);
! static void dumpNamespace(Archive *fout, NamespaceInfo *nspinfo);
! static void dumpExtension(Archive *fout, ExtensionInfo *extinfo);
! static void dumpType(Archive *fout, TypeInfo *tyinfo);
! static void dumpBaseType(Archive *fout, TypeInfo *tyinfo);
! static void dumpEnumType(Archive *fout, TypeInfo *tyinfo);
! static void dumpRangeType(Archive *fout, TypeInfo *tyinfo);
! static void dumpDomain(Archive *fout, TypeInfo *tyinfo);
! static void dumpCompositeType(Archive *fout, TypeInfo *tyinfo);
static void dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo);
! static void dumpShellType(Archive *fout, ShellTypeInfo *stinfo);
! static void dumpProcLang(Archive *fout, ProcLangInfo *plang);
! static void dumpFunc(Archive *fout, FuncInfo *finfo);
! static void dumpCast(Archive *fout, CastInfo *cast);
! static void dumpOpr(Archive *fout, OprInfo *oprinfo);
! static void dumpOpclass(Archive *fout, OpclassInfo *opcinfo);
! static void dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo);
! static void dumpCollation(Archive *fout, CollInfo *convinfo);
! static void dumpConversion(Archive *fout, ConvInfo *convinfo);
! static void dumpRule(Archive *fout, RuleInfo *rinfo);
! static void dumpAgg(Archive *fout, AggInfo *agginfo);
! static void dumpTrigger(Archive *fout, TriggerInfo *tginfo);
! static void dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo);
! static void dumpTable(Archive *fout, TableInfo *tbinfo);
! static void dumpTableSchema(Archive *fout, TableInfo *tbinfo);
! static void dumpAttrDef(Archive *fout, AttrDefInfo *adinfo);
! static void dumpSequence(Archive *fout, TableInfo *tbinfo);
static void dumpSequenceData(Archive *fout, TableDataInfo *tdinfo);
! static void dumpIndex(Archive *fout, IndxInfo *indxinfo);
! static void dumpConstraint(Archive *fout, ConstraintInfo *coninfo);
! static void dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo);
! static void dumpTSParser(Archive *fout, TSParserInfo *prsinfo);
! static void dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo);
! static void dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo);
! static void dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo);
! static void dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo);
! static void dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo);
static void dumpUserMappings(Archive *fout,
const char *servername, const char *namespace,
const char *owner, CatalogId catalogId, DumpId dumpId);
! static void dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo);
! static void dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls);
--- 128,191 ----
SimpleStringList *patterns,
SimpleOidList *oids);
static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid);
! static void dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo);
static void refreshMatViewData(Archive *fout, TableDataInfo *tdinfo);
static void guessConstraintInheritance(TableInfo *tblinfo, int numTables);
! static void dumpComment(Archive *fout, DumpOptions* dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findComments(Archive *fout, Oid classoid, Oid objoid,
CommentItem **items);
static int collectComments(Archive *fout, CommentItem **items);
! static void dumpSecLabel(Archive *fout, DumpOptions* dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId);
static int findSecLabels(Archive *fout, Oid classoid, Oid objoid,
SecLabelItem **items);
static int collectSecLabels(Archive *fout, SecLabelItem **items);
! static void dumpDumpableObject(Archive *fout, DumpOptions* dopt, DumpableObject *dobj);
! static void dumpNamespace(Archive *fout, DumpOptions* dopt, NamespaceInfo *nspinfo);
! static void dumpExtension(Archive *fout, DumpOptions* dopt, ExtensionInfo *extinfo);
! static void dumpType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpBaseType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpEnumType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpRangeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpDomain(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
! static void dumpCompositeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo);
static void dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo);
! static void dumpShellType(Archive *fout, DumpOptions* dopt, ShellTypeInfo *stinfo);
! static void dumpProcLang(Archive *fout, DumpOptions* dopt, ProcLangInfo *plang);
! static void dumpFunc(Archive *fout, DumpOptions* dopt, FuncInfo *finfo);
! static void dumpCast(Archive *fout, DumpOptions* dopt, CastInfo *cast);
! static void dumpOpr(Archive *fout, DumpOptions* dopt, OprInfo *oprinfo);
! static void dumpOpclass(Archive *fout, DumpOptions* dopt, OpclassInfo *opcinfo);
! static void dumpOpfamily(Archive *fout, DumpOptions* dopt, OpfamilyInfo *opfinfo);
! static void dumpCollation(Archive *fout, DumpOptions* dopt, CollInfo *convinfo);
! static void dumpConversion(Archive *fout, DumpOptions* dopt, ConvInfo *convinfo);
! static void dumpRule(Archive *fout, DumpOptions* dopt, RuleInfo *rinfo);
! static void dumpAgg(Archive *fout, DumpOptions* dopt, AggInfo *agginfo);
! static void dumpTrigger(Archive *fout, DumpOptions* dopt, TriggerInfo *tginfo);
! static void dumpEventTrigger(Archive *fout, DumpOptions* dopt, EventTriggerInfo *evtinfo);
! static void dumpTable(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo);
! static void dumpTableSchema(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo);
! static void dumpAttrDef(Archive *fout, DumpOptions* dopt, AttrDefInfo *adinfo);
! static void dumpSequence(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo);
static void dumpSequenceData(Archive *fout, TableDataInfo *tdinfo);
! static void dumpIndex(Archive *fout, DumpOptions* dopt, IndxInfo *indxinfo);
! static void dumpConstraint(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo);
! static void dumpTableConstraintComment(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo);
! static void dumpTSParser(Archive *fout, DumpOptions* dopt, TSParserInfo *prsinfo);
! static void dumpTSDictionary(Archive *fout, DumpOptions* dopt, TSDictInfo *dictinfo);
! static void dumpTSTemplate(Archive *fout, DumpOptions* dopt, TSTemplateInfo *tmplinfo);
! static void dumpTSConfig(Archive *fout, DumpOptions* dopt, TSConfigInfo *cfginfo);
! static void dumpForeignDataWrapper(Archive *fout, DumpOptions* dopt, FdwInfo *fdwinfo);
! static void dumpForeignServer(Archive *fout, DumpOptions* dopt, ForeignServerInfo *srvinfo);
static void dumpUserMappings(Archive *fout,
const char *servername, const char *namespace,
const char *owner, CatalogId catalogId, DumpId dumpId);
! static void dumpDefaultACL(Archive *fout, DumpOptions* dopt, DefaultACLInfo *daclinfo);
! static void dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls);
*************** static void addBoundaryDependencies(Dump
*** 222,229 ****
DumpableObject *boundaryObjs);
static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo);
! static void getTableData(TableInfo *tblinfo, int numTables, bool oids);
! static void makeTableDataInfo(TableInfo *tbinfo, bool oids);
static void buildMatViewRefreshDependencies(Archive *fout);
static void getTableDataFKConstraints(void);
static char *format_function_arguments(FuncInfo *finfo, char *funcargs,
--- 200,207 ----
DumpableObject *boundaryObjs);
static void getDomainConstraints(Archive *fout, TypeInfo *tyinfo);
! static void getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids);
! static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids);
static void buildMatViewRefreshDependencies(Archive *fout);
static void getTableDataFKConstraints(void);
static char *format_function_arguments(FuncInfo *finfo, char *funcargs,
*************** static void selectSourceSchema(Archive *
*** 245,253 ****
static char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts);
static char *myFormatType(const char *typname, int32 typmod);
static void getBlobs(Archive *fout);
! static void dumpBlob(Archive *fout, BlobInfo *binfo);
! static int dumpBlobs(Archive *fout, void *arg);
! static void dumpDatabase(Archive *AH);
static void dumpEncoding(Archive *AH);
static void dumpStdStrings(Archive *AH);
static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout,
--- 223,231 ----
static char *getFormattedTypeName(Archive *fout, Oid oid, OidOptions opts);
static char *myFormatType(const char *typname, int32 typmod);
static void getBlobs(Archive *fout);
! static void dumpBlob(Archive *fout, DumpOptions *dopt, BlobInfo *binfo);
! static int dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg);
! static void dumpDatabase(Archive *AH, DumpOptions *dopt);
static void dumpEncoding(Archive *AH);
static void dumpStdStrings(Archive *AH);
static void binary_upgrade_set_type_oids_by_type_oid(Archive *fout,
*************** static const char *getAttrName(int attrn
*** 264,270 ****
static const char *fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer);
static char *get_synchronized_snapshot(Archive *fout);
static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query);
! static void setupDumpWorker(Archive *AHX, RestoreOptions *ropt);
int
--- 242,248 ----
static const char *fmtCopyColumnList(const TableInfo *ti, PQExpBuffer buffer);
static char *get_synchronized_snapshot(Archive *fout);
static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query);
! static void setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt);
int
*************** main(int argc, char **argv)
*** 273,311 ****
int c;
const char *filename = NULL;
const char *format = "p";
- const char *dbname = NULL;
- const char *pghost = NULL;
- const char *pgport = NULL;
- const char *username = NULL;
- const char *dumpencoding = NULL;
- bool oids = false;
TableInfo *tblinfo;
int numTables;
DumpableObject **dobjs;
int numObjs;
DumpableObject *boundaryObjs;
int i;
int numWorkers = 1;
enum trivalue prompt_password = TRI_DEFAULT;
int compressLevel = -1;
int plainText = 0;
- int outputClean = 0;
- int outputCreateDB = 0;
- bool outputBlobs = false;
- int outputNoOwner = 0;
- char *outputSuperuser = NULL;
- char *use_role = NULL;
- int optindex;
- RestoreOptions *ropt;
ArchiveFormat archiveFormat = archUnknown;
! ArchiveMode archiveMode;
! Archive *fout; /* the script file */
! static int disable_triggers = 0;
! static int outputNoTablespaces = 0;
! static int use_setsessauth = 0;
! static struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
{"blobs", no_argument, NULL, 'b'},
{"clean", no_argument, NULL, 'c'},
--- 251,277 ----
int c;
const char *filename = NULL;
const char *format = "p";
TableInfo *tblinfo;
int numTables;
DumpableObject **dobjs;
int numObjs;
DumpableObject *boundaryObjs;
int i;
+ int optindex;
+ RestoreOptions *ropt;
+ Archive *fout; /* the script file */
+ const char *dumpencoding = NULL;
+ char *use_role = NULL;
int numWorkers = 1;
enum trivalue prompt_password = TRI_DEFAULT;
int compressLevel = -1;
int plainText = 0;
ArchiveFormat archiveFormat = archUnknown;
! ArchiveMode archiveMode;
! DumpOptions *dopt = NewDumpOptions();
! struct option long_options[] = {
{"data-only", no_argument, NULL, 'a'},
{"blobs", no_argument, NULL, 'b'},
{"clean", no_argument, NULL, 'c'},
*************** main(int argc, char **argv)
*** 340,363 ****
/*
* the following options don't have an equivalent short option letter
*/
! {"attribute-inserts", no_argument, &column_inserts, 1},
! {"binary-upgrade", no_argument, &binary_upgrade, 1},
! {"column-inserts", no_argument, &column_inserts, 1},
! {"disable-dollar-quoting", no_argument, &disable_dollar_quoting, 1},
! {"disable-triggers", no_argument, &disable_triggers, 1},
{"exclude-table-data", required_argument, NULL, 4},
! {"if-exists", no_argument, &if_exists, 1},
! {"inserts", no_argument, &dump_inserts, 1},
{"lock-wait-timeout", required_argument, NULL, 2},
! {"no-tablespaces", no_argument, &outputNoTablespaces, 1},
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
{"role", required_argument, NULL, 3},
{"section", required_argument, NULL, 5},
! {"serializable-deferrable", no_argument, &serializable_deferrable, 1},
! {"use-set-session-authorization", no_argument, &use_setsessauth, 1},
! {"no-security-labels", no_argument, &no_security_labels, 1},
! {"no-synchronized-snapshots", no_argument, &no_synchronized_snapshots, 1},
! {"no-unlogged-table-data", no_argument, &no_unlogged_table_data, 1},
{NULL, 0, NULL, 0}
};
--- 306,329 ----
/*
* the following options don't have an equivalent short option letter
*/
! {"attribute-inserts", no_argument, &dopt->column_inserts, 1},
! {"binary-upgrade", no_argument, &dopt->binary_upgrade, 1},
! {"column-inserts", no_argument, &dopt->column_inserts, 1},
! {"disable-dollar-quoting", no_argument, &dopt->disable_dollar_quoting, 1},
! {"disable-triggers", no_argument, &dopt->disable_triggers, 1},
{"exclude-table-data", required_argument, NULL, 4},
! {"if-exists", no_argument, &dopt->if_exists, 1},
! {"inserts", no_argument, &dopt->dump_inserts, 1},
{"lock-wait-timeout", required_argument, NULL, 2},
! {"no-tablespaces", no_argument, &dopt->outputNoTablespaces, 1},
{"quote-all-identifiers", no_argument, "e_all_identifiers, 1},
{"role", required_argument, NULL, 3},
{"section", required_argument, NULL, 5},
! {"serializable-deferrable", no_argument, &dopt->serializable_deferrable, 1},
! {"use-set-session-authorization", no_argument, &dopt->use_setsessauth, 1},
! {"no-security-labels", no_argument, &dopt->no_security_labels, 1},
! {"no-synchronized-snapshots", no_argument, &dopt->no_synchronized_snapshots, 1},
! {"no-unlogged-table-data", no_argument, &dopt->no_unlogged_table_data, 1},
{NULL, 0, NULL, 0}
};
*************** main(int argc, char **argv)
*** 376,385 ****
g_comment_end[0] = '\0';
strcpy(g_opaque_type, "opaque");
- dataOnly = schemaOnly = false;
- dumpSections = DUMP_UNSECTIONED;
- lockWaitTimeout = NULL;
-
progname = get_progname(argv[0]);
/* Set default options based on progname */
--- 342,347 ----
*************** main(int argc, char **argv)
*** 406,428 ****
switch (c)
{
case 'a': /* Dump data only */
! dataOnly = true;
break;
case 'b': /* Dump blobs */
! outputBlobs = true;
break;
case 'c': /* clean (i.e., drop) schema prior to create */
! outputClean = 1;
break;
case 'C': /* Create DB */
! outputCreateDB = 1;
break;
case 'd': /* database name */
! dbname = pg_strdup(optarg);
break;
case 'E': /* Dump encoding */
--- 368,390 ----
switch (c)
{
case 'a': /* Dump data only */
! dopt->dataOnly = true;
break;
case 'b': /* Dump blobs */
! dopt->outputBlobs = true;
break;
case 'c': /* clean (i.e., drop) schema prior to create */
! dopt->outputClean = 1;
break;
case 'C': /* Create DB */
! dopt->outputCreateDB = 1;
break;
case 'd': /* database name */
! dopt->dbname = pg_strdup(optarg);
break;
case 'E': /* Dump encoding */
*************** main(int argc, char **argv)
*** 438,444 ****
break;
case 'h': /* server host */
! pghost = pg_strdup(optarg);
break;
case 'i':
--- 400,406 ----
break;
case 'h': /* server host */
! dopt->pghost = pg_strdup(optarg);
break;
case 'i':
*************** main(int argc, char **argv)
*** 451,457 ****
case 'n': /* include schema(s) */
simple_string_list_append(&schema_include_patterns, optarg);
! include_everything = false;
break;
case 'N': /* exclude schema(s) */
--- 413,419 ----
case 'n': /* include schema(s) */
simple_string_list_append(&schema_include_patterns, optarg);
! dopt->include_everything = false;
break;
case 'N': /* exclude schema(s) */
*************** main(int argc, char **argv)
*** 459,473 ****
break;
case 'o': /* Dump oids */
! oids = true;
break;
case 'O': /* Don't reconnect to match owner */
! outputNoOwner = 1;
break;
case 'p': /* server port */
! pgport = pg_strdup(optarg);
break;
case 'R':
--- 421,435 ----
break;
case 'o': /* Dump oids */
! dopt->oids = true;
break;
case 'O': /* Don't reconnect to match owner */
! dopt->outputNoOwner = 1;
break;
case 'p': /* server port */
! dopt->pgport = pg_strdup(optarg);
break;
case 'R':
*************** main(int argc, char **argv)
*** 475,490 ****
break;
case 's': /* dump schema only */
! schemaOnly = true;
break;
case 'S': /* Username for superuser in plain text output */
! outputSuperuser = pg_strdup(optarg);
break;
case 't': /* include table(s) */
simple_string_list_append(&table_include_patterns, optarg);
! include_everything = false;
break;
case 'T': /* exclude table(s) */
--- 437,452 ----
break;
case 's': /* dump schema only */
! dopt->schemaOnly = true;
break;
case 'S': /* Username for superuser in plain text output */
! dopt->outputSuperuser = pg_strdup(optarg);
break;
case 't': /* include table(s) */
simple_string_list_append(&table_include_patterns, optarg);
! dopt->include_everything = false;
break;
case 'T': /* exclude table(s) */
*************** main(int argc, char **argv)
*** 492,498 ****
break;
case 'U':
! username = pg_strdup(optarg);
break;
case 'v': /* verbose */
--- 454,460 ----
break;
case 'U':
! dopt->username = pg_strdup(optarg);
break;
case 'v': /* verbose */
*************** main(int argc, char **argv)
*** 508,514 ****
break;
case 'x': /* skip ACL dump */
! aclsSkip = true;
break;
case 'Z': /* Compression Level */
--- 470,476 ----
break;
case 'x': /* skip ACL dump */
! dopt->aclsSkip = true;
break;
case 'Z': /* Compression Level */
*************** main(int argc, char **argv)
*** 520,526 ****
break;
case 2: /* lock-wait-timeout */
! lockWaitTimeout = pg_strdup(optarg);
break;
case 3: /* SET ROLE */
--- 482,488 ----
break;
case 2: /* lock-wait-timeout */
! dopt->lockWaitTimeout = pg_strdup(optarg);
break;
case 3: /* SET ROLE */
*************** main(int argc, char **argv)
*** 532,538 ****
break;
case 5: /* section */
! set_dump_section(optarg, &dumpSections);
break;
default:
--- 494,500 ----
break;
case 5: /* section */
! set_dump_section(optarg, &dopt->dumpSections);
break;
default:
*************** main(int argc, char **argv)
*** 545,552 ****
* Non-option argument specifies database name as long as it wasn't
* already specified with -d / --dbname
*/
! if (optind < argc && dbname == NULL)
! dbname = argv[optind++];
/* Complain if any arguments remain */
if (optind < argc)
--- 507,514 ----
* Non-option argument specifies database name as long as it wasn't
* already specified with -d / --dbname
*/
! if (optind < argc && dopt->dbname == NULL)
! dopt->dbname = argv[optind++];
/* Complain if any arguments remain */
if (optind < argc)
*************** main(int argc, char **argv)
*** 559,587 ****
}
/* --column-inserts implies --inserts */
! if (column_inserts)
! dump_inserts = 1;
! if (dataOnly && schemaOnly)
{
write_msg(NULL, "options -s/--schema-only and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dataOnly && outputClean)
{
write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dump_inserts && oids)
{
write_msg(NULL, "options --inserts/--column-inserts and -o/--oids cannot be used together\n");
write_msg(NULL, "(The INSERT command cannot set OIDs.)\n");
exit_nicely(1);
}
! if (if_exists && !outputClean)
exit_horribly(NULL, "option --if-exists requires option -c/--clean\n");
/* Identify archive format to emit */
--- 521,549 ----
}
/* --column-inserts implies --inserts */
! if (dopt->column_inserts)
! dopt->dump_inserts = 1;
! if (dopt->dataOnly && dopt->schemaOnly)
{
write_msg(NULL, "options -s/--schema-only and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dopt->dataOnly && dopt->outputClean)
{
write_msg(NULL, "options -c/--clean and -a/--data-only cannot be used together\n");
exit_nicely(1);
}
! if (dopt->dump_inserts && dopt->oids)
{
write_msg(NULL, "options --inserts/--column-inserts and -o/--oids cannot be used together\n");
write_msg(NULL, "(The INSERT command cannot set OIDs.)\n");
exit_nicely(1);
}
! if (dopt->if_exists && !dopt->outputClean)
exit_horribly(NULL, "option --if-exists requires option -c/--clean\n");
/* Identify archive format to emit */
*************** main(int argc, char **argv)
*** 642,656 ****
* Open the database using the Archiver, so it knows about it. Errors mean
* death.
*/
! ConnectDatabase(fout, dbname, pghost, pgport, username, prompt_password);
! setup_connection(fout, dumpencoding, use_role);
/*
* Disable security label support if server version < v9.1.x (prevents
* access to nonexistent pg_seclabel catalog)
*/
if (fout->remoteVersion < 90100)
! no_security_labels = 1;
/*
* When running against 9.0 or later, check if we are in recovery mode,
--- 604,618 ----
* Open the database using the Archiver, so it knows about it. Errors mean
* death.
*/
! ConnectDatabase(fout, dopt->dbname, dopt->pghost, dopt->pgport, dopt->username, prompt_password);
! setup_connection(fout, dopt, dumpencoding, use_role);
/*
* Disable security label support if server version < v9.1.x (prevents
* access to nonexistent pg_seclabel catalog)
*/
if (fout->remoteVersion < 90100)
! dopt->no_security_labels = 1;
/*
* When running against 9.0 or later, check if we are in recovery mode,
*************** main(int argc, char **argv)
*** 666,672 ****
* On hot standby slaves, never try to dump unlogged table data,
* since it will just throw an error.
*/
! no_unlogged_table_data = true;
}
PQclear(res);
}
--- 628,634 ----
* On hot standby slaves, never try to dump unlogged table data,
* since it will just throw an error.
*/
! dopt->no_unlogged_table_data = true;
}
PQclear(res);
}
*************** main(int argc, char **argv)
*** 681,687 ****
/* check the version for the synchronized snapshots feature */
if (numWorkers > 1 && fout->remoteVersion < 90200
! && !no_synchronized_snapshots)
exit_horribly(NULL,
"Synchronized snapshots are not supported by this server version.\n"
"Run with --no-synchronized-snapshots instead if you do not need\n"
--- 643,649 ----
/* check the version for the synchronized snapshots feature */
if (numWorkers > 1 && fout->remoteVersion < 90200
! && !dopt->no_synchronized_snapshots)
exit_horribly(NULL,
"Synchronized snapshots are not supported by this server version.\n"
"Run with --no-synchronized-snapshots instead if you do not need\n"
*************** main(int argc, char **argv)
*** 731,757 ****
* Dumping blobs is now default unless we saw an inclusion switch or -s
* ... but even if we did see one of these, -b turns it back on.
*/
! if (include_everything && !schemaOnly)
! outputBlobs = true;
/*
* Now scan the database and create DumpableObject structs for all the
* objects we intend to dump.
*/
! tblinfo = getSchemaData(fout, &numTables);
if (fout->remoteVersion < 80400)
guessConstraintInheritance(tblinfo, numTables);
! if (!schemaOnly)
{
! getTableData(tblinfo, numTables, oids);
buildMatViewRefreshDependencies(fout);
! if (dataOnly)
getTableDataFKConstraints();
}
! if (outputBlobs)
getBlobs(fout);
/*
--- 693,719 ----
* Dumping blobs is now default unless we saw an inclusion switch or -s
* ... but even if we did see one of these, -b turns it back on.
*/
! if (dopt->include_everything && !dopt->schemaOnly)
! dopt->outputBlobs = true;
/*
* Now scan the database and create DumpableObject structs for all the
* objects we intend to dump.
*/
! tblinfo = getSchemaData(fout, dopt, &numTables);
if (fout->remoteVersion < 80400)
guessConstraintInheritance(tblinfo, numTables);
! if (!dopt->schemaOnly)
{
! getTableData(dopt, tblinfo, numTables, dopt->oids);
buildMatViewRefreshDependencies(fout);
! if (dopt->dataOnly)
getTableDataFKConstraints();
}
! if (dopt->outputBlobs)
getBlobs(fout);
/*
*************** main(int argc, char **argv)
*** 801,830 ****
dumpStdStrings(fout);
/* The database item is always next, unless we don't want it at all */
! if (include_everything && !dataOnly)
! dumpDatabase(fout);
/* Now the rearrangeable objects. */
for (i = 0; i < numObjs; i++)
! dumpDumpableObject(fout, dobjs[i]);
/*
* Set up options info to ensure we dump what we want.
*/
ropt = NewRestoreOptions();
ropt->filename = filename;
! ropt->dropSchema = outputClean;
! ropt->dataOnly = dataOnly;
! ropt->schemaOnly = schemaOnly;
! ropt->if_exists = if_exists;
! ropt->dumpSections = dumpSections;
! ropt->aclsSkip = aclsSkip;
! ropt->superuser = outputSuperuser;
! ropt->createDB = outputCreateDB;
! ropt->noOwner = outputNoOwner;
! ropt->noTablespace = outputNoTablespaces;
! ropt->disable_triggers = disable_triggers;
! ropt->use_setsessauth = use_setsessauth;
if (compressLevel == -1)
ropt->compression = 0;
--- 763,798 ----
dumpStdStrings(fout);
/* The database item is always next, unless we don't want it at all */
! if (dopt->include_everything && !dopt->dataOnly)
! dumpDatabase(fout, dopt);
/* Now the rearrangeable objects. */
for (i = 0; i < numObjs; i++)
! dumpDumpableObject(fout, dopt, dobjs[i]);
/*
* Set up options info to ensure we dump what we want.
*/
ropt = NewRestoreOptions();
ropt->filename = filename;
! ropt->dropSchema = dopt->outputClean;
! ropt->dataOnly = dopt->dataOnly;
! ropt->schemaOnly = dopt->schemaOnly;
! ropt->if_exists = dopt->if_exists;
! ropt->column_inserts = dopt->column_inserts;
! ropt->dumpSections = dopt->dumpSections;
! ropt->aclsSkip = dopt->aclsSkip;
! ropt->superuser = dopt->outputSuperuser;
! ropt->createDB = dopt->outputCreateDB;
! ropt->noOwner = dopt->outputNoOwner;
! ropt->noTablespace = dopt->outputNoTablespaces;
! ropt->disable_triggers = dopt->disable_triggers;
! ropt->use_setsessauth = dopt->use_setsessauth;
! ropt->disable_dollar_quoting = dopt->disable_dollar_quoting;
! ropt->dump_inserts = dopt->dump_inserts;
! ropt->no_security_labels = dopt->no_security_labels;
! ropt->lockWaitTimeout = dopt->lockWaitTimeout;
! ropt->include_everything = dopt->include_everything;
if (compressLevel == -1)
ropt->compression = 0;
*************** main(int argc, char **argv)
*** 853,859 ****
if (plainText)
RestoreArchive(fout);
! CloseArchive(fout);
exit_nicely(0);
}
--- 821,827 ----
if (plainText)
RestoreArchive(fout);
! CloseArchive(fout, dopt);
exit_nicely(0);
}
*************** help(const char *progname)
*** 926,932 ****
}
static void
! setup_connection(Archive *AH, const char *dumpencoding, char *use_role)
{
PGconn *conn = GetConnection(AH);
const char *std_strings;
--- 894,900 ----
}
static void
! setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding, char *use_role)
{
PGconn *conn = GetConnection(AH);
const char *std_strings;
*************** setup_connection(Archive *AH, const char
*** 1014,1020 ****
ExecuteSqlStatement(AH, "BEGIN");
if (AH->remoteVersion >= 90100)
{
! if (serializable_deferrable)
ExecuteSqlStatement(AH,
"SET TRANSACTION ISOLATION LEVEL "
"SERIALIZABLE, READ ONLY, DEFERRABLE");
--- 982,988 ----
ExecuteSqlStatement(AH, "BEGIN");
if (AH->remoteVersion >= 90100)
{
! if (dopt->serializable_deferrable)
ExecuteSqlStatement(AH,
"SET TRANSACTION ISOLATION LEVEL "
"SERIALIZABLE, READ ONLY, DEFERRABLE");
*************** setup_connection(Archive *AH, const char
*** 1036,1042 ****
! if (AH->numWorkers > 1 && AH->remoteVersion >= 90200 && !no_synchronized_snapshots)
{
if (AH->sync_snapshot_id)
{
--- 1004,1010 ----
! if (AH->numWorkers > 1 && AH->remoteVersion >= 90200 && !dopt->no_synchronized_snapshots)
{
if (AH->sync_snapshot_id)
{
*************** setup_connection(Archive *AH, const char
*** 1053,1061 ****
}
static void
! setupDumpWorker(Archive *AHX, RestoreOptions *ropt)
{
! setup_connection(AHX, NULL, NULL);
}
static char *
--- 1021,1029 ----
}
static void
! setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt)
{
! setup_connection(AHX, dopt, NULL, NULL);
}
static char *
*************** selectDumpableType(TypeInfo *tyinfo)
*** 1326,1337 ****
* and aclsSkip are checked separately.
*/
static void
! selectDumpableDefaultACL(DefaultACLInfo *dinfo)
{
if (dinfo->dobj.namespace)
dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump;
else
! dinfo->dobj.dump = include_everything;
}
/*
--- 1294,1305 ----
* and aclsSkip are checked separately.
*/
static void
! selectDumpableDefaultACL(DumpOptions *dopt, DefaultACLInfo *dinfo)
{
if (dinfo->dobj.namespace)
dinfo->dobj.dump = dinfo->dobj.namespace->dobj.dump;
else
! dinfo->dobj.dump = dopt->include_everything;
}
/*
*************** selectDumpableDefaultACL(DefaultACLInfo
*** 1345,1356 ****
* such extensions by their having OIDs in the range reserved for initdb.
*/
static void
! selectDumpableExtension(ExtensionInfo *extinfo)
{
! if (binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
extinfo->dobj.dump = false;
else
! extinfo->dobj.dump = include_everything;
}
/*
--- 1313,1324 ----
* such extensions by their having OIDs in the range reserved for initdb.
*/
static void
! selectDumpableExtension(DumpOptions *dopt, ExtensionInfo *extinfo)
{
! if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
extinfo->dobj.dump = false;
else
! extinfo->dobj.dump = dopt->include_everything;
}
/*
*************** selectDumpableObject(DumpableObject *dob
*** 1379,1385 ****
*/
static int
! dumpTableData_copy(Archive *fout, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
--- 1347,1353 ----
*/
static int
! dumpTableData_copy(Archive *fout, DumpOptions *dopt, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
*************** dumpTableData_copy(Archive *fout, void *
*** 1554,1560 ****
* E'' strings, or dollar-quoted strings. So don't emit anything like that.
*/
static int
! dumpTableData_insert(Archive *fout, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
--- 1522,1528 ----
* E'' strings, or dollar-quoted strings. So don't emit anything like that.
*/
static int
! dumpTableData_insert(Archive *fout, DumpOptions *dopt, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
*************** dumpTableData_insert(Archive *fout, void
*** 1623,1629 ****
else
{
/* append the list of column names if required */
! if (column_inserts)
{
appendPQExpBufferStr(insertStmt, "(");
for (field = 0; field < nfields; field++)
--- 1591,1597 ----
else
{
/* append the list of column names if required */
! if (dopt->column_inserts)
{
appendPQExpBufferStr(insertStmt, "(");
for (field = 0; field < nfields; field++)
*************** dumpTableData_insert(Archive *fout, void
*** 1740,1746 ****
* Actually, this just makes an ArchiveEntry for the table contents.
*/
static void
! dumpTableData(Archive *fout, TableDataInfo *tdinfo)
{
TableInfo *tbinfo = tdinfo->tdtable;
PQExpBuffer copyBuf = createPQExpBuffer();
--- 1708,1714 ----
* Actually, this just makes an ArchiveEntry for the table contents.
*/
static void
! dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo)
{
TableInfo *tbinfo = tdinfo->tdtable;
PQExpBuffer copyBuf = createPQExpBuffer();
*************** dumpTableData(Archive *fout, TableDataIn
*** 1748,1754 ****
DataDumperPtr dumpFn;
char *copyStmt;
! if (!dump_inserts)
{
/* Dump/restore using COPY */
dumpFn = dumpTableData_copy;
--- 1716,1722 ----
DataDumperPtr dumpFn;
char *copyStmt;
! if (!dopt->dump_inserts)
{
/* Dump/restore using COPY */
dumpFn = dumpTableData_copy;
*************** refreshMatViewData(Archive *fout, TableD
*** 1832,1845 ****
* set up dumpable objects representing the contents of tables
*/
static void
! getTableData(TableInfo *tblinfo, int numTables, bool oids)
{
int i;
for (i = 0; i < numTables; i++)
{
if (tblinfo[i].dobj.dump)
! makeTableDataInfo(&(tblinfo[i]), oids);
}
}
--- 1800,1813 ----
* set up dumpable objects representing the contents of tables
*/
static void
! getTableData(DumpOptions *dopt, TableInfo *tblinfo, int numTables, bool oids)
{
int i;
for (i = 0; i < numTables; i++)
{
if (tblinfo[i].dobj.dump)
! makeTableDataInfo(dopt, &(tblinfo[i]), oids);
}
}
*************** getTableData(TableInfo *tblinfo, int num
*** 1850,1856 ****
* table data; the "dump" flag in such objects isn't used.
*/
static void
! makeTableDataInfo(TableInfo *tbinfo, bool oids)
{
TableDataInfo *tdinfo;
--- 1818,1824 ----
* table data; the "dump" flag in such objects isn't used.
*/
static void
! makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids)
{
TableDataInfo *tdinfo;
*************** makeTableDataInfo(TableInfo *tbinfo, boo
*** 1870,1876 ****
/* Don't dump data in unlogged tables, if so requested */
if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED &&
! no_unlogged_table_data)
return;
/* Check that the data is not explicitly excluded */
--- 1838,1844 ----
/* Don't dump data in unlogged tables, if so requested */
if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED &&
! dopt->no_unlogged_table_data)
return;
/* Check that the data is not explicitly excluded */
*************** guessConstraintInheritance(TableInfo *tb
*** 2143,2149 ****
* dump the database definition
*/
static void
! dumpDatabase(Archive *fout)
{
PQExpBuffer dbQry = createPQExpBuffer();
PQExpBuffer delQry = createPQExpBuffer();
--- 2111,2117 ----
* dump the database definition
*/
static void
! dumpDatabase(Archive *fout, DumpOptions *dopt)
{
PQExpBuffer dbQry = createPQExpBuffer();
PQExpBuffer delQry = createPQExpBuffer();
*************** dumpDatabase(Archive *fout)
*** 2305,2311 ****
fmtId(tablespace));
appendPQExpBufferStr(creaQry, ";\n");
! if (binary_upgrade)
{
appendPQExpBufferStr(creaQry, "\n-- For binary upgrade, set datfrozenxid and datminmxid.\n");
appendPQExpBuffer(creaQry, "UPDATE pg_catalog.pg_database\n"
--- 2273,2279 ----
fmtId(tablespace));
appendPQExpBufferStr(creaQry, ";\n");
! if (dopt->binary_upgrade)
{
appendPQExpBufferStr(creaQry, "\n-- For binary upgrade, set datfrozenxid and datminmxid.\n");
appendPQExpBuffer(creaQry, "UPDATE pg_catalog.pg_database\n"
*************** dumpDatabase(Archive *fout)
*** 2344,2350 ****
* pg_largeobject and pg_largeobject_metadata come from the old system
* intact, so set their relfrozenxids and relminmxids.
*/
! if (binary_upgrade)
{
PGresult *lo_res;
PQExpBuffer loFrozenQry = createPQExpBuffer();
--- 2312,2318 ----
* pg_largeobject and pg_largeobject_metadata come from the old system
* intact, so set their relfrozenxids and relminmxids.
*/
! if (dopt->binary_upgrade)
{
PGresult *lo_res;
PQExpBuffer loFrozenQry = createPQExpBuffer();
*************** dumpDatabase(Archive *fout)
*** 2462,2475 ****
{
resetPQExpBuffer(dbQry);
appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname));
! dumpComment(fout, dbQry->data, NULL, "",
dbCatId, 0, dbDumpId);
}
PQclear(res);
/* Dump shared security label. */
! if (!no_security_labels && fout->remoteVersion >= 90200)
{
PQExpBuffer seclabelQry = createPQExpBuffer();
--- 2430,2443 ----
{
resetPQExpBuffer(dbQry);
appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname));
! dumpComment(fout, dopt, dbQry->data, NULL, "",
dbCatId, 0, dbDumpId);
}
PQclear(res);
/* Dump shared security label. */
! if (!dopt->no_security_labels && fout->remoteVersion >= 90200)
{
PQExpBuffer seclabelQry = createPQExpBuffer();
*************** dumpDatabase(Archive *fout)
*** 2490,2496 ****
destroyPQExpBuffer(creaQry);
}
-
/*
* dumpEncoding: put the correct encoding into the archive
*/
--- 2458,2463 ----
*************** getBlobs(Archive *fout)
*** 2630,2636 ****
* dump the definition (metadata) of the given large object
*/
static void
! dumpBlob(Archive *fout, BlobInfo *binfo)
{
PQExpBuffer cquery = createPQExpBuffer();
PQExpBuffer dquery = createPQExpBuffer();
--- 2597,2603 ----
* dump the definition (metadata) of the given large object
*/
static void
! dumpBlob(Archive *fout, DumpOptions* dopt, BlobInfo *binfo)
{
PQExpBuffer cquery = createPQExpBuffer();
PQExpBuffer dquery = createPQExpBuffer();
*************** dumpBlob(Archive *fout, BlobInfo *binfo)
*** 2657,2674 ****
appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name);
/* Dump comment if any */
! dumpComment(fout, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump security label if any */
! dumpSecLabel(fout, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump ACL if any */
if (binfo->blobacl)
! dumpACL(fout, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT",
binfo->dobj.name, NULL, cquery->data,
NULL, binfo->rolname, binfo->blobacl);
--- 2624,2641 ----
appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name);
/* Dump comment if any */
! dumpComment(fout, dopt, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump security label if any */
! dumpSecLabel(fout, dopt, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump ACL if any */
if (binfo->blobacl)
! dumpACL(fout, dopt, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT",
binfo->dobj.name, NULL, cquery->data,
NULL, binfo->rolname, binfo->blobacl);
*************** dumpBlob(Archive *fout, BlobInfo *binfo)
*** 2681,2687 ****
* dump the data contents of all large objects
*/
static int
! dumpBlobs(Archive *fout, void *arg)
{
const char *blobQry;
const char *blobFetchQry;
--- 2648,2654 ----
* dump the data contents of all large objects
*/
static int
! dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg)
{
const char *blobQry;
const char *blobFetchQry;
*************** findNamespace(Archive *fout, Oid nsoid,
*** 3092,3098 ****
* numExtensions is set to the number of extensions read in
*/
ExtensionInfo *
! getExtensions(Archive *fout, int *numExtensions)
{
PGresult *res;
int ntups;
--- 3059,3065 ----
* numExtensions is set to the number of extensions read in
*/
ExtensionInfo *
! getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions)
{
PGresult *res;
int ntups;
*************** getExtensions(Archive *fout, int *numExt
*** 3156,3162 ****
extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition));
/* Decide whether we want to dump it */
! selectDumpableExtension(&(extinfo[i]));
}
PQclear(res);
--- 3123,3129 ----
extinfo[i].extcondition = pg_strdup(PQgetvalue(res, i, i_extcondition));
/* Decide whether we want to dump it */
! selectDumpableExtension(dopt, &(extinfo[i]));
}
PQclear(res);
*************** getOpfamilies(Archive *fout, int *numOpf
*** 3907,3913 ****
* numAggs is set to the number of aggregates read in
*/
AggInfo *
! getAggregates(Archive *fout, int *numAggs)
{
PGresult *res;
int ntups;
--- 3874,3880 ----
* numAggs is set to the number of aggregates read in
*/
AggInfo *
! getAggregates(Archive *fout, DumpOptions *dopt, int *numAggs)
{
PGresult *res;
int ntups;
*************** getAggregates(Archive *fout, int *numAgg
*** 3946,3952 ****
"(SELECT oid FROM pg_namespace "
"WHERE nspname = 'pg_catalog')",
username_subquery);
! if (binary_upgrade && fout->remoteVersion >= 90100)
appendPQExpBufferStr(query,
" OR EXISTS(SELECT 1 FROM pg_depend WHERE "
"classid = 'pg_proc'::regclass AND "
--- 3913,3919 ----
"(SELECT oid FROM pg_namespace "
"WHERE nspname = 'pg_catalog')",
username_subquery);
! if (dopt->binary_upgrade && fout->remoteVersion >= 90100)
appendPQExpBufferStr(query,
" OR EXISTS(SELECT 1 FROM pg_depend WHERE "
"classid = 'pg_proc'::regclass AND "
*************** getAggregates(Archive *fout, int *numAgg
*** 4086,4092 ****
* numFuncs is set to the number of functions read in
*/
FuncInfo *
! getFuncs(Archive *fout, int *numFuncs)
{
PGresult *res;
int ntups;
--- 4053,4059 ----
* numFuncs is set to the number of functions read in
*/
FuncInfo *
! getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs)
{
PGresult *res;
int ntups;
*************** getFuncs(Archive *fout, int *numFuncs)
*** 4143,4149 ****
"\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
"WHERE classid = 'pg_proc'::regclass AND "
"objid = p.oid AND deptype = 'i')");
! if (binary_upgrade && fout->remoteVersion >= 90100)
appendPQExpBufferStr(query,
"\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
"classid = 'pg_proc'::regclass AND "
--- 4110,4116 ----
"\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
"WHERE classid = 'pg_proc'::regclass AND "
"objid = p.oid AND deptype = 'i')");
! if (dopt->binary_upgrade && fout->remoteVersion >= 90100)
appendPQExpBufferStr(query,
"\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "
"classid = 'pg_proc'::regclass AND "
*************** getFuncs(Archive *fout, int *numFuncs)
*** 4269,4275 ****
* numTables is set to the number of tables read in
*/
TableInfo *
! getTables(Archive *fout, int *numTables)
{
PGresult *res;
int ntups;
--- 4236,4242 ----
* numTables is set to the number of tables read in
*/
TableInfo *
! getTables(Archive *fout, DumpOptions *dopt, int *numTables)
{
PGresult *res;
int ntups;
*************** getTables(Archive *fout, int *numTables)
*** 4766,4772 ****
i_toastreloptions = PQfnumber(res, "toast_reloptions");
i_reloftype = PQfnumber(res, "reloftype");
! if (lockWaitTimeout && fout->remoteVersion >= 70300)
{
/*
* Arrange to fail instead of waiting forever for a table lock.
--- 4733,4739 ----
i_toastreloptions = PQfnumber(res, "toast_reloptions");
i_reloftype = PQfnumber(res, "reloftype");
! if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300)
{
/*
* Arrange to fail instead of waiting forever for a table lock.
*************** getTables(Archive *fout, int *numTables)
*** 4777,4783 ****
*/
resetPQExpBuffer(query);
appendPQExpBufferStr(query, "SET statement_timeout = ");
! appendStringLiteralConn(query, lockWaitTimeout, GetConnection(fout));
ExecuteSqlStatement(fout, query->data);
}
--- 4744,4750 ----
*/
resetPQExpBuffer(query);
appendPQExpBufferStr(query, "SET statement_timeout = ");
! appendStringLiteralConn(query, dopt->lockWaitTimeout, GetConnection(fout));
ExecuteSqlStatement(fout, query->data);
}
*************** getTables(Archive *fout, int *numTables)
*** 4872,4878 ****
tblinfo[i].dobj.name);
}
! if (lockWaitTimeout && fout->remoteVersion >= 70300)
{
ExecuteSqlStatement(fout, "SET statement_timeout = 0");
}
--- 4839,4845 ----
tblinfo[i].dobj.name);
}
! if (dopt->lockWaitTimeout && fout->remoteVersion >= 70300)
{
ExecuteSqlStatement(fout, "SET statement_timeout = 0");
}
*************** getCasts(Archive *fout, int *numCasts)
*** 6287,6293 ****
* modifies tblinfo
*/
void
! getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
{
int i,
j;
--- 6254,6260 ----
* modifies tblinfo
*/
void
! getTableAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tblinfo, int numTables)
{
int i,
j;
*************** getTableAttrs(Archive *fout, TableInfo *
*** 6642,6648 ****
addObjectDependency(&attrdefs[j].dobj,
tbinfo->dobj.dumpId);
}
! else if (!shouldPrintColumn(tbinfo, adnum - 1))
{
/* column will be suppressed, print default separately */
attrdefs[j].separate = true;
--- 6609,6615 ----
addObjectDependency(&attrdefs[j].dobj,
tbinfo->dobj.dumpId);
}
! else if (!shouldPrintColumn(dopt, tbinfo, adnum - 1))
{
/* column will be suppressed, print default separately */
attrdefs[j].separate = true;
*************** getTableAttrs(Archive *fout, TableInfo *
*** 6855,6863 ****
* must be kept in sync with this decision.
*/
bool
! shouldPrintColumn(TableInfo *tbinfo, int colno)
{
! if (binary_upgrade)
return true;
return (tbinfo->attislocal[colno] && !tbinfo->attisdropped[colno]);
}
--- 6822,6830 ----
* must be kept in sync with this decision.
*/
bool
! shouldPrintColumn(DumpOptions *dopt, TableInfo *tbinfo, int colno)
{
! if (dopt->binary_upgrade)
return true;
return (tbinfo->attislocal[colno] && !tbinfo->attisdropped[colno]);
}
*************** getForeignServers(Archive *fout, int *nu
*** 7403,7409 ****
* numDefaultACLs is set to the number of ACLs read in
*/
DefaultACLInfo *
! getDefaultACLs(Archive *fout, int *numDefaultACLs)
{
DefaultACLInfo *daclinfo;
PQExpBuffer query;
--- 7370,7376 ----
* numDefaultACLs is set to the number of ACLs read in
*/
DefaultACLInfo *
! getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs)
{
DefaultACLInfo *daclinfo;
PQExpBuffer query;
*************** getDefaultACLs(Archive *fout, int *numDe
*** 7472,7478 ****
daclinfo[i].defaclacl = pg_strdup(PQgetvalue(res, i, i_defaclacl));
/* Decide whether we want to dump it */
! selectDumpableDefaultACL(&(daclinfo[i]));
}
PQclear(res);
--- 7439,7445 ----
daclinfo[i].defaclacl = pg_strdup(PQgetvalue(res, i, i_defaclacl));
/* Decide whether we want to dump it */
! selectDumpableDefaultACL(dopt, &(daclinfo[i]));
}
PQclear(res);
*************** getDefaultACLs(Archive *fout, int *numDe
*** 7501,7507 ****
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpComment(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
--- 7468,7474 ----
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpComment(Archive *fout, DumpOptions *dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
*************** dumpComment(Archive *fout, const char *t
*** 7511,7522 ****
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dataOnly)
return;
}
else
{
! if (schemaOnly)
return;
}
--- 7478,7489 ----
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dopt->dataOnly)
return;
}
else
{
! if (dopt->schemaOnly)
return;
}
*************** dumpComment(Archive *fout, const char *t
*** 7565,7571 ****
* and its columns.
*/
static void
! dumpTableComment(Archive *fout, TableInfo *tbinfo,
const char *reltypename)
{
CommentItem *comments;
--- 7532,7538 ----
* and its columns.
*/
static void
! dumpTableComment(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo,
const char *reltypename)
{
CommentItem *comments;
*************** dumpTableComment(Archive *fout, TableInf
*** 7574,7580 ****
PQExpBuffer target;
/* Comments are SCHEMA not data */
! if (dataOnly)
return;
/* Search for comments associated with relation, using table */
--- 7541,7547 ----
PQExpBuffer target;
/* Comments are SCHEMA not data */
! if (dopt->dataOnly)
return;
/* Search for comments associated with relation, using table */
*************** collectComments(Archive *fout, CommentIt
*** 7819,7926 ****
* ArchiveEntries (TOC objects) for each object to be dumped.
*/
static void
! dumpDumpableObject(Archive *fout, DumpableObject *dobj)
{
switch (dobj->objType)
{
case DO_NAMESPACE:
! dumpNamespace(fout, (NamespaceInfo *) dobj);
break;
case DO_EXTENSION:
! dumpExtension(fout, (ExtensionInfo *) dobj);
break;
case DO_TYPE:
! dumpType(fout, (TypeInfo *) dobj);
break;
case DO_SHELL_TYPE:
! dumpShellType(fout, (ShellTypeInfo *) dobj);
break;
case DO_FUNC:
! dumpFunc(fout, (FuncInfo *) dobj);
break;
case DO_AGG:
! dumpAgg(fout, (AggInfo *) dobj);
break;
case DO_OPERATOR:
! dumpOpr(fout, (OprInfo *) dobj);
break;
case DO_OPCLASS:
! dumpOpclass(fout, (OpclassInfo *) dobj);
break;
case DO_OPFAMILY:
! dumpOpfamily(fout, (OpfamilyInfo *) dobj);
break;
case DO_COLLATION:
! dumpCollation(fout, (CollInfo *) dobj);
break;
case DO_CONVERSION:
! dumpConversion(fout, (ConvInfo *) dobj);
break;
case DO_TABLE:
! dumpTable(fout, (TableInfo *) dobj);
break;
case DO_ATTRDEF:
! dumpAttrDef(fout, (AttrDefInfo *) dobj);
break;
case DO_INDEX:
! dumpIndex(fout, (IndxInfo *) dobj);
break;
case DO_REFRESH_MATVIEW:
refreshMatViewData(fout, (TableDataInfo *) dobj);
break;
case DO_RULE:
! dumpRule(fout, (RuleInfo *) dobj);
break;
case DO_TRIGGER:
! dumpTrigger(fout, (TriggerInfo *) dobj);
break;
case DO_EVENT_TRIGGER:
! dumpEventTrigger(fout, (EventTriggerInfo *) dobj);
break;
case DO_CONSTRAINT:
! dumpConstraint(fout, (ConstraintInfo *) dobj);
break;
case DO_FK_CONSTRAINT:
! dumpConstraint(fout, (ConstraintInfo *) dobj);
break;
case DO_PROCLANG:
! dumpProcLang(fout, (ProcLangInfo *) dobj);
break;
case DO_CAST:
! dumpCast(fout, (CastInfo *) dobj);
break;
case DO_TABLE_DATA:
if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE)
dumpSequenceData(fout, (TableDataInfo *) dobj);
else
! dumpTableData(fout, (TableDataInfo *) dobj);
break;
case DO_DUMMY_TYPE:
/* table rowtypes and array types are never dumped separately */
break;
case DO_TSPARSER:
! dumpTSParser(fout, (TSParserInfo *) dobj);
break;
case DO_TSDICT:
! dumpTSDictionary(fout, (TSDictInfo *) dobj);
break;
case DO_TSTEMPLATE:
! dumpTSTemplate(fout, (TSTemplateInfo *) dobj);
break;
case DO_TSCONFIG:
! dumpTSConfig(fout, (TSConfigInfo *) dobj);
break;
case DO_FDW:
! dumpForeignDataWrapper(fout, (FdwInfo *) dobj);
break;
case DO_FOREIGN_SERVER:
! dumpForeignServer(fout, (ForeignServerInfo *) dobj);
break;
case DO_DEFAULT_ACL:
! dumpDefaultACL(fout, (DefaultACLInfo *) dobj);
break;
case DO_BLOB:
! dumpBlob(fout, (BlobInfo *) dobj);
break;
case DO_BLOB_DATA:
ArchiveEntry(fout, dobj->catId, dobj->dumpId,
--- 7786,7893 ----
* ArchiveEntries (TOC objects) for each object to be dumped.
*/
static void
! dumpDumpableObject(Archive *fout, DumpOptions *dopt, DumpableObject *dobj)
{
switch (dobj->objType)
{
case DO_NAMESPACE:
! dumpNamespace(fout, dopt, (NamespaceInfo *) dobj);
break;
case DO_EXTENSION:
! dumpExtension(fout, dopt, (ExtensionInfo *) dobj);
break;
case DO_TYPE:
! dumpType(fout, dopt, (TypeInfo *) dobj);
break;
case DO_SHELL_TYPE:
! dumpShellType(fout, dopt, (ShellTypeInfo *) dobj);
break;
case DO_FUNC:
! dumpFunc(fout, dopt, (FuncInfo *) dobj);
break;
case DO_AGG:
! dumpAgg(fout, dopt, (AggInfo *) dobj);
break;
case DO_OPERATOR:
! dumpOpr(fout, dopt, (OprInfo *) dobj);
break;
case DO_OPCLASS:
! dumpOpclass(fout, dopt, (OpclassInfo *) dobj);
break;
case DO_OPFAMILY:
! dumpOpfamily(fout, dopt, (OpfamilyInfo *) dobj);
break;
case DO_COLLATION:
! dumpCollation(fout, dopt, (CollInfo *) dobj);
break;
case DO_CONVERSION:
! dumpConversion(fout, dopt, (ConvInfo *) dobj);
break;
case DO_TABLE:
! dumpTable(fout, dopt, (TableInfo *) dobj);
break;
case DO_ATTRDEF:
! dumpAttrDef(fout, dopt, (AttrDefInfo *) dobj);
break;
case DO_INDEX:
! dumpIndex(fout, dopt, (IndxInfo *) dobj);
break;
case DO_REFRESH_MATVIEW:
refreshMatViewData(fout, (TableDataInfo *) dobj);
break;
case DO_RULE:
! dumpRule(fout, dopt, (RuleInfo *) dobj);
break;
case DO_TRIGGER:
! dumpTrigger(fout, dopt, (TriggerInfo *) dobj);
break;
case DO_EVENT_TRIGGER:
! dumpEventTrigger(fout, dopt, (EventTriggerInfo *) dobj);
break;
case DO_CONSTRAINT:
! dumpConstraint(fout, dopt, (ConstraintInfo *) dobj);
break;
case DO_FK_CONSTRAINT:
! dumpConstraint(fout, dopt, (ConstraintInfo *) dobj);
break;
case DO_PROCLANG:
! dumpProcLang(fout, dopt, (ProcLangInfo *) dobj);
break;
case DO_CAST:
! dumpCast(fout, dopt, (CastInfo *) dobj);
break;
case DO_TABLE_DATA:
if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE)
dumpSequenceData(fout, (TableDataInfo *) dobj);
else
! dumpTableData(fout, dopt, (TableDataInfo *) dobj);
break;
case DO_DUMMY_TYPE:
/* table rowtypes and array types are never dumped separately */
break;
case DO_TSPARSER:
! dumpTSParser(fout, dopt, (TSParserInfo *) dobj);
break;
case DO_TSDICT:
! dumpTSDictionary(fout, dopt, (TSDictInfo *) dobj);
break;
case DO_TSTEMPLATE:
! dumpTSTemplate(fout, dopt, (TSTemplateInfo *) dobj);
break;
case DO_TSCONFIG:
! dumpTSConfig(fout, dopt, (TSConfigInfo *) dobj);
break;
case DO_FDW:
! dumpForeignDataWrapper(fout, dopt, (FdwInfo *) dobj);
break;
case DO_FOREIGN_SERVER:
! dumpForeignServer(fout, dopt, (ForeignServerInfo *) dobj);
break;
case DO_DEFAULT_ACL:
! dumpDefaultACL(fout, dopt, (DefaultACLInfo *) dobj);
break;
case DO_BLOB:
! dumpBlob(fout, dopt, (BlobInfo *) dobj);
break;
case DO_BLOB_DATA:
ArchiveEntry(fout, dobj->catId, dobj->dumpId,
*************** dumpDumpableObject(Archive *fout, Dumpab
*** 7942,7948 ****
* writes out to fout the queries to recreate a user-defined namespace
*/
static void
! dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 7909,7915 ----
* writes out to fout the queries to recreate a user-defined namespace
*/
static void
! dumpNamespace(Archive *fout, DumpOptions *dopt, NamespaceInfo *nspinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpNamespace(Archive *fout, NamespaceIn
*** 7950,7956 ****
char *qnspname;
/* Skip if not to be dumped */
! if (!nspinfo->dobj.dump || dataOnly)
return;
/* don't dump dummy namespace from pre-7.3 source */
--- 7917,7923 ----
char *qnspname;
/* Skip if not to be dumped */
! if (!nspinfo->dobj.dump || dopt->dataOnly)
return;
/* don't dump dummy namespace from pre-7.3 source */
*************** dumpNamespace(Archive *fout, NamespaceIn
*** 7969,7975 ****
appendPQExpBuffer(labelq, "SCHEMA %s", qnspname);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &nspinfo->dobj, labelq->data);
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
--- 7936,7942 ----
appendPQExpBuffer(labelq, "SCHEMA %s", qnspname);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &nspinfo->dobj, labelq->data);
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
*************** dumpNamespace(Archive *fout, NamespaceIn
*** 7982,7995 ****
NULL, NULL);
/* Dump Schema Comments and Security Labels */
! dumpComment(fout, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
qnspname, NULL, nspinfo->dobj.name, NULL,
nspinfo->rolname, nspinfo->nspacl);
--- 7949,7962 ----
NULL, NULL);
/* Dump Schema Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
! dumpACL(fout, dopt, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
qnspname, NULL, nspinfo->dobj.name, NULL,
nspinfo->rolname, nspinfo->nspacl);
*************** dumpNamespace(Archive *fout, NamespaceIn
*** 8005,8011 ****
* writes out to fout the queries to recreate an extension
*/
static void
! dumpExtension(Archive *fout, ExtensionInfo *extinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 7972,7978 ----
* writes out to fout the queries to recreate an extension
*/
static void
! dumpExtension(Archive *fout, DumpOptions *dopt, ExtensionInfo *extinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpExtension(Archive *fout, ExtensionIn
*** 8013,8019 ****
char *qextname;
/* Skip if not to be dumped */
! if (!extinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 7980,7986 ----
char *qextname;
/* Skip if not to be dumped */
! if (!extinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpExtension(Archive *fout, ExtensionIn
*** 8024,8030 ****
appendPQExpBuffer(delq, "DROP EXTENSION %s;\n", qextname);
! if (!binary_upgrade)
{
/*
* In a regular dump, we use IF NOT EXISTS so that there isn't a
--- 7991,7997 ----
appendPQExpBuffer(delq, "DROP EXTENSION %s;\n", qextname);
! if (!dopt->binary_upgrade)
{
/*
* In a regular dump, we use IF NOT EXISTS so that there isn't a
*************** dumpExtension(Archive *fout, ExtensionIn
*** 8110,8119 ****
NULL, NULL);
/* Dump Extension Comments and Security Labels */
! dumpComment(fout, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
--- 8077,8086 ----
NULL, NULL);
/* Dump Extension Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
*************** dumpExtension(Archive *fout, ExtensionIn
*** 8129,8151 ****
* writes out to fout the queries to recreate a user-defined type
*/
static void
! dumpType(Archive *fout, TypeInfo *tyinfo)
{
/* Skip if not to be dumped */
! if (!tyinfo->dobj.dump || dataOnly)
return;
/* Dump out in proper style */
if (tyinfo->typtype == TYPTYPE_BASE)
! dumpBaseType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_DOMAIN)
! dumpDomain(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_COMPOSITE)
! dumpCompositeType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_ENUM)
! dumpEnumType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_RANGE)
! dumpRangeType(fout, tyinfo);
else
write_msg(NULL, "WARNING: typtype of data type \"%s\" appears to be invalid\n",
tyinfo->dobj.name);
--- 8096,8118 ----
* writes out to fout the queries to recreate a user-defined type
*/
static void
! dumpType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
/* Skip if not to be dumped */
! if (!tyinfo->dobj.dump || dopt->dataOnly)
return;
/* Dump out in proper style */
if (tyinfo->typtype == TYPTYPE_BASE)
! dumpBaseType(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_DOMAIN)
! dumpDomain(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_COMPOSITE)
! dumpCompositeType(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_ENUM)
! dumpEnumType(fout, dopt, tyinfo);
else if (tyinfo->typtype == TYPTYPE_RANGE)
! dumpRangeType(fout, dopt, tyinfo);
else
write_msg(NULL, "WARNING: typtype of data type \"%s\" appears to be invalid\n",
tyinfo->dobj.name);
*************** dumpType(Archive *fout, TypeInfo *tyinfo
*** 8156,8162 ****
* writes out to fout the queries to recreate a user-defined enum type
*/
static void
! dumpEnumType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8123,8129 ----
* writes out to fout the queries to recreate a user-defined enum type
*/
static void
! dumpEnumType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpEnumType(Archive *fout, TypeInfo *ty
*** 8201,8214 ****
appendPQExpBuffer(delq, "%s;\n",
qtypname);
! if (binary_upgrade)
binary_upgrade_set_type_oids_by_type_oid(fout, q,
tyinfo->dobj.catId.oid);
appendPQExpBuffer(q, "CREATE TYPE %s AS ENUM (",
qtypname);
! if (!binary_upgrade)
{
/* Labels with server-assigned oids */
for (i = 0; i < num; i++)
--- 8168,8181 ----
appendPQExpBuffer(delq, "%s;\n",
qtypname);
! if (dopt->binary_upgrade)
binary_upgrade_set_type_oids_by_type_oid(fout, q,
tyinfo->dobj.catId.oid);
appendPQExpBuffer(q, "CREATE TYPE %s AS ENUM (",
qtypname);
! if (!dopt->binary_upgrade)
{
/* Labels with server-assigned oids */
for (i = 0; i < num; i++)
*************** dumpEnumType(Archive *fout, TypeInfo *ty
*** 8223,8229 ****
appendPQExpBufferStr(q, "\n);\n");
! if (binary_upgrade)
{
/* Labels with dump-assigned (preserved) oids */
for (i = 0; i < num; i++)
--- 8190,8196 ----
appendPQExpBufferStr(q, "\n);\n");
! if (dopt->binary_upgrade)
{
/* Labels with dump-assigned (preserved) oids */
for (i = 0; i < num; i++)
*************** dumpEnumType(Archive *fout, TypeInfo *ty
*** 8247,8253 ****
appendPQExpBuffer(labelq, "TYPE %s", qtypname);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
--- 8214,8220 ----
appendPQExpBuffer(labelq, "TYPE %s", qtypname);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
*************** dumpEnumType(Archive *fout, TypeInfo *ty
*** 8261,8274 ****
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8228,8241 ----
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpEnumType(Archive *fout, TypeInfo *ty
*** 8285,8291 ****
* writes out to fout the queries to recreate a user-defined range type
*/
static void
! dumpRangeType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8252,8258 ----
* writes out to fout the queries to recreate a user-defined range type
*/
static void
! dumpRangeType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpRangeType(Archive *fout, TypeInfo *t
*** 8331,8337 ****
appendPQExpBuffer(delq, "%s;\n",
qtypname);
! if (binary_upgrade)
binary_upgrade_set_type_oids_by_type_oid(fout,
q, tyinfo->dobj.catId.oid);
--- 8298,8304 ----
appendPQExpBuffer(delq, "%s;\n",
qtypname);
! if (dopt->binary_upgrade)
binary_upgrade_set_type_oids_by_type_oid(fout,
q, tyinfo->dobj.catId.oid);
*************** dumpRangeType(Archive *fout, TypeInfo *t
*** 8379,8385 ****
appendPQExpBuffer(labelq, "TYPE %s", qtypname);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
--- 8346,8352 ----
appendPQExpBuffer(labelq, "TYPE %s", qtypname);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
*************** dumpRangeType(Archive *fout, TypeInfo *t
*** 8393,8406 ****
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8360,8373 ----
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpRangeType(Archive *fout, TypeInfo *t
*** 8417,8423 ****
* writes out to fout the queries to recreate a user-defined base type
*/
static void
! dumpBaseType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8384,8390 ----
* writes out to fout the queries to recreate a user-defined base type
*/
static void
! dumpBaseType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpBaseType(Archive *fout, TypeInfo *ty
*** 8671,8677 ****
qtypname);
/* We might already have a shell type, but setting pg_type_oid is harmless */
! if (binary_upgrade)
binary_upgrade_set_type_oids_by_type_oid(fout, q,
tyinfo->dobj.catId.oid);
--- 8638,8644 ----
qtypname);
/* We might already have a shell type, but setting pg_type_oid is harmless */
! if (dopt->binary_upgrade)
binary_upgrade_set_type_oids_by_type_oid(fout, q,
tyinfo->dobj.catId.oid);
*************** dumpBaseType(Archive *fout, TypeInfo *ty
*** 8769,8775 ****
appendPQExpBuffer(labelq, "TYPE %s", qtypname);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
--- 8736,8742 ----
appendPQExpBuffer(labelq, "TYPE %s", qtypname);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
*************** dumpBaseType(Archive *fout, TypeInfo *ty
*** 8783,8796 ****
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8750,8763 ----
NULL, NULL);
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpBaseType(Archive *fout, TypeInfo *ty
*** 8807,8813 ****
* writes out to fout the queries to recreate a user-defined domain
*/
static void
! dumpDomain(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 8774,8780 ----
* writes out to fout the queries to recreate a user-defined domain
*/
static void
! dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpDomain(Archive *fout, TypeInfo *tyin
*** 8867,8873 ****
typdefault = NULL;
typcollation = atooid(PQgetvalue(res, 0, PQfnumber(res, "typcollation")));
! if (binary_upgrade)
binary_upgrade_set_type_oids_by_type_oid(fout, q,
tyinfo->dobj.catId.oid);
--- 8834,8840 ----
typdefault = NULL;
typcollation = atooid(PQgetvalue(res, 0, PQfnumber(res, "typcollation")));
! if (dopt->binary_upgrade)
binary_upgrade_set_type_oids_by_type_oid(fout, q,
tyinfo->dobj.catId.oid);
*************** dumpDomain(Archive *fout, TypeInfo *tyin
*** 8931,8937 ****
appendPQExpBuffer(labelq, "DOMAIN %s", qtypname);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
--- 8898,8904 ----
appendPQExpBuffer(labelq, "DOMAIN %s", qtypname);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
*************** dumpDomain(Archive *fout, TypeInfo *tyin
*** 8945,8958 ****
NULL, NULL);
/* Dump Domain Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 8912,8925 ----
NULL, NULL);
/* Dump Domain Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpDomain(Archive *fout, TypeInfo *tyin
*** 8969,8975 ****
* composite type
*/
static void
! dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer dropped = createPQExpBuffer();
--- 8936,8942 ----
* composite type
*/
static void
! dumpCompositeType(Archive *fout, DumpOptions* dopt, TypeInfo *tyinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer dropped = createPQExpBuffer();
*************** dumpCompositeType(Archive *fout, TypeInf
*** 9046,9052 ****
i_attcollation = PQfnumber(res, "attcollation");
i_typrelid = PQfnumber(res, "typrelid");
! if (binary_upgrade)
{
Oid typrelid = atooid(PQgetvalue(res, 0, i_typrelid));
--- 9013,9019 ----
i_attcollation = PQfnumber(res, "attcollation");
i_typrelid = PQfnumber(res, "typrelid");
! if (dopt->binary_upgrade)
{
Oid typrelid = atooid(PQgetvalue(res, 0, i_typrelid));
*************** dumpCompositeType(Archive *fout, TypeInf
*** 9077,9083 ****
attisdropped = (PQgetvalue(res, i, i_attisdropped)[0] == 't');
attcollation = atooid(PQgetvalue(res, i, i_attcollation));
! if (attisdropped && !binary_upgrade)
continue;
/* Format properly if not first attr */
--- 9044,9050 ----
attisdropped = (PQgetvalue(res, i, i_attisdropped)[0] == 't');
attcollation = atooid(PQgetvalue(res, i, i_attcollation));
! if (attisdropped && !dopt->binary_upgrade)
continue;
/* Format properly if not first attr */
*************** dumpCompositeType(Archive *fout, TypeInf
*** 9145,9151 ****
appendPQExpBuffer(labelq, "TYPE %s", qtypname);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
--- 9112,9118 ----
appendPQExpBuffer(labelq, "TYPE %s", qtypname);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tyinfo->dobj, labelq->data);
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
*************** dumpCompositeType(Archive *fout, TypeInf
*** 9160,9173 ****
/* Dump Type Comments and Security Labels */
! dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
--- 9127,9140 ----
/* Dump Type Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
! dumpACL(fout, dopt, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
*************** dumpCompositeTypeColComments(Archive *fo
*** 9298,9309 ****
* We dump a shell definition in advance of the I/O functions for the type.
*/
static void
! dumpShellType(Archive *fout, ShellTypeInfo *stinfo)
{
PQExpBuffer q;
/* Skip if not to be dumped */
! if (!stinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 9265,9276 ----
* We dump a shell definition in advance of the I/O functions for the type.
*/
static void
! dumpShellType(Archive *fout, DumpOptions *dopt, ShellTypeInfo *stinfo)
{
PQExpBuffer q;
/* Skip if not to be dumped */
! if (!stinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpShellType(Archive *fout, ShellTypeIn
*** 9317,9323 ****
* after it's filled in, otherwise the backend complains.
*/
! if (binary_upgrade)
binary_upgrade_set_type_oids_by_type_oid(fout, q,
stinfo->baseType->dobj.catId.oid);
--- 9284,9290 ----
* after it's filled in, otherwise the backend complains.
*/
! if (dopt->binary_upgrade)
binary_upgrade_set_type_oids_by_type_oid(fout, q,
stinfo->baseType->dobj.catId.oid);
*************** dumpShellType(Archive *fout, ShellTypeIn
*** 9353,9364 ****
* That case isn't checked here either.
*/
static bool
! shouldDumpProcLangs(void)
{
! if (!include_everything)
return false;
/* And they're schema not data */
! if (dataOnly)
return false;
return true;
}
--- 9320,9331 ----
* That case isn't checked here either.
*/
static bool
! shouldDumpProcLangs(DumpOptions *dopt)
{
! if (!dopt->include_everything)
return false;
/* And they're schema not data */
! if (dopt->dataOnly)
return false;
return true;
}
*************** shouldDumpProcLangs(void)
*** 9369,9375 ****
* procedural language
*/
static void
! dumpProcLang(Archive *fout, ProcLangInfo *plang)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
--- 9336,9342 ----
* procedural language
*/
static void
! dumpProcLang(Archive *fout, DumpOptions* dopt, ProcLangInfo *plang)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
*************** dumpProcLang(Archive *fout, ProcLangInfo
*** 9382,9388 ****
FuncInfo *validatorInfo = NULL;
/* Skip if not to be dumped */
! if (!plang->dobj.dump || dataOnly)
return;
/*
--- 9349,9355 ----
FuncInfo *validatorInfo = NULL;
/* Skip if not to be dumped */
! if (!plang->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpProcLang(Archive *fout, ProcLangInfo
*** 9428,9434 ****
if (!plang->dobj.ext_member)
{
! if (!useParams && !shouldDumpProcLangs())
return;
}
--- 9395,9401 ----
if (!plang->dobj.ext_member)
{
! if (!useParams && !shouldDumpProcLangs(dopt))
return;
}
*************** dumpProcLang(Archive *fout, ProcLangInfo
*** 9495,9501 ****
appendPQExpBuffer(labelq, "LANGUAGE %s", qlanname);
! if (binary_upgrade)
binary_upgrade_extension_member(defqry, &plang->dobj, labelq->data);
ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId,
--- 9462,9468 ----
appendPQExpBuffer(labelq, "LANGUAGE %s", qlanname);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(defqry, &plang->dobj, labelq->data);
ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId,
*************** dumpProcLang(Archive *fout, ProcLangInfo
*** 9507,9521 ****
NULL, NULL);
/* Dump Proc Lang Comments and Security Labels */
! dumpComment(fout, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
if (plang->lanpltrusted)
! dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
qlanname, NULL, plang->dobj.name,
lanschema,
plang->lanowner, plang->lanacl);
--- 9474,9488 ----
NULL, NULL);
/* Dump Proc Lang Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
if (plang->lanpltrusted)
! dumpACL(fout, dopt, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
qlanname, NULL, plang->dobj.name,
lanschema,
plang->lanowner, plang->lanacl);
*************** format_function_signature(Archive *fout,
*** 9662,9668 ****
* dump out one function
*/
static void
! dumpFunc(Archive *fout, FuncInfo *finfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 9629,9635 ----
* dump out one function
*/
static void
! dumpFunc(Archive *fout, DumpOptions* dopt, FuncInfo *finfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 9701,9707 ****
int i;
/* Skip if not to be dumped */
! if (!finfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 9668,9674 ----
int i;
/* Skip if not to be dumped */
! if (!finfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 9894,9900 ****
* where we have bin, use dollar quoting if allowed and src
* contains quote or backslash; else use regular quoting.
*/
! if (disable_dollar_quoting ||
(strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL))
appendStringLiteralAH(asPart, prosrc, fout);
else
--- 9861,9867 ----
* where we have bin, use dollar quoting if allowed and src
* contains quote or backslash; else use regular quoting.
*/
! if (dopt->disable_dollar_quoting ||
(strchr(prosrc, '\'') == NULL && strchr(prosrc, '\\') == NULL))
appendStringLiteralAH(asPart, prosrc, fout);
else
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 9907,9913 ****
{
appendPQExpBufferStr(asPart, "AS ");
/* with no bin, dollar quote src unconditionally if allowed */
! if (disable_dollar_quoting)
appendStringLiteralAH(asPart, prosrc, fout);
else
appendStringLiteralDQ(asPart, prosrc, NULL);
--- 9874,9880 ----
{
appendPQExpBufferStr(asPart, "AS ");
/* with no bin, dollar quote src unconditionally if allowed */
! if (dopt->disable_dollar_quoting)
appendStringLiteralAH(asPart, prosrc, fout);
else
appendStringLiteralDQ(asPart, prosrc, NULL);
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 10083,10089 ****
appendPQExpBuffer(labelq, "FUNCTION %s", funcsig);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &finfo->dobj, labelq->data);
ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId,
--- 10050,10056 ----
appendPQExpBuffer(labelq, "FUNCTION %s", funcsig);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &finfo->dobj, labelq->data);
ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId,
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 10097,10110 ****
NULL, NULL);
/* Dump Function Comments and Security Labels */
! dumpComment(fout, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, NULL, funcsig_tag,
finfo->dobj.namespace->dobj.name,
finfo->rolname, finfo->proacl);
--- 10064,10077 ----
NULL, NULL);
/* Dump Function Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
! dumpACL(fout, dopt, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, NULL, funcsig_tag,
finfo->dobj.namespace->dobj.name,
finfo->rolname, finfo->proacl);
*************** dumpFunc(Archive *fout, FuncInfo *finfo)
*** 10135,10141 ****
* Dump a user-defined cast
*/
static void
! dumpCast(Archive *fout, CastInfo *cast)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
--- 10102,10108 ----
* Dump a user-defined cast
*/
static void
! dumpCast(Archive *fout, DumpOptions* dopt, CastInfo *cast)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
*************** dumpCast(Archive *fout, CastInfo *cast)
*** 10143,10149 ****
FuncInfo *funcInfo = NULL;
/* Skip if not to be dumped */
! if (!cast->dobj.dump || dataOnly)
return;
/* Cannot dump if we don't have the cast function's info */
--- 10110,10116 ----
FuncInfo *funcInfo = NULL;
/* Skip if not to be dumped */
! if (!cast->dobj.dump || dopt->dataOnly)
return;
/* Cannot dump if we don't have the cast function's info */
*************** dumpCast(Archive *fout, CastInfo *cast)
*** 10257,10263 ****
getFormattedTypeName(fout, cast->castsource, zeroAsNone),
getFormattedTypeName(fout, cast->casttarget, zeroAsNone));
! if (binary_upgrade)
binary_upgrade_extension_member(defqry, &cast->dobj, labelq->data);
ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId,
--- 10224,10230 ----
getFormattedTypeName(fout, cast->castsource, zeroAsNone),
getFormattedTypeName(fout, cast->casttarget, zeroAsNone));
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(defqry, &cast->dobj, labelq->data);
ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId,
*************** dumpCast(Archive *fout, CastInfo *cast)
*** 10269,10275 ****
NULL, NULL);
/* Dump Cast Comments */
! dumpComment(fout, labelq->data,
NULL, "",
cast->dobj.catId, 0, cast->dobj.dumpId);
--- 10236,10242 ----
NULL, NULL);
/* Dump Cast Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
cast->dobj.catId, 0, cast->dobj.dumpId);
*************** dumpCast(Archive *fout, CastInfo *cast)
*** 10283,10289 ****
* write out a single operator definition
*/
static void
! dumpOpr(Archive *fout, OprInfo *oprinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 10250,10256 ----
* write out a single operator definition
*/
static void
! dumpOpr(Archive *fout, DumpOptions* dopt, OprInfo *oprinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpOpr(Archive *fout, OprInfo *oprinfo)
*** 10317,10323 ****
char *oprref;
/* Skip if not to be dumped */
! if (!oprinfo->dobj.dump || dataOnly)
return;
/*
--- 10284,10290 ----
char *oprref;
/* Skip if not to be dumped */
! if (!oprinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpOpr(Archive *fout, OprInfo *oprinfo)
*** 10507,10513 ****
appendPQExpBuffer(labelq, "OPERATOR %s", oprid->data);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &oprinfo->dobj, labelq->data);
ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId,
--- 10474,10480 ----
appendPQExpBuffer(labelq, "OPERATOR %s", oprid->data);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &oprinfo->dobj, labelq->data);
ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId,
*************** dumpOpr(Archive *fout, OprInfo *oprinfo)
*** 10521,10527 ****
NULL, NULL);
/* Dump Operator Comments */
! dumpComment(fout, labelq->data,
oprinfo->dobj.namespace->dobj.name, oprinfo->rolname,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
--- 10488,10494 ----
NULL, NULL);
/* Dump Operator Comments */
! dumpComment(fout, dopt, labelq->data,
oprinfo->dobj.namespace->dobj.name, oprinfo->rolname,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
*************** convertTSFunction(Archive *fout, Oid fun
*** 10671,10677 ****
* write out a single operator class definition
*/
static void
! dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 10638,10644 ----
* write out a single operator class definition
*/
static void
! dumpOpclass(Archive *fout, DumpOptions* dopt, OpclassInfo *opcinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpOpclass(Archive *fout, OpclassInfo *
*** 10715,10721 ****
int i;
/* Skip if not to be dumped */
! if (!opcinfo->dobj.dump || dataOnly)
return;
/*
--- 10682,10688 ----
int i;
/* Skip if not to be dumped */
! if (!opcinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpOpclass(Archive *fout, OpclassInfo *
*** 11015,11021 ****
appendPQExpBuffer(labelq, " USING %s",
fmtId(amname));
! if (binary_upgrade)
binary_upgrade_extension_member(q, &opcinfo->dobj, labelq->data);
ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId,
--- 10982,10988 ----
appendPQExpBuffer(labelq, " USING %s",
fmtId(amname));
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &opcinfo->dobj, labelq->data);
ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId,
*************** dumpOpclass(Archive *fout, OpclassInfo *
*** 11029,11035 ****
NULL, NULL);
/* Dump Operator Class Comments */
! dumpComment(fout, labelq->data,
NULL, opcinfo->rolname,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
--- 10996,11002 ----
NULL, NULL);
/* Dump Operator Class Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, opcinfo->rolname,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
*************** dumpOpclass(Archive *fout, OpclassInfo *
*** 11048,11054 ****
* specific opclass within the opfamily.
*/
static void
! dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11015,11021 ----
* specific opclass within the opfamily.
*/
static void
! dumpOpfamily(Archive *fout, DumpOptions* dopt, OpfamilyInfo *opfinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpOpfamily(Archive *fout, OpfamilyInfo
*** 11082,11088 ****
int i;
/* Skip if not to be dumped */
! if (!opfinfo->dobj.dump || dataOnly)
return;
/*
--- 11049,11055 ----
int i;
/* Skip if not to be dumped */
! if (!opfinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpOpfamily(Archive *fout, OpfamilyInfo
*** 11328,11334 ****
appendPQExpBuffer(labelq, " USING %s",
fmtId(amname));
! if (binary_upgrade)
binary_upgrade_extension_member(q, &opfinfo->dobj, labelq->data);
ArchiveEntry(fout, opfinfo->dobj.catId, opfinfo->dobj.dumpId,
--- 11295,11301 ----
appendPQExpBuffer(labelq, " USING %s",
fmtId(amname));
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &opfinfo->dobj, labelq->data);
ArchiveEntry(fout, opfinfo->dobj.catId, opfinfo->dobj.dumpId,
*************** dumpOpfamily(Archive *fout, OpfamilyInfo
*** 11342,11348 ****
NULL, NULL);
/* Dump Operator Family Comments */
! dumpComment(fout, labelq->data,
NULL, opfinfo->rolname,
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
--- 11309,11315 ----
NULL, NULL);
/* Dump Operator Family Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, opfinfo->rolname,
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
*************** dumpOpfamily(Archive *fout, OpfamilyInfo
*** 11360,11366 ****
* write out a single collation definition
*/
static void
! dumpCollation(Archive *fout, CollInfo *collinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11327,11333 ----
* write out a single collation definition
*/
static void
! dumpCollation(Archive *fout, DumpOptions* dopt, CollInfo *collinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpCollation(Archive *fout, CollInfo *c
*** 11373,11379 ****
const char *collctype;
/* Skip if not to be dumped */
! if (!collinfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 11340,11346 ----
const char *collctype;
/* Skip if not to be dumped */
! if (!collinfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpCollation(Archive *fout, CollInfo *c
*** 11417,11423 ****
appendPQExpBuffer(labelq, "COLLATION %s", fmtId(collinfo->dobj.name));
! if (binary_upgrade)
binary_upgrade_extension_member(q, &collinfo->dobj, labelq->data);
ArchiveEntry(fout, collinfo->dobj.catId, collinfo->dobj.dumpId,
--- 11384,11390 ----
appendPQExpBuffer(labelq, "COLLATION %s", fmtId(collinfo->dobj.name));
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &collinfo->dobj, labelq->data);
ArchiveEntry(fout, collinfo->dobj.catId, collinfo->dobj.dumpId,
*************** dumpCollation(Archive *fout, CollInfo *c
*** 11431,11437 ****
NULL, NULL);
/* Dump Collation Comments */
! dumpComment(fout, labelq->data,
collinfo->dobj.namespace->dobj.name, collinfo->rolname,
collinfo->dobj.catId, 0, collinfo->dobj.dumpId);
--- 11398,11404 ----
NULL, NULL);
/* Dump Collation Comments */
! dumpComment(fout, dopt, labelq->data,
collinfo->dobj.namespace->dobj.name, collinfo->rolname,
collinfo->dobj.catId, 0, collinfo->dobj.dumpId);
*************** dumpCollation(Archive *fout, CollInfo *c
*** 11448,11454 ****
* write out a single conversion definition
*/
static void
! dumpConversion(Archive *fout, ConvInfo *convinfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11415,11421 ----
* write out a single conversion definition
*/
static void
! dumpConversion(Archive *fout, DumpOptions* dopt, ConvInfo *convinfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpConversion(Archive *fout, ConvInfo *
*** 11465,11471 ****
bool condefault;
/* Skip if not to be dumped */
! if (!convinfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 11432,11438 ----
bool condefault;
/* Skip if not to be dumped */
! if (!convinfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpConversion(Archive *fout, ConvInfo *
*** 11516,11522 ****
appendPQExpBuffer(labelq, "CONVERSION %s", fmtId(convinfo->dobj.name));
! if (binary_upgrade)
binary_upgrade_extension_member(q, &convinfo->dobj, labelq->data);
ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId,
--- 11483,11489 ----
appendPQExpBuffer(labelq, "CONVERSION %s", fmtId(convinfo->dobj.name));
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &convinfo->dobj, labelq->data);
ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId,
*************** dumpConversion(Archive *fout, ConvInfo *
*** 11530,11536 ****
NULL, NULL);
/* Dump Conversion Comments */
! dumpComment(fout, labelq->data,
convinfo->dobj.namespace->dobj.name, convinfo->rolname,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
--- 11497,11503 ----
NULL, NULL);
/* Dump Conversion Comments */
! dumpComment(fout, dopt, labelq->data,
convinfo->dobj.namespace->dobj.name, convinfo->rolname,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
*************** format_aggregate_signature(AggInfo *aggi
*** 11587,11593 ****
* write out a single aggregate definition
*/
static void
! dumpAgg(Archive *fout, AggInfo *agginfo)
{
PQExpBuffer query;
PQExpBuffer q;
--- 11554,11560 ----
* write out a single aggregate definition
*/
static void
! dumpAgg(Archive *fout, DumpOptions* dopt, AggInfo *agginfo)
{
PQExpBuffer query;
PQExpBuffer q;
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11633,11639 ****
bool convertok;
/* Skip if not to be dumped */
! if (!agginfo->aggfn.dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 11600,11606 ----
bool convertok;
/* Skip if not to be dumped */
! if (!agginfo->aggfn.dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11912,11918 ****
appendPQExpBuffer(labelq, "AGGREGATE %s", aggsig);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &agginfo->aggfn.dobj, labelq->data);
ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
--- 11879,11885 ----
appendPQExpBuffer(labelq, "AGGREGATE %s", aggsig);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &agginfo->aggfn.dobj, labelq->data);
ArchiveEntry(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11926,11935 ****
NULL, NULL);
/* Dump Aggregate Comments */
! dumpComment(fout, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
--- 11893,11902 ----
NULL, NULL);
/* Dump Aggregate Comments */
! dumpComment(fout, dopt, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11944,11950 ****
aggsig = format_function_signature(fout, &agginfo->aggfn, true);
aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false);
! dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
"FUNCTION",
aggsig, NULL, aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
--- 11911,11917 ----
aggsig = format_function_signature(fout, &agginfo->aggfn, true);
aggsig_tag = format_function_signature(fout, &agginfo->aggfn, false);
! dumpACL(fout, dopt, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
"FUNCTION",
aggsig, NULL, aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
*************** dumpAgg(Archive *fout, AggInfo *agginfo)
*** 11969,11982 ****
* write out a single text search parser
*/
static void
! dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!prsinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 11936,11949 ----
* write out a single text search parser
*/
static void
! dumpTSParser(Archive *fout, DumpOptions* dopt, TSParserInfo *prsinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!prsinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSParser(Archive *fout, TSParserInfo
*** 12012,12018 ****
appendPQExpBuffer(labelq, "TEXT SEARCH PARSER %s",
fmtId(prsinfo->dobj.name));
! if (binary_upgrade)
binary_upgrade_extension_member(q, &prsinfo->dobj, labelq->data);
ArchiveEntry(fout, prsinfo->dobj.catId, prsinfo->dobj.dumpId,
--- 11979,11985 ----
appendPQExpBuffer(labelq, "TEXT SEARCH PARSER %s",
fmtId(prsinfo->dobj.name));
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &prsinfo->dobj, labelq->data);
ArchiveEntry(fout, prsinfo->dobj.catId, prsinfo->dobj.dumpId,
*************** dumpTSParser(Archive *fout, TSParserInfo
*** 12026,12032 ****
NULL, NULL);
/* Dump Parser Comments */
! dumpComment(fout, labelq->data,
NULL, "",
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
--- 11993,11999 ----
NULL, NULL);
/* Dump Parser Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
*************** dumpTSParser(Archive *fout, TSParserInfo
*** 12040,12046 ****
* write out a single text search dictionary
*/
static void
! dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12007,12013 ----
* write out a single text search dictionary
*/
static void
! dumpTSDictionary(Archive *fout, DumpOptions* dopt, TSDictInfo *dictinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpTSDictionary(Archive *fout, TSDictIn
*** 12051,12057 ****
char *tmplname;
/* Skip if not to be dumped */
! if (!dictinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 12018,12024 ----
char *tmplname;
/* Skip if not to be dumped */
! if (!dictinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSDictionary(Archive *fout, TSDictIn
*** 12099,12105 ****
appendPQExpBuffer(labelq, "TEXT SEARCH DICTIONARY %s",
fmtId(dictinfo->dobj.name));
! if (binary_upgrade)
binary_upgrade_extension_member(q, &dictinfo->dobj, labelq->data);
ArchiveEntry(fout, dictinfo->dobj.catId, dictinfo->dobj.dumpId,
--- 12066,12072 ----
appendPQExpBuffer(labelq, "TEXT SEARCH DICTIONARY %s",
fmtId(dictinfo->dobj.name));
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &dictinfo->dobj, labelq->data);
ArchiveEntry(fout, dictinfo->dobj.catId, dictinfo->dobj.dumpId,
*************** dumpTSDictionary(Archive *fout, TSDictIn
*** 12113,12119 ****
NULL, NULL);
/* Dump Dictionary Comments */
! dumpComment(fout, labelq->data,
NULL, dictinfo->rolname,
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
--- 12080,12086 ----
NULL, NULL);
/* Dump Dictionary Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, dictinfo->rolname,
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
*************** dumpTSDictionary(Archive *fout, TSDictIn
*** 12128,12141 ****
* write out a single text search template
*/
static void
! dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!tmplinfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 12095,12108 ----
* write out a single text search template
*/
static void
! dumpTSTemplate(Archive *fout, DumpOptions* dopt, TSTemplateInfo *tmplinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!tmplinfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSTemplate(Archive *fout, TSTemplate
*** 12165,12171 ****
appendPQExpBuffer(labelq, "TEXT SEARCH TEMPLATE %s",
fmtId(tmplinfo->dobj.name));
! if (binary_upgrade)
binary_upgrade_extension_member(q, &tmplinfo->dobj, labelq->data);
ArchiveEntry(fout, tmplinfo->dobj.catId, tmplinfo->dobj.dumpId,
--- 12132,12138 ----
appendPQExpBuffer(labelq, "TEXT SEARCH TEMPLATE %s",
fmtId(tmplinfo->dobj.name));
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tmplinfo->dobj, labelq->data);
ArchiveEntry(fout, tmplinfo->dobj.catId, tmplinfo->dobj.dumpId,
*************** dumpTSTemplate(Archive *fout, TSTemplate
*** 12179,12185 ****
NULL, NULL);
/* Dump Template Comments */
! dumpComment(fout, labelq->data,
NULL, "",
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
--- 12146,12152 ----
NULL, NULL);
/* Dump Template Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, "",
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
*************** dumpTSTemplate(Archive *fout, TSTemplate
*** 12193,12199 ****
* write out a single text search configuration
*/
static void
! dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12160,12166 ----
* write out a single text search configuration
*/
static void
! dumpTSConfig(Archive *fout, DumpOptions* dopt, TSConfigInfo *cfginfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpTSConfig(Archive *fout, TSConfigInfo
*** 12208,12214 ****
int i_dictname;
/* Skip if not to be dumped */
! if (!cfginfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 12175,12181 ----
int i_dictname;
/* Skip if not to be dumped */
! if (!cfginfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpTSConfig(Archive *fout, TSConfigInfo
*** 12293,12299 ****
appendPQExpBuffer(labelq, "TEXT SEARCH CONFIGURATION %s",
fmtId(cfginfo->dobj.name));
! if (binary_upgrade)
binary_upgrade_extension_member(q, &cfginfo->dobj, labelq->data);
ArchiveEntry(fout, cfginfo->dobj.catId, cfginfo->dobj.dumpId,
--- 12260,12266 ----
appendPQExpBuffer(labelq, "TEXT SEARCH CONFIGURATION %s",
fmtId(cfginfo->dobj.name));
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &cfginfo->dobj, labelq->data);
ArchiveEntry(fout, cfginfo->dobj.catId, cfginfo->dobj.dumpId,
*************** dumpTSConfig(Archive *fout, TSConfigInfo
*** 12307,12313 ****
NULL, NULL);
/* Dump Configuration Comments */
! dumpComment(fout, labelq->data,
NULL, cfginfo->rolname,
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
--- 12274,12280 ----
NULL, NULL);
/* Dump Configuration Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, cfginfo->rolname,
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
*************** dumpTSConfig(Archive *fout, TSConfigInfo
*** 12322,12328 ****
* write out a single foreign-data wrapper definition
*/
static void
! dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12289,12295 ----
* write out a single foreign-data wrapper definition
*/
static void
! dumpForeignDataWrapper(Archive *fout, DumpOptions* dopt, FdwInfo *fdwinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12330,12336 ****
char *qfdwname;
/* Skip if not to be dumped */
! if (!fdwinfo->dobj.dump || dataOnly)
return;
/*
--- 12297,12303 ----
char *qfdwname;
/* Skip if not to be dumped */
! if (!fdwinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12338,12344 ****
* field. Otherwise omit them if we are only dumping some specific object.
*/
if (!fdwinfo->dobj.ext_member)
! if (!include_everything)
return;
q = createPQExpBuffer();
--- 12305,12311 ----
* field. Otherwise omit them if we are only dumping some specific object.
*/
if (!fdwinfo->dobj.ext_member)
! if (!dopt->include_everything)
return;
q = createPQExpBuffer();
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12367,12373 ****
appendPQExpBuffer(labelq, "FOREIGN DATA WRAPPER %s",
qfdwname);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &fdwinfo->dobj, labelq->data);
ArchiveEntry(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
--- 12334,12340 ----
appendPQExpBuffer(labelq, "FOREIGN DATA WRAPPER %s",
qfdwname);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &fdwinfo->dobj, labelq->data);
ArchiveEntry(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12381,12394 ****
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
"FOREIGN DATA WRAPPER",
qfdwname, NULL, fdwinfo->dobj.name,
NULL, fdwinfo->rolname,
fdwinfo->fdwacl);
/* Dump Foreign Data Wrapper Comments */
! dumpComment(fout, labelq->data,
NULL, fdwinfo->rolname,
fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId);
--- 12348,12361 ----
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, dopt, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
"FOREIGN DATA WRAPPER",
qfdwname, NULL, fdwinfo->dobj.name,
NULL, fdwinfo->rolname,
fdwinfo->fdwacl);
/* Dump Foreign Data Wrapper Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, fdwinfo->rolname,
fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId);
*************** dumpForeignDataWrapper(Archive *fout, Fd
*** 12404,12410 ****
* write out a foreign server definition
*/
static void
! dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
--- 12371,12377 ----
* write out a foreign server definition
*/
static void
! dumpForeignServer(Archive *fout, DumpOptions* dopt, ForeignServerInfo *srvinfo)
{
PQExpBuffer q;
PQExpBuffer delq;
*************** dumpForeignServer(Archive *fout, Foreign
*** 12415,12421 ****
char *fdwname;
/* Skip if not to be dumped */
! if (!srvinfo->dobj.dump || dataOnly || !include_everything)
return;
q = createPQExpBuffer();
--- 12382,12388 ----
char *fdwname;
/* Skip if not to be dumped */
! if (!srvinfo->dobj.dump || dopt->dataOnly || !dopt->include_everything)
return;
q = createPQExpBuffer();
*************** dumpForeignServer(Archive *fout, Foreign
*** 12459,12465 ****
appendPQExpBuffer(labelq, "SERVER %s", qsrvname);
! if (binary_upgrade)
binary_upgrade_extension_member(q, &srvinfo->dobj, labelq->data);
ArchiveEntry(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
--- 12426,12432 ----
appendPQExpBuffer(labelq, "SERVER %s", qsrvname);
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &srvinfo->dobj, labelq->data);
ArchiveEntry(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
*************** dumpForeignServer(Archive *fout, Foreign
*** 12473,12479 ****
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
"FOREIGN SERVER",
qsrvname, NULL, srvinfo->dobj.name,
NULL, srvinfo->rolname,
--- 12440,12446 ----
NULL, NULL);
/* Handle the ACL */
! dumpACL(fout, dopt, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
"FOREIGN SERVER",
qsrvname, NULL, srvinfo->dobj.name,
NULL, srvinfo->rolname,
*************** dumpForeignServer(Archive *fout, Foreign
*** 12486,12492 ****
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
/* Dump Foreign Server Comments */
! dumpComment(fout, labelq->data,
NULL, srvinfo->rolname,
srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId);
--- 12453,12459 ----
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
/* Dump Foreign Server Comments */
! dumpComment(fout, dopt, labelq->data,
NULL, srvinfo->rolname,
srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId);
*************** dumpUserMappings(Archive *fout,
*** 12602,12615 ****
* Write out default privileges information
*/
static void
! dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo)
{
PQExpBuffer q;
PQExpBuffer tag;
const char *type;
/* Skip if not to be dumped */
! if (!daclinfo->dobj.dump || dataOnly || aclsSkip)
return;
q = createPQExpBuffer();
--- 12569,12582 ----
* Write out default privileges information
*/
static void
! dumpDefaultACL(Archive *fout, DumpOptions *dopt, DefaultACLInfo *daclinfo)
{
PQExpBuffer q;
PQExpBuffer tag;
const char *type;
/* Skip if not to be dumped */
! if (!daclinfo->dobj.dump || dopt->dataOnly || dopt->aclsSkip)
return;
q = createPQExpBuffer();
*************** dumpDefaultACL(Archive *fout, DefaultACL
*** 12682,12688 ****
*----------
*/
static void
! dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls)
--- 12649,12655 ----
*----------
*/
static void
! dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId,
const char *type, const char *name, const char *subname,
const char *tag, const char *nspname, const char *owner,
const char *acls)
*************** dumpACL(Archive *fout, CatalogId objCatI
*** 12690,12700 ****
PQExpBuffer sql;
/* Do nothing if ACL dump is not enabled */
! if (aclsSkip)
return;
/* --data-only skips ACLs *except* BLOB ACLs */
! if (dataOnly && strcmp(type, "LARGE OBJECT") != 0)
return;
sql = createPQExpBuffer();
--- 12657,12667 ----
PQExpBuffer sql;
/* Do nothing if ACL dump is not enabled */
! if (dopt->aclsSkip)
return;
/* --data-only skips ACLs *except* BLOB ACLs */
! if (dopt->dataOnly && strcmp(type, "LARGE OBJECT") != 0)
return;
sql = createPQExpBuffer();
*************** dumpACL(Archive *fout, CatalogId objCatI
*** 12737,12743 ****
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpSecLabel(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
--- 12704,12710 ----
* calling ArchiveEntry() for the specified object.
*/
static void
! dumpSecLabel(Archive *fout, DumpOptions* dopt, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
*************** dumpSecLabel(Archive *fout, const char *
*** 12747,12764 ****
PQExpBuffer query;
/* do nothing, if --no-security-labels is supplied */
! if (no_security_labels)
return;
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dataOnly)
return;
}
else
{
! if (schemaOnly)
return;
}
--- 12714,12731 ----
PQExpBuffer query;
/* do nothing, if --no-security-labels is supplied */
! if (dopt->no_security_labels)
return;
/* Comments are schema not data ... except blob comments are data */
if (strncmp(target, "LARGE OBJECT ", 13) != 0)
{
! if (dopt->dataOnly)
return;
}
else
{
! if (dopt->schemaOnly)
return;
}
*************** dumpSecLabel(Archive *fout, const char *
*** 12801,12807 ****
* and its columns.
*/
static void
! dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename)
{
SecLabelItem *labels;
int nlabels;
--- 12768,12774 ----
* and its columns.
*/
static void
! dumpTableSecLabel(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, const char *reltypename)
{
SecLabelItem *labels;
int nlabels;
*************** dumpTableSecLabel(Archive *fout, TableIn
*** 12810,12820 ****
PQExpBuffer target;
/* do nothing, if --no-security-labels is supplied */
! if (no_security_labels)
return;
/* SecLabel are SCHEMA not data */
! if (dataOnly)
return;
/* Search for comments associated with relation, using table */
--- 12777,12787 ----
PQExpBuffer target;
/* do nothing, if --no-security-labels is supplied */
! if (dopt->no_security_labels)
return;
/* SecLabel are SCHEMA not data */
! if (dopt->dataOnly)
return;
/* Search for comments associated with relation, using table */
*************** collectSecLabels(Archive *fout, SecLabel
*** 13022,13041 ****
* write out to fout the declarations (not data) of a user-defined table
*/
static void
! dumpTable(Archive *fout, TableInfo *tbinfo)
{
! if (tbinfo->dobj.dump && !dataOnly)
{
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
! dumpSequence(fout, tbinfo);
else
! dumpTableSchema(fout, tbinfo);
/* Handle the ACL here */
namecopy = pg_strdup(fmtId(tbinfo->dobj.name));
! dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
(tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" :
"TABLE",
namecopy, NULL, tbinfo->dobj.name,
--- 12989,13008 ----
* write out to fout the declarations (not data) of a user-defined table
*/
static void
! dumpTable(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
{
! if (tbinfo->dobj.dump && !dopt->dataOnly)
{
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
! dumpSequence(fout, dopt, tbinfo);
else
! dumpTableSchema(fout, dopt, tbinfo);
/* Handle the ACL here */
namecopy = pg_strdup(fmtId(tbinfo->dobj.name));
! dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
(tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" :
"TABLE",
namecopy, NULL, tbinfo->dobj.name,
*************** dumpTable(Archive *fout, TableInfo *tbin
*** 13070,13076 ****
attnamecopy = pg_strdup(fmtId(attname));
acltag = psprintf("%s.%s", tbinfo->dobj.name, attname);
/* Column's GRANT type is always TABLE */
! dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
namecopy, attnamecopy, acltag,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
attacl);
--- 13037,13043 ----
attnamecopy = pg_strdup(fmtId(attname));
acltag = psprintf("%s.%s", tbinfo->dobj.name, attname);
/* Column's GRANT type is always TABLE */
! dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
namecopy, attnamecopy, acltag,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
attacl);
*************** createViewAsClause(Archive *fout, TableI
*** 13147,13153 ****
* write the declaration (not data) of one user-defined table or view
*/
static void
! dumpTableSchema(Archive *fout, TableInfo *tbinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
--- 13114,13120 ----
* write the declaration (not data) of one user-defined table or view
*/
static void
! dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
{
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13165,13171 ****
/* Make sure we are in proper schema */
selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name);
! if (binary_upgrade)
binary_upgrade_set_type_oids_by_rel_oid(fout, q,
tbinfo->dobj.catId.oid);
--- 13132,13138 ----
/* Make sure we are in proper schema */
selectSourceSchema(fout, tbinfo->dobj.namespace->dobj.name);
! if (dopt->binary_upgrade)
binary_upgrade_set_type_oids_by_rel_oid(fout, q,
tbinfo->dobj.catId.oid);
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13185,13191 ****
appendPQExpBuffer(delq, "%s;\n",
fmtId(tbinfo->dobj.name));
! if (binary_upgrade)
binary_upgrade_set_pg_class_oids(fout, q,
tbinfo->dobj.catId.oid, false);
--- 13152,13158 ----
appendPQExpBuffer(delq, "%s;\n",
fmtId(tbinfo->dobj.name));
! if (dopt->binary_upgrade)
binary_upgrade_set_pg_class_oids(fout, q,
tbinfo->dobj.catId.oid, false);
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13265,13271 ****
appendPQExpBuffer(labelq, "%s %s", reltypename,
fmtId(tbinfo->dobj.name));
! if (binary_upgrade)
binary_upgrade_set_pg_class_oids(fout, q,
tbinfo->dobj.catId.oid, false);
--- 13232,13238 ----
appendPQExpBuffer(labelq, "%s %s", reltypename,
fmtId(tbinfo->dobj.name));
! if (dopt->binary_upgrade)
binary_upgrade_set_pg_class_oids(fout, q,
tbinfo->dobj.catId.oid, false);
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13279,13285 ****
* Attach to type, if reloftype; except in case of a binary upgrade,
* we dump the table normally and attach it to the type afterward.
*/
! if (tbinfo->reloftype && !binary_upgrade)
appendPQExpBuffer(q, " OF %s", tbinfo->reloftype);
if (tbinfo->relkind != RELKIND_MATVIEW)
--- 13246,13252 ----
* Attach to type, if reloftype; except in case of a binary upgrade,
* we dump the table normally and attach it to the type afterward.
*/
! if (tbinfo->reloftype && !dopt->binary_upgrade)
appendPQExpBuffer(q, " OF %s", tbinfo->reloftype);
if (tbinfo->relkind != RELKIND_MATVIEW)
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13294,13300 ****
* columns, and then fix up the dropped and nonlocal cases
* below.
*/
! if (shouldPrintColumn(tbinfo, j))
{
/*
* Default value --- suppress if to be printed separately.
--- 13261,13267 ----
* columns, and then fix up the dropped and nonlocal cases
* below.
*/
! if (shouldPrintColumn(dopt, tbinfo, j))
{
/*
* Default value --- suppress if to be printed separately.
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13308,13318 ****
*/
bool has_notnull = (tbinfo->notnull[j] &&
(!tbinfo->inhNotNull[j] ||
! binary_upgrade));
/* Skip column if fully defined by reloftype */
if (tbinfo->reloftype &&
! !has_default && !has_notnull && !binary_upgrade)
continue;
/* Format properly if not first attr */
--- 13275,13285 ----
*/
bool has_notnull = (tbinfo->notnull[j] &&
(!tbinfo->inhNotNull[j] ||
! dopt->binary_upgrade));
/* Skip column if fully defined by reloftype */
if (tbinfo->reloftype &&
! !has_default && !has_notnull && !dopt->binary_upgrade)
continue;
/* Format properly if not first attr */
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13340,13346 ****
}
/* Attribute type */
! if (tbinfo->reloftype && !binary_upgrade)
{
appendPQExpBufferStr(q, " WITH OPTIONS");
}
--- 13307,13313 ----
}
/* Attribute type */
! if (tbinfo->reloftype && !dopt->binary_upgrade)
{
appendPQExpBufferStr(q, " WITH OPTIONS");
}
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13405,13411 ****
if (actual_atts)
appendPQExpBufferStr(q, "\n)");
! else if (!(tbinfo->reloftype && !binary_upgrade))
{
/*
* We must have a parenthesized attribute list, even though
--- 13372,13378 ----
if (actual_atts)
appendPQExpBufferStr(q, "\n)");
! else if (!(tbinfo->reloftype && !dopt->binary_upgrade))
{
/*
* We must have a parenthesized attribute list, even though
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13414,13420 ****
appendPQExpBufferStr(q, " (\n)");
}
! if (numParents > 0 && !binary_upgrade)
{
appendPQExpBufferStr(q, "\nINHERITS (");
for (k = 0; k < numParents; k++)
--- 13381,13387 ----
appendPQExpBufferStr(q, " (\n)");
}
! if (numParents > 0 && !dopt->binary_upgrade)
{
appendPQExpBufferStr(q, "\nINHERITS (");
for (k = 0; k < numParents; k++)
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13487,13493 ****
* attislocal correctly, plus fix up any inherited CHECK constraints.
* Analogously, we set up typed tables using ALTER TABLE / OF here.
*/
! if (binary_upgrade && (tbinfo->relkind == RELKIND_RELATION ||
tbinfo->relkind == RELKIND_FOREIGN_TABLE))
{
for (j = 0; j < tbinfo->numatts; j++)
--- 13454,13460 ----
* attislocal correctly, plus fix up any inherited CHECK constraints.
* Analogously, we set up typed tables using ALTER TABLE / OF here.
*/
! if (dopt->binary_upgrade && (tbinfo->relkind == RELKIND_RELATION ||
tbinfo->relkind == RELKIND_FOREIGN_TABLE))
{
for (j = 0; j < tbinfo->numatts; j++)
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13603,13609 ****
* REFRESH MATERIALIZED VIEW since it's possible that some underlying
* matview is not populated even though this matview is.
*/
! if (binary_upgrade && tbinfo->relkind == RELKIND_MATVIEW &&
tbinfo->relispopulated)
{
appendPQExpBufferStr(q, "\n-- For binary upgrade, mark materialized view as populated\n");
--- 13570,13576 ----
* REFRESH MATERIALIZED VIEW since it's possible that some underlying
* matview is not populated even though this matview is.
*/
! if (dopt->binary_upgrade && tbinfo->relkind == RELKIND_MATVIEW &&
tbinfo->relispopulated)
{
appendPQExpBufferStr(q, "\n-- For binary upgrade, mark materialized view as populated\n");
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13629,13635 ****
* it is NOT NULL and did not inherit that property from a parent,
* we have to mark it separately.
*/
! if (!shouldPrintColumn(tbinfo, j) &&
tbinfo->notnull[j] && !tbinfo->inhNotNull[j])
{
appendPQExpBuffer(q, "ALTER TABLE ONLY %s ",
--- 13596,13602 ----
* it is NOT NULL and did not inherit that property from a parent,
* we have to mark it separately.
*/
! if (!shouldPrintColumn(dopt, tbinfo, j) &&
tbinfo->notnull[j] && !tbinfo->inhNotNull[j])
{
appendPQExpBuffer(q, "ALTER TABLE ONLY %s ",
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13743,13749 ****
}
}
! if (binary_upgrade)
binary_upgrade_extension_member(q, &tbinfo->dobj, labelq->data);
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
--- 13710,13716 ----
}
}
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(q, &tbinfo->dobj, labelq->data);
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13760,13769 ****
/* Dump Table Comments */
! dumpTableComment(fout, tbinfo, reltypename);
/* Dump Table Security Labels */
! dumpTableSecLabel(fout, tbinfo, reltypename);
/* Dump comments on inlined table constraints */
for (j = 0; j < tbinfo->ncheck; j++)
--- 13727,13736 ----
/* Dump Table Comments */
! dumpTableComment(fout, dopt, tbinfo, reltypename);
/* Dump Table Security Labels */
! dumpTableSecLabel(fout, dopt, tbinfo, reltypename);
/* Dump comments on inlined table constraints */
for (j = 0; j < tbinfo->ncheck; j++)
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13773,13779 ****
if (constr->separate || !constr->conislocal)
continue;
! dumpTableConstraintComment(fout, constr);
}
destroyPQExpBuffer(q);
--- 13740,13746 ----
if (constr->separate || !constr->conislocal)
continue;
! dumpTableConstraintComment(fout, dopt, constr);
}
destroyPQExpBuffer(q);
*************** dumpTableSchema(Archive *fout, TableInfo
*** 13785,13791 ****
* dumpAttrDef --- dump an attribute's default-value declaration
*/
static void
! dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
{
TableInfo *tbinfo = adinfo->adtable;
int adnum = adinfo->adnum;
--- 13752,13758 ----
* dumpAttrDef --- dump an attribute's default-value declaration
*/
static void
! dumpAttrDef(Archive *fout, DumpOptions *dopt, AttrDefInfo *adinfo)
{
TableInfo *tbinfo = adinfo->adtable;
int adnum = adinfo->adnum;
*************** dumpAttrDef(Archive *fout, AttrDefInfo *
*** 13793,13799 ****
PQExpBuffer delq;
/* Skip if table definition not to be dumped */
! if (!tbinfo->dobj.dump || dataOnly)
return;
/* Skip if not "separate"; it was dumped in the table's definition */
--- 13760,13766 ----
PQExpBuffer delq;
/* Skip if table definition not to be dumped */
! if (!tbinfo->dobj.dump || dopt->dataOnly)
return;
/* Skip if not "separate"; it was dumped in the table's definition */
*************** getAttrName(int attrnum, TableInfo *tblI
*** 13872,13878 ****
* write out to fout a user-defined index
*/
static void
! dumpIndex(Archive *fout, IndxInfo *indxinfo)
{
TableInfo *tbinfo = indxinfo->indextable;
bool is_constraint = (indxinfo->indexconstraint != 0);
--- 13839,13845 ----
* write out to fout a user-defined index
*/
static void
! dumpIndex(Archive *fout, DumpOptions* dopt, IndxInfo *indxinfo)
{
TableInfo *tbinfo = indxinfo->indextable;
bool is_constraint = (indxinfo->indexconstraint != 0);
*************** dumpIndex(Archive *fout, IndxInfo *indxi
*** 13880,13886 ****
PQExpBuffer delq;
PQExpBuffer labelq;
! if (dataOnly)
return;
q = createPQExpBuffer();
--- 13847,13853 ----
PQExpBuffer delq;
PQExpBuffer labelq;
! if (dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpIndex(Archive *fout, IndxInfo *indxi
*** 13899,13905 ****
*/
if (!is_constraint)
{
! if (binary_upgrade)
binary_upgrade_set_pg_class_oids(fout, q,
indxinfo->dobj.catId.oid, true);
--- 13866,13872 ----
*/
if (!is_constraint)
{
! if (dopt->binary_upgrade)
binary_upgrade_set_pg_class_oids(fout, q,
indxinfo->dobj.catId.oid, true);
*************** dumpIndex(Archive *fout, IndxInfo *indxi
*** 13945,13951 ****
}
/* Dump Index Comments */
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
indxinfo->dobj.catId, 0,
--- 13912,13918 ----
}
/* Dump Index Comments */
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
indxinfo->dobj.catId, 0,
*************** dumpIndex(Archive *fout, IndxInfo *indxi
*** 13962,13975 ****
* write out to fout a user-defined constraint
*/
static void
! dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer q;
PQExpBuffer delq;
/* Skip if not to be dumped */
! if (!coninfo->dobj.dump || dataOnly)
return;
q = createPQExpBuffer();
--- 13929,13942 ----
* write out to fout a user-defined constraint
*/
static void
! dumpConstraint(Archive *fout, DumpOptions *dopt, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer q;
PQExpBuffer delq;
/* Skip if not to be dumped */
! if (!coninfo->dobj.dump || dopt->dataOnly)
return;
q = createPQExpBuffer();
*************** dumpConstraint(Archive *fout, Constraint
*** 13989,13995 ****
exit_horribly(NULL, "missing index for constraint \"%s\"\n",
coninfo->dobj.name);
! if (binary_upgrade)
binary_upgrade_set_pg_class_oids(fout, q,
indxinfo->dobj.catId.oid, true);
--- 13956,13962 ----
exit_horribly(NULL, "missing index for constraint \"%s\"\n",
coninfo->dobj.name);
! if (dopt->binary_upgrade)
binary_upgrade_set_pg_class_oids(fout, q,
indxinfo->dobj.catId.oid, true);
*************** dumpConstraint(Archive *fout, Constraint
*** 14179,14185 ****
/* Dump Constraint Comments --- only works for table constraints */
if (tbinfo && coninfo->separate)
! dumpTableConstraintComment(fout, coninfo);
destroyPQExpBuffer(q);
destroyPQExpBuffer(delq);
--- 14146,14152 ----
/* Dump Constraint Comments --- only works for table constraints */
if (tbinfo && coninfo->separate)
! dumpTableConstraintComment(fout, dopt, coninfo);
destroyPQExpBuffer(q);
destroyPQExpBuffer(delq);
*************** dumpConstraint(Archive *fout, Constraint
*** 14193,14199 ****
* or as a separate ALTER command.
*/
static void
! dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer labelq = createPQExpBuffer();
--- 14160,14166 ----
* or as a separate ALTER command.
*/
static void
! dumpTableConstraintComment(Archive *fout, DumpOptions* dopt, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer labelq = createPQExpBuffer();
*************** dumpTableConstraintComment(Archive *fout
*** 14202,14208 ****
fmtId(coninfo->dobj.name));
appendPQExpBuffer(labelq, "ON %s",
fmtId(tbinfo->dobj.name));
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
coninfo->dobj.catId, 0,
--- 14169,14175 ----
fmtId(coninfo->dobj.name));
appendPQExpBuffer(labelq, "ON %s",
fmtId(tbinfo->dobj.name));
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
coninfo->dobj.catId, 0,
*************** findLastBuiltinOid_V70(Archive *fout)
*** 14262,14268 ****
* write the declaration (not data) of one user-defined sequence
*/
static void
! dumpSequence(Archive *fout, TableInfo *tbinfo)
{
PGresult *res;
char *startv,
--- 14229,14235 ----
* write the declaration (not data) of one user-defined sequence
*/
static void
! dumpSequence(Archive *fout, DumpOptions* dopt, TableInfo *tbinfo)
{
PGresult *res;
char *startv,
*************** dumpSequence(Archive *fout, TableInfo *t
*** 14358,14364 ****
resetPQExpBuffer(query);
! if (binary_upgrade)
{
binary_upgrade_set_pg_class_oids(fout, query,
tbinfo->dobj.catId.oid, false);
--- 14325,14331 ----
resetPQExpBuffer(query);
! if (dopt->binary_upgrade)
{
binary_upgrade_set_pg_class_oids(fout, query,
tbinfo->dobj.catId.oid, false);
*************** dumpSequence(Archive *fout, TableInfo *t
*** 14395,14401 ****
/* binary_upgrade: no need to clear TOAST table oid */
! if (binary_upgrade)
binary_upgrade_extension_member(query, &tbinfo->dobj,
labelq->data);
--- 14362,14368 ----
/* binary_upgrade: no need to clear TOAST table oid */
! if (dopt->binary_upgrade)
binary_upgrade_extension_member(query, &tbinfo->dobj,
labelq->data);
*************** dumpSequence(Archive *fout, TableInfo *t
*** 14448,14457 ****
}
/* Dump Sequence Comments and Security Labels */
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
! dumpSecLabel(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
--- 14415,14424 ----
}
/* Dump Sequence Comments and Security Labels */
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
! dumpSecLabel(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
*************** dumpSequenceData(Archive *fout, TableDat
*** 14522,14528 ****
* write the declaration of one user-defined table trigger
*/
static void
! dumpTrigger(Archive *fout, TriggerInfo *tginfo)
{
TableInfo *tbinfo = tginfo->tgtable;
PQExpBuffer query;
--- 14489,14495 ----
* write the declaration of one user-defined table trigger
*/
static void
! dumpTrigger(Archive *fout, DumpOptions* dopt, TriggerInfo *tginfo)
{
TableInfo *tbinfo = tginfo->tgtable;
PQExpBuffer query;
*************** dumpTrigger(Archive *fout, TriggerInfo *
*** 14537,14543 ****
* we needn't check dobj.dump because TriggerInfo wouldn't have been
* created in the first place for non-dumpable triggers
*/
! if (dataOnly)
return;
query = createPQExpBuffer();
--- 14504,14510 ----
* we needn't check dobj.dump because TriggerInfo wouldn't have been
* created in the first place for non-dumpable triggers
*/
! if (dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpTrigger(Archive *fout, TriggerInfo *
*** 14718,14724 ****
NULL, 0,
NULL, NULL);
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
--- 14685,14691 ----
NULL, 0,
NULL, NULL);
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
*************** dumpTrigger(Archive *fout, TriggerInfo *
*** 14732,14744 ****
* write the declaration of one user-defined event trigger
*/
static void
! dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
{
PQExpBuffer query;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!evtinfo->dobj.dump || dataOnly)
return;
query = createPQExpBuffer();
--- 14699,14711 ----
* write the declaration of one user-defined event trigger
*/
static void
! dumpEventTrigger(Archive *fout, DumpOptions* dopt, EventTriggerInfo *evtinfo)
{
PQExpBuffer query;
PQExpBuffer labelq;
/* Skip if not to be dumped */
! if (!evtinfo->dobj.dump || dopt->dataOnly)
return;
query = createPQExpBuffer();
*************** dumpEventTrigger(Archive *fout, EventTri
*** 14790,14796 ****
"EVENT TRIGGER", SECTION_POST_DATA,
query->data, "", NULL, NULL, 0, NULL, NULL);
! dumpComment(fout, labelq->data,
NULL, NULL,
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
--- 14757,14763 ----
"EVENT TRIGGER", SECTION_POST_DATA,
query->data, "", NULL, NULL, 0, NULL, NULL);
! dumpComment(fout, dopt, labelq->data,
NULL, NULL,
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
*************** dumpEventTrigger(Archive *fout, EventTri
*** 14803,14809 ****
* Dump a rule
*/
static void
! dumpRule(Archive *fout, RuleInfo *rinfo)
{
TableInfo *tbinfo = rinfo->ruletable;
PQExpBuffer query;
--- 14770,14776 ----
* Dump a rule
*/
static void
! dumpRule(Archive *fout, DumpOptions *dopt, RuleInfo *rinfo)
{
TableInfo *tbinfo = rinfo->ruletable;
PQExpBuffer query;
*************** dumpRule(Archive *fout, RuleInfo *rinfo)
*** 14813,14819 ****
PGresult *res;
/* Skip if not to be dumped */
! if (!rinfo->dobj.dump || dataOnly)
return;
/*
--- 14780,14786 ----
PGresult *res;
/* Skip if not to be dumped */
! if (!rinfo->dobj.dump || dopt->dataOnly)
return;
/*
*************** dumpRule(Archive *fout, RuleInfo *rinfo)
*** 14918,14924 ****
NULL, NULL);
/* Dump rule comments */
! dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId);
--- 14885,14891 ----
NULL, NULL);
/* Dump rule comments */
! dumpComment(fout, dopt, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId);
*************** dumpRule(Archive *fout, RuleInfo *rinfo)
*** 14935,14941 ****
* getExtensionMembership --- obtain extension membership data
*/
void
! getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
int numExtensions)
{
PQExpBuffer query;
--- 14902,14908 ----
* getExtensionMembership --- obtain extension membership data
*/
void
! getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[],
int numExtensions)
{
PQExpBuffer query;
*************** getExtensionMembership(Archive *fout, Ex
*** 15032,15038 ****
* idea is to exactly reproduce the database contents rather than
* replace the extension contents with something different.
*/
! if (!binary_upgrade)
dobj->dump = false;
else
dobj->dump = refdobj->dump;
--- 14999,15005 ----
* idea is to exactly reproduce the database contents rather than
* replace the extension contents with something different.
*/
! if (!dopt->binary_upgrade)
dobj->dump = false;
else
dobj->dump = refdobj->dump;
*************** getExtensionMembership(Archive *fout, Ex
*** 15111,15117 ****
* of the --oids setting. This is because row filtering
* conditions aren't compatible with dumping OIDs.
*/
! makeTableDataInfo(configtbl, false);
if (configtbl->dataObj != NULL)
{
if (strlen(extconditionarray[j]) > 0)
--- 15078,15084 ----
* of the --oids setting. This is because row filtering
* conditions aren't compatible with dumping OIDs.
*/
! makeTableDataInfo(dopt, configtbl, false);
if (configtbl->dataObj != NULL)
{
if (strlen(extconditionarray[j]) > 0)
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
new file mode 100644
index d184187..c8864a0
*** a/src/bin/pg_dump/pg_dump.h
--- b/src/bin/pg_dump/pg_dump.h
*************** extern char g_opaque_type[10]; /* name f
*** 503,509 ****
struct Archive;
typedef struct Archive Archive;
! extern TableInfo *getSchemaData(Archive *, int *numTablesPtr);
typedef enum _OidOptions
{
--- 503,511 ----
struct Archive;
typedef struct Archive Archive;
! struct _dumpOptions;
!
! extern TableInfo *getSchemaData(Archive *, struct _dumpOptions *dopt, int *numTablesPtr);
typedef enum _OidOptions
{
*************** extern void sortDataAndIndexObjectsBySiz
*** 545,560 ****
* version specific routines
*/
extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
! extern ExtensionInfo *getExtensions(Archive *fout, int *numExtensions);
extern TypeInfo *getTypes(Archive *fout, int *numTypes);
! extern FuncInfo *getFuncs(Archive *fout, int *numFuncs);
! extern AggInfo *getAggregates(Archive *fout, int *numAggregates);
extern OprInfo *getOperators(Archive *fout, int *numOperators);
extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses);
extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(Archive *fout, int *numConversions);
! extern TableInfo *getTables(Archive *fout, int *numTables);
extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
--- 547,562 ----
* version specific routines
*/
extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
! extern ExtensionInfo *getExtensions(Archive *fout, struct _dumpOptions *dopt, int *numExtensions);
extern TypeInfo *getTypes(Archive *fout, int *numTypes);
! extern FuncInfo *getFuncs(Archive *fout, struct _dumpOptions *dopt, int *numFuncs);
! extern AggInfo *getAggregates(Archive *fout, struct _dumpOptions *dopt, int *numAggregates);
extern OprInfo *getOperators(Archive *fout, int *numOperators);
extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses);
extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(Archive *fout, int *numConversions);
! extern TableInfo *getTables(Archive *fout, struct _dumpOptions *dopt, int *numTables);
extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
*************** extern RuleInfo *getRules(Archive *fout,
*** 563,570 ****
extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables);
extern ProcLangInfo *getProcLangs(Archive *fout, int *numProcLangs);
extern CastInfo *getCasts(Archive *fout, int *numCasts);
! extern void getTableAttrs(Archive *fout, TableInfo *tbinfo, int numTables);
! extern bool shouldPrintColumn(TableInfo *tbinfo, int colno);
extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers);
extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts);
extern TSTemplateInfo *getTSTemplates(Archive *fout, int *numTSTemplates);
--- 565,572 ----
extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables);
extern ProcLangInfo *getProcLangs(Archive *fout, int *numProcLangs);
extern CastInfo *getCasts(Archive *fout, int *numCasts);
! extern void getTableAttrs(Archive *fout, struct _dumpOptions *dopt, TableInfo *tbinfo, int numTables);
! extern bool shouldPrintColumn(struct _dumpOptions *dopt, TableInfo *tbinfo, int colno);
extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers);
extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts);
extern TSTemplateInfo *getTSTemplates(Archive *fout, int *numTSTemplates);
*************** extern FdwInfo *getForeignDataWrappers(A
*** 573,580 ****
int *numForeignDataWrappers);
extern ForeignServerInfo *getForeignServers(Archive *fout,
int *numForeignServers);
! extern DefaultACLInfo *getDefaultACLs(Archive *fout, int *numDefaultACLs);
! extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
int numExtensions);
extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
--- 575,582 ----
int *numForeignDataWrappers);
extern ForeignServerInfo *getForeignServers(Archive *fout,
int *numForeignServers);
! extern DefaultACLInfo *getDefaultACLs(Archive *fout, struct _dumpOptions *dopt, int *numDefaultACLs);
! extern void getExtensionMembership(Archive *fout, struct _dumpOptions *dopt, ExtensionInfo extinfo[],
int numExtensions);
extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
new file mode 100644
index fdfdc19..514615b
*** a/src/bin/pg_dump/pg_restore.c
--- b/src/bin/pg_dump/pg_restore.c
*************** main(int argc, char **argv)
*** 420,426 ****
/* AH may be freed in CloseArchive? */
exit_code = AH->n_errors ? 1 : 0;
! CloseArchive(AH);
return exit_code;
}
--- 420,426 ----
/* AH may be freed in CloseArchive? */
exit_code = AH->n_errors ? 1 : 0;
! CloseArchive(AH, NULL);
return exit_code;
}
Here's a rebased patch for this (I also pgindented it).
One thing I find a bit odd is the fact that we copy
RestoreOptions->superuser into DumpOptions->outputSuperuser (a char *
pointer) without pstrdup or similar. We're already doing the inverse
elsewhere, and the uses of the routine where this is done are pretty
limited, so it seems harmless. Still, it's pretty weird. (Really,
the whole dumpOptionsFromRestoreOptions() business is odd.)
I'm not real happy with the forward struct declare in pg_backup.h, but I
think this is just general messiness in this code structure and not this
patch' fault.
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachments:
pg_dump_refactor_globals.5.difftext/x-diff; charset=us-asciiDownload
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 2f855cf..17e9574 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");
@@ -307,7 +307,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,
@@ -384,7 +384,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/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 921bc1b..915cd50 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;
@@ -153,7 +158,51 @@ typedef struct _restoreOptions
int enable_row_security;
} RestoreOptions;
-typedef void (*SetupWorkerPtr) (Archive *AH, RestoreOptions *ropt);
+typedef struct _dumpOptions
+{
+ const char *dbname;
+ const char *pghost;
+ const char *pgport;
+ const char *username;
+ bool oids;
+
+ int binary_upgrade;
+
+ /* various user-settable parameters */
+ bool schemaOnly;
+ bool dataOnly;
+ int dumpSections; /* bitmask of chosen sections */
+ bool aclsSkip;
+ const char *lockWaitTimeout;
+
+ /* flags for various command-line long options */
+ int disable_dollar_quoting;
+ int dump_inserts;
+ int column_inserts;
+ int if_exists;
+ int no_security_labels;
+ int no_synchronized_snapshots;
+ int no_unlogged_table_data;
+ int serializable_deferrable;
+ int quote_all_identifiers;
+ int disable_triggers;
+ int outputNoTablespaces;
+ int use_setsessauth;
+ int enable_row_security;
+
+ /* default, if no "inclusion" switches appear, is to dump everything */
+ bool include_everything;
+
+ int outputClean;
+ int outputCreateDB;
+ bool outputBlobs;
+ int outputNoOwner;
+ char *outputSuperuser;
+} DumpOptions;
+
+typedef int (*DataDumperPtr) (Archive *AH, DumpOptions *dopt, void *userArg);
+
+typedef void (*SetupWorkerPtr) (Archive *AH, DumpOptions *dopt, RestoreOptions *ropt);
/*
* Main archiver interface.
@@ -186,7 +235,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);
@@ -205,6 +254,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 1303ef6..71ac6e5 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -107,6 +107,62 @@ 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->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;
+ dopt->enable_row_security = ropt->enable_row_security;
+
+ return dopt;
+}
+
+
+/*
* Wrapper functions.
*
* The objective it to make writing new formats and dumpers as simple
@@ -120,7 +176,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 +208,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)
@@ -548,7 +604,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);
@@ -2240,7 +2296,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
}
void
-WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
+WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate)
{
TocEntry *te;
@@ -2263,13 +2319,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;
@@ -2293,7 +2349,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..6f29430 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);
@@ -687,14 +687,14 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
* the process of saving it to files. No data should be written prior
* to this point, since the user could sort the TOC after creating it.
*
- * If an archive is to be written, this toutine must call:
+ * If an archive is to be written, this routine must call:
* WriteHead to save the archive header
* WriteToc to save the TOC entries
* WriteDataChunks to save all DATA & BLOBs.
*
*/
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..430ad41 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,16 @@ _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 +231,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 1a9e82e..7240ee3 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 */
@@ -127,22 +118,9 @@ char g_comment_end[10];
static const CatalogId nilCatalogId = {0, 0};
-/* flags for various command-line long options */
-static int binary_upgrade = 0;
-static int disable_dollar_quoting = 0;
-static int dump_inserts = 0;
-static int column_inserts = 0;
-static int if_exists = 0;
-static int no_security_labels = 0;
-static int no_synchronized_snapshots = 0;
-static int no_unlogged_table_data = 0;
-static int serializable_deferrable = 0;
-static int enable_row_security = 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,
+ const char *dumpencoding, char *use_role);
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
static void expand_schema_name_patterns(Archive *fout,
SimpleStringList *patterns,
@@ -151,64 +129,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);
@@ -223,8 +201,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,
@@ -246,10 +224,10 @@ 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 dumpRowSecurity(Archive *fout, RowSecurityInfo *rsinfo);
-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 dumpRowSecurity(Archive *fout, DumpOptions *dopt, RowSecurityInfo *rsinfo);
+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,
@@ -266,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
@@ -275,39 +253,27 @@ 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 optindex;
+ RestoreOptions *ropt;
+ Archive *fout; /* the script file */
+ const char *dumpencoding = NULL;
+ char *use_role = NULL;
int numWorkers = 1;
enum trivalue prompt_password = TRI_DEFAULT;
int compressLevel = -1;
int plainText = 0;
- 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 */
+ ArchiveMode archiveMode;
- 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'},
@@ -342,25 +308,25 @@ 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},
- {"enable-row-security", no_argument, &enable_row_security, 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},
+ {"enable-row-security", no_argument, &dopt->enable_row_security, 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}
};
@@ -379,10 +345,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 */
@@ -409,23 +371,23 @@ 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 */
@@ -441,7 +403,7 @@ main(int argc, char **argv)
break;
case 'h': /* server host */
- pghost = pg_strdup(optarg);
+ dopt->pghost = pg_strdup(optarg);
break;
case 'i':
@@ -454,7 +416,7 @@ main(int argc, char **argv)
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) */
@@ -462,15 +424,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':
@@ -478,16 +440,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) */
@@ -495,7 +457,7 @@ main(int argc, char **argv)
break;
case 'U':
- username = pg_strdup(optarg);
+ dopt->username = pg_strdup(optarg);
break;
case 'v': /* verbose */
@@ -511,7 +473,7 @@ main(int argc, char **argv)
break;
case 'x': /* skip ACL dump */
- aclsSkip = true;
+ dopt->aclsSkip = true;
break;
case 'Z': /* Compression Level */
@@ -523,7 +485,7 @@ 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 */
@@ -535,7 +497,7 @@ main(int argc, char **argv)
break;
case 5: /* section */
- set_dump_section(optarg, &dumpSections);
+ set_dump_section(optarg, &dopt->dumpSections);
break;
default:
@@ -548,8 +510,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)
@@ -562,29 +524,29 @@ 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 */
@@ -645,15 +607,15 @@ main(int argc, char **argv)
* 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, prompt_password);
+ setup_connection(fout, dopt, dumpencoding, use_role);
/*
* Disable security label support if server version < v9.1.x (prevents
* access to nonexistent pg_seclabel catalog)
*/
if (fout->remoteVersion < 90100)
- no_security_labels = 1;
+ dopt->no_security_labels = 1;
/*
* When running against 9.0 or later, check if we are in recovery mode,
@@ -669,7 +631,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);
}
@@ -684,7 +646,7 @@ main(int argc, char **argv)
/* check the version for the synchronized snapshots feature */
if (numWorkers > 1 && fout->remoteVersion < 90200
- && !no_synchronized_snapshots)
+ && !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"
@@ -734,27 +696,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);
/*
@@ -804,31 +766,37 @@ 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;
- ropt->enable_row_security = enable_row_security;
+ 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;
+ ropt->enable_row_security = dopt->enable_row_security;
if (compressLevel == -1)
ropt->compression = 0;
@@ -857,7 +825,7 @@ main(int argc, char **argv)
if (plainText)
RestoreArchive(fout);
- CloseArchive(fout);
+ CloseArchive(fout, dopt);
exit_nicely(0);
}
@@ -931,7 +899,7 @@ help(const char *progname)
}
static void
-setup_connection(Archive *AH, const char *dumpencoding, char *use_role)
+setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding, char *use_role)
{
PGconn *conn = GetConnection(AH);
const char *std_strings;
@@ -1019,7 +987,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");
@@ -1041,7 +1009,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)
{
@@ -1058,7 +1026,7 @@ setup_connection(Archive *AH, const char *dumpencoding, char *use_role)
if (AH->remoteVersion >= 90500)
{
- if (enable_row_security)
+ if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security TO ON");
else
ExecuteSqlStatement(AH, "SET row_security TO OFF");
@@ -1066,9 +1034,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, NULL, NULL);
}
static char *
@@ -1339,12 +1307,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;
}
/*
@@ -1358,12 +1326,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;
}
/*
@@ -1392,7 +1360,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;
@@ -1567,7 +1535,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;
@@ -1636,7 +1604,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++)
@@ -1753,7 +1721,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();
@@ -1761,7 +1729,7 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
DataDumperPtr dumpFn;
char *copyStmt;
- if (!dump_inserts)
+ if (!dopt->dump_inserts)
{
/* Dump/restore using COPY */
dumpFn = dumpTableData_copy;
@@ -1845,14 +1813,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);
}
}
@@ -1863,7 +1831,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;
@@ -1883,7 +1851,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 */
@@ -2156,7 +2124,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();
@@ -2318,7 +2286,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"
@@ -2357,7 +2325,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();
@@ -2475,14 +2443,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();
@@ -2503,7 +2471,6 @@ dumpDatabase(Archive *fout)
destroyPQExpBuffer(creaQry);
}
-
/*
* dumpEncoding: put the correct encoding into the archive
*/
@@ -2643,7 +2610,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();
@@ -2670,18 +2637,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);
@@ -2694,7 +2661,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;
@@ -2922,14 +2889,14 @@ getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables)
* dump the definition of the given row-security policy
*/
static void
-dumpRowSecurity(Archive *fout, RowSecurityInfo *rsinfo)
+dumpRowSecurity(Archive *fout, DumpOptions *dopt, RowSecurityInfo *rsinfo)
{
TableInfo *tbinfo = rsinfo->rstable;
PQExpBuffer query;
PQExpBuffer delqry;
const char *cmd;
- if (dataOnly)
+ if (dopt->dataOnly)
return;
/*
@@ -3343,7 +3310,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;
@@ -3407,7 +3374,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);
@@ -4158,7 +4125,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;
@@ -4197,7 +4164,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 "
@@ -4337,7 +4304,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;
@@ -4394,7 +4361,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 "
@@ -4520,7 +4487,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;
@@ -5071,7 +5038,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.
@@ -5082,7 +5049,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);
}
@@ -5178,7 +5145,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");
}
@@ -6593,7 +6560,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;
@@ -6948,7 +6915,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;
@@ -7161,9 +7128,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]);
}
@@ -7709,7 +7676,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;
@@ -7778,7 +7745,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);
@@ -7807,7 +7774,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)
{
@@ -7817,12 +7784,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;
}
@@ -7871,7 +7838,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;
@@ -7880,7 +7847,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 */
@@ -8125,108 +8092,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,
@@ -8237,7 +8204,7 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj)
dumpBlobs, NULL);
break;
case DO_ROW_SECURITY:
- dumpRowSecurity(fout, (RowSecurityInfo *) dobj);
+ dumpRowSecurity(fout, dopt, (RowSecurityInfo *) dobj);
break;
case DO_PRE_DATA_BOUNDARY:
case DO_POST_DATA_BOUNDARY:
@@ -8251,7 +8218,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;
@@ -8259,7 +8226,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 */
@@ -8278,7 +8245,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,
@@ -8291,14 +8258,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);
@@ -8314,7 +8281,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;
@@ -8322,7 +8289,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();
@@ -8333,7 +8300,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
@@ -8419,10 +8386,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);
@@ -8438,23 +8405,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);
@@ -8465,7 +8432,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();
@@ -8510,14 +8477,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++)
@@ -8532,7 +8499,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++)
@@ -8556,7 +8523,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,
@@ -8570,14 +8537,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);
@@ -8594,7 +8561,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();
@@ -8640,7 +8607,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);
@@ -8688,7 +8655,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,
@@ -8702,14 +8669,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);
@@ -8726,7 +8693,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();
@@ -8980,7 +8947,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);
@@ -9078,7 +9045,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,
@@ -9092,14 +9059,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);
@@ -9116,7 +9083,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();
@@ -9176,7 +9143,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);
@@ -9240,7 +9207,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,
@@ -9254,14 +9221,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);
@@ -9278,7 +9245,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();
@@ -9355,7 +9322,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));
@@ -9386,7 +9353,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 */
@@ -9454,7 +9421,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,
@@ -9469,14 +9436,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);
@@ -9607,12 +9574,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();
@@ -9626,7 +9593,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);
@@ -9662,12 +9629,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;
}
@@ -9678,7 +9645,7 @@ shouldDumpProcLangs(void)
* procedural language
*/
static void
-dumpProcLang(Archive *fout, ProcLangInfo *plang)
+dumpProcLang(Archive *fout, DumpOptions *dopt, ProcLangInfo *plang)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
@@ -9691,7 +9658,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;
/*
@@ -9737,7 +9704,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
if (!plang->dobj.ext_member)
{
- if (!useParams && !shouldDumpProcLangs())
+ if (!useParams && !shouldDumpProcLangs(dopt))
return;
}
@@ -9804,7 +9771,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,
@@ -9816,15 +9783,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);
@@ -9971,7 +9938,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;
@@ -10010,7 +9977,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();
@@ -10203,7 +10170,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
@@ -10216,7 +10183,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);
@@ -10392,7 +10359,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,
@@ -10406,14 +10373,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);
@@ -10444,7 +10411,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;
@@ -10452,7 +10419,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 */
@@ -10566,7 +10533,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,
@@ -10578,7 +10545,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);
@@ -10592,7 +10559,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;
@@ -10626,7 +10593,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;
/*
@@ -10816,7 +10783,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,
@@ -10830,7 +10797,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);
@@ -10980,7 +10947,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;
@@ -11024,7 +10991,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;
/*
@@ -11324,7 +11291,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,
@@ -11338,7 +11305,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);
@@ -11357,7 +11324,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;
@@ -11391,7 +11358,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;
/*
@@ -11637,7 +11604,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,
@@ -11651,7 +11618,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);
@@ -11669,7 +11636,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;
@@ -11682,7 +11649,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();
@@ -11726,7 +11693,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,
@@ -11740,7 +11707,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);
@@ -11757,7 +11724,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;
@@ -11774,7 +11741,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();
@@ -11825,7 +11792,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,
@@ -11839,7 +11806,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);
@@ -11896,7 +11863,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;
@@ -11942,7 +11909,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();
@@ -12221,7 +12188,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,
@@ -12235,10 +12202,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);
@@ -12253,7 +12220,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,
@@ -12278,14 +12245,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();
@@ -12321,7 +12288,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,
@@ -12335,7 +12302,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);
@@ -12349,7 +12316,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;
@@ -12360,7 +12327,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();
@@ -12408,7 +12375,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,
@@ -12422,7 +12389,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);
@@ -12437,14 +12404,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();
@@ -12474,7 +12441,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,
@@ -12488,7 +12455,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);
@@ -12502,7 +12469,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;
@@ -12517,7 +12484,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();
@@ -12602,7 +12569,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,
@@ -12616,7 +12583,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);
@@ -12631,7 +12598,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;
@@ -12639,7 +12606,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;
/*
@@ -12647,7 +12614,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();
@@ -12676,7 +12643,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,
@@ -12690,14 +12657,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);
@@ -12713,7 +12680,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;
@@ -12724,7 +12691,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();
@@ -12768,7 +12735,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,
@@ -12782,7 +12749,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,
@@ -12795,7 +12762,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);
@@ -12911,14 +12878,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();
@@ -12991,7 +12958,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)
@@ -12999,11 +12966,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();
@@ -13046,7 +13013,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)
{
@@ -13056,18 +13023,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;
}
@@ -13110,7 +13077,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;
@@ -13119,11 +13086,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 */
@@ -13331,20 +13298,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,
@@ -13379,7 +13346,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);
@@ -13456,7 +13423,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();
@@ -13474,7 +13441,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);
@@ -13494,7 +13461,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);
@@ -13574,7 +13541,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);
@@ -13588,7 +13555,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)
@@ -13603,7 +13570,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.
@@ -13617,11 +13584,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 */
@@ -13649,7 +13616,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
}
/* Attribute type */
- if (tbinfo->reloftype && !binary_upgrade)
+ if (tbinfo->reloftype && !dopt->binary_upgrade)
{
appendPQExpBufferStr(q, " WITH OPTIONS");
}
@@ -13714,7 +13681,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
@@ -13723,7 +13690,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++)
@@ -13796,7 +13763,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++)
@@ -13912,7 +13879,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");
@@ -13938,7 +13905,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 ",
@@ -14052,7 +14019,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,
@@ -14069,10 +14036,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++)
@@ -14082,7 +14049,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (constr->separate || !constr->conislocal)
continue;
- dumpTableConstraintComment(fout, constr);
+ dumpTableConstraintComment(fout, dopt, constr);
}
destroyPQExpBuffer(q);
@@ -14094,7 +14061,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;
@@ -14102,7 +14069,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 */
@@ -14181,7 +14148,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);
@@ -14189,7 +14156,7 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
PQExpBuffer delq;
PQExpBuffer labelq;
- if (dataOnly)
+ if (dopt->dataOnly)
return;
q = createPQExpBuffer();
@@ -14208,7 +14175,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);
@@ -14254,7 +14221,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,
@@ -14271,14 +14238,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();
@@ -14298,7 +14265,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);
@@ -14488,7 +14455,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);
@@ -14502,7 +14469,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();
@@ -14511,7 +14478,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,
@@ -14571,7 +14538,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,
@@ -14667,7 +14634,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);
@@ -14704,7 +14671,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);
@@ -14757,10 +14724,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);
@@ -14831,7 +14798,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;
@@ -14846,7 +14813,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();
@@ -15027,7 +14994,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);
@@ -15041,13 +15008,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();
@@ -15099,7 +15066,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);
@@ -15112,7 +15079,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;
@@ -15122,7 +15089,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;
/*
@@ -15227,7 +15194,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);
@@ -15244,7 +15211,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;
@@ -15341,7 +15308,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;
@@ -15420,7 +15387,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 fd1184e..e81c390 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -522,7 +522,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
{
@@ -564,16 +566,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);
@@ -582,8 +584,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);
@@ -592,8 +594,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);
extern void getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables);
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 21715dc..f954b3c 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -423,7 +423,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;
}
Joachim Wieland wrote:
On Sat, Aug 30, 2014 at 11:12 PM, Peter Eisentraut <peter_e@gmx.net> wrote:
- The forward declaration of struct _dumpOptions in pg_backup.h seems
kind of useless. You could move some things around so that that's not
necessary.Agreed, fixed.
- NewDumpOptions() and NewRestoreOptions() are both in
pg_backup_archiver.c, but NewRestoreOptions() is in pg_backup.h whereas
NewDumpOptions() is being put into pg_backup_archiver.h. None of that
makes too much sense, but it could be made more consistent.I would have created the prototype in the respective header of the .c
file that holds the function definition, but that's a bit fuzzy around
pg_dump. I have now moved the DumpOptions over to pg_backup.h, because
pg_backup_archiver.h includes pg_backup.h so that makes pg_backup.h
the lower header.
I gave this a look and my conclusion is that the current situation
doesn't make much sense -- supposedly, pg_backup.h is the public header
and pg_dump.h is the private header; then how does it make sense that
the former includes the latter? I think the reason is that the struct
definitions are not well placed. In the attached patch, which applies
on top of the rebase of Joachim's patch I submitted yesterday, I fix
that by moving some structs (those that make sense for the public
interface) to a new file, pg_dump_structs.h (better naming suggestions
welcome). This is included everywhere as needed; it's included by
pg_backup.h, in particular.
With the new header in place I was able to remove most of cross-header
forward struct declarations that were liberally used to work around what
would otherwise be circularity in header dependencies. I think it makes
much more sense this way.
With this, headers are cleaner and they compile standalone. pg_backup.h
does not include pg_dump.h anymore. DumpId and CatalogId, which were
kinda public but defined in the private header (!?), were moved to
pg_backup.h. This is necessary because the public functions use them.
The one header not real clear to me is pg_backup_db.h. Right now it
includes pg_backup_archiver.h, because some of its routines take an
ArchiveHandle argument, but that seems pretty strange if looking at it
from 10,000 miles. I think we could fix this by having the routines
take Archive (the public one, defined in pg_dump_structs.h) and cast to
ArchiveHandle internally. However, since pg_backup_db.h is not used
much, I guess it doesn't really matter.
There are some further (smaller) improvements that could be made if we
really cared about it, but I'm satisfied with this.
(I just realized after writing all this that I could achieve exactly the
same by putting the contents of the new pg_dump_structs.h in pg_backup.h
instead. If there are no strong opinions to the contrary, I'm inclined
to do it that way instead, but I want to post it this way to gather
opinions in case anyone cares.)
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachments:
dumpstructs.patchtext/x-diff; charset=us-asciiDownload
commit b044ed612c51be47124974d0d2d5cab7f41cdab3
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: Wed Oct 8 14:57:38 2014 -0300
pg_dump_structs.h
diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h
index b387aa1..a6a2d65 100644
--- a/src/bin/pg_dump/dumputils.h
+++ b/src/bin/pg_dump/dumputils.h
@@ -19,17 +19,7 @@
#include "libpq-fe.h"
#include "pqexpbuffer.h"
-typedef struct SimpleStringListCell
-{
- struct SimpleStringListCell *next;
- char val[1]; /* VARIABLE LENGTH FIELD */
-} SimpleStringListCell;
-
-typedef struct SimpleStringList
-{
- SimpleStringListCell *head;
- SimpleStringListCell *tail;
-} SimpleStringList;
+#include "pg_dump_structs.h"
extern int quote_all_identifiers;
diff --git a/src/bin/pg_dump/parallel.h b/src/bin/pg_dump/parallel.h
index 81a823d..744c76b 100644
--- a/src/bin/pg_dump/parallel.h
+++ b/src/bin/pg_dump/parallel.h
@@ -19,10 +19,7 @@
#ifndef PG_DUMP_PARALLEL_H
#define PG_DUMP_PARALLEL_H
-#include "pg_backup_db.h"
-
-struct _archiveHandle;
-struct _tocEntry;
+#include "pg_backup_archiver.h"
typedef enum
{
@@ -35,8 +32,8 @@ typedef enum
/* Arguments needed for a worker process */
typedef struct ParallelArgs
{
- struct _archiveHandle *AH;
- struct _tocEntry *te;
+ ArchiveHandle *AH;
+ TocEntry *te;
} ParallelArgs;
/* State for each parallel activity slot */
@@ -74,20 +71,20 @@ extern void init_parallel_dump_utils(void);
extern int GetIdleWorker(ParallelState *pstate);
extern bool IsEveryWorkerIdle(ParallelState *pstate);
-extern void ListenToWorkers(struct _archiveHandle * AH, ParallelState *pstate, bool do_wait);
+extern void ListenToWorkers(ArchiveHandle *AH, ParallelState *pstate, bool do_wait);
extern int ReapWorkerStatus(ParallelState *pstate, int *status);
-extern void EnsureIdleWorker(struct _archiveHandle * AH, ParallelState *pstate);
-extern void EnsureWorkersFinished(struct _archiveHandle * AH, ParallelState *pstate);
+extern void EnsureIdleWorker(ArchiveHandle *AH, ParallelState *pstate);
+extern void EnsureWorkersFinished(ArchiveHandle *AH, ParallelState *pstate);
-extern ParallelState *ParallelBackupStart(struct _archiveHandle * AH,
+extern ParallelState *ParallelBackupStart(ArchiveHandle *AH,
DumpOptions *dopt,
RestoreOptions *ropt);
-extern void DispatchJobForTocEntry(struct _archiveHandle * AH,
+extern void DispatchJobForTocEntry(ArchiveHandle *AH,
ParallelState *pstate,
- struct _tocEntry * te, T_Action act);
-extern void ParallelBackupEnd(struct _archiveHandle * AH, ParallelState *pstate);
+ TocEntry *te, T_Action act);
+extern void ParallelBackupEnd(ArchiveHandle *AH, ParallelState *pstate);
-extern void checkAborting(struct _archiveHandle * AH);
+extern void checkAborting(ArchiveHandle *AH);
extern void
exit_horribly(const char *modulename, const char *fmt,...)
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 915cd50..664a7cc 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -25,11 +25,35 @@
#include "postgres_fe.h"
-#include "pg_dump.h"
+#include "pg_dump_structs.h"
#include "dumputils.h"
#include "libpq-fe.h"
+/*
+ * pg_dump uses two different mechanisms for identifying database objects:
+ *
+ * CatalogId represents an object by the tableoid and oid of its defining
+ * entry in the system catalogs. We need this to interpret pg_depend entries,
+ * for instance.
+ *
+ * DumpId is a simple sequential integer counter assigned as dumpable objects
+ * are identified during a pg_dump run. We use DumpId internally in preference
+ * to CatalogId for two reasons: it's more compact, and we can assign DumpIds
+ * to "objects" that don't have a separate CatalogId. For example, it is
+ * convenient to consider a table, its data, and its ACL as three separate
+ * dumpable "objects" with distinct DumpIds --- this lets us reason about the
+ * order in which to dump these things.
+ */
+
+typedef struct
+{
+ Oid tableoid;
+ Oid oid;
+} CatalogId;
+
+typedef int DumpId;
+
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
#define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) )
@@ -38,167 +62,6 @@
#define oidge(x,y) ( (x) >= (y) )
#define oidzero(x) ( (x) == 0 )
-enum trivalue
-{
- TRI_DEFAULT,
- TRI_NO,
- TRI_YES
-};
-
-typedef enum _archiveFormat
-{
- archUnknown = 0,
- archCustom = 1,
- archTar = 3,
- archNull = 4,
- archDirectory = 5
-} ArchiveFormat;
-
-typedef enum _archiveMode
-{
- archModeAppend,
- archModeWrite,
- archModeRead
-} ArchiveMode;
-
-typedef enum _teSection
-{
- SECTION_NONE = 1, /* COMMENTs, ACLs, etc; can be anywhere */
- SECTION_PRE_DATA, /* stuff to be processed before data */
- SECTION_DATA, /* TABLE DATA, BLOBS, BLOB COMMENTS */
- SECTION_POST_DATA /* stuff to be processed after data */
-} teSection;
-
-/*
- * We may want to have some more user-readable data, but in the mean
- * time this gives us some abstraction and type checking.
- */
-struct Archive
-{
- int verbose;
- char *remoteVersionStr; /* server's version string */
- int remoteVersion; /* same in numeric form */
-
- int minRemoteVersion; /* allowable range */
- int maxRemoteVersion;
-
- int numWorkers; /* number of parallel processes */
- char *sync_snapshot_id; /* sync snapshot id for parallel
- * operation */
-
- /* info needed for string escaping */
- int encoding; /* libpq code for client_encoding */
- bool std_strings; /* standard_conforming_strings */
- char *use_role; /* Issue SET ROLE to this */
-
- /* error handling */
- bool exit_on_error; /* whether to exit on SQL errors... */
- int n_errors; /* number of errors (if no die) */
-
- /* The rest is private */
-};
-
-typedef struct _restoreOptions
-{
- int createDB; /* Issue commands to create the database */
- int noOwner; /* Don't try to match original object owner */
- int noTablespace; /* Don't issue tablespace-related commands */
- int disable_triggers; /* disable triggers during data-only
- * restore */
- int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
- * instead of OWNER TO */
- char *superuser; /* Username to use as superuser */
- char *use_role; /* Issue SET ROLE to this */
- int dropSchema;
- int disable_dollar_quoting;
- int dump_inserts;
- int column_inserts;
- int if_exists;
- int no_security_labels; /* Skip security label entries */
-
- const char *filename;
- int dataOnly;
- int schemaOnly;
- int dumpSections;
- int verbose;
- int aclsSkip;
- const char *lockWaitTimeout;
- int include_everything;
-
- int tocSummary;
- char *tocFile;
- int format;
- char *formatName;
-
- int selTypes;
- int selIndex;
- int selFunction;
- int selTrigger;
- int selTable;
- SimpleStringList indexNames;
- SimpleStringList functionNames;
- SimpleStringList schemaNames;
- SimpleStringList triggerNames;
- SimpleStringList tableNames;
-
- int useDB;
- char *dbname;
- char *pgport;
- char *pghost;
- char *username;
- int noDataForFailedTables;
- enum trivalue promptPassword;
- int exit_on_error;
- int compression;
- int suppressDumpWarnings; /* Suppress output of WARNING entries
- * to stderr */
- bool single_txn;
-
- bool *idWanted; /* array showing which dump IDs to emit */
- int enable_row_security;
-} RestoreOptions;
-
-typedef struct _dumpOptions
-{
- const char *dbname;
- const char *pghost;
- const char *pgport;
- const char *username;
- bool oids;
-
- int binary_upgrade;
-
- /* various user-settable parameters */
- bool schemaOnly;
- bool dataOnly;
- int dumpSections; /* bitmask of chosen sections */
- bool aclsSkip;
- const char *lockWaitTimeout;
-
- /* flags for various command-line long options */
- int disable_dollar_quoting;
- int dump_inserts;
- int column_inserts;
- int if_exists;
- int no_security_labels;
- int no_synchronized_snapshots;
- int no_unlogged_table_data;
- int serializable_deferrable;
- int quote_all_identifiers;
- int disable_triggers;
- int outputNoTablespaces;
- int use_setsessauth;
- int enable_row_security;
-
- /* default, if no "inclusion" switches appear, is to dump everything */
- bool include_everything;
-
- int outputClean;
- int outputCreateDB;
- bool outputBlobs;
- int outputNoOwner;
- char *outputSuperuser;
-} DumpOptions;
typedef int (*DataDumperPtr) (Archive *AH, DumpOptions *dopt, void *userArg);
@@ -213,7 +76,7 @@ extern void ConnectDatabase(Archive *AH,
const char *pghost,
const char *pgport,
const char *username,
- enum trivalue prompt_password);
+ trivalue prompt_password);
extern void DisconnectDatabase(Archive *AHX);
extern PGconn *GetConnection(Archive *AHX);
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index 2dac52c..59c7721 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -29,6 +29,7 @@
#include <time.h>
+#include "pg_dump.h"
#include "pg_backup.h"
#include "libpq-fe.h"
@@ -111,9 +112,8 @@ typedef z_stream *z_streamp;
#define WORKER_INHIBIT_DATA 11
#define WORKER_IGNORED_ERRORS 12
-struct _archiveHandle;
-struct _tocEntry;
-struct _restoreList;
+typedef struct _archiveHandle ArchiveHandle;
+typedef struct _tocEntry TocEntry;
struct ParallelArgs;
struct ParallelState;
@@ -139,40 +139,40 @@ typedef enum T_Action
ACT_RESTORE
} T_Action;
-typedef void (*ClosePtr) (struct _archiveHandle * AH, DumpOptions *dopt);
-typedef void (*ReopenPtr) (struct _archiveHandle * AH);
-typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+typedef void (*ClosePtr) (ArchiveHandle *AH, DumpOptions *dopt);
+typedef void (*ReopenPtr) (ArchiveHandle *AH);
+typedef void (*ArchiveEntryPtr) (ArchiveHandle *AH, TocEntry *te);
-typedef void (*StartDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*WriteDataPtr) (struct _archiveHandle * AH, const void *data, size_t dLen);
-typedef void (*EndDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+typedef void (*StartDataPtr) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*WriteDataPtr) (ArchiveHandle *AH, const void *data, size_t dLen);
+typedef void (*EndDataPtr) (ArchiveHandle *AH, TocEntry *te);
-typedef void (*StartBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*StartBlobPtr) (struct _archiveHandle * AH, struct _tocEntry * te, Oid oid);
-typedef void (*EndBlobPtr) (struct _archiveHandle * AH, struct _tocEntry * te, Oid oid);
-typedef void (*EndBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
+typedef void (*StartBlobsPtr) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*StartBlobPtr) (ArchiveHandle *AH, TocEntry *te, Oid oid);
+typedef void (*EndBlobPtr) (ArchiveHandle *AH, TocEntry *te, Oid oid);
+typedef void (*EndBlobsPtr) (ArchiveHandle *AH, TocEntry *te);
-typedef int (*WriteBytePtr) (struct _archiveHandle * AH, const int i);
-typedef int (*ReadBytePtr) (struct _archiveHandle * AH);
-typedef void (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, size_t len);
-typedef void (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, size_t len);
-typedef void (*SaveArchivePtr) (struct _archiveHandle * AH);
-typedef void (*WriteExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*ReadExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*PrintExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*PrintTocDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te, RestoreOptions *ropt);
+typedef int (*WriteBytePtr) (ArchiveHandle *AH, const int i);
+typedef int (*ReadBytePtr) (ArchiveHandle *AH);
+typedef void (*WriteBufPtr) (ArchiveHandle *AH, const void *c, size_t len);
+typedef void (*ReadBufPtr) (ArchiveHandle *AH, void *buf, size_t len);
+typedef void (*SaveArchivePtr) (ArchiveHandle *AH);
+typedef void (*WriteExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*ReadExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*PrintExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*PrintTocDataPtr) (ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
-typedef void (*ClonePtr) (struct _archiveHandle * AH);
-typedef void (*DeClonePtr) (struct _archiveHandle * AH);
+typedef void (*ClonePtr) (ArchiveHandle *AH);
+typedef void (*DeClonePtr) (ArchiveHandle *AH);
-typedef char *(*WorkerJobRestorePtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef char *(*WorkerJobDumpPtr) (struct _archiveHandle * AH, DumpOptions *dopt, struct _tocEntry * te);
-typedef char *(*MasterStartParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
+typedef char *(*WorkerJobRestorePtr) (ArchiveHandle *AH, TocEntry *te);
+typedef char *(*WorkerJobDumpPtr) (ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te);
+typedef char *(*MasterStartParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
T_Action act);
-typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
+typedef int (*MasterEndParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
const char *str, T_Action act);
-typedef size_t (*CustomOutPtr) (struct _archiveHandle * AH, const void *buf, size_t len);
+typedef size_t (*CustomOutPtr) (ArchiveHandle *AH, const void *buf, size_t len);
typedef enum
{
@@ -210,7 +210,7 @@ typedef enum
REQ_SPECIAL = 0x04 /* for special TOC entries */
} teReqs;
-typedef struct _archiveHandle
+struct _archiveHandle
{
Archive public; /* Public part of archive */
char vmaj; /* Version of file */
@@ -284,7 +284,7 @@ typedef struct _archiveHandle
/* Stuff for direct DB connection */
char *archdbname; /* DB name *read* from archive */
- enum trivalue promptPassword;
+ trivalue promptPassword;
char *savedPassword; /* password for ropt->username, if known */
char *use_role;
PGconn *connection;
@@ -336,9 +336,9 @@ typedef struct _archiveHandle
ArchiverStage lastErrorStage;
struct _tocEntry *currentTE;
struct _tocEntry *lastErrorTE;
-} ArchiveHandle;
+};
-typedef struct _tocEntry
+struct _tocEntry
{
struct _tocEntry *prev;
struct _tocEntry *next;
@@ -376,7 +376,7 @@ typedef struct _tocEntry
int nRevDeps; /* number of such dependencies */
DumpId *lockDeps; /* dumpIds of objects this one needs lock on */
int nLockDeps; /* number of such dependencies */
-} TocEntry;
+};
extern int parallel_restore(struct ParallelArgs *args);
extern void on_exit_close_archive(Archive *AHX);
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c
index 4d1d14f..85bf92c 100644
--- a/src/bin/pg_dump/pg_backup_db.c
+++ b/src/bin/pg_dump/pg_backup_db.c
@@ -217,7 +217,7 @@ ConnectDatabase(Archive *AHX,
const char *pghost,
const char *pgport,
const char *username,
- enum trivalue prompt_password)
+ trivalue prompt_password)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
char *password = AH->savedPassword;
diff --git a/src/bin/pg_dump/pg_backup_db.h b/src/bin/pg_dump/pg_backup_db.h
index 2eea1c3..26eaa4e 100644
--- a/src/bin/pg_dump/pg_backup_db.h
+++ b/src/bin/pg_dump/pg_backup_db.h
@@ -16,7 +16,7 @@ extern void ExecuteSqlStatement(Archive *AHX, const char *query);
extern PGresult *ExecuteSqlQuery(Archive *AHX, const char *query,
ExecStatusType status);
-extern void EndDBCopyMode(ArchiveHandle *AH, struct _tocEntry * te);
+extern void EndDBCopyMode(ArchiveHandle *AH, TocEntry *te);
extern void StartTransaction(ArchiveHandle *AH);
extern void CommitTransaction(ArchiveHandle *AH);
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 7240ee3..53a1254 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -81,6 +81,14 @@ typedef struct
int objsubid; /* subobject (table column #) */
} SecLabelItem;
+typedef enum OidOptions
+{
+ zeroAsOpaque = 1,
+ zeroAsAny = 2,
+ zeroAsStar = 4,
+ zeroAsNone = 8
+} OidOptions;
+
/* global decls */
bool g_verbose; /* User wants verbose narration of our
* activities. */
@@ -265,7 +273,7 @@ main(int argc, char **argv)
const char *dumpencoding = NULL;
char *use_role = NULL;
int numWorkers = 1;
- enum trivalue prompt_password = TRI_DEFAULT;
+ trivalue prompt_password = TRI_DEFAULT;
int compressLevel = -1;
int plainText = 0;
ArchiveFormat archiveFormat = archUnknown;
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index e81c390..72a12f7 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -16,47 +16,8 @@
#include "postgres_fe.h"
-/*
- * pg_dump uses two different mechanisms for identifying database objects:
- *
- * CatalogId represents an object by the tableoid and oid of its defining
- * entry in the system catalogs. We need this to interpret pg_depend entries,
- * for instance.
- *
- * DumpId is a simple sequential integer counter assigned as dumpable objects
- * are identified during a pg_dump run. We use DumpId internally in preference
- * to CatalogId for two reasons: it's more compact, and we can assign DumpIds
- * to "objects" that don't have a separate CatalogId. For example, it is
- * convenient to consider a table, its data, and its ACL as three separate
- * dumpable "objects" with distinct DumpIds --- this lets us reason about the
- * order in which to dump these things.
- */
-
-typedef struct
-{
- Oid tableoid;
- Oid oid;
-} CatalogId;
-
-typedef int DumpId;
-
-/*
- * Data structures for simple lists of OIDs and strings. The support for
- * these is very primitive compared to the backend's List facilities, but
- * it's all we need in pg_dump.
- */
-
-typedef struct SimpleOidListCell
-{
- struct SimpleOidListCell *next;
- Oid val;
-} SimpleOidListCell;
-
-typedef struct SimpleOidList
-{
- SimpleOidListCell *head;
- SimpleOidListCell *tail;
-} SimpleOidList;
+#include "pg_backup.h"
+#include "pg_dump_structs.h"
/*
@@ -519,20 +480,7 @@ extern char g_opaque_type[10]; /* name for the opaque type */
* common utility functions
*/
-struct Archive;
-typedef struct Archive Archive;
-
-struct _dumpOptions;
-
-extern TableInfo *getSchemaData(Archive *, struct _dumpOptions * dopt, int *numTablesPtr);
-
-typedef enum _OidOptions
-{
- zeroAsOpaque = 1,
- zeroAsAny = 2,
- zeroAsStar = 4,
- zeroAsNone = 8
-} OidOptions;
+extern TableInfo *getSchemaData(Archive *, DumpOptions *dopt, int *numTablesPtr);
extern void AssignDumpId(DumpableObject *dobj);
extern DumpId createDumpId(void);
@@ -566,16 +514,16 @@ extern void sortDataAndIndexObjectsBySize(DumpableObject **objs, int numObjs);
* version specific routines
*/
extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
-extern ExtensionInfo *getExtensions(Archive *fout, struct _dumpOptions * dopt, int *numExtensions);
+extern ExtensionInfo *getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions);
extern TypeInfo *getTypes(Archive *fout, int *numTypes);
-extern FuncInfo *getFuncs(Archive *fout, struct _dumpOptions * dopt, int *numFuncs);
-extern AggInfo *getAggregates(Archive *fout, struct _dumpOptions * dopt, int *numAggregates);
+extern FuncInfo *getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs);
+extern AggInfo *getAggregates(Archive *fout, DumpOptions *dopt, int *numAggregates);
extern OprInfo *getOperators(Archive *fout, int *numOperators);
extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses);
extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(Archive *fout, int *numConversions);
-extern TableInfo *getTables(Archive *fout, struct _dumpOptions * dopt, int *numTables);
+extern TableInfo *getTables(Archive *fout, DumpOptions *dopt, int *numTables);
extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
@@ -584,8 +532,8 @@ extern RuleInfo *getRules(Archive *fout, int *numRules);
extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables);
extern ProcLangInfo *getProcLangs(Archive *fout, int *numProcLangs);
extern CastInfo *getCasts(Archive *fout, int *numCasts);
-extern void getTableAttrs(Archive *fout, struct _dumpOptions * dopt, TableInfo *tbinfo, int numTables);
-extern bool shouldPrintColumn(struct _dumpOptions * dopt, TableInfo *tbinfo, int colno);
+extern void getTableAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, int numTables);
+extern bool shouldPrintColumn(DumpOptions *dopt, TableInfo *tbinfo, int colno);
extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers);
extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts);
extern TSTemplateInfo *getTSTemplates(Archive *fout, int *numTSTemplates);
@@ -594,8 +542,8 @@ extern FdwInfo *getForeignDataWrappers(Archive *fout,
int *numForeignDataWrappers);
extern ForeignServerInfo *getForeignServers(Archive *fout,
int *numForeignServers);
-extern DefaultACLInfo *getDefaultACLs(Archive *fout, struct _dumpOptions * dopt, int *numDefaultACLs);
-extern void getExtensionMembership(Archive *fout, struct _dumpOptions * dopt, ExtensionInfo extinfo[],
+extern DefaultACLInfo *getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs);
+extern void getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[],
int numExtensions);
extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
extern void getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables);
diff --git a/src/bin/pg_dump/pg_dump_structs.h b/src/bin/pg_dump/pg_dump_structs.h
new file mode 100644
index 0000000..b733182
--- /dev/null
+++ b/src/bin/pg_dump/pg_dump_structs.h
@@ -0,0 +1,216 @@
+/*-------------------------------------------------------------------------
+ *
+ * pg_dump_structs.h
+ *
+ * Struct definitions used across all pg_dump utilities
+ *
+ * Copyright (c) 2000, Philip Warner
+ * Rights are granted to use this software in any way so long
+ * as this notice is not removed.
+ *
+ * The author is not responsible for loss or damages that may
+ * result from it's use.
+ *
+ *
+ * IDENTIFICATION
+ * src/bin/pg_dump/pg_dump_structs.h
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef PG_DUMP_STRUCTS_H
+#define PG_DUMP_STRUCTS_H
+
+
+/*
+ * Data structures for simple lists of OIDs and strings. The support for
+ * these is very primitive compared to the backend's List facilities, but
+ * it's all we need in pg_dump.
+ */
+typedef struct SimpleOidListCell
+{
+ struct SimpleOidListCell *next;
+ Oid val;
+} SimpleOidListCell;
+
+typedef struct SimpleOidList
+{
+ SimpleOidListCell *head;
+ SimpleOidListCell *tail;
+} SimpleOidList;
+
+typedef struct SimpleStringListCell
+{
+ struct SimpleStringListCell *next;
+ char val[1]; /* VARIABLE LENGTH FIELD */
+} SimpleStringListCell;
+
+typedef struct SimpleStringList
+{
+ SimpleStringListCell *head;
+ SimpleStringListCell *tail;
+} SimpleStringList;
+
+typedef enum trivalue
+{
+ TRI_DEFAULT,
+ TRI_NO,
+ TRI_YES
+} trivalue;
+
+typedef enum _archiveFormat
+{
+ archUnknown = 0,
+ archCustom = 1,
+ archTar = 3,
+ archNull = 4,
+ archDirectory = 5
+} ArchiveFormat;
+
+typedef enum _archiveMode
+{
+ archModeAppend,
+ archModeWrite,
+ archModeRead
+} ArchiveMode;
+
+typedef enum _teSection
+{
+ SECTION_NONE = 1, /* COMMENTs, ACLs, etc; can be anywhere */
+ SECTION_PRE_DATA, /* stuff to be processed before data */
+ SECTION_DATA, /* TABLE DATA, BLOBS, BLOB COMMENTS */
+ SECTION_POST_DATA /* stuff to be processed after data */
+} teSection;
+
+/*
+ * We may want to have some more user-readable data, but in the mean
+ * time this gives us some abstraction and type checking.
+ */
+typedef struct Archive
+{
+ int verbose;
+ char *remoteVersionStr; /* server's version string */
+ int remoteVersion; /* same in numeric form */
+
+ int minRemoteVersion; /* allowable range */
+ int maxRemoteVersion;
+
+ int numWorkers; /* number of parallel processes */
+ char *sync_snapshot_id; /* sync snapshot id for parallel
+ * operation */
+
+ /* info needed for string escaping */
+ int encoding; /* libpq code for client_encoding */
+ bool std_strings; /* standard_conforming_strings */
+ char *use_role; /* Issue SET ROLE to this */
+
+ /* error handling */
+ bool exit_on_error; /* whether to exit on SQL errors... */
+ int n_errors; /* number of errors (if no die) */
+
+ /* The rest is private */
+} Archive;
+
+typedef struct _restoreOptions
+{
+ int createDB; /* Issue commands to create the database */
+ int noOwner; /* Don't try to match original object owner */
+ int noTablespace; /* Don't issue tablespace-related commands */
+ int disable_triggers; /* disable triggers during data-only
+ * restore */
+ int use_setsessauth;/* Use SET SESSION AUTHORIZATION commands
+ * instead of OWNER TO */
+ char *superuser; /* Username to use as superuser */
+ char *use_role; /* Issue SET ROLE to this */
+ int dropSchema;
+ int disable_dollar_quoting;
+ int dump_inserts;
+ int column_inserts;
+ int if_exists;
+ int no_security_labels; /* Skip security label entries */
+
+ const char *filename;
+ int dataOnly;
+ int schemaOnly;
+ int dumpSections;
+ int verbose;
+ int aclsSkip;
+ const char *lockWaitTimeout;
+ int include_everything;
+
+ int tocSummary;
+ char *tocFile;
+ int format;
+ char *formatName;
+
+ int selTypes;
+ int selIndex;
+ int selFunction;
+ int selTrigger;
+ int selTable;
+ SimpleStringList indexNames;
+ SimpleStringList functionNames;
+ SimpleStringList schemaNames;
+ SimpleStringList triggerNames;
+ SimpleStringList tableNames;
+
+ int useDB;
+ char *dbname;
+ char *pgport;
+ char *pghost;
+ char *username;
+ int noDataForFailedTables;
+ trivalue promptPassword;
+ int exit_on_error;
+ int compression;
+ int suppressDumpWarnings; /* Suppress output of WARNING entries
+ * to stderr */
+ bool single_txn;
+
+ bool *idWanted; /* array showing which dump IDs to emit */
+ int enable_row_security;
+} RestoreOptions;
+
+typedef struct _dumpOptions
+{
+ const char *dbname;
+ const char *pghost;
+ const char *pgport;
+ const char *username;
+ bool oids;
+
+ int binary_upgrade;
+
+ /* various user-settable parameters */
+ bool schemaOnly;
+ bool dataOnly;
+ int dumpSections; /* bitmask of chosen sections */
+ bool aclsSkip;
+ const char *lockWaitTimeout;
+
+ /* flags for various command-line long options */
+ int disable_dollar_quoting;
+ int dump_inserts;
+ int column_inserts;
+ int if_exists;
+ int no_security_labels;
+ int no_synchronized_snapshots;
+ int no_unlogged_table_data;
+ int serializable_deferrable;
+ int quote_all_identifiers;
+ int disable_triggers;
+ int outputNoTablespaces;
+ int use_setsessauth;
+ int enable_row_security;
+
+ /* default, if no "inclusion" switches appear, is to dump everything */
+ bool include_everything;
+
+ int outputClean;
+ int outputCreateDB;
+ bool outputBlobs;
+ int outputNoOwner;
+ char *outputSuperuser;
+} DumpOptions;
+
+#endif /* PG_DUMP_STRUCTS_H */
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index c25ea85..6d72ef9 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -57,7 +57,7 @@ static void buildShSecLabels(PGconn *conn, const char *catalog_name,
uint32 objectId, PQExpBuffer buffer,
const char *target, const char *objname);
static PGconn *connectDatabase(const char *dbname, const char *connstr, const char *pghost, const char *pgport,
- const char *pguser, enum trivalue prompt_password, bool fail_on_error);
+ const char *pguser, trivalue prompt_password, bool fail_on_error);
static char *constructConnStr(const char **keywords, const char **values);
static PGresult *executeQuery(PGconn *conn, const char *query);
static void executeCommand(PGconn *conn, const char *query);
@@ -138,7 +138,7 @@ main(int argc, char *argv[])
char *pguser = NULL;
char *pgdb = NULL;
char *use_role = NULL;
- enum trivalue prompt_password = TRI_DEFAULT;
+ trivalue prompt_password = TRI_DEFAULT;
bool data_only = false;
bool globals_only = false;
bool output_clean = false;
@@ -1765,7 +1765,7 @@ buildShSecLabels(PGconn *conn, const char *catalog_name, uint32 objectId,
static PGconn *
connectDatabase(const char *dbname, const char *connection_string,
const char *pghost, const char *pgport, const char *pguser,
- enum trivalue prompt_password, bool fail_on_error)
+ trivalue prompt_password, bool fail_on_error)
{
PGconn *conn;
bool new_pass;
Here's the complete patch in case anyone is wondering.
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachments:
pg_dump_refactor_globals.6.difftext/x-diff; charset=us-asciiDownload
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 2f855cf..17e9574 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");
@@ -307,7 +307,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,
@@ -384,7 +384,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..06763ed 100644
--- a/src/bin/pg_dump/dumputils.h
+++ b/src/bin/pg_dump/dumputils.h
@@ -19,6 +19,23 @@
#include "libpq-fe.h"
#include "pqexpbuffer.h"
+/*
+ * Data structures for simple lists of OIDs and strings. The support for
+ * these is very primitive compared to the backend's List facilities, but
+ * it's all we need in pg_dump.
+ */
+typedef struct SimpleOidListCell
+{
+ struct SimpleOidListCell *next;
+ Oid val;
+} SimpleOidListCell;
+
+typedef struct SimpleOidList
+{
+ SimpleOidListCell *head;
+ SimpleOidListCell *tail;
+} SimpleOidList;
+
typedef struct SimpleStringListCell
{
struct SimpleStringListCell *next;
@@ -31,6 +48,7 @@ typedef struct SimpleStringList
SimpleStringListCell *tail;
} SimpleStringList;
+#define atooid(x) ((Oid) strtoul((x), NULL, 10))
extern int quote_all_identifiers;
extern PQExpBuffer (*getLocalPQExpBuffer) (void);
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..744c76b 100644
--- a/src/bin/pg_dump/parallel.h
+++ b/src/bin/pg_dump/parallel.h
@@ -19,10 +19,7 @@
#ifndef PG_DUMP_PARALLEL_H
#define PG_DUMP_PARALLEL_H
-#include "pg_backup_db.h"
-
-struct _archiveHandle;
-struct _tocEntry;
+#include "pg_backup_archiver.h"
typedef enum
{
@@ -35,8 +32,8 @@ typedef enum
/* Arguments needed for a worker process */
typedef struct ParallelArgs
{
- struct _archiveHandle *AH;
- struct _tocEntry *te;
+ ArchiveHandle *AH;
+ TocEntry *te;
} ParallelArgs;
/* State for each parallel activity slot */
@@ -74,19 +71,20 @@ extern void init_parallel_dump_utils(void);
extern int GetIdleWorker(ParallelState *pstate);
extern bool IsEveryWorkerIdle(ParallelState *pstate);
-extern void ListenToWorkers(struct _archiveHandle * AH, ParallelState *pstate, bool do_wait);
+extern void ListenToWorkers(ArchiveHandle *AH, ParallelState *pstate, bool do_wait);
extern int ReapWorkerStatus(ParallelState *pstate, int *status);
-extern void EnsureIdleWorker(struct _archiveHandle * AH, ParallelState *pstate);
-extern void EnsureWorkersFinished(struct _archiveHandle * AH, ParallelState *pstate);
+extern void EnsureIdleWorker(ArchiveHandle *AH, ParallelState *pstate);
+extern void EnsureWorkersFinished(ArchiveHandle *AH, ParallelState *pstate);
-extern ParallelState *ParallelBackupStart(struct _archiveHandle * AH,
+extern ParallelState *ParallelBackupStart(ArchiveHandle *AH,
+ DumpOptions *dopt,
RestoreOptions *ropt);
-extern void DispatchJobForTocEntry(struct _archiveHandle * AH,
+extern void DispatchJobForTocEntry(ArchiveHandle *AH,
ParallelState *pstate,
- struct _tocEntry * te, T_Action act);
-extern void ParallelBackupEnd(struct _archiveHandle * AH, ParallelState *pstate);
+ TocEntry *te, T_Action act);
+extern void ParallelBackupEnd(ArchiveHandle *AH, ParallelState *pstate);
-extern void checkAborting(struct _archiveHandle * AH);
+extern void checkAborting(ArchiveHandle *AH);
extern void
exit_horribly(const char *modulename, const char *fmt,...)
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 921bc1b..37fdd8c 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -25,25 +25,17 @@
#include "postgres_fe.h"
-#include "pg_dump.h"
#include "dumputils.h"
#include "libpq-fe.h"
-#define atooid(x) ((Oid) strtoul((x), NULL, 10))
-#define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) )
-#define oideq(x,y) ( (x) == (y) )
-#define oidle(x,y) ( (x) <= (y) )
-#define oidge(x,y) ( (x) >= (y) )
-#define oidzero(x) ( (x) == 0 )
-
-enum trivalue
+typedef enum trivalue
{
TRI_DEFAULT,
TRI_NO,
TRI_YES
-};
+} trivalue;
typedef enum _archiveFormat
{
@@ -73,7 +65,7 @@ typedef enum _teSection
* We may want to have some more user-readable data, but in the mean
* time this gives us some abstraction and type checking.
*/
-struct Archive
+typedef struct Archive
{
int verbose;
char *remoteVersionStr; /* server's version string */
@@ -96,9 +88,7 @@ struct Archive
int n_errors; /* number of errors (if no die) */
/* The rest is private */
-};
-
-typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
+} Archive;
typedef struct _restoreOptions
{
@@ -109,17 +99,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;
@@ -142,7 +139,7 @@ typedef struct _restoreOptions
char *pghost;
char *username;
int noDataForFailedTables;
- enum trivalue promptPassword;
+ trivalue promptPassword;
int exit_on_error;
int compression;
int suppressDumpWarnings; /* Suppress output of WARNING entries
@@ -153,7 +150,76 @@ typedef struct _restoreOptions
int enable_row_security;
} RestoreOptions;
-typedef void (*SetupWorkerPtr) (Archive *AH, RestoreOptions *ropt);
+typedef struct _dumpOptions
+{
+ const char *dbname;
+ const char *pghost;
+ const char *pgport;
+ const char *username;
+ bool oids;
+
+ int binary_upgrade;
+
+ /* various user-settable parameters */
+ bool schemaOnly;
+ bool dataOnly;
+ int dumpSections; /* bitmask of chosen sections */
+ bool aclsSkip;
+ const char *lockWaitTimeout;
+
+ /* flags for various command-line long options */
+ int disable_dollar_quoting;
+ int dump_inserts;
+ int column_inserts;
+ int if_exists;
+ int no_security_labels;
+ int no_synchronized_snapshots;
+ int no_unlogged_table_data;
+ int serializable_deferrable;
+ int quote_all_identifiers;
+ int disable_triggers;
+ int outputNoTablespaces;
+ int use_setsessauth;
+ int enable_row_security;
+
+ /* default, if no "inclusion" switches appear, is to dump everything */
+ bool include_everything;
+
+ int outputClean;
+ int outputCreateDB;
+ bool outputBlobs;
+ int outputNoOwner;
+ char *outputSuperuser;
+} DumpOptions;
+
+
+/*
+ * pg_dump uses two different mechanisms for identifying database objects:
+ *
+ * CatalogId represents an object by the tableoid and oid of its defining
+ * entry in the system catalogs. We need this to interpret pg_depend entries,
+ * for instance.
+ *
+ * DumpId is a simple sequential integer counter assigned as dumpable objects
+ * are identified during a pg_dump run. We use DumpId internally in preference
+ * to CatalogId for two reasons: it's more compact, and we can assign DumpIds
+ * to "objects" that don't have a separate CatalogId. For example, it is
+ * convenient to consider a table, its data, and its ACL as three separate
+ * dumpable "objects" with distinct DumpIds --- this lets us reason about the
+ * order in which to dump these things.
+ */
+
+typedef struct
+{
+ Oid tableoid;
+ Oid oid;
+} CatalogId;
+
+typedef int DumpId;
+
+typedef int (*DataDumperPtr) (Archive *AH, DumpOptions *dopt, void *userArg);
+
+typedef void (*SetupWorkerPtr) (Archive *AH, DumpOptions *dopt, RestoreOptions *ropt);
/*
* Main archiver interface.
@@ -164,7 +230,7 @@ extern void ConnectDatabase(Archive *AH,
const char *pghost,
const char *pgport,
const char *username,
- enum trivalue prompt_password);
+ trivalue prompt_password);
extern void DisconnectDatabase(Archive *AHX);
extern PGconn *GetConnection(Archive *AHX);
@@ -186,7 +252,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);
@@ -205,6 +271,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 1303ef6..71ac6e5 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -107,6 +107,62 @@ 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->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;
+ dopt->enable_row_security = ropt->enable_row_security;
+
+ return dopt;
+}
+
+
+/*
* Wrapper functions.
*
* The objective it to make writing new formats and dumpers as simple
@@ -120,7 +176,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 +208,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)
@@ -548,7 +604,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);
@@ -2240,7 +2296,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
}
void
-WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
+WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate)
{
TocEntry *te;
@@ -2263,13 +2319,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;
@@ -2293,7 +2349,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..59c7721 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -29,6 +29,7 @@
#include <time.h>
+#include "pg_dump.h"
#include "pg_backup.h"
#include "libpq-fe.h"
@@ -111,9 +112,8 @@ typedef z_stream *z_streamp;
#define WORKER_INHIBIT_DATA 11
#define WORKER_IGNORED_ERRORS 12
-struct _archiveHandle;
-struct _tocEntry;
-struct _restoreList;
+typedef struct _archiveHandle ArchiveHandle;
+typedef struct _tocEntry TocEntry;
struct ParallelArgs;
struct ParallelState;
@@ -139,40 +139,40 @@ typedef enum T_Action
ACT_RESTORE
} T_Action;
-typedef void (*ClosePtr) (struct _archiveHandle * AH);
-typedef void (*ReopenPtr) (struct _archiveHandle * AH);
-typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-
-typedef void (*StartDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*WriteDataPtr) (struct _archiveHandle * AH, const void *data, size_t dLen);
-typedef void (*EndDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-
-typedef void (*StartBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*StartBlobPtr) (struct _archiveHandle * AH, struct _tocEntry * te, Oid oid);
-typedef void (*EndBlobPtr) (struct _archiveHandle * AH, struct _tocEntry * te, Oid oid);
-typedef void (*EndBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-
-typedef int (*WriteBytePtr) (struct _archiveHandle * AH, const int i);
-typedef int (*ReadBytePtr) (struct _archiveHandle * AH);
-typedef void (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, size_t len);
-typedef void (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, size_t len);
-typedef void (*SaveArchivePtr) (struct _archiveHandle * AH);
-typedef void (*WriteExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*ReadExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*PrintExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
-typedef void (*PrintTocDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te, RestoreOptions *ropt);
-
-typedef 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 *(*MasterStartParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
+typedef void (*ClosePtr) (ArchiveHandle *AH, DumpOptions *dopt);
+typedef void (*ReopenPtr) (ArchiveHandle *AH);
+typedef void (*ArchiveEntryPtr) (ArchiveHandle *AH, TocEntry *te);
+
+typedef void (*StartDataPtr) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*WriteDataPtr) (ArchiveHandle *AH, const void *data, size_t dLen);
+typedef void (*EndDataPtr) (ArchiveHandle *AH, TocEntry *te);
+
+typedef void (*StartBlobsPtr) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*StartBlobPtr) (ArchiveHandle *AH, TocEntry *te, Oid oid);
+typedef void (*EndBlobPtr) (ArchiveHandle *AH, TocEntry *te, Oid oid);
+typedef void (*EndBlobsPtr) (ArchiveHandle *AH, TocEntry *te);
+
+typedef int (*WriteBytePtr) (ArchiveHandle *AH, const int i);
+typedef int (*ReadBytePtr) (ArchiveHandle *AH);
+typedef void (*WriteBufPtr) (ArchiveHandle *AH, const void *c, size_t len);
+typedef void (*ReadBufPtr) (ArchiveHandle *AH, void *buf, size_t len);
+typedef void (*SaveArchivePtr) (ArchiveHandle *AH);
+typedef void (*WriteExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*ReadExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*PrintExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
+typedef void (*PrintTocDataPtr) (ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
+
+typedef void (*ClonePtr) (ArchiveHandle *AH);
+typedef void (*DeClonePtr) (ArchiveHandle *AH);
+
+typedef char *(*WorkerJobRestorePtr) (ArchiveHandle *AH, TocEntry *te);
+typedef char *(*WorkerJobDumpPtr) (ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te);
+typedef char *(*MasterStartParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
T_Action act);
-typedef int (*MasterEndParallelItemPtr) (struct _archiveHandle * AH, struct _tocEntry * te,
+typedef int (*MasterEndParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
const char *str, T_Action act);
-typedef size_t (*CustomOutPtr) (struct _archiveHandle * AH, const void *buf, size_t len);
+typedef size_t (*CustomOutPtr) (ArchiveHandle *AH, const void *buf, size_t len);
typedef enum
{
@@ -210,7 +210,7 @@ typedef enum
REQ_SPECIAL = 0x04 /* for special TOC entries */
} teReqs;
-typedef struct _archiveHandle
+struct _archiveHandle
{
Archive public; /* Public part of archive */
char vmaj; /* Version of file */
@@ -284,7 +284,7 @@ typedef struct _archiveHandle
/* Stuff for direct DB connection */
char *archdbname; /* DB name *read* from archive */
- enum trivalue promptPassword;
+ trivalue promptPassword;
char *savedPassword; /* password for ropt->username, if known */
char *use_role;
PGconn *connection;
@@ -336,9 +336,9 @@ typedef struct _archiveHandle
ArchiverStage lastErrorStage;
struct _tocEntry *currentTE;
struct _tocEntry *lastErrorTE;
-} ArchiveHandle;
+};
-typedef struct _tocEntry
+struct _tocEntry
{
struct _tocEntry *prev;
struct _tocEntry *next;
@@ -376,7 +376,7 @@ typedef struct _tocEntry
int nRevDeps; /* number of such dependencies */
DumpId *lockDeps; /* dumpIds of objects this one needs lock on */
int nLockDeps; /* number of such dependencies */
-} TocEntry;
+};
extern int parallel_restore(struct ParallelArgs *args);
extern void on_exit_close_archive(Archive *AHX);
@@ -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..6f29430 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);
@@ -687,14 +687,14 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
* the process of saving it to files. No data should be written prior
* to this point, since the user could sort the TOC after creating it.
*
- * If an archive is to be written, this toutine must call:
+ * If an archive is to be written, this routine must call:
* WriteHead to save the archive header
* WriteToc to save the TOC entries
* WriteDataChunks to save all DATA & BLOBs.
*
*/
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_db.c b/src/bin/pg_dump/pg_backup_db.c
index 4d1d14f..85bf92c 100644
--- a/src/bin/pg_dump/pg_backup_db.c
+++ b/src/bin/pg_dump/pg_backup_db.c
@@ -217,7 +217,7 @@ ConnectDatabase(Archive *AHX,
const char *pghost,
const char *pgport,
const char *username,
- enum trivalue prompt_password)
+ trivalue prompt_password)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
char *password = AH->savedPassword;
diff --git a/src/bin/pg_dump/pg_backup_db.h b/src/bin/pg_dump/pg_backup_db.h
index 2eea1c3..26eaa4e 100644
--- a/src/bin/pg_dump/pg_backup_db.h
+++ b/src/bin/pg_dump/pg_backup_db.h
@@ -16,7 +16,7 @@ extern void ExecuteSqlStatement(Archive *AHX, const char *query);
extern PGresult *ExecuteSqlQuery(Archive *AHX, const char *query,
ExecStatusType status);
-extern void EndDBCopyMode(ArchiveHandle *AH, struct _tocEntry * te);
+extern void EndDBCopyMode(ArchiveHandle *AH, TocEntry *te);
extern void StartTransaction(ArchiveHandle *AH);
extern void CommitTransaction(ArchiveHandle *AH);
diff --git a/src/bin/pg_dump/pg_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..430ad41 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,16 @@ _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 +231,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 1a9e82e..53a1254 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -81,17 +81,18 @@ typedef struct
int objsubid; /* subobject (table column #) */
} SecLabelItem;
+typedef enum OidOptions
+{
+ zeroAsOpaque = 1,
+ zeroAsAny = 2,
+ zeroAsStar = 4,
+ zeroAsNone = 8
+} OidOptions;
+
/* global decls */
bool g_verbose; /* User wants verbose narration of our
* activities. */
-/* 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 +117,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 */
@@ -127,22 +126,9 @@ char g_comment_end[10];
static const CatalogId nilCatalogId = {0, 0};
-/* flags for various command-line long options */
-static int binary_upgrade = 0;
-static int disable_dollar_quoting = 0;
-static int dump_inserts = 0;
-static int column_inserts = 0;
-static int if_exists = 0;
-static int no_security_labels = 0;
-static int no_synchronized_snapshots = 0;
-static int no_unlogged_table_data = 0;
-static int serializable_deferrable = 0;
-static int enable_row_security = 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,
+ const char *dumpencoding, char *use_role);
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
static void expand_schema_name_patterns(Archive *fout,
SimpleStringList *patterns,
@@ -151,64 +137,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);
@@ -223,8 +209,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,
@@ -246,10 +232,10 @@ 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 dumpRowSecurity(Archive *fout, RowSecurityInfo *rsinfo);
-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 dumpRowSecurity(Archive *fout, DumpOptions *dopt, RowSecurityInfo *rsinfo);
+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,
@@ -266,7 +252,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
@@ -275,39 +261,27 @@ 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 optindex;
+ RestoreOptions *ropt;
+ Archive *fout; /* the script file */
+ const char *dumpencoding = NULL;
+ char *use_role = NULL;
int numWorkers = 1;
- enum trivalue prompt_password = TRI_DEFAULT;
+ 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 */
+ ArchiveMode archiveMode;
- 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'},
@@ -342,25 +316,25 @@ 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},
- {"enable-row-security", no_argument, &enable_row_security, 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},
+ {"enable-row-security", no_argument, &dopt->enable_row_security, 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}
};
@@ -379,10 +353,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 */
@@ -409,23 +379,23 @@ 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 */
@@ -441,7 +411,7 @@ main(int argc, char **argv)
break;
case 'h': /* server host */
- pghost = pg_strdup(optarg);
+ dopt->pghost = pg_strdup(optarg);
break;
case 'i':
@@ -454,7 +424,7 @@ main(int argc, char **argv)
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) */
@@ -462,15 +432,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':
@@ -478,16 +448,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) */
@@ -495,7 +465,7 @@ main(int argc, char **argv)
break;
case 'U':
- username = pg_strdup(optarg);
+ dopt->username = pg_strdup(optarg);
break;
case 'v': /* verbose */
@@ -511,7 +481,7 @@ main(int argc, char **argv)
break;
case 'x': /* skip ACL dump */
- aclsSkip = true;
+ dopt->aclsSkip = true;
break;
case 'Z': /* Compression Level */
@@ -523,7 +493,7 @@ 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 */
@@ -535,7 +505,7 @@ main(int argc, char **argv)
break;
case 5: /* section */
- set_dump_section(optarg, &dumpSections);
+ set_dump_section(optarg, &dopt->dumpSections);
break;
default:
@@ -548,8 +518,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)
@@ -562,29 +532,29 @@ 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 */
@@ -645,15 +615,15 @@ main(int argc, char **argv)
* 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, prompt_password);
+ setup_connection(fout, dopt, dumpencoding, use_role);
/*
* Disable security label support if server version < v9.1.x (prevents
* access to nonexistent pg_seclabel catalog)
*/
if (fout->remoteVersion < 90100)
- no_security_labels = 1;
+ dopt->no_security_labels = 1;
/*
* When running against 9.0 or later, check if we are in recovery mode,
@@ -669,7 +639,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);
}
@@ -684,7 +654,7 @@ main(int argc, char **argv)
/* check the version for the synchronized snapshots feature */
if (numWorkers > 1 && fout->remoteVersion < 90200
- && !no_synchronized_snapshots)
+ && !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"
@@ -734,27 +704,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);
/*
@@ -804,31 +774,37 @@ 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;
- ropt->enable_row_security = enable_row_security;
+ 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;
+ ropt->enable_row_security = dopt->enable_row_security;
if (compressLevel == -1)
ropt->compression = 0;
@@ -857,7 +833,7 @@ main(int argc, char **argv)
if (plainText)
RestoreArchive(fout);
- CloseArchive(fout);
+ CloseArchive(fout, dopt);
exit_nicely(0);
}
@@ -931,7 +907,7 @@ help(const char *progname)
}
static void
-setup_connection(Archive *AH, const char *dumpencoding, char *use_role)
+setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding, char *use_role)
{
PGconn *conn = GetConnection(AH);
const char *std_strings;
@@ -1019,7 +995,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");
@@ -1041,7 +1017,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)
{
@@ -1058,7 +1034,7 @@ setup_connection(Archive *AH, const char *dumpencoding, char *use_role)
if (AH->remoteVersion >= 90500)
{
- if (enable_row_security)
+ if (dopt->enable_row_security)
ExecuteSqlStatement(AH, "SET row_security TO ON");
else
ExecuteSqlStatement(AH, "SET row_security TO OFF");
@@ -1066,9 +1042,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, NULL, NULL);
}
static char *
@@ -1339,12 +1315,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;
}
/*
@@ -1358,12 +1334,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;
}
/*
@@ -1392,7 +1368,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;
@@ -1567,7 +1543,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;
@@ -1636,7 +1612,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++)
@@ -1753,7 +1729,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();
@@ -1761,7 +1737,7 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
DataDumperPtr dumpFn;
char *copyStmt;
- if (!dump_inserts)
+ if (!dopt->dump_inserts)
{
/* Dump/restore using COPY */
dumpFn = dumpTableData_copy;
@@ -1845,14 +1821,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);
}
}
@@ -1863,7 +1839,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;
@@ -1883,7 +1859,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 */
@@ -2156,7 +2132,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();
@@ -2318,7 +2294,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"
@@ -2357,7 +2333,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();
@@ -2475,14 +2451,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();
@@ -2503,7 +2479,6 @@ dumpDatabase(Archive *fout)
destroyPQExpBuffer(creaQry);
}
-
/*
* dumpEncoding: put the correct encoding into the archive
*/
@@ -2643,7 +2618,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();
@@ -2670,18 +2645,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);
@@ -2694,7 +2669,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;
@@ -2922,14 +2897,14 @@ getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables)
* dump the definition of the given row-security policy
*/
static void
-dumpRowSecurity(Archive *fout, RowSecurityInfo *rsinfo)
+dumpRowSecurity(Archive *fout, DumpOptions *dopt, RowSecurityInfo *rsinfo)
{
TableInfo *tbinfo = rsinfo->rstable;
PQExpBuffer query;
PQExpBuffer delqry;
const char *cmd;
- if (dataOnly)
+ if (dopt->dataOnly)
return;
/*
@@ -3343,7 +3318,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;
@@ -3407,7 +3382,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);
@@ -4158,7 +4133,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;
@@ -4197,7 +4172,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 "
@@ -4337,7 +4312,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;
@@ -4394,7 +4369,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 "
@@ -4520,7 +4495,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;
@@ -5071,7 +5046,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.
@@ -5082,7 +5057,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);
}
@@ -5178,7 +5153,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");
}
@@ -6593,7 +6568,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;
@@ -6948,7 +6923,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;
@@ -7161,9 +7136,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]);
}
@@ -7709,7 +7684,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;
@@ -7778,7 +7753,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);
@@ -7807,7 +7782,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)
{
@@ -7817,12 +7792,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;
}
@@ -7871,7 +7846,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;
@@ -7880,7 +7855,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 */
@@ -8125,108 +8100,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,
@@ -8237,7 +8212,7 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj)
dumpBlobs, NULL);
break;
case DO_ROW_SECURITY:
- dumpRowSecurity(fout, (RowSecurityInfo *) dobj);
+ dumpRowSecurity(fout, dopt, (RowSecurityInfo *) dobj);
break;
case DO_PRE_DATA_BOUNDARY:
case DO_POST_DATA_BOUNDARY:
@@ -8251,7 +8226,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;
@@ -8259,7 +8234,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 */
@@ -8278,7 +8253,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,
@@ -8291,14 +8266,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);
@@ -8314,7 +8289,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;
@@ -8322,7 +8297,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();
@@ -8333,7 +8308,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
@@ -8419,10 +8394,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);
@@ -8438,23 +8413,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);
@@ -8465,7 +8440,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();
@@ -8510,14 +8485,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++)
@@ -8532,7 +8507,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++)
@@ -8556,7 +8531,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,
@@ -8570,14 +8545,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);
@@ -8594,7 +8569,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();
@@ -8640,7 +8615,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);
@@ -8688,7 +8663,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,
@@ -8702,14 +8677,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);
@@ -8726,7 +8701,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();
@@ -8980,7 +8955,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);
@@ -9078,7 +9053,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,
@@ -9092,14 +9067,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);
@@ -9116,7 +9091,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();
@@ -9176,7 +9151,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);
@@ -9240,7 +9215,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,
@@ -9254,14 +9229,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);
@@ -9278,7 +9253,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();
@@ -9355,7 +9330,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));
@@ -9386,7 +9361,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 */
@@ -9454,7 +9429,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,
@@ -9469,14 +9444,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);
@@ -9607,12 +9582,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();
@@ -9626,7 +9601,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);
@@ -9662,12 +9637,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;
}
@@ -9678,7 +9653,7 @@ shouldDumpProcLangs(void)
* procedural language
*/
static void
-dumpProcLang(Archive *fout, ProcLangInfo *plang)
+dumpProcLang(Archive *fout, DumpOptions *dopt, ProcLangInfo *plang)
{
PQExpBuffer defqry;
PQExpBuffer delqry;
@@ -9691,7 +9666,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;
/*
@@ -9737,7 +9712,7 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
if (!plang->dobj.ext_member)
{
- if (!useParams && !shouldDumpProcLangs())
+ if (!useParams && !shouldDumpProcLangs(dopt))
return;
}
@@ -9804,7 +9779,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,
@@ -9816,15 +9791,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);
@@ -9971,7 +9946,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;
@@ -10010,7 +9985,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();
@@ -10203,7 +10178,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
@@ -10216,7 +10191,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);
@@ -10392,7 +10367,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,
@@ -10406,14 +10381,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);
@@ -10444,7 +10419,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;
@@ -10452,7 +10427,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 */
@@ -10566,7 +10541,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,
@@ -10578,7 +10553,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);
@@ -10592,7 +10567,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;
@@ -10626,7 +10601,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;
/*
@@ -10816,7 +10791,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,
@@ -10830,7 +10805,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);
@@ -10980,7 +10955,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;
@@ -11024,7 +10999,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;
/*
@@ -11324,7 +11299,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,
@@ -11338,7 +11313,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);
@@ -11357,7 +11332,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;
@@ -11391,7 +11366,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;
/*
@@ -11637,7 +11612,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,
@@ -11651,7 +11626,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);
@@ -11669,7 +11644,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;
@@ -11682,7 +11657,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();
@@ -11726,7 +11701,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,
@@ -11740,7 +11715,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);
@@ -11757,7 +11732,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;
@@ -11774,7 +11749,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();
@@ -11825,7 +11800,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,
@@ -11839,7 +11814,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);
@@ -11896,7 +11871,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;
@@ -11942,7 +11917,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();
@@ -12221,7 +12196,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,
@@ -12235,10 +12210,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);
@@ -12253,7 +12228,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,
@@ -12278,14 +12253,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();
@@ -12321,7 +12296,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,
@@ -12335,7 +12310,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);
@@ -12349,7 +12324,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;
@@ -12360,7 +12335,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();
@@ -12408,7 +12383,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,
@@ -12422,7 +12397,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);
@@ -12437,14 +12412,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();
@@ -12474,7 +12449,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,
@@ -12488,7 +12463,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);
@@ -12502,7 +12477,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;
@@ -12517,7 +12492,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();
@@ -12602,7 +12577,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,
@@ -12616,7 +12591,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);
@@ -12631,7 +12606,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;
@@ -12639,7 +12614,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;
/*
@@ -12647,7 +12622,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();
@@ -12676,7 +12651,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,
@@ -12690,14 +12665,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);
@@ -12713,7 +12688,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;
@@ -12724,7 +12699,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();
@@ -12768,7 +12743,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,
@@ -12782,7 +12757,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,
@@ -12795,7 +12770,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);
@@ -12911,14 +12886,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();
@@ -12991,7 +12966,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)
@@ -12999,11 +12974,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();
@@ -13046,7 +13021,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)
{
@@ -13056,18 +13031,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;
}
@@ -13110,7 +13085,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;
@@ -13119,11 +13094,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 */
@@ -13331,20 +13306,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,
@@ -13379,7 +13354,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);
@@ -13456,7 +13431,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();
@@ -13474,7 +13449,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);
@@ -13494,7 +13469,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);
@@ -13574,7 +13549,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);
@@ -13588,7 +13563,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)
@@ -13603,7 +13578,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.
@@ -13617,11 +13592,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 */
@@ -13649,7 +13624,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
}
/* Attribute type */
- if (tbinfo->reloftype && !binary_upgrade)
+ if (tbinfo->reloftype && !dopt->binary_upgrade)
{
appendPQExpBufferStr(q, " WITH OPTIONS");
}
@@ -13714,7 +13689,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
@@ -13723,7 +13698,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++)
@@ -13796,7 +13771,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++)
@@ -13912,7 +13887,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");
@@ -13938,7 +13913,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 ",
@@ -14052,7 +14027,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,
@@ -14069,10 +14044,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++)
@@ -14082,7 +14057,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (constr->separate || !constr->conislocal)
continue;
- dumpTableConstraintComment(fout, constr);
+ dumpTableConstraintComment(fout, dopt, constr);
}
destroyPQExpBuffer(q);
@@ -14094,7 +14069,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;
@@ -14102,7 +14077,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 */
@@ -14181,7 +14156,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);
@@ -14189,7 +14164,7 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
PQExpBuffer delq;
PQExpBuffer labelq;
- if (dataOnly)
+ if (dopt->dataOnly)
return;
q = createPQExpBuffer();
@@ -14208,7 +14183,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);
@@ -14254,7 +14229,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,
@@ -14271,14 +14246,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();
@@ -14298,7 +14273,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);
@@ -14488,7 +14463,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);
@@ -14502,7 +14477,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();
@@ -14511,7 +14486,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,
@@ -14571,7 +14546,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,
@@ -14667,7 +14642,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);
@@ -14704,7 +14679,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);
@@ -14757,10 +14732,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);
@@ -14831,7 +14806,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;
@@ -14846,7 +14821,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();
@@ -15027,7 +15002,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);
@@ -15041,13 +15016,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();
@@ -15099,7 +15074,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);
@@ -15112,7 +15087,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;
@@ -15122,7 +15097,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;
/*
@@ -15227,7 +15202,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);
@@ -15244,7 +15219,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;
@@ -15341,7 +15316,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;
@@ -15420,7 +15395,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 fd1184e..ba25004 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -16,48 +16,14 @@
#include "postgres_fe.h"
-/*
- * pg_dump uses two different mechanisms for identifying database objects:
- *
- * CatalogId represents an object by the tableoid and oid of its defining
- * entry in the system catalogs. We need this to interpret pg_depend entries,
- * for instance.
- *
- * DumpId is a simple sequential integer counter assigned as dumpable objects
- * are identified during a pg_dump run. We use DumpId internally in preference
- * to CatalogId for two reasons: it's more compact, and we can assign DumpIds
- * to "objects" that don't have a separate CatalogId. For example, it is
- * convenient to consider a table, its data, and its ACL as three separate
- * dumpable "objects" with distinct DumpIds --- this lets us reason about the
- * order in which to dump these things.
- */
-
-typedef struct
-{
- Oid tableoid;
- Oid oid;
-} CatalogId;
-
-typedef int DumpId;
-
-/*
- * Data structures for simple lists of OIDs and strings. The support for
- * these is very primitive compared to the backend's List facilities, but
- * it's all we need in pg_dump.
- */
-
-typedef struct SimpleOidListCell
-{
- struct SimpleOidListCell *next;
- Oid val;
-} SimpleOidListCell;
+#include "pg_backup.h"
-typedef struct SimpleOidList
-{
- SimpleOidListCell *head;
- SimpleOidListCell *tail;
-} SimpleOidList;
+#define oidcmp(x,y) ( ((x) < (y) ? -1 : ((x) > (y)) ? 1 : 0) )
+#define oideq(x,y) ( (x) == (y) )
+#define oidle(x,y) ( (x) <= (y) )
+#define oidge(x,y) ( (x) >= (y) )
+#define oidzero(x) ( (x) == 0 )
/*
* The data structures used to store system catalog information. Every
@@ -519,18 +485,7 @@ extern char g_opaque_type[10]; /* name for the opaque type */
* common utility functions
*/
-struct Archive;
-typedef struct Archive Archive;
-
-extern TableInfo *getSchemaData(Archive *, int *numTablesPtr);
-
-typedef enum _OidOptions
-{
- zeroAsOpaque = 1,
- zeroAsAny = 2,
- zeroAsStar = 4,
- zeroAsNone = 8
-} OidOptions;
+extern TableInfo *getSchemaData(Archive *, DumpOptions *dopt, int *numTablesPtr);
extern void AssignDumpId(DumpableObject *dobj);
extern DumpId createDumpId(void);
@@ -564,16 +519,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, 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, DumpOptions *dopt, int *numFuncs);
+extern AggInfo *getAggregates(Archive *fout, DumpOptions *dopt, int *numAggregates);
extern OprInfo *getOperators(Archive *fout, int *numOperators);
extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses);
extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(Archive *fout, int *numConversions);
-extern TableInfo *getTables(Archive *fout, int *numTables);
+extern TableInfo *getTables(Archive *fout, DumpOptions *dopt, int *numTables);
extern void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables);
@@ -582,8 +537,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, DumpOptions *dopt, TableInfo *tbinfo, int numTables);
+extern bool shouldPrintColumn(DumpOptions *dopt, TableInfo *tbinfo, int colno);
extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers);
extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts);
extern TSTemplateInfo *getTSTemplates(Archive *fout, int *numTSTemplates);
@@ -592,8 +547,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, DumpOptions *dopt, int *numDefaultACLs);
+extern void getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[],
int numExtensions);
extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
extern void getRowSecurity(Archive *fout, TableInfo tblinfo[], int numTables);
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index c25ea85..6d72ef9 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -57,7 +57,7 @@ static void buildShSecLabels(PGconn *conn, const char *catalog_name,
uint32 objectId, PQExpBuffer buffer,
const char *target, const char *objname);
static PGconn *connectDatabase(const char *dbname, const char *connstr, const char *pghost, const char *pgport,
- const char *pguser, enum trivalue prompt_password, bool fail_on_error);
+ const char *pguser, trivalue prompt_password, bool fail_on_error);
static char *constructConnStr(const char **keywords, const char **values);
static PGresult *executeQuery(PGconn *conn, const char *query);
static void executeCommand(PGconn *conn, const char *query);
@@ -138,7 +138,7 @@ main(int argc, char *argv[])
char *pguser = NULL;
char *pgdb = NULL;
char *use_role = NULL;
- enum trivalue prompt_password = TRI_DEFAULT;
+ trivalue prompt_password = TRI_DEFAULT;
bool data_only = false;
bool globals_only = false;
bool output_clean = false;
@@ -1765,7 +1765,7 @@ buildShSecLabels(PGconn *conn, const char *catalog_name, uint32 objectId,
static PGconn *
connectDatabase(const char *dbname, const char *connection_string,
const char *pghost, const char *pgport, const char *pguser,
- enum trivalue prompt_password, bool fail_on_error)
+ trivalue prompt_password, bool fail_on_error)
{
PGconn *conn;
bool new_pass;
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 21715dc..f954b3c 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -423,7 +423,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;
}
On Sat, Oct 11, 2014 at 2:56 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
Here's the complete patch in case anyone is wondering.
Hi,
Your patch doesn't apply to master:
$ git apply ~/Downloads/pg_dump_refactor_globals.6.diff
/home/fabrizio/Downloads/pg_dump_refactor_globals.6.diff:10: trailing
whitespace.
static void flagInhAttrs(DumpOptions *dopt, TableInfo *tblinfo, int
numTables);
/home/fabrizio/Downloads/pg_dump_refactor_globals.6.diff:19: trailing
whitespace.
getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
/home/fabrizio/Downloads/pg_dump_refactor_globals.6.diff:28: trailing
whitespace.
tblinfo = getTables(fout, dopt, &numTables);
/home/fabrizio/Downloads/pg_dump_refactor_globals.6.diff:37: trailing
whitespace.
extinfo = getExtensions(fout, dopt, &numExtensions);
/home/fabrizio/Downloads/pg_dump_refactor_globals.6.diff:42: trailing
whitespace.
funinfo = getFuncs(fout, dopt, &numFuncs);
error: patch failed: src/bin/pg_dump/common.c:64
error: src/bin/pg_dump/common.c: patch does not apply
error: patch failed: src/bin/pg_dump/dumputils.h:19
error: src/bin/pg_dump/dumputils.h: patch does not apply
error: patch failed: src/bin/pg_dump/parallel.c:89
error: src/bin/pg_dump/parallel.c: patch does not apply
error: patch failed: src/bin/pg_dump/parallel.h:19
error: src/bin/pg_dump/parallel.h: patch does not apply
error: patch failed: src/bin/pg_dump/pg_backup.h:25
error: src/bin/pg_dump/pg_backup.h: patch does not apply
error: patch failed: src/bin/pg_dump/pg_backup_archiver.c:107
error: src/bin/pg_dump/pg_backup_archiver.c: patch does not apply
error: patch failed: src/bin/pg_dump/pg_backup_archiver.h:29
error: src/bin/pg_dump/pg_backup_archiver.h: patch does not apply
error: patch failed: src/bin/pg_dump/pg_backup_custom.c:41
error: src/bin/pg_dump/pg_backup_custom.c: patch does not apply
error: patch failed: src/bin/pg_dump/pg_backup_db.c:217
error: src/bin/pg_dump/pg_backup_db.c: patch does not apply
error: patch failed: src/bin/pg_dump/pg_backup_db.h:16
error: src/bin/pg_dump/pg_backup_db.h: patch does not apply
error: patch failed: src/bin/pg_dump/pg_backup_directory.c:71
error: src/bin/pg_dump/pg_backup_directory.c: patch does not apply
error: patch failed: src/bin/pg_dump/pg_backup_null.c:35
error: src/bin/pg_dump/pg_backup_null.c: patch does not apply
error: patch failed: src/bin/pg_dump/pg_backup_tar.c:48
error: src/bin/pg_dump/pg_backup_tar.c: patch does not apply
error: patch failed: src/bin/pg_dump/pg_dump.c:81
error: src/bin/pg_dump/pg_dump.c: patch does not apply
error: patch failed: src/bin/pg_dump/pg_dump.h:16
error: src/bin/pg_dump/pg_dump.h: patch does not apply
error: patch failed: src/bin/pg_dump/pg_dumpall.c:57
error: src/bin/pg_dump/pg_dumpall.c: patch does not apply
error: patch failed: src/bin/pg_dump/pg_restore.c:423
error: src/bin/pg_dump/pg_restore.c: patch does not apply
Regards,
--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
Show quoted text
Timbira: http://www.timbira.com.br
Blog: http://fabriziomello.github.io
Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello
Github: http://github.com/fabriziomello
Fabrízio de Royes Mello wrote:
On Sat, Oct 11, 2014 at 2:56 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:Here's the complete patch in case anyone is wondering.
Hi,
Your patch doesn't apply to master:
I think your email system mangled it. I can download it from archives
and apply it just fine:
$ wget /messages/by-id/attachment/35216/pg_dump_refactor_globals.6.diff -O - | patch -p1
--2014-10-11 20:44:52-- /messages/by-id/attachment/35216/pg_dump_refactor_globals.6.diff
Resolviendo www.postgresql.org (www.postgresql.org)... 87.238.57.232, 174.143.35.230, 217.196.149.50, ...
Conectando con www.postgresql.org (www.postgresql.org)[87.238.57.232]:80... conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: no especificado [text/x-diff]
Grabando a: “STDOUT”
[ <=> ] 140.127 105K/s en 1,3s
2014-10-11 20:44:55 (105 KB/s) - escritos a stdout [140127]
patching file src/bin/pg_dump/common.c
patching file src/bin/pg_dump/dumputils.h
patching file src/bin/pg_dump/parallel.c
patching file src/bin/pg_dump/parallel.h
patching file src/bin/pg_dump/pg_backup.h
patching file src/bin/pg_dump/pg_backup_archiver.c
patching file src/bin/pg_dump/pg_backup_archiver.h
patching file src/bin/pg_dump/pg_backup_custom.c
patching file src/bin/pg_dump/pg_backup_db.c
patching file src/bin/pg_dump/pg_backup_db.h
patching file src/bin/pg_dump/pg_backup_directory.c
patching file src/bin/pg_dump/pg_backup_null.c
patching file src/bin/pg_dump/pg_backup_tar.c
patching file src/bin/pg_dump/pg_dump.c
patching file src/bin/pg_dump/pg_dump.h
patching file src/bin/pg_dump/pg_dumpall.c
patching file src/bin/pg_dump/pg_restore.c
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Sat, Oct 11, 2014 at 10:15 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
Fabrízio de Royes Mello wrote:
On Sat, Oct 11, 2014 at 2:56 PM, Alvaro Herrera <
alvherre@2ndquadrant.com>
wrote:
Here's the complete patch in case anyone is wondering.
Hi,
Your patch doesn't apply to master:
I think your email system mangled it. I can download it from archives
and apply it just fine:$ wget
/messages/by-id/attachment/35216/pg_dump_refactor_globals.6.diff
-O - | patch -p1
--2014-10-11 20:44:52--
/messages/by-id/attachment/35216/pg_dump_refactor_globals.6.diff
Resolviendo www.postgresql.org (www.postgresql.org)... 87.238.57.232,
174.143.35.230, 217.196.149.50, ...
Conectando con www.postgresql.org (www.postgresql.org)[87.238.57.232]:80...
conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: no especificado [text/x-diff]
Grabando a: “STDOUT”[ <=> ] 140.127 105K/s en 1,3s
2014-10-11 20:44:55 (105 KB/s) - escritos a stdout [140127]
patching file src/bin/pg_dump/common.c
patching file src/bin/pg_dump/dumputils.h
patching file src/bin/pg_dump/parallel.c
patching file src/bin/pg_dump/parallel.h
patching file src/bin/pg_dump/pg_backup.h
patching file src/bin/pg_dump/pg_backup_archiver.c
patching file src/bin/pg_dump/pg_backup_archiver.h
patching file src/bin/pg_dump/pg_backup_custom.c
patching file src/bin/pg_dump/pg_backup_db.c
patching file src/bin/pg_dump/pg_backup_db.h
patching file src/bin/pg_dump/pg_backup_directory.c
patching file src/bin/pg_dump/pg_backup_null.c
patching file src/bin/pg_dump/pg_backup_tar.c
patching file src/bin/pg_dump/pg_dump.c
patching file src/bin/pg_dump/pg_dump.h
patching file src/bin/pg_dump/pg_dumpall.c
patching file src/bin/pg_dump/pg_restore.c
Yeah... my gmail mangled the attached file.
Thanks and sorry by the noise.
I'll see the changes.
Regards.
--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
Show quoted text
Timbira: http://www.timbira.com.br
Blog: http://fabriziomello.github.io
Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello
Github: http://github.com/fabriziomello
Alvaro Herrera wrote:
Here's the complete patch in case anyone is wondering.
I found out that with just a little bit of extra header hacking, the
whole thing ends up cleaner -- for instance, with the attached patch,
pg_backup_archiver.h is no longer needed by pg_backup_db.h. I also
tweaked things so that no .h file includes postgres_fe.h, but instead
every .c file includes it before including anything else, as is already
customary for postgres.h in backend code.
The main changes herein are:
* some routines in pg_backup_db.c/h had an argument of type
ArchiveHandle. I made them take Archive instead, and cast internally.
This is already done for some other routines.
* also in pg_backup_db.c/h, EndDBCopyMode() had an argument of type
TocEntry, and then it only uses te->tag for an error message. If I
instead pass the te->tag I can remove the TocEntry, and there is no more
need for pg_backup_archiver.h in pg_backup_db.h.
* I moved exit_horribly() from parallel.h to pg_backup_utils.h, where
prototypes for other exit routines such as exit_nicely() are already
located. (The implementation of exit_horribly() is in parallel.c, but
the prototype looks misplaced in parallel.h.)
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachments:
pg_dump_headers.patchtext/x-diff; charset=us-asciiDownload
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 17e9574..8bfc604 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -13,8 +13,11 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
+
#include "pg_backup_archiver.h"
#include "pg_backup_utils.h"
+#include "pg_dump.h"
#include <ctype.h>
diff --git a/src/bin/pg_dump/compress_io.c b/src/bin/pg_dump/compress_io.c
index 2e2a447..2c568cd 100644
--- a/src/bin/pg_dump/compress_io.c
+++ b/src/bin/pg_dump/compress_io.c
@@ -51,10 +51,11 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
#include "compress_io.h"
-#include "pg_backup_utils.h"
#include "parallel.h"
+#include "pg_backup_utils.h"
/*----------------------
* Compressor API
diff --git a/src/bin/pg_dump/compress_io.h b/src/bin/pg_dump/compress_io.h
index 713c78b..5a21450 100644
--- a/src/bin/pg_dump/compress_io.h
+++ b/src/bin/pg_dump/compress_io.h
@@ -15,7 +15,6 @@
#ifndef __COMPRESS_IO__
#define __COMPRESS_IO__
-#include "postgres_fe.h"
#include "pg_backup_archiver.h"
/* Initial buffer sizes used in zlib compression. */
diff --git a/src/bin/pg_dump/dumputils.h b/src/bin/pg_dump/dumputils.h
index 06763ed..688e9ca 100644
--- a/src/bin/pg_dump/dumputils.h
+++ b/src/bin/pg_dump/dumputils.h
@@ -12,7 +12,6 @@
*
*-------------------------------------------------------------------------
*/
-
#ifndef DUMPUTILS_H
#define DUMPUTILS_H
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
index ceed115..3b8d584 100644
--- a/src/bin/pg_dump/parallel.c
+++ b/src/bin/pg_dump/parallel.c
@@ -18,8 +18,8 @@
#include "postgres_fe.h"
-#include "pg_backup_utils.h"
#include "parallel.h"
+#include "pg_backup_utils.h"
#ifndef WIN32
#include <sys/types.h>
diff --git a/src/bin/pg_dump/parallel.h b/src/bin/pg_dump/parallel.h
index 744c76b..dd3546f 100644
--- a/src/bin/pg_dump/parallel.h
+++ b/src/bin/pg_dump/parallel.h
@@ -86,8 +86,4 @@ extern void ParallelBackupEnd(ArchiveHandle *AH, ParallelState *pstate);
extern void checkAborting(ArchiveHandle *AH);
-extern void
-exit_horribly(const char *modulename, const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3), noreturn));
-
#endif /* PG_DUMP_PARALLEL_H */
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index 37fdd8c..c2ebcd4 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -23,10 +23,7 @@
#ifndef PG_BACKUP_H
#define PG_BACKUP_H
-#include "postgres_fe.h"
-
#include "dumputils.h"
-
#include "libpq-fe.h"
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 71ac6e5..95cb6e8 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -19,10 +19,12 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
+#include "parallel.h"
+#include "pg_backup_archiver.h"
#include "pg_backup_db.h"
#include "pg_backup_utils.h"
-#include "parallel.h"
#include <ctype.h>
#include <fcntl.h>
@@ -424,7 +426,7 @@ RestoreArchive(Archive *AHX)
if (ropt->single_txn)
{
if (AH->connection)
- StartTransaction(AH);
+ StartTransaction(AHX);
else
ahprintf(AH, "BEGIN;\n\n");
}
@@ -642,7 +644,7 @@ RestoreArchive(Archive *AHX)
if (ropt->single_txn)
{
if (AH->connection)
- CommitTransaction(AH);
+ CommitTransaction(AHX);
else
ahprintf(AH, "COMMIT;\n\n");
}
@@ -823,7 +825,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
* Parallel restore is always talking directly to a
* server, so no need to see if we should issue BEGIN.
*/
- StartTransaction(AH);
+ StartTransaction(&AH->public);
/*
* If the server version is >= 8.4, make sure we issue
@@ -854,12 +856,12 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
*/
if (AH->outputKind == OUTPUT_COPYDATA &&
RestoringToDB(AH))
- EndDBCopyMode(AH, te);
+ EndDBCopyMode(&AH->public, te->tag);
AH->outputKind = OUTPUT_SQLCMDS;
/* close out the transaction started above */
if (is_parallel && te->created)
- CommitTransaction(AH);
+ CommitTransaction(&AH->public);
_enableTriggersIfNecessary(AH, te, ropt);
}
@@ -1155,7 +1157,7 @@ StartRestoreBlobs(ArchiveHandle *AH)
if (!AH->ropt->single_txn)
{
if (AH->connection)
- StartTransaction(AH);
+ StartTransaction(&AH->public);
else
ahprintf(AH, "BEGIN;\n\n");
}
@@ -1172,7 +1174,7 @@ EndRestoreBlobs(ArchiveHandle *AH)
if (!AH->ropt->single_txn)
{
if (AH->connection)
- CommitTransaction(AH);
+ CommitTransaction(&AH->public);
else
ahprintf(AH, "COMMIT;\n\n");
}
@@ -1629,7 +1631,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
* connected then send it to the DB.
*/
if (RestoringToDB(AH))
- bytes_written = ExecuteSqlCommandBuf(AH, (const char *) ptr, size * nmemb);
+ bytes_written = ExecuteSqlCommandBuf(&AH->public, (const char *) ptr, size * nmemb);
else
bytes_written = fwrite(ptr, size, nmemb, AH->OF) * size;
}
diff --git a/src/bin/pg_dump/pg_backup_archiver.h b/src/bin/pg_dump/pg_backup_archiver.h
index 59c7721..144027c 100644
--- a/src/bin/pg_dump/pg_backup_archiver.h
+++ b/src/bin/pg_dump/pg_backup_archiver.h
@@ -21,15 +21,12 @@
*
*-------------------------------------------------------------------------
*/
-
#ifndef __PG_BACKUP_ARCHIVE__
#define __PG_BACKUP_ARCHIVE__
-#include "postgres_fe.h"
#include <time.h>
-#include "pg_dump.h"
#include "pg_backup.h"
#include "libpq-fe.h"
diff --git a/src/bin/pg_dump/pg_backup_custom.c b/src/bin/pg_dump/pg_backup_custom.c
index 6f29430..ee05380 100644
--- a/src/bin/pg_dump/pg_backup_custom.c
+++ b/src/bin/pg_dump/pg_backup_custom.c
@@ -23,6 +23,7 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
#include "compress_io.h"
#include "parallel.h"
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c
index 85bf92c..07313f4 100644
--- a/src/bin/pg_dump/pg_backup_db.c
+++ b/src/bin/pg_dump/pg_backup_db.c
@@ -9,11 +9,12 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
+#include "dumputils.h"
+#include "pg_backup_archiver.h"
#include "pg_backup_db.h"
#include "pg_backup_utils.h"
-#include "dumputils.h"
-#include "parallel.h"
#include <unistd.h>
#include <ctype.h>
@@ -500,8 +501,10 @@ ExecuteSimpleCommands(ArchiveHandle *AH, const char *buf, size_t bufLen)
* Implement ahwrite() for direct-to-DB restore
*/
int
-ExecuteSqlCommandBuf(ArchiveHandle *AH, const char *buf, size_t bufLen)
+ExecuteSqlCommandBuf(Archive *AHX, const char *buf, size_t bufLen)
{
+ ArchiveHandle *AH = (ArchiveHandle *) AHX;
+
if (AH->outputKind == OUTPUT_COPYDATA)
{
/*
@@ -553,8 +556,10 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, const char *buf, size_t bufLen)
* Terminate a COPY operation during direct-to-DB restore
*/
void
-EndDBCopyMode(ArchiveHandle *AH, TocEntry *te)
+EndDBCopyMode(Archive *AHX, const char *tocEntryTag)
{
+ ArchiveHandle *AH = (ArchiveHandle *) AHX;
+
if (AH->pgCopyIn)
{
PGresult *res;
@@ -567,7 +572,7 @@ EndDBCopyMode(ArchiveHandle *AH, TocEntry *te)
res = PQgetResult(AH->connection);
if (PQresultStatus(res) != PGRES_COMMAND_OK)
warn_or_exit_horribly(AH, modulename, "COPY failed for table \"%s\": %s",
- te->tag, PQerrorMessage(AH->connection));
+ tocEntryTag, PQerrorMessage(AH->connection));
PQclear(res);
AH->pgCopyIn = false;
@@ -575,14 +580,18 @@ EndDBCopyMode(ArchiveHandle *AH, TocEntry *te)
}
void
-StartTransaction(ArchiveHandle *AH)
+StartTransaction(Archive *AHX)
{
+ ArchiveHandle *AH = (ArchiveHandle *) AHX;
+
ExecuteSqlCommand(AH, "BEGIN", "could not start database transaction");
}
void
-CommitTransaction(ArchiveHandle *AH)
+CommitTransaction(Archive *AHX)
{
+ ArchiveHandle *AH = (ArchiveHandle *) AHX;
+
ExecuteSqlCommand(AH, "COMMIT", "could not commit database transaction");
}
diff --git a/src/bin/pg_dump/pg_backup_db.h b/src/bin/pg_dump/pg_backup_db.h
index 26eaa4e..6408f14 100644
--- a/src/bin/pg_dump/pg_backup_db.h
+++ b/src/bin/pg_dump/pg_backup_db.h
@@ -8,17 +8,18 @@
#ifndef PG_BACKUP_DB_H
#define PG_BACKUP_DB_H
-#include "pg_backup_archiver.h"
+#include "pg_backup.h"
-extern int ExecuteSqlCommandBuf(ArchiveHandle *AH, const char *buf, size_t bufLen);
+
+extern int ExecuteSqlCommandBuf(Archive *AHX, const char *buf, size_t bufLen);
extern void ExecuteSqlStatement(Archive *AHX, const char *query);
extern PGresult *ExecuteSqlQuery(Archive *AHX, const char *query,
ExecStatusType status);
-extern void EndDBCopyMode(ArchiveHandle *AH, TocEntry *te);
+extern void EndDBCopyMode(Archive *AHX, const char *tocEntryTag);
-extern void StartTransaction(ArchiveHandle *AH);
-extern void CommitTransaction(ArchiveHandle *AH);
+extern void StartTransaction(Archive *AHX);
+extern void CommitTransaction(Archive *AHX);
#endif
diff --git a/src/bin/pg_dump/pg_backup_directory.c b/src/bin/pg_dump/pg_backup_directory.c
index 01b0e97..4c8cd40 100644
--- a/src/bin/pg_dump/pg_backup_directory.c
+++ b/src/bin/pg_dump/pg_backup_directory.c
@@ -32,10 +32,11 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
#include "compress_io.h"
-#include "pg_backup_utils.h"
#include "parallel.h"
+#include "pg_backup_utils.h"
#include <dirent.h>
#include <sys/stat.h>
diff --git a/src/bin/pg_dump/pg_backup_null.c b/src/bin/pg_dump/pg_backup_null.c
index 430ad41..716cb18 100644
--- a/src/bin/pg_dump/pg_backup_null.c
+++ b/src/bin/pg_dump/pg_backup_null.c
@@ -21,12 +21,10 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
#include "pg_backup_archiver.h"
#include "pg_backup_utils.h"
-#include "parallel.h"
-
-#include <unistd.h> /* for dup */
#include "libpq/libpq-fs.h"
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index 1c5056c..f48d369 100644
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -27,12 +27,11 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
-#include "pg_backup.h"
#include "pg_backup_archiver.h"
#include "pg_backup_tar.h"
#include "pg_backup_utils.h"
-#include "parallel.h"
#include "pgtar.h"
#include <sys/stat.h>
diff --git a/src/bin/pg_dump/pg_backup_utils.c b/src/bin/pg_dump/pg_backup_utils.c
index a9a0396..0d7c6db 100644
--- a/src/bin/pg_dump/pg_backup_utils.c
+++ b/src/bin/pg_dump/pg_backup_utils.c
@@ -14,7 +14,6 @@
#include "postgres_fe.h"
#include "pg_backup_utils.h"
-#include "parallel.h"
/* Globals exported by this file */
const char *progname = NULL;
diff --git a/src/bin/pg_dump/pg_backup_utils.h b/src/bin/pg_dump/pg_backup_utils.h
index 9af6d6f..22903a4 100644
--- a/src/bin/pg_dump/pg_backup_utils.h
+++ b/src/bin/pg_dump/pg_backup_utils.h
@@ -37,4 +37,8 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0)));
extern void on_exit_nicely(on_exit_nicely_callback function, void *arg);
extern void exit_nicely(int code) __attribute__((noreturn));
+extern void
+exit_horribly(const char *modulename, const char *fmt,...)
+__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3), noreturn));
+
#endif /* PG_BACKUP_UTILS_H */
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 53a1254..66b1407 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -29,7 +29,6 @@
*
*-------------------------------------------------------------------------
*/
-
#include "postgres_fe.h"
#include <unistd.h>
@@ -49,7 +48,6 @@
#include "catalog/pg_cast.h"
#include "catalog/pg_class.h"
#include "catalog/pg_default_acl.h"
-#include "catalog/pg_event_trigger.h"
#include "catalog/pg_largeobject.h"
#include "catalog/pg_largeobject_metadata.h"
#include "catalog/pg_proc.h"
@@ -57,11 +55,11 @@
#include "catalog/pg_type.h"
#include "libpq/libpq-fs.h"
-#include "pg_backup_archiver.h"
-#include "pg_backup_db.h"
-#include "pg_backup_utils.h"
#include "dumputils.h"
#include "parallel.h"
+#include "pg_backup_db.h"
+#include "pg_backup_utils.h"
+#include "pg_dump.h"
typedef struct
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index ba25004..10ae87a 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -14,8 +14,6 @@
#ifndef PG_DUMP_H
#define PG_DUMP_H
-#include "postgres_fe.h"
-
#include "pg_backup.h"
diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c
index 90aedee..030bccc 100644
--- a/src/bin/pg_dump/pg_dump_sort.c
+++ b/src/bin/pg_dump/pg_dump_sort.c
@@ -13,9 +13,11 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
+
#include "pg_backup_archiver.h"
#include "pg_backup_utils.h"
-#include "parallel.h"
+#include "pg_dump.h"
/* translator: this is a module name */
static const char *modulename = gettext_noop("sorter");
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index f954b3c..9c6e533 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -38,12 +38,13 @@
*
*-------------------------------------------------------------------------
*/
+#include "postgres_fe.h"
+
+#include "getopt_long.h"
-#include "pg_backup_archiver.h"
-#include "pg_backup_utils.h"
#include "dumputils.h"
#include "parallel.h"
-#include "getopt_long.h"
+#include "pg_backup_utils.h"
#include <ctype.h>
I have pushed this, thanks.
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers