Commit 5b5fea2a authored by Tom Lane's avatar Tom Lane

Access pg_dump's options structs through Archive struct, not directly.

Rather than passing around DumpOptions and RestoreOptions as separate
arguments, add fields to struct Archive to carry pointers to these objects,
and access them through those fields when needed.  There already was a
RestoreOptions pointer in Archive, though for no obvious reason it was part
of the "private" struct rather than out where pg_dump.c could see it.

Doing this allows reversion of quite a lot of parameter-addition changes
made in commit 0eea8047, which is a good thing IMO because this will
reduce the code delta between 9.4 and 9.5, probably easing a few future
back-patch efforts.  Moreover, the previous commit only added a DumpOptions
argument to functions that had to have it at the time, which means we could
anticipate still more code churn (and more back-patch hazard) as the
requirement spread further.  I'd hit exactly that problem in my upcoming
patch to fix extension membership marking, which is what motivated me to
do this.
parent 26905e00
......@@ -81,7 +81,7 @@ static int strInArray(const char *pattern, char **arr, int arr_size);
* Collect information about all potentially dumpable objects
*/
TableInfo *
getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
getSchemaData(Archive *fout, int *numTablesPtr)
{
ExtensionInfo *extinfo;
InhInfo *inhinfo;
......@@ -118,7 +118,7 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
*/
if (g_verbose)
write_msg(NULL, "reading user-defined tables\n");
tblinfo = getTables(fout, dopt, &numTables);
tblinfo = getTables(fout, &numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
/* Do this after we've built tblinfoindex */
......@@ -126,11 +126,11 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
if (g_verbose)
write_msg(NULL, "reading extensions\n");
extinfo = getExtensions(fout, dopt, &numExtensions);
extinfo = getExtensions(fout, &numExtensions);
if (g_verbose)
write_msg(NULL, "reading user-defined functions\n");
funinfo = getFuncs(fout, dopt, &numFuncs);
funinfo = getFuncs(fout, &numFuncs);
funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo));
/* this must be after getTables and getFuncs */
......@@ -146,7 +146,7 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
if (g_verbose)
write_msg(NULL, "reading user-defined aggregate functions\n");
getAggregates(fout, dopt, &numAggregates);
getAggregates(fout, &numAggregates);
if (g_verbose)
write_msg(NULL, "reading user-defined operators\n");
......@@ -187,7 +187,7 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
if (g_verbose)
write_msg(NULL, "reading default privileges\n");
getDefaultACLs(fout, dopt, &numDefaultACLs);
getDefaultACLs(fout, &numDefaultACLs);
if (g_verbose)
write_msg(NULL, "reading user-defined collations\n");
......@@ -200,7 +200,7 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
if (g_verbose)
write_msg(NULL, "reading type casts\n");
getCasts(fout, dopt, &numCasts);
getCasts(fout, &numCasts);
if (g_verbose)
write_msg(NULL, "reading transforms\n");
......@@ -221,7 +221,7 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
*/
if (g_verbose)
write_msg(NULL, "finding extension members\n");
getExtensionMembership(fout, dopt, extinfo, numExtensions);
getExtensionMembership(fout, extinfo, numExtensions);
/* Link tables to parents, mark parents of target tables interesting */
if (g_verbose)
......@@ -230,11 +230,11 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
if (g_verbose)
write_msg(NULL, "reading column info for interesting tables\n");
getTableAttrs(fout, dopt, tblinfo, numTables);
getTableAttrs(fout, tblinfo, numTables);
if (g_verbose)
write_msg(NULL, "flagging inherited columns in subtables\n");
flagInhAttrs(dopt, tblinfo, numTables);
flagInhAttrs(fout->dopt, tblinfo, numTables);
if (g_verbose)
write_msg(NULL, "reading indexes\n");
......
......@@ -46,8 +46,6 @@ static int piperead(int s, char *buf, int len);
typedef struct
{
ArchiveHandle *AH;
RestoreOptions *ropt;
DumpOptions *dopt;
int worker;
int pipeRead;
int pipeWrite;
......@@ -87,13 +85,11 @@ static void WaitForTerminatingWorkers(ParallelState *pstate);
#ifndef WIN32
static void sigTermHandler(int signum);
#endif
static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
DumpOptions *dopt,
RestoreOptions *ropt);
static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker);
static bool HasEveryWorkerTerminated(ParallelState *pstate);
static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te);
static void WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]);
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);
......@@ -435,9 +431,7 @@ sigTermHandler(int signum)
* worker process.
*/
static void
SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker,
DumpOptions *dopt,
RestoreOptions *ropt)
SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker)
{
/*
* Call the setup worker function that's defined in the ArchiveHandle.
......@@ -446,11 +440,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, dopt, ropt);
(AH->SetupWorkerPtr) ((Archive *) AH);
Assert(AH->connection != NULL);
WaitForCommands(AH, dopt, pipefd);
WaitForCommands(AH, pipefd);
closesocket(pipefd[PIPE_READ]);
closesocket(pipefd[PIPE_WRITE]);
......@@ -463,13 +457,11 @@ init_spawned_worker_win32(WorkerInfo *wi)
ArchiveHandle *AH;
int pipefd[2] = {wi->pipeRead, wi->pipeWrite};
int worker = wi->worker;
DumpOptions *dopt = wi->dopt;
RestoreOptions *ropt = wi->ropt;
AH = CloneArchive(wi->AH);
free(wi);
SetupWorker(AH, pipefd, worker, dopt, ropt);
SetupWorker(AH, pipefd, worker);
DeCloneArchive(AH);
_endthreadex(0);
......@@ -483,7 +475,7 @@ init_spawned_worker_win32(WorkerInfo *wi)
* of threads while it does a fork() on Unix.
*/
ParallelState *
ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt)
ParallelBackupStart(ArchiveHandle *AH)
{
ParallelState *pstate;
int i;
......@@ -545,8 +537,6 @@ ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt)
/* Allocate a new structure for every worker */
wi = (WorkerInfo *) pg_malloc(sizeof(WorkerInfo));
wi->ropt = ropt;
wi->dopt = dopt;
wi->worker = i;
wi->AH = AH;
wi->pipeRead = pstate->parallelSlot[i].pipeRevRead = pipeMW[PIPE_READ];
......@@ -601,7 +591,7 @@ ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt)
closesocket(pstate->parallelSlot[j].pipeWrite);
}
SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, dopt, ropt);
SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i);
exit(0);
}
......@@ -859,7 +849,7 @@ lockTableNoWait(ArchiveHandle *AH, TocEntry *te)
* exit.
*/
static void
WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2])
WaitForCommands(ArchiveHandle *AH, int pipefd[2])
{
char *command;
DumpId dumpId;
......@@ -899,7 +889,7 @@ WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, 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, dopt, te);
str = (AH->WorkerJobDumpPtr) (AH, te);
Assert(AH->connection != NULL);
sendMessageToMaster(pipefd, str);
free(str);
......
......@@ -76,9 +76,7 @@ extern int ReapWorkerStatus(ParallelState *pstate, int *status);
extern void EnsureIdleWorker(ArchiveHandle *AH, ParallelState *pstate);
extern void EnsureWorkersFinished(ArchiveHandle *AH, ParallelState *pstate);
extern ParallelState *ParallelBackupStart(ArchiveHandle *AH,
DumpOptions *dopt,
RestoreOptions *ropt);
extern ParallelState *ParallelBackupStart(ArchiveHandle *AH);
extern void DispatchJobForTocEntry(ArchiveHandle *AH,
ParallelState *pstate,
TocEntry *te, T_Action act);
......
......@@ -58,35 +58,6 @@ typedef enum _teSection
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 */
......@@ -190,6 +161,38 @@ typedef struct _dumpOptions
char *outputSuperuser;
} DumpOptions;
/*
* 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
{
DumpOptions *dopt; /* options, if dumping */
RestoreOptions *ropt; /* options, if restoring */
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;
/*
* pg_dump uses two different mechanisms for identifying database objects:
......@@ -215,9 +218,9 @@ typedef struct
typedef int DumpId;
typedef int (*DataDumperPtr) (Archive *AH, DumpOptions *dopt, void *userArg);
typedef int (*DataDumperPtr) (Archive *AH, void *userArg);
typedef void (*SetupWorkerPtr) (Archive *AH, DumpOptions *dopt, RestoreOptions *ropt);
typedef void (*SetupWorkerPtr) (Archive *AH);
/*
* Main archiver interface.
......@@ -250,9 +253,11 @@ 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, DumpOptions *dopt);
extern void CloseArchive(Archive *AH);
extern void SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt);
extern void SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt);
extern void ProcessArchiveRestoreOptions(Archive *AH);
extern void RestoreArchive(Archive *AH);
......@@ -265,7 +270,7 @@ extern Archive *CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
SetupWorkerPtr setupDumpWorker);
/* The --list option */
extern void PrintTOCSummary(Archive *AH, RestoreOptions *ropt);
extern void PrintTOCSummary(Archive *AH);
extern RestoreOptions *NewRestoreOptions(void);
......@@ -274,7 +279,7 @@ extern void InitDumpOptions(DumpOptions *opts);
extern DumpOptions *dumpOptionsFromRestoreOptions(RestoreOptions *ropt);
/* Rearrange and filter TOC entries */
extern void SortTocFromFile(Archive *AHX, RestoreOptions *ropt);
extern void SortTocFromFile(Archive *AHX);
/* Convenience functions used only when writing DATA */
extern void archputs(const char *s, Archive *AH);
......
......@@ -57,7 +57,7 @@ static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
const int compression, ArchiveMode mode, SetupWorkerPtr setupWorkerPtr);
static void _getObjectDescription(PQExpBuffer buf, TocEntry *te,
ArchiveHandle *AH);
static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass);
static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData, bool acl_pass);
static char *replace_line_endings(const char *str);
static void _doSetFixedOutputState(ArchiveHandle *AH);
static void _doSetSessionAuth(ArchiveHandle *AH, const char *user);
......@@ -71,8 +71,8 @@ static void processEncodingEntry(ArchiveHandle *AH, TocEntry *te);
static void processStdStringsEntry(ArchiveHandle *AH, TocEntry *te);
static teReqs _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt);
static bool _tocEntryIsACL(TocEntry *te);
static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te);
static void _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te);
static void buildTocEntryArrays(ArchiveHandle *AH);
static void _moveBefore(ArchiveHandle *AH, TocEntry *pos, TocEntry *te);
static int _discoverArchiveFormat(ArchiveHandle *AH);
......@@ -84,8 +84,7 @@ static void SetOutput(ArchiveHandle *AH, const char *filename, int compression);
static OutputContext SaveOutput(ArchiveHandle *AH);
static void RestoreOutput(ArchiveHandle *AH, OutputContext savedContext);
static int restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
RestoreOptions *ropt, bool is_parallel);
static int restore_toc_entry(ArchiveHandle *AH, TocEntry *te, bool is_parallel);
static void restore_toc_entries_prefork(ArchiveHandle *AH);
static void restore_toc_entries_parallel(ArchiveHandle *AH, ParallelState *pstate,
TocEntry *pending_list);
......@@ -184,7 +183,7 @@ dumpOptionsFromRestoreOptions(RestoreOptions *ropt)
* setup doesn't need to know anything much, so it's defined here.
*/
static void
setupRestoreWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt)
setupRestoreWorker(Archive *AHX)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
......@@ -216,12 +215,12 @@ OpenArchive(const char *FileSpec, const ArchiveFormat fmt)
/* Public */
void
CloseArchive(Archive *AHX, DumpOptions *dopt)
CloseArchive(Archive *AHX)
{
int res = 0;
ArchiveHandle *AH = (ArchiveHandle *) AHX;
(*AH->ClosePtr) (AH, dopt);
(*AH->ClosePtr) (AH);
/* Close the output */
if (AH->gzOut)
......@@ -236,14 +235,25 @@ CloseArchive(Archive *AHX, DumpOptions *dopt)
/* Public */
void
SetArchiveRestoreOptions(Archive *AHX, RestoreOptions *ropt)
SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
TocEntry *te;
teSection curSection;
/* Caller can omit dump options, in which case we synthesize them */
if (dopt == NULL && ropt != NULL)
dopt = dumpOptionsFromRestoreOptions(ropt);
/* Save options for later access */
AH->dopt = dopt;
AH->ropt = ropt;
}
/* Public */
void
ProcessArchiveRestoreOptions(Archive *AHX)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
RestoreOptions *ropt = AH->public.ropt;
TocEntry *te;
teSection curSection;
/* Decide which TOC entries will be dumped/restored, and mark them */
curSection = SECTION_PRE_DATA;
......@@ -298,7 +308,7 @@ void
RestoreArchive(Archive *AHX)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
RestoreOptions *ropt = AH->ropt;
RestoreOptions *ropt = AH->public.ropt;
bool parallel_mode;
TocEntry *te;
OutputContext sav;
......@@ -605,7 +615,7 @@ RestoreArchive(Archive *AHX)
Assert(AH->connection == NULL);
/* ParallelBackupStart() will actually fork the processes */
pstate = ParallelBackupStart(AH, NULL, ropt);
pstate = ParallelBackupStart(AH);
restore_toc_entries_parallel(AH, pstate, &pending_list);
ParallelBackupEnd(AH, pstate);
......@@ -616,7 +626,7 @@ RestoreArchive(Archive *AHX)
else
{
for (te = AH->toc->next; te != AH->toc; te = te->next)
(void) restore_toc_entry(AH, te, ropt, false);
(void) restore_toc_entry(AH, te, false);
}
/*
......@@ -636,7 +646,7 @@ RestoreArchive(Archive *AHX)
else
ahlog(AH, 1, "setting owner and privileges for %s \"%s\"\n",
te->desc, te->tag);
_printTocEntry(AH, te, ropt, false, true);
_printTocEntry(AH, te, false, true);
}
}
......@@ -673,9 +683,9 @@ RestoreArchive(Archive *AHX)
* the parallel parent has to make the corresponding status update.
*/
static int
restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
RestoreOptions *ropt, bool is_parallel)
restore_toc_entry(ArchiveHandle *AH, TocEntry *te, bool is_parallel)
{
RestoreOptions *ropt = AH->public.ropt;
int status = WORKER_OK;
teReqs reqs;
bool defnDumped;
......@@ -717,7 +727,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
ahlog(AH, 1, "creating %s \"%s\"\n", te->desc, te->tag);
_printTocEntry(AH, te, ropt, false, false);
_printTocEntry(AH, te, false, false);
defnDumped = true;
if (strcmp(te->desc, "TABLE") == 0)
......@@ -782,7 +792,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
*/
if (AH->PrintTocDataPtr !=NULL)
{
_printTocEntry(AH, te, ropt, true, false);
_printTocEntry(AH, te, true, false);
if (strcmp(te->desc, "BLOBS") == 0 ||
strcmp(te->desc, "BLOB COMMENTS") == 0)
......@@ -795,13 +805,13 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
if (strcmp(te->desc, "BLOB COMMENTS") == 0)
AH->outputKind = OUTPUT_OTHERDATA;
(*AH->PrintTocDataPtr) (AH, te, ropt);
(*AH->PrintTocDataPtr) (AH, te);
AH->outputKind = OUTPUT_SQLCMDS;
}
else
{
_disableTriggersIfNecessary(AH, te, ropt);
_disableTriggersIfNecessary(AH, te);
/* Select owner and schema as necessary */
_becomeOwner(AH, te);
......@@ -848,7 +858,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
else
AH->outputKind = OUTPUT_OTHERDATA;
(*AH->PrintTocDataPtr) (AH, te, ropt);
(*AH->PrintTocDataPtr) (AH, te);
/*
* Terminate COPY if needed.
......@@ -862,7 +872,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
if (is_parallel && te->created)
CommitTransaction(&AH->public);
_enableTriggersIfNecessary(AH, te, ropt);
_enableTriggersIfNecessary(AH, te);
}
}
}
......@@ -870,7 +880,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
{
/* If we haven't already dumped the defn part, do so now */
ahlog(AH, 1, "executing %s %s\n", te->desc, te->tag);
_printTocEntry(AH, te, ropt, false, false);
_printTocEntry(AH, te, false, false);
}
}
......@@ -900,8 +910,10 @@ NewRestoreOptions(void)
}
static void
_disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
_disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te)
{
RestoreOptions *ropt = AH->public.ropt;
/* This hack is only needed in a data-only restore */
if (!ropt->dataOnly || !ropt->disable_triggers)
return;
......@@ -926,8 +938,10 @@ _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *rop
}
static void
_enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
_enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te)
{
RestoreOptions *ropt = AH->public.ropt;
/* This hack is only needed in a data-only restore */
if (!ropt->dataOnly || !ropt->disable_triggers)
return;
......@@ -1040,9 +1054,10 @@ ArchiveEntry(Archive *AHX,
/* Public */
void
PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
PrintTOCSummary(Archive *AHX)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
RestoreOptions *ropt = AH->public.ropt;
TocEntry *te;
teSection curSection;
OutputContext sav;
......@@ -1159,7 +1174,9 @@ EndBlob(Archive *AHX, Oid oid)
void
StartRestoreBlobs(ArchiveHandle *AH)
{
if (!AH->ropt->single_txn)
RestoreOptions *ropt = AH->public.ropt;
if (!ropt->single_txn)
{
if (AH->connection)
StartTransaction(&AH->public);
......@@ -1176,7 +1193,9 @@ StartRestoreBlobs(ArchiveHandle *AH)
void
EndRestoreBlobs(ArchiveHandle *AH)
{
if (!AH->ropt->single_txn)
RestoreOptions *ropt = AH->public.ropt;
if (!ropt->single_txn)
{
if (AH->connection)
CommitTransaction(&AH->public);
......@@ -1265,9 +1284,10 @@ EndRestoreBlob(ArchiveHandle *AH, Oid oid)
***********/
void
SortTocFromFile(Archive *AHX, RestoreOptions *ropt)
SortTocFromFile(Archive *AHX)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
RestoreOptions *ropt = AH->public.ropt;
FILE *fh;
char buf[100];
bool incomplete_line;
......@@ -1550,7 +1570,9 @@ ahlog(ArchiveHandle *AH, int level, const char *fmt,...)
static int
RestoringToDB(ArchiveHandle *AH)
{
return (AH->ropt && AH->ropt->useDB && AH->connection);
RestoreOptions *ropt = AH->public.ropt;
return (ropt && ropt->useDB && AH->connection);
}
/*
......@@ -2303,7 +2325,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
}
void
WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate)
WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
{
TocEntry *te;
......@@ -2326,13 +2348,13 @@ WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate)
DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP);
}
else
WriteDataChunksForTocEntry(AH, dopt, te);
WriteDataChunksForTocEntry(AH, te);
}
EnsureWorkersFinished(AH, pstate);
}
void
WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
{
StartDataPtr startPtr;
EndDataPtr endPtr;
......@@ -2356,7 +2378,7 @@ WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
/*
* The user-provided DataDumper routine needs to call AH->WriteData
*/
(*te->dataDumper) ((Archive *) AH, dopt, te->dataDumperArg);
(*te->dataDumper) ((Archive *) AH, te->dataDumperArg);
if (endPtr != NULL)
(*endPtr) (AH, te);
......@@ -2827,6 +2849,8 @@ _tocEntryIsACL(TocEntry *te)
static void
_doSetFixedOutputState(ArchiveHandle *AH)
{
RestoreOptions *ropt = AH->public.ropt;
/* Disable statement_timeout since restore is probably slow */
ahprintf(AH, "SET statement_timeout = 0;\n");
......@@ -2842,8 +2866,8 @@ _doSetFixedOutputState(ArchiveHandle *AH)
AH->public.std_strings ? "on" : "off");
/* Select the role to be used during restore */
if (AH->ropt && AH->ropt->use_role)
ahprintf(AH, "SET ROLE %s;\n", fmtId(AH->ropt->use_role));
if (ropt && ropt->use_role)
ahprintf(AH, "SET ROLE %s;\n", fmtId(ropt->use_role));
/* Make sure function checking is disabled */
ahprintf(AH, "SET check_function_bodies = false;\n");
......@@ -2854,7 +2878,7 @@ _doSetFixedOutputState(ArchiveHandle *AH)
ahprintf(AH, "SET escape_string_warning = off;\n");
/* Adjust row-security state */
if (AH->ropt && AH->ropt->enable_row_security)
if (ropt && ropt->enable_row_security)
ahprintf(AH, "SET row_security = on;\n");
else
ahprintf(AH, "SET row_security = off;\n");
......@@ -3012,7 +3036,9 @@ _becomeUser(ArchiveHandle *AH, const char *user)
static void
_becomeOwner(ArchiveHandle *AH, TocEntry *te)
{
if (AH->ropt && (AH->ropt->noOwner || !AH->ropt->use_setsessauth))
RestoreOptions *ropt = AH->public.ropt;
if (ropt && (ropt->noOwner || !ropt->use_setsessauth))
return;
_becomeUser(AH, te->owner);
......@@ -3083,12 +3109,13 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
static void
_selectTablespace(ArchiveHandle *AH, const char *tablespace)
{
RestoreOptions *ropt = AH->public.ropt;
PQExpBuffer qry;
const char *want,
*have;
/* do nothing in --no-tablespaces mode */
if (AH->ropt->noTablespace)
if (ropt->noTablespace)
return;
have = AH->currTablespace;
......@@ -3214,8 +3241,10 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
}
static void
_printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isData, bool acl_pass)
_printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData, bool acl_pass)
{
RestoreOptions *ropt = AH->public.ropt;
/* ACLs are dumped only during acl pass */
if (acl_pass)
{
......@@ -3624,7 +3653,6 @@ dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim)
static void
restore_toc_entries_prefork(ArchiveHandle *AH)
{
RestoreOptions *ropt = AH->ropt;
bool skipped_some;
TocEntry *next_work_item;
......@@ -3676,7 +3704,7 @@ restore_toc_entries_prefork(ArchiveHandle *AH)
next_work_item->dumpId,
next_work_item->desc, next_work_item->tag);
(void) restore_toc_entry(AH, next_work_item, ropt, false);
(void) restore_toc_entry(AH, next_work_item, false);
/* there should be no touch of ready_list here, so pass NULL */
reduce_dependencies(AH, next_work_item, NULL);
......@@ -3857,7 +3885,7 @@ restore_toc_entries_parallel(ArchiveHandle *AH, ParallelState *pstate,
static void
restore_toc_entries_postfork(ArchiveHandle *AH, TocEntry *pending_list)
{
RestoreOptions *ropt = AH->ropt;
RestoreOptions *ropt = AH->public.ropt;
TocEntry *te;
ahlog(AH, 2, "entering restore_toc_entries_postfork\n");
......@@ -3880,7 +3908,7 @@ restore_toc_entries_postfork(ArchiveHandle *AH, TocEntry *pending_list)
{
ahlog(AH, 1, "processing missed item %d %s %s\n",
te->dumpId, te->desc, te->tag);
(void) restore_toc_entry(AH, te, ropt, false);
(void) restore_toc_entry(AH, te, false);
}
/* The ACLs will be handled back in RestoreArchive. */
......@@ -4045,7 +4073,6 @@ parallel_restore(ParallelArgs *args)
{
ArchiveHandle *AH = args->AH;
TocEntry *te = args->te;
RestoreOptions *ropt = AH->ropt;
int status;
_doSetFixedOutputState(AH);
......@@ -4055,7 +4082,7 @@ parallel_restore(ParallelArgs *args)
AH->public.n_errors = 0;
/* Restore the TOC item */
status = restore_toc_entry(AH, te, ropt, true);
status = restore_toc_entry(AH, te, true);
return status;
}
......@@ -4417,7 +4444,7 @@ CloneArchive(ArchiveHandle *AH)
*/
if (AH->mode == archModeRead)
{
RestoreOptions *ropt = AH->ropt;
RestoreOptions *ropt = AH->public.ropt;
Assert(AH->connection == NULL);
/* this also sets clone->connection */
......
......@@ -136,7 +136,7 @@ typedef enum T_Action
ACT_RESTORE
} T_Action;
typedef void (*ClosePtr) (ArchiveHandle *AH, DumpOptions *dopt);
typedef void (*ClosePtr) (ArchiveHandle *AH);
typedef void (*ReopenPtr) (ArchiveHandle *AH);
typedef void (*ArchiveEntryPtr) (ArchiveHandle *AH, TocEntry *te);
......@@ -157,13 +157,13 @@ 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 (*PrintTocDataPtr) (ArchiveHandle *AH, TocEntry *te);
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 *(*WorkerJobDumpPtr) (ArchiveHandle *AH, TocEntry *te);
typedef char *(*MasterStartParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
T_Action act);
typedef int (*MasterEndParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
......@@ -315,9 +315,6 @@ struct _archiveHandle
ArchiveMode mode; /* File mode - r or w */
void *formatData; /* Header data specific to file format */
RestoreOptions *ropt; /* Used to check restore options in ahwrite
* etc */
/* these vars track state to avoid sending redundant SET commands */
char *currUser; /* current username, or NULL if unknown */
char *currSchema; /* current schema, or NULL */
......@@ -386,8 +383,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, DumpOptions *dopt, struct ParallelState *pstate);
extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te);
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);
......
......@@ -42,9 +42,9 @@ 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, DumpOptions *dopt);
static void _CloseArchive(ArchiveHandle *AH);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _PrintExtraToc(ArchiveHandle *AH, TocEntry *te);
......@@ -419,7 +419,7 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te)
* Print data for a given TOC entry
*/
static void
_PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
_PrintTocData(ArchiveHandle *AH, TocEntry *te)
{
lclContext *ctx = (lclContext *) AH->formatData;
lclTocEntry *tctx = (lclTocEntry *) te->formatData;
......@@ -500,7 +500,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
break;
case BLK_BLOBS:
_LoadBlobs(AH, ropt->dropSchema);
_LoadBlobs(AH, AH->public.ropt->dropSchema);
break;
default: /* Always have a default */
......@@ -695,7 +695,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
*
*/
static void
_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
_CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
pgoff_t tpos;
......@@ -710,7 +710,7 @@ _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
strerror(errno));
WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx);
WriteDataChunks(AH, dopt, NULL);
WriteDataChunks(AH, NULL);
/*
* If possible, re-write the TOC in order to update the data offset
......
......@@ -72,9 +72,9 @@ 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, DumpOptions *dopt);
static void _CloseArchive(ArchiveHandle *AH);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
......@@ -84,7 +84,7 @@ static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
static void _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
static void _EndBlobs(ArchiveHandle *AH, TocEntry *te);
static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt);
static void _LoadBlobs(ArchiveHandle *AH);
static void _Clone(ArchiveHandle *AH);
static void _DeClone(ArchiveHandle *AH);
......@@ -93,7 +93,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, DumpOptions *dopt, TocEntry *te);
static char *_WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te);
static void setFilePath(ArchiveHandle *AH, char *buf,
const char *relativeFilename);
......@@ -386,7 +386,7 @@ _EndData(ArchiveHandle *AH, TocEntry *te)
* Print data for a given file (can be a BLOB as well)
*/
static void
_PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
_PrintFileData(ArchiveHandle *AH, char *filename)
{
size_t cnt;
char *buf;
......@@ -418,7 +418,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
* Print data for a given TOC entry
*/
static void
_PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
_PrintTocData(ArchiveHandle *AH, TocEntry *te)
{
lclTocEntry *tctx = (lclTocEntry *) te->formatData;
......@@ -426,18 +426,18 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
return;
if (strcmp(te->desc, "BLOBS") == 0)
_LoadBlobs(AH, ropt);
_LoadBlobs(AH);
else
{
char fname[MAXPGPATH];
setFilePath(AH, fname, tctx->filename);
_PrintFileData(AH, fname, ropt);
_PrintFileData(AH, fname);
}
}
static void
_LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
_LoadBlobs(ArchiveHandle *AH)
{
Oid oid;
lclContext *ctx = (lclContext *) AH->formatData;
......@@ -465,9 +465,9 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
exit_horribly(modulename, "invalid line in large object TOC file \"%s\": \"%s\"\n",
fname, line);
StartRestoreBlob(AH, oid, ropt->dropSchema);
StartRestoreBlob(AH, oid, AH->public.ropt->dropSchema);
snprintf(path, MAXPGPATH, "%s/%s", ctx->directory, fname);
_PrintFileData(AH, path, ropt);
_PrintFileData(AH, path);
EndRestoreBlob(AH, oid);
}
if (!cfeof(ctx->blobsTocFH))
......@@ -567,7 +567,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
* WriteDataChunks to save all DATA & BLOBs.
*/
static void
_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
_CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
......@@ -579,7 +579,7 @@ _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
setFilePath(AH, fname, "toc.dat");
/* this will actually fork the processes for a parallel backup */
ctx->pstate = ParallelBackupStart(AH, dopt, NULL);
ctx->pstate = ParallelBackupStart(AH);
/* The TOC is always created uncompressed */
tocFH = cfopen_write(fname, PG_BINARY_W, 0);
......@@ -600,7 +600,7 @@ _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
if (cfclose(tocFH) != 0)
exit_horribly(modulename, "could not close TOC file: %s\n",
strerror(errno));
WriteDataChunks(AH, dopt, ctx->pstate);
WriteDataChunks(AH, ctx->pstate);
ParallelBackupEnd(AH, ctx->pstate);
}
......@@ -791,7 +791,7 @@ _MasterStartParallelItem(ArchiveHandle *AH, TocEntry *te, T_Action act)
* function of the respective dump format.
*/
static char *
_WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
_WorkerJobDumpDirectory(ArchiveHandle *AH, TocEntry *te)
{
/*
* short fixed-size string + some ID so far, this needs to be malloc'ed
......@@ -810,7 +810,7 @@ _WorkerJobDumpDirectory(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
* succeed... A failure will be detected by the parent when the child dies
* unexpectedly.
*/
WriteDataChunksForTocEntry(AH, dopt, te);
WriteDataChunksForTocEntry(AH, te);
snprintf(buf, buflen, "OK DUMP %d", te->dumpId);
......
......@@ -33,8 +33,8 @@ 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, DumpOptions *dopt);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
static void _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
......@@ -149,7 +149,7 @@ _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
exit_horribly(NULL, "invalid OID for large object\n");
/* With an old archive we must do drop and create logic here */
if (old_blob_style && AH->ropt->dropSchema)
if (old_blob_style && AH->public.ropt->dropSchema)
DropBlobIfExists(AH, oid);
if (old_blob_style)
......@@ -192,20 +192,16 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te)
*------
*/
static void
_PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
_PrintTocData(ArchiveHandle *AH, TocEntry *te)
{
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);
pg_free(dopt);
(*te->dataDumper) ((Archive *) AH, te->dataDumperArg);
if (strcmp(te->desc, "BLOBS") == 0)
_EndBlobs(AH, te);
......@@ -229,7 +225,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
}
static void
_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
_CloseArchive(ArchiveHandle *AH)
{
/* Nothing to do */
}
......@@ -47,8 +47,8 @@ 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, DumpOptions *dopt);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _PrintExtraToc(ArchiveHandle *AH, TocEntry *te);
......@@ -100,7 +100,7 @@ typedef struct
/* translator: this is a module name */
static const char *modulename = gettext_noop("tar archiver");
static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt);
static void _LoadBlobs(ArchiveHandle *AH);
static TAR_MEMBER *tarOpen(ArchiveHandle *AH, const char *filename, char mode);
static void tarClose(ArchiveHandle *AH, TAR_MEMBER *TH);
......@@ -632,7 +632,7 @@ _EndData(ArchiveHandle *AH, TocEntry *te)
* Print data for a given file
*/
static void
_PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
_PrintFileData(ArchiveHandle *AH, char *filename)
{
lclContext *ctx = (lclContext *) AH->formatData;
char buf[4096];
......@@ -659,7 +659,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
* Print data for a given TOC entry
*/
static void
_PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
_PrintTocData(ArchiveHandle *AH, TocEntry *te)
{
lclContext *ctx = (lclContext *) AH->formatData;
lclTocEntry *tctx = (lclTocEntry *) te->formatData;
......@@ -708,13 +708,13 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
}
if (strcmp(te->desc, "BLOBS") == 0)
_LoadBlobs(AH, ropt);
_LoadBlobs(AH);
else
_PrintFileData(AH, tctx->filename, ropt);
_PrintFileData(AH, tctx->filename);
}
static void
_LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
_LoadBlobs(ArchiveHandle *AH)
{
Oid oid;
lclContext *ctx = (lclContext *) AH->formatData;
......@@ -737,7 +737,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
{
ahlog(AH, 1, "restoring large object with OID %u\n", oid);
StartRestoreBlob(AH, oid, ropt->dropSchema);
StartRestoreBlob(AH, oid, AH->public.ropt->dropSchema);
while ((cnt = tarRead(buf, 4095, th)) > 0)
{
......@@ -824,12 +824,13 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
}
static void
_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
_CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
TAR_MEMBER *th;
RestoreOptions *ropt;
RestoreOptions *savRopt;
DumpOptions *savDopt;
int savVerbose,
i;
......@@ -847,7 +848,7 @@ _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
/*
* Now send the data (tables & blobs)
*/
WriteDataChunks(AH, dopt, NULL);
WriteDataChunks(AH, NULL);
/*
* Now this format wants to append a script which does a full restore
......@@ -869,22 +870,25 @@ _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
ctx->scriptTH = th;
ropt = NewRestoreOptions();
memcpy(ropt, AH->ropt, sizeof(RestoreOptions));
memcpy(ropt, AH->public.ropt, sizeof(RestoreOptions));
ropt->filename = NULL;
ropt->dropSchema = 1;
ropt->compression = 0;
ropt->superuser = NULL;
ropt->suppressDumpWarnings = true;
savRopt = AH->ropt;
AH->ropt = ropt;
savDopt = AH->public.dopt;
savRopt = AH->public.ropt;
SetArchiveOptions((Archive *) AH, NULL, ropt);
savVerbose = AH->public.verbose;
AH->public.verbose = 0;
RestoreArchive((Archive *) AH);
AH->ropt = savRopt;
SetArchiveOptions((Archive *) AH, savDopt, savRopt);
AH->public.verbose = savVerbose;
tarClose(AH, th);
......
......@@ -128,7 +128,7 @@ char g_comment_end[10];
static const CatalogId nilCatalogId = {0, 0};
static void help(const char *progname);
static void setup_connection(Archive *AH, DumpOptions *dopt,
static void setup_connection(Archive *AH,
const char *dumpencoding, const char *dumpsnapshot,
char *use_role);
static ArchiveFormat parseArchiveFormat(const char *format, ArchiveMode *mode);
......@@ -141,66 +141,66 @@ static void expand_table_name_patterns(Archive *fout,
SimpleOidList *oids,
bool strict_names);
static NamespaceInfo *findNamespace(Archive *fout, Oid nsoid, Oid objoid);
static void dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo);
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, DumpOptions *dopt, const char *target,
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, DumpOptions *dopt, const char *target,
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, 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 dumpUndefinedType(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 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 dumpUndefinedType(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, 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 dumpTransform(Archive *fout, DumpOptions *dopt, TransformInfo *transform);
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 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 dumpTransform(Archive *fout, TransformInfo *transform);
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, 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 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, DumpOptions *dopt, DefaultACLInfo *daclinfo);
static void dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo);
static void dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId,
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);
......@@ -238,10 +238,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, DumpOptions *dopt, BlobInfo *binfo);
static int dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg);
static void dumpPolicy(Archive *fout, DumpOptions *dopt, PolicyInfo *polinfo);
static void dumpDatabase(Archive *AH, DumpOptions *dopt);
static void dumpBlob(Archive *fout, BlobInfo *binfo);
static int dumpBlobs(Archive *fout, void *arg);
static void dumpPolicy(Archive *fout, PolicyInfo *polinfo);
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,
......@@ -261,7 +261,7 @@ static void fmtReloptionsArray(Archive *fout, PQExpBuffer buffer,
const char *reloptions, const char *prefix);
static char *get_synchronized_snapshot(Archive *fout);
static PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, char *query);
static void setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt);
static void setupDumpWorker(Archive *AHX);
int
......@@ -611,6 +611,9 @@ main(int argc, char **argv)
fout = CreateArchive(filename, archiveFormat, compressLevel, archiveMode,
setupDumpWorker);
/* Make dump options accessible right away */
SetArchiveOptions(fout, &dopt, NULL);
/* Register the cleanup hook */
on_exit_close_archive(fout);
......@@ -634,7 +637,7 @@ main(int argc, char **argv)
* death.
*/
ConnectDatabase(fout, dopt.dbname, dopt.pghost, dopt.pgport, dopt.username, prompt_password);
setup_connection(fout, &dopt, dumpencoding, dumpsnapshot, use_role);
setup_connection(fout, dumpencoding, dumpsnapshot, use_role);
/*
* Disable security label support if server version < v9.1.x (prevents
......@@ -739,7 +742,7 @@ main(int argc, char **argv)
* Now scan the database and create DumpableObject structs for all the
* objects we intend to dump.
*/
tblinfo = getSchemaData(fout, &dopt, &numTables);
tblinfo = getSchemaData(fout, &numTables);
if (fout->remoteVersion < 80400)
guessConstraintInheritance(tblinfo, numTables);
......@@ -803,11 +806,11 @@ main(int argc, char **argv)
/* The database item is always next, unless we don't want it at all */
if (dopt.include_everything && !dopt.dataOnly)
dumpDatabase(fout, &dopt);
dumpDatabase(fout);
/* Now the rearrangeable objects. */
for (i = 0; i < numObjs; i++)
dumpDumpableObject(fout, &dopt, dobjs[i]);
dumpDumpableObject(fout, dobjs[i]);
/*
* Set up options info to ensure we dump what we want.
......@@ -843,7 +846,10 @@ main(int argc, char **argv)
ropt->suppressDumpWarnings = true; /* We've already shown them */
SetArchiveRestoreOptions(fout, ropt);
SetArchiveOptions(fout, &dopt, ropt);
/* Mark which entries should be output */
ProcessArchiveRestoreOptions(fout);
/*
* The archive's TOC entries are now marked as to which ones will actually
......@@ -863,7 +869,7 @@ main(int argc, char **argv)
if (plainText)
RestoreArchive(fout);
CloseArchive(fout, &dopt);
CloseArchive(fout);
exit_nicely(0);
}
......@@ -941,9 +947,10 @@ help(const char *progname)
}
static void
setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding,
setup_connection(Archive *AH, const char *dumpencoding,
const char *dumpsnapshot, char *use_role)
{
DumpOptions *dopt = AH->dopt;
PGconn *conn = GetConnection(AH);
const char *std_strings;
......@@ -1092,9 +1099,9 @@ setup_connection(Archive *AH, DumpOptions *dopt, const char *dumpencoding,
}
static void
setupDumpWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt)
setupDumpWorker(Archive *AHX)
{
setup_connection(AHX, dopt, NULL, NULL, NULL);
setup_connection(AHX, NULL, NULL, NULL);
}
static char *
......@@ -1437,7 +1444,7 @@ selectDumpableObject(DumpableObject *dobj)
*/
static int
dumpTableData_copy(Archive *fout, DumpOptions *dopt, void *dcontext)
dumpTableData_copy(Archive *fout, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
......@@ -1612,11 +1619,12 @@ dumpTableData_copy(Archive *fout, DumpOptions *dopt, void *dcontext)
* E'' strings, or dollar-quoted strings. So don't emit anything like that.
*/
static int
dumpTableData_insert(Archive *fout, DumpOptions *dopt, void *dcontext)
dumpTableData_insert(Archive *fout, void *dcontext)
{
TableDataInfo *tdinfo = (TableDataInfo *) dcontext;
TableInfo *tbinfo = tdinfo->tdtable;
const char *classname = tbinfo->dobj.name;
DumpOptions *dopt = fout->dopt;
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer insertStmt = NULL;
PGresult *res;
......@@ -1798,8 +1806,9 @@ dumpTableData_insert(Archive *fout, DumpOptions *dopt, void *dcontext)
* Actually, this just makes an ArchiveEntry for the table contents.
*/
static void
dumpTableData(Archive *fout, DumpOptions *dopt, TableDataInfo *tdinfo)
dumpTableData(Archive *fout, TableDataInfo *tdinfo)
{
DumpOptions *dopt = fout->dopt;
TableInfo *tbinfo = tdinfo->tdtable;
PQExpBuffer copyBuf = createPQExpBuffer();
PQExpBuffer clistBuf = createPQExpBuffer();
......@@ -2201,8 +2210,9 @@ guessConstraintInheritance(TableInfo *tblinfo, int numTables)
* dump the database definition
*/
static void
dumpDatabase(Archive *fout, DumpOptions *dopt)
dumpDatabase(Archive *fout)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer dbQry = createPQExpBuffer();
PQExpBuffer delQry = createPQExpBuffer();
PQExpBuffer creaQry = createPQExpBuffer();
......@@ -2522,7 +2532,7 @@ dumpDatabase(Archive *fout, DumpOptions *dopt)
{
resetPQExpBuffer(dbQry);
appendPQExpBuffer(dbQry, "DATABASE %s", fmtId(datname));
dumpComment(fout, dopt, dbQry->data, NULL, "",
dumpComment(fout, dbQry->data, NULL, "",
dbCatId, 0, dbDumpId);
}
......@@ -2693,7 +2703,7 @@ getBlobs(Archive *fout)
* dump the definition (metadata) of the given large object
*/
static void
dumpBlob(Archive *fout, DumpOptions *dopt, BlobInfo *binfo)
dumpBlob(Archive *fout, BlobInfo *binfo)
{
PQExpBuffer cquery = createPQExpBuffer();
PQExpBuffer dquery = createPQExpBuffer();
......@@ -2720,18 +2730,18 @@ dumpBlob(Archive *fout, DumpOptions *dopt, BlobInfo *binfo)
appendPQExpBuffer(cquery, "LARGE OBJECT %s", binfo->dobj.name);
/* Dump comment if any */
dumpComment(fout, dopt, cquery->data,
dumpComment(fout, cquery->data,
NULL, binfo->rolname,
binfo->dobj.catId, 0, binfo->dobj.dumpId);
/* Dump security label if any */
dumpSecLabel(fout, dopt, cquery->data,
dumpSecLabel(fout, 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",
dumpACL(fout, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT",
binfo->dobj.name, NULL, cquery->data,
NULL, binfo->rolname, binfo->blobacl);
......@@ -2744,7 +2754,7 @@ dumpBlob(Archive *fout, DumpOptions *dopt, BlobInfo *binfo)
* dump the data contents of all large objects
*/
static int
dumpBlobs(Archive *fout, DumpOptions *dopt, void *arg)
dumpBlobs(Archive *fout, void *arg)
{
const char *blobQry;
const char *blobFetchQry;
......@@ -2968,8 +2978,9 @@ getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
* dump the definition of the given policy
*/
static void
dumpPolicy(Archive *fout, DumpOptions *dopt, PolicyInfo *polinfo)
dumpPolicy(Archive *fout, PolicyInfo *polinfo)
{
DumpOptions *dopt = fout->dopt;
TableInfo *tbinfo = polinfo->poltable;
PQExpBuffer query;
PQExpBuffer delqry;
......@@ -3390,8 +3401,9 @@ findNamespace(Archive *fout, Oid nsoid, Oid objoid)
* numExtensions is set to the number of extensions read in
*/
ExtensionInfo *
getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions)
getExtensions(Archive *fout, int *numExtensions)
{
DumpOptions *dopt = fout->dopt;
PGresult *res;
int ntups;
int i;
......@@ -4205,8 +4217,9 @@ getOpfamilies(Archive *fout, int *numOpfamilies)
* numAggs is set to the number of aggregates read in
*/
AggInfo *
getAggregates(Archive *fout, DumpOptions *dopt, int *numAggs)
getAggregates(Archive *fout, int *numAggs)
{
DumpOptions *dopt = fout->dopt;
PGresult *res;
int ntups;
int i;
......@@ -4362,8 +4375,9 @@ getAggregates(Archive *fout, DumpOptions *dopt, int *numAggs)
* numFuncs is set to the number of functions read in
*/
FuncInfo *
getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs)
getFuncs(Archive *fout, int *numFuncs)
{
DumpOptions *dopt = fout->dopt;
PGresult *res;
int ntups;
int i;
......@@ -4524,8 +4538,9 @@ getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs)
* numTables is set to the number of tables read in
*/
TableInfo *
getTables(Archive *fout, DumpOptions *dopt, int *numTables)
getTables(Archive *fout, int *numTables)
{
DumpOptions *dopt = fout->dopt;
PGresult *res;
int ntups;
int i;
......@@ -6493,8 +6508,9 @@ getProcLangs(Archive *fout, int *numProcLangs)
* numCasts is set to the number of casts read in
*/
CastInfo *
getCasts(Archive *fout, DumpOptions *dopt, int *numCasts)
getCasts(Archive *fout, int *numCasts)
{
DumpOptions *dopt = fout->dopt;
PGresult *res;
int ntups;
int i;
......@@ -6731,8 +6747,9 @@ getTransforms(Archive *fout, int *numTransforms)
* modifies tblinfo
*/
void
getTableAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tblinfo, int numTables)
getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
{
DumpOptions *dopt = fout->dopt;
int i,
j;
PQExpBuffer q = createPQExpBuffer();
......@@ -7847,8 +7864,9 @@ getForeignServers(Archive *fout, int *numForeignServers)
* numDefaultACLs is set to the number of ACLs read in
*/
DefaultACLInfo *
getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs)
getDefaultACLs(Archive *fout, int *numDefaultACLs)
{
DumpOptions *dopt = fout->dopt;
DefaultACLInfo *daclinfo;
PQExpBuffer query;
PGresult *res;
......@@ -7945,10 +7963,11 @@ getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs)
* calling ArchiveEntry() for the specified object.
*/
static void
dumpComment(Archive *fout, DumpOptions *dopt, const char *target,
dumpComment(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
DumpOptions *dopt = fout->dopt;
CommentItem *comments;
int ncomments;
......@@ -8009,9 +8028,10 @@ dumpComment(Archive *fout, DumpOptions *dopt, const char *target,
* and its columns.
*/
static void
dumpTableComment(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo,
dumpTableComment(Archive *fout, TableInfo *tbinfo,
const char *reltypename)
{
DumpOptions *dopt = fout->dopt;
CommentItem *comments;
int ncomments;
PQExpBuffer query;
......@@ -8263,111 +8283,111 @@ collectComments(Archive *fout, CommentItem **items)
* ArchiveEntries (TOC objects) for each object to be dumped.
*/
static void
dumpDumpableObject(Archive *fout, DumpOptions *dopt, DumpableObject *dobj)
dumpDumpableObject(Archive *fout, DumpableObject *dobj)
{
switch (dobj->objType)
{
case DO_NAMESPACE:
dumpNamespace(fout, dopt, (NamespaceInfo *) dobj);
dumpNamespace(fout, (NamespaceInfo *) dobj);
break;
case DO_EXTENSION:
dumpExtension(fout, dopt, (ExtensionInfo *) dobj);
dumpExtension(fout, (ExtensionInfo *) dobj);
break;
case DO_TYPE:
dumpType(fout, dopt, (TypeInfo *) dobj);
dumpType(fout, (TypeInfo *) dobj);
break;
case DO_SHELL_TYPE:
dumpShellType(fout, dopt, (ShellTypeInfo *) dobj);
dumpShellType(fout, (ShellTypeInfo *) dobj);
break;
case DO_FUNC:
dumpFunc(fout, dopt, (FuncInfo *) dobj);
dumpFunc(fout, (FuncInfo *) dobj);
break;
case DO_AGG:
dumpAgg(fout, dopt, (AggInfo *) dobj);
dumpAgg(fout, (AggInfo *) dobj);
break;
case DO_OPERATOR:
dumpOpr(fout, dopt, (OprInfo *) dobj);
dumpOpr(fout, (OprInfo *) dobj);
break;
case DO_OPCLASS:
dumpOpclass(fout, dopt, (OpclassInfo *) dobj);
dumpOpclass(fout, (OpclassInfo *) dobj);
break;
case DO_OPFAMILY:
dumpOpfamily(fout, dopt, (OpfamilyInfo *) dobj);
dumpOpfamily(fout, (OpfamilyInfo *) dobj);
break;
case DO_COLLATION:
dumpCollation(fout, dopt, (CollInfo *) dobj);
dumpCollation(fout, (CollInfo *) dobj);
break;
case DO_CONVERSION:
dumpConversion(fout, dopt, (ConvInfo *) dobj);
dumpConversion(fout, (ConvInfo *) dobj);
break;
case DO_TABLE:
dumpTable(fout, dopt, (TableInfo *) dobj);
dumpTable(fout, (TableInfo *) dobj);
break;
case DO_ATTRDEF:
dumpAttrDef(fout, dopt, (AttrDefInfo *) dobj);
dumpAttrDef(fout, (AttrDefInfo *) dobj);
break;
case DO_INDEX:
dumpIndex(fout, dopt, (IndxInfo *) dobj);
dumpIndex(fout, (IndxInfo *) dobj);
break;
case DO_REFRESH_MATVIEW:
refreshMatViewData(fout, (TableDataInfo *) dobj);
break;
case DO_RULE:
dumpRule(fout, dopt, (RuleInfo *) dobj);
dumpRule(fout, (RuleInfo *) dobj);
break;
case DO_TRIGGER:
dumpTrigger(fout, dopt, (TriggerInfo *) dobj);
dumpTrigger(fout, (TriggerInfo *) dobj);
break;
case DO_EVENT_TRIGGER:
dumpEventTrigger(fout, dopt, (EventTriggerInfo *) dobj);
dumpEventTrigger(fout, (EventTriggerInfo *) dobj);
break;
case DO_CONSTRAINT:
dumpConstraint(fout, dopt, (ConstraintInfo *) dobj);
dumpConstraint(fout, (ConstraintInfo *) dobj);
break;
case DO_FK_CONSTRAINT:
dumpConstraint(fout, dopt, (ConstraintInfo *) dobj);
dumpConstraint(fout, (ConstraintInfo *) dobj);
break;
case DO_PROCLANG:
dumpProcLang(fout, dopt, (ProcLangInfo *) dobj);
dumpProcLang(fout, (ProcLangInfo *) dobj);
break;
case DO_CAST:
dumpCast(fout, dopt, (CastInfo *) dobj);
dumpCast(fout, (CastInfo *) dobj);
break;
case DO_TRANSFORM:
dumpTransform(fout, dopt, (TransformInfo *) dobj);
dumpTransform(fout, (TransformInfo *) dobj);
break;
case DO_TABLE_DATA:
if (((TableDataInfo *) dobj)->tdtable->relkind == RELKIND_SEQUENCE)
dumpSequenceData(fout, (TableDataInfo *) dobj);
else
dumpTableData(fout, dopt, (TableDataInfo *) dobj);
dumpTableData(fout, (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);
dumpTSParser(fout, (TSParserInfo *) dobj);
break;
case DO_TSDICT:
dumpTSDictionary(fout, dopt, (TSDictInfo *) dobj);
dumpTSDictionary(fout, (TSDictInfo *) dobj);
break;
case DO_TSTEMPLATE:
dumpTSTemplate(fout, dopt, (TSTemplateInfo *) dobj);
dumpTSTemplate(fout, (TSTemplateInfo *) dobj);
break;
case DO_TSCONFIG:
dumpTSConfig(fout, dopt, (TSConfigInfo *) dobj);
dumpTSConfig(fout, (TSConfigInfo *) dobj);
break;
case DO_FDW:
dumpForeignDataWrapper(fout, dopt, (FdwInfo *) dobj);
dumpForeignDataWrapper(fout, (FdwInfo *) dobj);
break;
case DO_FOREIGN_SERVER:
dumpForeignServer(fout, dopt, (ForeignServerInfo *) dobj);
dumpForeignServer(fout, (ForeignServerInfo *) dobj);
break;
case DO_DEFAULT_ACL:
dumpDefaultACL(fout, dopt, (DefaultACLInfo *) dobj);
dumpDefaultACL(fout, (DefaultACLInfo *) dobj);
break;
case DO_BLOB:
dumpBlob(fout, dopt, (BlobInfo *) dobj);
dumpBlob(fout, (BlobInfo *) dobj);
break;
case DO_BLOB_DATA:
ArchiveEntry(fout, dobj->catId, dobj->dumpId,
......@@ -8378,7 +8398,7 @@ dumpDumpableObject(Archive *fout, DumpOptions *dopt, DumpableObject *dobj)
dumpBlobs, NULL);
break;
case DO_POLICY:
dumpPolicy(fout, dopt, (PolicyInfo *) dobj);
dumpPolicy(fout, (PolicyInfo *) dobj);
break;
case DO_PRE_DATA_BOUNDARY:
case DO_POST_DATA_BOUNDARY:
......@@ -8392,8 +8412,9 @@ dumpDumpableObject(Archive *fout, DumpOptions *dopt, DumpableObject *dobj)
* writes out to fout the queries to recreate a user-defined namespace
*/
static void
dumpNamespace(Archive *fout, DumpOptions *dopt, NamespaceInfo *nspinfo)
dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
......@@ -8432,14 +8453,14 @@ dumpNamespace(Archive *fout, DumpOptions *dopt, NamespaceInfo *nspinfo)
NULL, NULL);
/* Dump Schema Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, labelq->data,
NULL, nspinfo->rolname,
nspinfo->dobj.catId, 0, nspinfo->dobj.dumpId);
dumpACL(fout, dopt, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
dumpACL(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId, "SCHEMA",
qnspname, NULL, nspinfo->dobj.name, NULL,
nspinfo->rolname, nspinfo->nspacl);
......@@ -8455,8 +8476,9 @@ dumpNamespace(Archive *fout, DumpOptions *dopt, NamespaceInfo *nspinfo)
* writes out to fout the queries to recreate an extension
*/
static void
dumpExtension(Archive *fout, DumpOptions *dopt, ExtensionInfo *extinfo)
dumpExtension(Archive *fout, ExtensionInfo *extinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
......@@ -8560,10 +8582,10 @@ dumpExtension(Archive *fout, DumpOptions *dopt, ExtensionInfo *extinfo)
NULL, NULL);
/* Dump Extension Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, labelq->data,
NULL, "",
extinfo->dobj.catId, 0, extinfo->dobj.dumpId);
......@@ -8579,25 +8601,27 @@ dumpExtension(Archive *fout, DumpOptions *dopt, ExtensionInfo *extinfo)
* writes out to fout the queries to recreate a user-defined type
*/
static void
dumpType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
dumpType(Archive *fout, TypeInfo *tyinfo)
{
DumpOptions *dopt = fout->dopt;
/* 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);
dumpBaseType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_DOMAIN)
dumpDomain(fout, dopt, tyinfo);
dumpDomain(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_COMPOSITE)
dumpCompositeType(fout, dopt, tyinfo);
dumpCompositeType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_ENUM)
dumpEnumType(fout, dopt, tyinfo);
dumpEnumType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_RANGE)
dumpRangeType(fout, dopt, tyinfo);
dumpRangeType(fout, tyinfo);
else if (tyinfo->typtype == TYPTYPE_PSEUDO && !tyinfo->isDefined)
dumpUndefinedType(fout, dopt, tyinfo);
dumpUndefinedType(fout, tyinfo);
else
write_msg(NULL, "WARNING: typtype of data type \"%s\" appears to be invalid\n",
tyinfo->dobj.name);
......@@ -8608,8 +8632,9 @@ dumpType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
* writes out to fout the queries to recreate a user-defined enum type
*/
static void
dumpEnumType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
dumpEnumType(Archive *fout, TypeInfo *tyinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
PQExpBuffer labelq = createPQExpBuffer();
......@@ -8713,14 +8738,14 @@ dumpEnumType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
NULL, NULL);
/* Dump Type Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, 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",
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
......@@ -8737,8 +8762,9 @@ dumpEnumType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
* writes out to fout the queries to recreate a user-defined range type
*/
static void
dumpRangeType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
dumpRangeType(Archive *fout, TypeInfo *tyinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
PQExpBuffer labelq = createPQExpBuffer();
......@@ -8845,14 +8871,14 @@ dumpRangeType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
NULL, NULL);
/* Dump Type Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, 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",
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
......@@ -8874,8 +8900,9 @@ dumpRangeType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
* depending on it.
*/
static void
dumpUndefinedType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
dumpUndefinedType(Archive *fout, TypeInfo *tyinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
PQExpBuffer labelq = createPQExpBuffer();
......@@ -8914,14 +8941,14 @@ dumpUndefinedType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
NULL, NULL);
/* Dump Type Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, 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",
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
......@@ -8936,8 +8963,9 @@ dumpUndefinedType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
* writes out to fout the queries to recreate a user-defined base type
*/
static void
dumpBaseType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
dumpBaseType(Archive *fout, TypeInfo *tyinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
PQExpBuffer labelq = createPQExpBuffer();
......@@ -9302,14 +9330,14 @@ dumpBaseType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
NULL, NULL);
/* Dump Type Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, 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",
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
......@@ -9326,8 +9354,9 @@ dumpBaseType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
* writes out to fout the queries to recreate a user-defined domain
*/
static void
dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
dumpDomain(Archive *fout, TypeInfo *tyinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
PQExpBuffer labelq = createPQExpBuffer();
......@@ -9464,14 +9493,14 @@ dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
NULL, NULL);
/* Dump Domain Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, 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",
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
......@@ -9486,7 +9515,7 @@ dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
fmtId(domcheck->dobj.name));
appendPQExpBuffer(labelq, "ON DOMAIN %s",
fmtId(qtypname));
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname,
domcheck->dobj.catId, 0, tyinfo->dobj.dumpId);
......@@ -9505,8 +9534,9 @@ dumpDomain(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
* composite type
*/
static void
dumpCompositeType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer dropped = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
......@@ -9690,14 +9720,14 @@ dumpCompositeType(Archive *fout, DumpOptions *dopt, TypeInfo *tyinfo)
/* Dump Type Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tyinfo->dobj.namespace->dobj.name, tyinfo->rolname,
tyinfo->dobj.catId, 0, tyinfo->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, 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",
dumpACL(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId, "TYPE",
qtypname, NULL, tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
tyinfo->rolname, tyinfo->typacl);
......@@ -9828,8 +9858,9 @@ 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, DumpOptions *dopt, ShellTypeInfo *stinfo)
dumpShellType(Archive *fout, ShellTypeInfo *stinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
/* Skip if not to be dumped */
......@@ -9899,8 +9930,9 @@ shouldDumpProcLangs(DumpOptions *dopt)
* procedural language
*/
static void
dumpProcLang(Archive *fout, DumpOptions *dopt, ProcLangInfo *plang)
dumpProcLang(Archive *fout, ProcLangInfo *plang)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer defqry;
PQExpBuffer delqry;
PQExpBuffer labelq;
......@@ -10037,15 +10069,15 @@ dumpProcLang(Archive *fout, DumpOptions *dopt, ProcLangInfo *plang)
NULL, NULL);
/* Dump Proc Lang Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, labelq->data,
NULL, "",
plang->dobj.catId, 0, plang->dobj.dumpId);
if (plang->lanpltrusted)
dumpACL(fout, dopt, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
dumpACL(fout, plang->dobj.catId, plang->dobj.dumpId, "LANGUAGE",
qlanname, NULL, plang->dobj.name,
lanschema,
plang->lanowner, plang->lanacl);
......@@ -10192,8 +10224,9 @@ format_function_signature(Archive *fout, FuncInfo *finfo, bool honor_quotes)
* dump out one function
*/
static void
dumpFunc(Archive *fout, DumpOptions *dopt, FuncInfo *finfo)
dumpFunc(Archive *fout, FuncInfo *finfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
PQExpBuffer q;
PQExpBuffer delqry;
......@@ -10703,14 +10736,14 @@ dumpFunc(Archive *fout, DumpOptions *dopt, FuncInfo *finfo)
NULL, NULL);
/* Dump Function Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
finfo->dobj.namespace->dobj.name, finfo->rolname,
finfo->dobj.catId, 0, finfo->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, 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",
dumpACL(fout, finfo->dobj.catId, finfo->dobj.dumpId, "FUNCTION",
funcsig, NULL, funcsig_tag,
finfo->dobj.namespace->dobj.name,
finfo->rolname, finfo->proacl);
......@@ -10741,8 +10774,9 @@ dumpFunc(Archive *fout, DumpOptions *dopt, FuncInfo *finfo)
* Dump a user-defined cast
*/
static void
dumpCast(Archive *fout, DumpOptions *dopt, CastInfo *cast)
dumpCast(Archive *fout, CastInfo *cast)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer defqry;
PQExpBuffer delqry;
PQExpBuffer labelq;
......@@ -10830,7 +10864,7 @@ dumpCast(Archive *fout, DumpOptions *dopt, CastInfo *cast)
NULL, NULL);
/* Dump Cast Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, "",
cast->dobj.catId, 0, cast->dobj.dumpId);
......@@ -10846,8 +10880,9 @@ dumpCast(Archive *fout, DumpOptions *dopt, CastInfo *cast)
* Dump a transform
*/
static void
dumpTransform(Archive *fout, DumpOptions *dopt, TransformInfo *transform)
dumpTransform(Archive *fout, TransformInfo *transform)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer defqry;
PQExpBuffer delqry;
PQExpBuffer labelq;
......@@ -10949,7 +10984,7 @@ dumpTransform(Archive *fout, DumpOptions *dopt, TransformInfo *transform)
NULL, NULL);
/* Dump Transform Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, "",
transform->dobj.catId, 0, transform->dobj.dumpId);
......@@ -10966,8 +11001,9 @@ dumpTransform(Archive *fout, DumpOptions *dopt, TransformInfo *transform)
* write out a single operator definition
*/
static void
dumpOpr(Archive *fout, DumpOptions *dopt, OprInfo *oprinfo)
dumpOpr(Archive *fout, OprInfo *oprinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
PQExpBuffer q;
PQExpBuffer delq;
......@@ -11204,7 +11240,7 @@ dumpOpr(Archive *fout, DumpOptions *dopt, OprInfo *oprinfo)
NULL, NULL);
/* Dump Operator Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
oprinfo->dobj.namespace->dobj.name, oprinfo->rolname,
oprinfo->dobj.catId, 0, oprinfo->dobj.dumpId);
......@@ -11354,8 +11390,9 @@ convertTSFunction(Archive *fout, Oid funcOid)
* write out a single operator class definition
*/
static void
dumpOpclass(Archive *fout, DumpOptions *dopt, OpclassInfo *opcinfo)
dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
PQExpBuffer q;
PQExpBuffer delq;
......@@ -11712,7 +11749,7 @@ dumpOpclass(Archive *fout, DumpOptions *dopt, OpclassInfo *opcinfo)
NULL, NULL);
/* Dump Operator Class Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, opcinfo->rolname,
opcinfo->dobj.catId, 0, opcinfo->dobj.dumpId);
......@@ -11731,8 +11768,9 @@ dumpOpclass(Archive *fout, DumpOptions *dopt, OpclassInfo *opcinfo)
* specific opclass within the opfamily.
*/
static void
dumpOpfamily(Archive *fout, DumpOptions *dopt, OpfamilyInfo *opfinfo)
dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
PQExpBuffer q;
PQExpBuffer delq;
......@@ -12025,7 +12063,7 @@ dumpOpfamily(Archive *fout, DumpOptions *dopt, OpfamilyInfo *opfinfo)
NULL, NULL);
/* Dump Operator Family Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, opfinfo->rolname,
opfinfo->dobj.catId, 0, opfinfo->dobj.dumpId);
......@@ -12043,8 +12081,9 @@ dumpOpfamily(Archive *fout, DumpOptions *dopt, OpfamilyInfo *opfinfo)
* write out a single collation definition
*/
static void
dumpCollation(Archive *fout, DumpOptions *dopt, CollInfo *collinfo)
dumpCollation(Archive *fout, CollInfo *collinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
PQExpBuffer q;
PQExpBuffer delq;
......@@ -12114,7 +12153,7 @@ dumpCollation(Archive *fout, DumpOptions *dopt, CollInfo *collinfo)
NULL, NULL);
/* Dump Collation Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
collinfo->dobj.namespace->dobj.name, collinfo->rolname,
collinfo->dobj.catId, 0, collinfo->dobj.dumpId);
......@@ -12131,8 +12170,9 @@ dumpCollation(Archive *fout, DumpOptions *dopt, CollInfo *collinfo)
* write out a single conversion definition
*/
static void
dumpConversion(Archive *fout, DumpOptions *dopt, ConvInfo *convinfo)
dumpConversion(Archive *fout, ConvInfo *convinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
PQExpBuffer q;
PQExpBuffer delq;
......@@ -12213,7 +12253,7 @@ dumpConversion(Archive *fout, DumpOptions *dopt, ConvInfo *convinfo)
NULL, NULL);
/* Dump Conversion Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
convinfo->dobj.namespace->dobj.name, convinfo->rolname,
convinfo->dobj.catId, 0, convinfo->dobj.dumpId);
......@@ -12270,8 +12310,9 @@ format_aggregate_signature(AggInfo *agginfo, Archive *fout, bool honor_quotes)
* write out a single aggregate definition
*/
static void
dumpAgg(Archive *fout, DumpOptions *dopt, AggInfo *agginfo)
dumpAgg(Archive *fout, AggInfo *agginfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
PQExpBuffer q;
PQExpBuffer delq;
......@@ -12609,10 +12650,10 @@ dumpAgg(Archive *fout, DumpOptions *dopt, AggInfo *agginfo)
NULL, NULL);
/* Dump Aggregate Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, 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,
dumpSecLabel(fout, labelq->data,
agginfo->aggfn.dobj.namespace->dobj.name, agginfo->aggfn.rolname,
agginfo->aggfn.dobj.catId, 0, agginfo->aggfn.dobj.dumpId);
......@@ -12627,7 +12668,7 @@ dumpAgg(Archive *fout, DumpOptions *dopt, AggInfo *agginfo)
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,
dumpACL(fout, agginfo->aggfn.dobj.catId, agginfo->aggfn.dobj.dumpId,
"FUNCTION",
aggsig, NULL, aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
......@@ -12652,8 +12693,9 @@ dumpAgg(Archive *fout, DumpOptions *dopt, AggInfo *agginfo)
* write out a single text search parser
*/
static void
dumpTSParser(Archive *fout, DumpOptions *dopt, TSParserInfo *prsinfo)
dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
......@@ -12709,7 +12751,7 @@ dumpTSParser(Archive *fout, DumpOptions *dopt, TSParserInfo *prsinfo)
NULL, NULL);
/* Dump Parser Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, "",
prsinfo->dobj.catId, 0, prsinfo->dobj.dumpId);
......@@ -12723,8 +12765,9 @@ dumpTSParser(Archive *fout, DumpOptions *dopt, TSParserInfo *prsinfo)
* write out a single text search dictionary
*/
static void
dumpTSDictionary(Archive *fout, DumpOptions *dopt, TSDictInfo *dictinfo)
dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
......@@ -12796,7 +12839,7 @@ dumpTSDictionary(Archive *fout, DumpOptions *dopt, TSDictInfo *dictinfo)
NULL, NULL);
/* Dump Dictionary Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, dictinfo->rolname,
dictinfo->dobj.catId, 0, dictinfo->dobj.dumpId);
......@@ -12811,8 +12854,9 @@ dumpTSDictionary(Archive *fout, DumpOptions *dopt, TSDictInfo *dictinfo)
* write out a single text search template
*/
static void
dumpTSTemplate(Archive *fout, DumpOptions *dopt, TSTemplateInfo *tmplinfo)
dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
......@@ -12862,7 +12906,7 @@ dumpTSTemplate(Archive *fout, DumpOptions *dopt, TSTemplateInfo *tmplinfo)
NULL, NULL);
/* Dump Template Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, "",
tmplinfo->dobj.catId, 0, tmplinfo->dobj.dumpId);
......@@ -12876,8 +12920,9 @@ dumpTSTemplate(Archive *fout, DumpOptions *dopt, TSTemplateInfo *tmplinfo)
* write out a single text search configuration
*/
static void
dumpTSConfig(Archive *fout, DumpOptions *dopt, TSConfigInfo *cfginfo)
dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
......@@ -12990,7 +13035,7 @@ dumpTSConfig(Archive *fout, DumpOptions *dopt, TSConfigInfo *cfginfo)
NULL, NULL);
/* Dump Configuration Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, cfginfo->rolname,
cfginfo->dobj.catId, 0, cfginfo->dobj.dumpId);
......@@ -13005,8 +13050,9 @@ dumpTSConfig(Archive *fout, DumpOptions *dopt, TSConfigInfo *cfginfo)
* write out a single foreign-data wrapper definition
*/
static void
dumpForeignDataWrapper(Archive *fout, DumpOptions *dopt, FdwInfo *fdwinfo)
dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
......@@ -13064,14 +13110,14 @@ dumpForeignDataWrapper(Archive *fout, DumpOptions *dopt, FdwInfo *fdwinfo)
NULL, NULL);
/* Handle the ACL */
dumpACL(fout, dopt, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
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, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, fdwinfo->rolname,
fdwinfo->dobj.catId, 0, fdwinfo->dobj.dumpId);
......@@ -13087,8 +13133,9 @@ dumpForeignDataWrapper(Archive *fout, DumpOptions *dopt, FdwInfo *fdwinfo)
* write out a foreign server definition
*/
static void
dumpForeignServer(Archive *fout, DumpOptions *dopt, ForeignServerInfo *srvinfo)
dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
PQExpBuffer delq;
PQExpBuffer labelq;
......@@ -13156,7 +13203,7 @@ dumpForeignServer(Archive *fout, DumpOptions *dopt, ForeignServerInfo *srvinfo)
NULL, NULL);
/* Handle the ACL */
dumpACL(fout, dopt, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
dumpACL(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
"FOREIGN SERVER",
qsrvname, NULL, srvinfo->dobj.name,
NULL, srvinfo->rolname,
......@@ -13169,7 +13216,7 @@ dumpForeignServer(Archive *fout, DumpOptions *dopt, ForeignServerInfo *srvinfo)
srvinfo->dobj.catId, srvinfo->dobj.dumpId);
/* Dump Foreign Server Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, srvinfo->rolname,
srvinfo->dobj.catId, 0, srvinfo->dobj.dumpId);
......@@ -13285,8 +13332,9 @@ dumpUserMappings(Archive *fout,
* Write out default privileges information
*/
static void
dumpDefaultACL(Archive *fout, DumpOptions *dopt, DefaultACLInfo *daclinfo)
dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q;
PQExpBuffer tag;
const char *type;
......@@ -13365,11 +13413,12 @@ dumpDefaultACL(Archive *fout, DumpOptions *dopt, DefaultACLInfo *daclinfo)
*----------
*/
static void
dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId,
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)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer sql;
/* Do nothing if ACL dump is not enabled */
......@@ -13420,10 +13469,11 @@ dumpACL(Archive *fout, DumpOptions *dopt, CatalogId objCatId, DumpId objDumpId,
* calling ArchiveEntry() for the specified object.
*/
static void
dumpSecLabel(Archive *fout, DumpOptions *dopt, const char *target,
dumpSecLabel(Archive *fout, const char *target,
const char *namespace, const char *owner,
CatalogId catalogId, int subid, DumpId dumpId)
{
DumpOptions *dopt = fout->dopt;
SecLabelItem *labels;
int nlabels;
int i;
......@@ -13484,8 +13534,9 @@ dumpSecLabel(Archive *fout, DumpOptions *dopt, const char *target,
* and its columns.
*/
static void
dumpTableSecLabel(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, const char *reltypename)
dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename)
{
DumpOptions *dopt = fout->dopt;
SecLabelItem *labels;
int nlabels;
int i;
......@@ -13705,20 +13756,22 @@ collectSecLabels(Archive *fout, SecLabelItem **items)
* write out to fout the declarations (not data) of a user-defined table
*/
static void
dumpTable(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
dumpTable(Archive *fout, TableInfo *tbinfo)
{
DumpOptions *dopt = fout->dopt;
if (tbinfo->dobj.dump && !dopt->dataOnly)
{
char *namecopy;
if (tbinfo->relkind == RELKIND_SEQUENCE)
dumpSequence(fout, dopt, tbinfo);
dumpSequence(fout, tbinfo);
else
dumpTableSchema(fout, dopt, tbinfo);
dumpTableSchema(fout, tbinfo);
/* Handle the ACL here */
namecopy = pg_strdup(fmtId(tbinfo->dobj.name));
dumpACL(fout, dopt, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
(tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" :
"TABLE",
namecopy, NULL, tbinfo->dobj.name,
......@@ -13753,7 +13806,7 @@ dumpTable(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
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",
dumpACL(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId, "TABLE",
namecopy, attnamecopy, acltag,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
attacl);
......@@ -13830,8 +13883,9 @@ createViewAsClause(Archive *fout, TableInfo *tbinfo)
* write the declaration (not data) of one user-defined table or view
*/
static void
dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
dumpTableSchema(Archive *fout, TableInfo *tbinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer q = createPQExpBuffer();
PQExpBuffer delq = createPQExpBuffer();
PQExpBuffer labelq = createPQExpBuffer();
......@@ -14456,10 +14510,10 @@ dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
/* Dump Table Comments */
dumpTableComment(fout, dopt, tbinfo, reltypename);
dumpTableComment(fout, tbinfo, reltypename);
/* Dump Table Security Labels */
dumpTableSecLabel(fout, dopt, tbinfo, reltypename);
dumpTableSecLabel(fout, tbinfo, reltypename);
/* Dump comments on inlined table constraints */
for (j = 0; j < tbinfo->ncheck; j++)
......@@ -14469,7 +14523,7 @@ dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
if (constr->separate || !constr->conislocal)
continue;
dumpTableConstraintComment(fout, dopt, constr);
dumpTableConstraintComment(fout, constr);
}
destroyPQExpBuffer(q);
......@@ -14481,8 +14535,9 @@ dumpTableSchema(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
* dumpAttrDef --- dump an attribute's default-value declaration
*/
static void
dumpAttrDef(Archive *fout, DumpOptions *dopt, AttrDefInfo *adinfo)
dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
{
DumpOptions *dopt = fout->dopt;
TableInfo *tbinfo = adinfo->adtable;
int adnum = adinfo->adnum;
PQExpBuffer q;
......@@ -14568,8 +14623,9 @@ getAttrName(int attrnum, TableInfo *tblInfo)
* write out to fout a user-defined index
*/
static void
dumpIndex(Archive *fout, DumpOptions *dopt, IndxInfo *indxinfo)
dumpIndex(Archive *fout, IndxInfo *indxinfo)
{
DumpOptions *dopt = fout->dopt;
TableInfo *tbinfo = indxinfo->indextable;
bool is_constraint = (indxinfo->indexconstraint != 0);
PQExpBuffer q;
......@@ -14641,7 +14697,7 @@ dumpIndex(Archive *fout, DumpOptions *dopt, IndxInfo *indxinfo)
}
/* Dump Index Comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
indxinfo->dobj.catId, 0,
......@@ -14658,8 +14714,9 @@ dumpIndex(Archive *fout, DumpOptions *dopt, IndxInfo *indxinfo)
* write out to fout a user-defined constraint
*/
static void
dumpConstraint(Archive *fout, DumpOptions *dopt, ConstraintInfo *coninfo)
dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
{
DumpOptions *dopt = fout->dopt;
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer q;
PQExpBuffer delq;
......@@ -14879,7 +14936,7 @@ dumpConstraint(Archive *fout, DumpOptions *dopt, ConstraintInfo *coninfo)
/* Dump Constraint Comments --- only works for table constraints */
if (tbinfo && coninfo->separate)
dumpTableConstraintComment(fout, dopt, coninfo);
dumpTableConstraintComment(fout, coninfo);
destroyPQExpBuffer(q);
destroyPQExpBuffer(delq);
......@@ -14893,7 +14950,7 @@ dumpConstraint(Archive *fout, DumpOptions *dopt, ConstraintInfo *coninfo)
* or as a separate ALTER command.
*/
static void
dumpTableConstraintComment(Archive *fout, DumpOptions *dopt, ConstraintInfo *coninfo)
dumpTableConstraintComment(Archive *fout, ConstraintInfo *coninfo)
{
TableInfo *tbinfo = coninfo->contable;
PQExpBuffer labelq = createPQExpBuffer();
......@@ -14902,7 +14959,7 @@ dumpTableConstraintComment(Archive *fout, DumpOptions *dopt, ConstraintInfo *con
fmtId(coninfo->dobj.name));
appendPQExpBuffer(labelq, "ON %s",
fmtId(tbinfo->dobj.name));
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
coninfo->dobj.catId, 0,
......@@ -14962,8 +15019,9 @@ findLastBuiltinOid_V70(Archive *fout)
* write the declaration (not data) of one user-defined sequence
*/
static void
dumpSequence(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
dumpSequence(Archive *fout, TableInfo *tbinfo)
{
DumpOptions *dopt = fout->dopt;
PGresult *res;
char *startv,
*incby,
......@@ -15148,10 +15206,10 @@ dumpSequence(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo)
}
/* Dump Sequence Comments and Security Labels */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
dumpSecLabel(fout, dopt, labelq->data,
dumpSecLabel(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tbinfo->dobj.catId, 0, tbinfo->dobj.dumpId);
......@@ -15222,8 +15280,9 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo)
* write the declaration of one user-defined table trigger
*/
static void
dumpTrigger(Archive *fout, DumpOptions *dopt, TriggerInfo *tginfo)
dumpTrigger(Archive *fout, TriggerInfo *tginfo)
{
DumpOptions *dopt = fout->dopt;
TableInfo *tbinfo = tginfo->tgtable;
PQExpBuffer query;
PQExpBuffer delqry;
......@@ -15418,7 +15477,7 @@ dumpTrigger(Archive *fout, DumpOptions *dopt, TriggerInfo *tginfo)
NULL, 0,
NULL, NULL);
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
tginfo->dobj.catId, 0, tginfo->dobj.dumpId);
......@@ -15432,8 +15491,9 @@ dumpTrigger(Archive *fout, DumpOptions *dopt, TriggerInfo *tginfo)
* write the declaration of one user-defined event trigger
*/
static void
dumpEventTrigger(Archive *fout, DumpOptions *dopt, EventTriggerInfo *evtinfo)
dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
PQExpBuffer labelq;
......@@ -15489,7 +15549,7 @@ dumpEventTrigger(Archive *fout, DumpOptions *dopt, EventTriggerInfo *evtinfo)
"EVENT TRIGGER", SECTION_POST_DATA,
query->data, "", NULL, NULL, 0, NULL, NULL);
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
NULL, evtinfo->evtowner,
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
......@@ -15502,8 +15562,9 @@ dumpEventTrigger(Archive *fout, DumpOptions *dopt, EventTriggerInfo *evtinfo)
* Dump a rule
*/
static void
dumpRule(Archive *fout, DumpOptions *dopt, RuleInfo *rinfo)
dumpRule(Archive *fout, RuleInfo *rinfo)
{
DumpOptions *dopt = fout->dopt;
TableInfo *tbinfo = rinfo->ruletable;
PQExpBuffer query;
PQExpBuffer cmd;
......@@ -15618,7 +15679,7 @@ dumpRule(Archive *fout, DumpOptions *dopt, RuleInfo *rinfo)
NULL, NULL);
/* Dump rule comments */
dumpComment(fout, dopt, labelq->data,
dumpComment(fout, labelq->data,
tbinfo->dobj.namespace->dobj.name,
tbinfo->rolname,
rinfo->dobj.catId, 0, rinfo->dobj.dumpId);
......@@ -15662,9 +15723,10 @@ dumpRule(Archive *fout, DumpOptions *dopt, RuleInfo *rinfo)
* but perhaps we can provide a better solution in the future.
*/
void
getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[],
getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
int numExtensions)
{
DumpOptions *dopt = fout->dopt;
PQExpBuffer query;
PGresult *res;
int ntups,
......
......@@ -493,7 +493,7 @@ extern char g_opaque_type[10]; /* name for the opaque type */
* common utility functions
*/
extern TableInfo *getSchemaData(Archive *, DumpOptions *dopt, int *numTablesPtr);
extern TableInfo *getSchemaData(Archive *fout, int *numTablesPtr);
extern void AssignDumpId(DumpableObject *dobj);
extern DumpId createDumpId(void);
......@@ -527,16 +527,16 @@ extern void sortDataAndIndexObjectsBySize(DumpableObject **objs, int numObjs);
* version specific routines
*/
extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces);
extern ExtensionInfo *getExtensions(Archive *fout, DumpOptions *dopt, int *numExtensions);
extern ExtensionInfo *getExtensions(Archive *fout, int *numExtensions);
extern TypeInfo *getTypes(Archive *fout, int *numTypes);
extern FuncInfo *getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs);
extern AggInfo *getAggregates(Archive *fout, DumpOptions *dopt, int *numAggregates);
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, DumpOptions *dopt, int *numTables);
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);
......@@ -544,9 +544,9 @@ extern void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables);
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, DumpOptions *dopt, int *numCasts);
extern CastInfo *getCasts(Archive *fout, int *numCasts);
extern TransformInfo *getTransforms(Archive *fout, int *numTransforms);
extern void getTableAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tbinfo, int numTables);
extern void getTableAttrs(Archive *fout, 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);
......@@ -556,8 +556,8 @@ extern FdwInfo *getForeignDataWrappers(Archive *fout,
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[],
extern DefaultACLInfo *getDefaultACLs(Archive *fout, int *numDefaultACLs);
extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
int numExtensions);
extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
extern void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables);
......
......@@ -377,6 +377,8 @@ main(int argc, char **argv)
AH = OpenArchive(inputFileSpec, opts->format);
SetArchiveOptions(AH, NULL, opts);
/*
* We don't have a connection yet but that doesn't matter. The connection
* is initialized to NULL and if we terminate through exit_nicely() while
......@@ -393,7 +395,7 @@ main(int argc, char **argv)
AH->exit_on_error = opts->exit_on_error;
if (opts->tocFile)
SortTocFromFile(AH, opts);
SortTocFromFile(AH);
/* See comments in pg_dump.c */
#ifdef WIN32
......@@ -408,10 +410,10 @@ main(int argc, char **argv)
AH->numWorkers = numWorkers;
if (opts->tocSummary)
PrintTOCSummary(AH, opts);
PrintTOCSummary(AH);
else
{
SetArchiveRestoreOptions(AH, opts);
ProcessArchiveRestoreOptions(AH);
RestoreArchive(AH);
}
......@@ -423,7 +425,7 @@ main(int argc, char **argv)
/* AH may be freed in CloseArchive? */
exit_code = AH->n_errors ? 1 : 0;
CloseArchive(AH, NULL);
CloseArchive(AH);
return exit_code;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment