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 0eea8047bf, 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.
This commit is contained in:
Tom Lane 2016-01-13 17:48:33 -05:00
parent 26905e009b
commit 5b5fea2a11
13 changed files with 486 additions and 405 deletions

View File

@ -81,7 +81,7 @@ static int strInArray(const char *pattern, char **arr, int arr_size);
* Collect information about all potentially dumpable objects * Collect information about all potentially dumpable objects
*/ */
TableInfo * TableInfo *
getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr) getSchemaData(Archive *fout, int *numTablesPtr)
{ {
ExtensionInfo *extinfo; ExtensionInfo *extinfo;
InhInfo *inhinfo; InhInfo *inhinfo;
@ -118,7 +118,7 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
*/ */
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined tables\n"); write_msg(NULL, "reading user-defined tables\n");
tblinfo = getTables(fout, dopt, &numTables); tblinfo = getTables(fout, &numTables);
tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo)); tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));
/* Do this after we've built tblinfoindex */ /* Do this after we've built tblinfoindex */
@ -126,11 +126,11 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading extensions\n"); write_msg(NULL, "reading extensions\n");
extinfo = getExtensions(fout, dopt, &numExtensions); extinfo = getExtensions(fout, &numExtensions);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined functions\n"); write_msg(NULL, "reading user-defined functions\n");
funinfo = getFuncs(fout, dopt, &numFuncs); funinfo = getFuncs(fout, &numFuncs);
funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo)); funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo));
/* this must be after getTables and getFuncs */ /* this must be after getTables and getFuncs */
@ -146,7 +146,7 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined aggregate functions\n"); write_msg(NULL, "reading user-defined aggregate functions\n");
getAggregates(fout, dopt, &numAggregates); getAggregates(fout, &numAggregates);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined operators\n"); write_msg(NULL, "reading user-defined operators\n");
@ -187,7 +187,7 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading default privileges\n"); write_msg(NULL, "reading default privileges\n");
getDefaultACLs(fout, dopt, &numDefaultACLs); getDefaultACLs(fout, &numDefaultACLs);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading user-defined collations\n"); write_msg(NULL, "reading user-defined collations\n");
@ -200,7 +200,7 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading type casts\n"); write_msg(NULL, "reading type casts\n");
getCasts(fout, dopt, &numCasts); getCasts(fout, &numCasts);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading transforms\n"); write_msg(NULL, "reading transforms\n");
@ -221,7 +221,7 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
*/ */
if (g_verbose) if (g_verbose)
write_msg(NULL, "finding extension members\n"); 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 */ /* Link tables to parents, mark parents of target tables interesting */
if (g_verbose) if (g_verbose)
@ -230,11 +230,11 @@ getSchemaData(Archive *fout, DumpOptions *dopt, int *numTablesPtr)
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading column info for interesting tables\n"); write_msg(NULL, "reading column info for interesting tables\n");
getTableAttrs(fout, dopt, tblinfo, numTables); getTableAttrs(fout, tblinfo, numTables);
if (g_verbose) if (g_verbose)
write_msg(NULL, "flagging inherited columns in subtables\n"); write_msg(NULL, "flagging inherited columns in subtables\n");
flagInhAttrs(dopt, tblinfo, numTables); flagInhAttrs(fout->dopt, tblinfo, numTables);
if (g_verbose) if (g_verbose)
write_msg(NULL, "reading indexes\n"); write_msg(NULL, "reading indexes\n");

View File

@ -46,8 +46,6 @@ static int piperead(int s, char *buf, int len);
typedef struct typedef struct
{ {
ArchiveHandle *AH; ArchiveHandle *AH;
RestoreOptions *ropt;
DumpOptions *dopt;
int worker; int worker;
int pipeRead; int pipeRead;
int pipeWrite; int pipeWrite;
@ -87,13 +85,11 @@ static void WaitForTerminatingWorkers(ParallelState *pstate);
#ifndef WIN32 #ifndef WIN32
static void sigTermHandler(int signum); static void sigTermHandler(int signum);
#endif #endif
static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker, static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker);
DumpOptions *dopt,
RestoreOptions *ropt);
static bool HasEveryWorkerTerminated(ParallelState *pstate); static bool HasEveryWorkerTerminated(ParallelState *pstate);
static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te); 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 char *getMessageFromMaster(int pipefd[2]);
static void sendMessageToMaster(int pipefd[2], const char *str); static void sendMessageToMaster(int pipefd[2], const char *str);
static int select_loop(int maxFd, fd_set *workerset); static int select_loop(int maxFd, fd_set *workerset);
@ -435,9 +431,7 @@ sigTermHandler(int signum)
* worker process. * worker process.
*/ */
static void static void
SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker, SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker)
DumpOptions *dopt,
RestoreOptions *ropt)
{ {
/* /*
* Call the setup worker function that's defined in the ArchiveHandle. * 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 * properly when we shut down. This happens only that way when it is
* brought down because of an error. * brought down because of an error.
*/ */
(AH->SetupWorkerPtr) ((Archive *) AH, dopt, ropt); (AH->SetupWorkerPtr) ((Archive *) AH);
Assert(AH->connection != NULL); Assert(AH->connection != NULL);
WaitForCommands(AH, dopt, pipefd); WaitForCommands(AH, pipefd);
closesocket(pipefd[PIPE_READ]); closesocket(pipefd[PIPE_READ]);
closesocket(pipefd[PIPE_WRITE]); closesocket(pipefd[PIPE_WRITE]);
@ -463,13 +457,11 @@ init_spawned_worker_win32(WorkerInfo *wi)
ArchiveHandle *AH; ArchiveHandle *AH;
int pipefd[2] = {wi->pipeRead, wi->pipeWrite}; int pipefd[2] = {wi->pipeRead, wi->pipeWrite};
int worker = wi->worker; int worker = wi->worker;
DumpOptions *dopt = wi->dopt;
RestoreOptions *ropt = wi->ropt;
AH = CloneArchive(wi->AH); AH = CloneArchive(wi->AH);
free(wi); free(wi);
SetupWorker(AH, pipefd, worker, dopt, ropt); SetupWorker(AH, pipefd, worker);
DeCloneArchive(AH); DeCloneArchive(AH);
_endthreadex(0); _endthreadex(0);
@ -483,7 +475,7 @@ init_spawned_worker_win32(WorkerInfo *wi)
* of threads while it does a fork() on Unix. * of threads while it does a fork() on Unix.
*/ */
ParallelState * ParallelState *
ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt) ParallelBackupStart(ArchiveHandle *AH)
{ {
ParallelState *pstate; ParallelState *pstate;
int i; int i;
@ -545,8 +537,6 @@ ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt)
/* Allocate a new structure for every worker */ /* Allocate a new structure for every worker */
wi = (WorkerInfo *) pg_malloc(sizeof(WorkerInfo)); wi = (WorkerInfo *) pg_malloc(sizeof(WorkerInfo));
wi->ropt = ropt;
wi->dopt = dopt;
wi->worker = i; wi->worker = i;
wi->AH = AH; wi->AH = AH;
wi->pipeRead = pstate->parallelSlot[i].pipeRevRead = pipeMW[PIPE_READ]; 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); 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); exit(0);
} }
@ -859,7 +849,7 @@ lockTableNoWait(ArchiveHandle *AH, TocEntry *te)
* exit. * exit.
*/ */
static void static void
WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]) WaitForCommands(ArchiveHandle *AH, int pipefd[2])
{ {
char *command; char *command;
DumpId dumpId; 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 * The message we return here has been pg_malloc()ed and we are
* responsible for free()ing it. * responsible for free()ing it.
*/ */
str = (AH->WorkerJobDumpPtr) (AH, dopt, te); str = (AH->WorkerJobDumpPtr) (AH, te);
Assert(AH->connection != NULL); Assert(AH->connection != NULL);
sendMessageToMaster(pipefd, str); sendMessageToMaster(pipefd, str);
free(str); free(str);

View File

@ -76,9 +76,7 @@ extern int ReapWorkerStatus(ParallelState *pstate, int *status);
extern void EnsureIdleWorker(ArchiveHandle *AH, ParallelState *pstate); extern void EnsureIdleWorker(ArchiveHandle *AH, ParallelState *pstate);
extern void EnsureWorkersFinished(ArchiveHandle *AH, ParallelState *pstate); extern void EnsureWorkersFinished(ArchiveHandle *AH, ParallelState *pstate);
extern ParallelState *ParallelBackupStart(ArchiveHandle *AH, extern ParallelState *ParallelBackupStart(ArchiveHandle *AH);
DumpOptions *dopt,
RestoreOptions *ropt);
extern void DispatchJobForTocEntry(ArchiveHandle *AH, extern void DispatchJobForTocEntry(ArchiveHandle *AH,
ParallelState *pstate, ParallelState *pstate,
TocEntry *te, T_Action act); TocEntry *te, T_Action act);

View File

@ -58,35 +58,6 @@ typedef enum _teSection
SECTION_POST_DATA /* stuff to be processed after data */ SECTION_POST_DATA /* stuff to be processed after data */
} teSection; } 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 typedef struct _restoreOptions
{ {
int createDB; /* Issue commands to create the database */ int createDB; /* Issue commands to create the database */
@ -190,6 +161,38 @@ typedef struct _dumpOptions
char *outputSuperuser; char *outputSuperuser;
} DumpOptions; } 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: * pg_dump uses two different mechanisms for identifying database objects:
@ -215,9 +218,9 @@ typedef struct
typedef int DumpId; 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. * 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 StartBlob(Archive *AH, Oid oid);
extern int EndBlob(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 SetArchiveRestoreOptions(Archive *AH, RestoreOptions *ropt); extern void SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt);
extern void ProcessArchiveRestoreOptions(Archive *AH);
extern void RestoreArchive(Archive *AH); extern void RestoreArchive(Archive *AH);
@ -265,7 +270,7 @@ extern Archive *CreateArchive(const char *FileSpec, const ArchiveFormat fmt,
SetupWorkerPtr setupDumpWorker); SetupWorkerPtr setupDumpWorker);
/* The --list option */ /* The --list option */
extern void PrintTOCSummary(Archive *AH, RestoreOptions *ropt); extern void PrintTOCSummary(Archive *AH);
extern RestoreOptions *NewRestoreOptions(void); extern RestoreOptions *NewRestoreOptions(void);
@ -274,7 +279,7 @@ extern void InitDumpOptions(DumpOptions *opts);
extern DumpOptions *dumpOptionsFromRestoreOptions(RestoreOptions *ropt); extern DumpOptions *dumpOptionsFromRestoreOptions(RestoreOptions *ropt);
/* Rearrange and filter TOC entries */ /* Rearrange and filter TOC entries */
extern void SortTocFromFile(Archive *AHX, RestoreOptions *ropt); extern void SortTocFromFile(Archive *AHX);
/* Convenience functions used only when writing DATA */ /* Convenience functions used only when writing DATA */
extern void archputs(const char *s, Archive *AH); extern void archputs(const char *s, Archive *AH);

View File

@ -57,7 +57,7 @@ static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
const int compression, ArchiveMode mode, SetupWorkerPtr setupWorkerPtr); const int compression, ArchiveMode mode, SetupWorkerPtr setupWorkerPtr);
static void _getObjectDescription(PQExpBuffer buf, TocEntry *te, static void _getObjectDescription(PQExpBuffer buf, TocEntry *te,
ArchiveHandle *AH); 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 char *replace_line_endings(const char *str);
static void _doSetFixedOutputState(ArchiveHandle *AH); static void _doSetFixedOutputState(ArchiveHandle *AH);
static void _doSetSessionAuth(ArchiveHandle *AH, const char *user); 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 void processStdStringsEntry(ArchiveHandle *AH, TocEntry *te);
static teReqs _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt); static teReqs _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt);
static bool _tocEntryIsACL(TocEntry *te); static bool _tocEntryIsACL(TocEntry *te);
static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te);
static void _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te);
static void buildTocEntryArrays(ArchiveHandle *AH); static void buildTocEntryArrays(ArchiveHandle *AH);
static void _moveBefore(ArchiveHandle *AH, TocEntry *pos, TocEntry *te); static void _moveBefore(ArchiveHandle *AH, TocEntry *pos, TocEntry *te);
static int _discoverArchiveFormat(ArchiveHandle *AH); 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 OutputContext SaveOutput(ArchiveHandle *AH);
static void RestoreOutput(ArchiveHandle *AH, OutputContext savedContext); static void RestoreOutput(ArchiveHandle *AH, OutputContext savedContext);
static int restore_toc_entry(ArchiveHandle *AH, TocEntry *te, static int restore_toc_entry(ArchiveHandle *AH, TocEntry *te, bool is_parallel);
RestoreOptions *ropt, bool is_parallel);
static void restore_toc_entries_prefork(ArchiveHandle *AH); static void restore_toc_entries_prefork(ArchiveHandle *AH);
static void restore_toc_entries_parallel(ArchiveHandle *AH, ParallelState *pstate, static void restore_toc_entries_parallel(ArchiveHandle *AH, ParallelState *pstate,
TocEntry *pending_list); TocEntry *pending_list);
@ -184,7 +183,7 @@ dumpOptionsFromRestoreOptions(RestoreOptions *ropt)
* setup doesn't need to know anything much, so it's defined here. * setup doesn't need to know anything much, so it's defined here.
*/ */
static void static void
setupRestoreWorker(Archive *AHX, DumpOptions *dopt, RestoreOptions *ropt) setupRestoreWorker(Archive *AHX)
{ {
ArchiveHandle *AH = (ArchiveHandle *) AHX; ArchiveHandle *AH = (ArchiveHandle *) AHX;
@ -216,12 +215,12 @@ OpenArchive(const char *FileSpec, const ArchiveFormat fmt)
/* Public */ /* Public */
void void
CloseArchive(Archive *AHX, DumpOptions *dopt) CloseArchive(Archive *AHX)
{ {
int res = 0; int res = 0;
ArchiveHandle *AH = (ArchiveHandle *) AHX; ArchiveHandle *AH = (ArchiveHandle *) AHX;
(*AH->ClosePtr) (AH, dopt); (*AH->ClosePtr) (AH);
/* Close the output */ /* Close the output */
if (AH->gzOut) if (AH->gzOut)
@ -236,14 +235,25 @@ CloseArchive(Archive *AHX, DumpOptions *dopt)
/* Public */ /* Public */
void void
SetArchiveRestoreOptions(Archive *AHX, RestoreOptions *ropt) SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt)
{ {
ArchiveHandle *AH = (ArchiveHandle *) AHX; /* Caller can omit dump options, in which case we synthesize them */
TocEntry *te; if (dopt == NULL && ropt != NULL)
teSection curSection; dopt = dumpOptionsFromRestoreOptions(ropt);
/* Save options for later access */ /* Save options for later access */
AH->dopt = dopt;
AH->ropt = ropt; 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 */ /* Decide which TOC entries will be dumped/restored, and mark them */
curSection = SECTION_PRE_DATA; curSection = SECTION_PRE_DATA;
@ -298,7 +308,7 @@ void
RestoreArchive(Archive *AHX) RestoreArchive(Archive *AHX)
{ {
ArchiveHandle *AH = (ArchiveHandle *) AHX; ArchiveHandle *AH = (ArchiveHandle *) AHX;
RestoreOptions *ropt = AH->ropt; RestoreOptions *ropt = AH->public.ropt;
bool parallel_mode; bool parallel_mode;
TocEntry *te; TocEntry *te;
OutputContext sav; OutputContext sav;
@ -605,7 +615,7 @@ RestoreArchive(Archive *AHX)
Assert(AH->connection == NULL); Assert(AH->connection == NULL);
/* ParallelBackupStart() will actually fork the processes */ /* ParallelBackupStart() will actually fork the processes */
pstate = ParallelBackupStart(AH, NULL, ropt); pstate = ParallelBackupStart(AH);
restore_toc_entries_parallel(AH, pstate, &pending_list); restore_toc_entries_parallel(AH, pstate, &pending_list);
ParallelBackupEnd(AH, pstate); ParallelBackupEnd(AH, pstate);
@ -616,7 +626,7 @@ RestoreArchive(Archive *AHX)
else else
{ {
for (te = AH->toc->next; te != AH->toc; te = te->next) 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 else
ahlog(AH, 1, "setting owner and privileges for %s \"%s\"\n", ahlog(AH, 1, "setting owner and privileges for %s \"%s\"\n",
te->desc, te->tag); 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. * the parallel parent has to make the corresponding status update.
*/ */
static int static int
restore_toc_entry(ArchiveHandle *AH, TocEntry *te, restore_toc_entry(ArchiveHandle *AH, TocEntry *te, bool is_parallel)
RestoreOptions *ropt, bool is_parallel)
{ {
RestoreOptions *ropt = AH->public.ropt;
int status = WORKER_OK; int status = WORKER_OK;
teReqs reqs; teReqs reqs;
bool defnDumped; bool defnDumped;
@ -717,7 +727,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
ahlog(AH, 1, "creating %s \"%s\"\n", te->desc, te->tag); ahlog(AH, 1, "creating %s \"%s\"\n", te->desc, te->tag);
_printTocEntry(AH, te, ropt, false, false); _printTocEntry(AH, te, false, false);
defnDumped = true; defnDumped = true;
if (strcmp(te->desc, "TABLE") == 0) if (strcmp(te->desc, "TABLE") == 0)
@ -782,7 +792,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
*/ */
if (AH->PrintTocDataPtr !=NULL) if (AH->PrintTocDataPtr !=NULL)
{ {
_printTocEntry(AH, te, ropt, true, false); _printTocEntry(AH, te, true, false);
if (strcmp(te->desc, "BLOBS") == 0 || if (strcmp(te->desc, "BLOBS") == 0 ||
strcmp(te->desc, "BLOB COMMENTS") == 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) if (strcmp(te->desc, "BLOB COMMENTS") == 0)
AH->outputKind = OUTPUT_OTHERDATA; AH->outputKind = OUTPUT_OTHERDATA;
(*AH->PrintTocDataPtr) (AH, te, ropt); (*AH->PrintTocDataPtr) (AH, te);
AH->outputKind = OUTPUT_SQLCMDS; AH->outputKind = OUTPUT_SQLCMDS;
} }
else else
{ {
_disableTriggersIfNecessary(AH, te, ropt); _disableTriggersIfNecessary(AH, te);
/* Select owner and schema as necessary */ /* Select owner and schema as necessary */
_becomeOwner(AH, te); _becomeOwner(AH, te);
@ -848,7 +858,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
else else
AH->outputKind = OUTPUT_OTHERDATA; AH->outputKind = OUTPUT_OTHERDATA;
(*AH->PrintTocDataPtr) (AH, te, ropt); (*AH->PrintTocDataPtr) (AH, te);
/* /*
* Terminate COPY if needed. * Terminate COPY if needed.
@ -862,7 +872,7 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
if (is_parallel && te->created) if (is_parallel && te->created)
CommitTransaction(&AH->public); 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 */ /* If we haven't already dumped the defn part, do so now */
ahlog(AH, 1, "executing %s %s\n", te->desc, te->tag); 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 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 */ /* This hack is only needed in a data-only restore */
if (!ropt->dataOnly || !ropt->disable_triggers) if (!ropt->dataOnly || !ropt->disable_triggers)
return; return;
@ -926,8 +938,10 @@ _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *rop
} }
static void 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 */ /* This hack is only needed in a data-only restore */
if (!ropt->dataOnly || !ropt->disable_triggers) if (!ropt->dataOnly || !ropt->disable_triggers)
return; return;
@ -1040,9 +1054,10 @@ ArchiveEntry(Archive *AHX,
/* Public */ /* Public */
void void
PrintTOCSummary(Archive *AHX, RestoreOptions *ropt) PrintTOCSummary(Archive *AHX)
{ {
ArchiveHandle *AH = (ArchiveHandle *) AHX; ArchiveHandle *AH = (ArchiveHandle *) AHX;
RestoreOptions *ropt = AH->public.ropt;
TocEntry *te; TocEntry *te;
teSection curSection; teSection curSection;
OutputContext sav; OutputContext sav;
@ -1159,7 +1174,9 @@ EndBlob(Archive *AHX, Oid oid)
void void
StartRestoreBlobs(ArchiveHandle *AH) StartRestoreBlobs(ArchiveHandle *AH)
{ {
if (!AH->ropt->single_txn) RestoreOptions *ropt = AH->public.ropt;
if (!ropt->single_txn)
{ {
if (AH->connection) if (AH->connection)
StartTransaction(&AH->public); StartTransaction(&AH->public);
@ -1176,7 +1193,9 @@ StartRestoreBlobs(ArchiveHandle *AH)
void void
EndRestoreBlobs(ArchiveHandle *AH) EndRestoreBlobs(ArchiveHandle *AH)
{ {
if (!AH->ropt->single_txn) RestoreOptions *ropt = AH->public.ropt;
if (!ropt->single_txn)
{ {
if (AH->connection) if (AH->connection)
CommitTransaction(&AH->public); CommitTransaction(&AH->public);
@ -1265,9 +1284,10 @@ EndRestoreBlob(ArchiveHandle *AH, Oid oid)
***********/ ***********/
void void
SortTocFromFile(Archive *AHX, RestoreOptions *ropt) SortTocFromFile(Archive *AHX)
{ {
ArchiveHandle *AH = (ArchiveHandle *) AHX; ArchiveHandle *AH = (ArchiveHandle *) AHX;
RestoreOptions *ropt = AH->public.ropt;
FILE *fh; FILE *fh;
char buf[100]; char buf[100];
bool incomplete_line; bool incomplete_line;
@ -1550,7 +1570,9 @@ ahlog(ArchiveHandle *AH, int level, const char *fmt,...)
static int static int
RestoringToDB(ArchiveHandle *AH) 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 void
WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate) WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
{ {
TocEntry *te; TocEntry *te;
@ -2326,13 +2348,13 @@ WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, ParallelState *pstate)
DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP); DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP);
} }
else else
WriteDataChunksForTocEntry(AH, dopt, te); WriteDataChunksForTocEntry(AH, te);
} }
EnsureWorkersFinished(AH, pstate); EnsureWorkersFinished(AH, pstate);
} }
void void
WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te) WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te)
{ {
StartDataPtr startPtr; StartDataPtr startPtr;
EndDataPtr endPtr; EndDataPtr endPtr;
@ -2356,7 +2378,7 @@ WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te)
/* /*
* The user-provided DataDumper routine needs to call AH->WriteData * 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) if (endPtr != NULL)
(*endPtr) (AH, te); (*endPtr) (AH, te);
@ -2827,6 +2849,8 @@ _tocEntryIsACL(TocEntry *te)
static void static void
_doSetFixedOutputState(ArchiveHandle *AH) _doSetFixedOutputState(ArchiveHandle *AH)
{ {
RestoreOptions *ropt = AH->public.ropt;
/* Disable statement_timeout since restore is probably slow */ /* Disable statement_timeout since restore is probably slow */
ahprintf(AH, "SET statement_timeout = 0;\n"); ahprintf(AH, "SET statement_timeout = 0;\n");
@ -2842,8 +2866,8 @@ _doSetFixedOutputState(ArchiveHandle *AH)
AH->public.std_strings ? "on" : "off"); AH->public.std_strings ? "on" : "off");
/* Select the role to be used during restore */ /* Select the role to be used during restore */
if (AH->ropt && AH->ropt->use_role) if (ropt && ropt->use_role)
ahprintf(AH, "SET ROLE %s;\n", fmtId(AH->ropt->use_role)); ahprintf(AH, "SET ROLE %s;\n", fmtId(ropt->use_role));
/* Make sure function checking is disabled */ /* Make sure function checking is disabled */
ahprintf(AH, "SET check_function_bodies = false;\n"); ahprintf(AH, "SET check_function_bodies = false;\n");
@ -2854,7 +2878,7 @@ _doSetFixedOutputState(ArchiveHandle *AH)
ahprintf(AH, "SET escape_string_warning = off;\n"); ahprintf(AH, "SET escape_string_warning = off;\n");
/* Adjust row-security state */ /* 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"); ahprintf(AH, "SET row_security = on;\n");
else else
ahprintf(AH, "SET row_security = off;\n"); ahprintf(AH, "SET row_security = off;\n");
@ -3012,7 +3036,9 @@ _becomeUser(ArchiveHandle *AH, const char *user)
static void static void
_becomeOwner(ArchiveHandle *AH, TocEntry *te) _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; return;
_becomeUser(AH, te->owner); _becomeUser(AH, te->owner);
@ -3083,12 +3109,13 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
static void static void
_selectTablespace(ArchiveHandle *AH, const char *tablespace) _selectTablespace(ArchiveHandle *AH, const char *tablespace)
{ {
RestoreOptions *ropt = AH->public.ropt;
PQExpBuffer qry; PQExpBuffer qry;
const char *want, const char *want,
*have; *have;
/* do nothing in --no-tablespaces mode */ /* do nothing in --no-tablespaces mode */
if (AH->ropt->noTablespace) if (ropt->noTablespace)
return; return;
have = AH->currTablespace; have = AH->currTablespace;
@ -3214,8 +3241,10 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
} }
static void 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 */ /* ACLs are dumped only during acl pass */
if (acl_pass) if (acl_pass)
{ {
@ -3624,7 +3653,6 @@ dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim)
static void static void
restore_toc_entries_prefork(ArchiveHandle *AH) restore_toc_entries_prefork(ArchiveHandle *AH)
{ {
RestoreOptions *ropt = AH->ropt;
bool skipped_some; bool skipped_some;
TocEntry *next_work_item; TocEntry *next_work_item;
@ -3676,7 +3704,7 @@ restore_toc_entries_prefork(ArchiveHandle *AH)
next_work_item->dumpId, next_work_item->dumpId,
next_work_item->desc, next_work_item->tag); 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 */ /* there should be no touch of ready_list here, so pass NULL */
reduce_dependencies(AH, next_work_item, NULL); reduce_dependencies(AH, next_work_item, NULL);
@ -3857,7 +3885,7 @@ restore_toc_entries_parallel(ArchiveHandle *AH, ParallelState *pstate,
static void static void
restore_toc_entries_postfork(ArchiveHandle *AH, TocEntry *pending_list) restore_toc_entries_postfork(ArchiveHandle *AH, TocEntry *pending_list)
{ {
RestoreOptions *ropt = AH->ropt; RestoreOptions *ropt = AH->public.ropt;
TocEntry *te; TocEntry *te;
ahlog(AH, 2, "entering restore_toc_entries_postfork\n"); 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", ahlog(AH, 1, "processing missed item %d %s %s\n",
te->dumpId, te->desc, te->tag); 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. */ /* The ACLs will be handled back in RestoreArchive. */
@ -4045,7 +4073,6 @@ parallel_restore(ParallelArgs *args)
{ {
ArchiveHandle *AH = args->AH; ArchiveHandle *AH = args->AH;
TocEntry *te = args->te; TocEntry *te = args->te;
RestoreOptions *ropt = AH->ropt;
int status; int status;
_doSetFixedOutputState(AH); _doSetFixedOutputState(AH);
@ -4055,7 +4082,7 @@ parallel_restore(ParallelArgs *args)
AH->public.n_errors = 0; AH->public.n_errors = 0;
/* Restore the TOC item */ /* Restore the TOC item */
status = restore_toc_entry(AH, te, ropt, true); status = restore_toc_entry(AH, te, true);
return status; return status;
} }
@ -4417,7 +4444,7 @@ CloneArchive(ArchiveHandle *AH)
*/ */
if (AH->mode == archModeRead) if (AH->mode == archModeRead)
{ {
RestoreOptions *ropt = AH->ropt; RestoreOptions *ropt = AH->public.ropt;
Assert(AH->connection == NULL); Assert(AH->connection == NULL);
/* this also sets clone->connection */ /* this also sets clone->connection */

View File

@ -136,7 +136,7 @@ typedef enum T_Action
ACT_RESTORE ACT_RESTORE
} T_Action; } T_Action;
typedef void (*ClosePtr) (ArchiveHandle *AH, DumpOptions *dopt); typedef void (*ClosePtr) (ArchiveHandle *AH);
typedef void (*ReopenPtr) (ArchiveHandle *AH); typedef void (*ReopenPtr) (ArchiveHandle *AH);
typedef void (*ArchiveEntryPtr) (ArchiveHandle *AH, TocEntry *te); 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 (*WriteExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
typedef void (*ReadExtraTocPtr) (ArchiveHandle *AH, TocEntry *te); typedef void (*ReadExtraTocPtr) (ArchiveHandle *AH, TocEntry *te);
typedef void (*PrintExtraTocPtr) (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 (*ClonePtr) (ArchiveHandle *AH);
typedef void (*DeClonePtr) (ArchiveHandle *AH); typedef void (*DeClonePtr) (ArchiveHandle *AH);
typedef char *(*WorkerJobRestorePtr) (ArchiveHandle *AH, TocEntry *te); 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, typedef char *(*MasterStartParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
T_Action act); T_Action act);
typedef int (*MasterEndParallelItemPtr) (ArchiveHandle *AH, TocEntry *te, typedef int (*MasterEndParallelItemPtr) (ArchiveHandle *AH, TocEntry *te,
@ -315,9 +315,6 @@ struct _archiveHandle
ArchiveMode mode; /* File mode - r or w */ ArchiveMode mode; /* File mode - r or w */
void *formatData; /* Header data specific to file format */ 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 */ /* these vars track state to avoid sending redundant SET commands */
char *currUser; /* current username, or NULL if unknown */ char *currUser; /* current username, or NULL if unknown */
char *currSchema; /* current schema, or NULL */ char *currSchema; /* current schema, or NULL */
@ -386,8 +383,8 @@ extern void WriteHead(ArchiveHandle *AH);
extern void ReadHead(ArchiveHandle *AH); extern void ReadHead(ArchiveHandle *AH);
extern void WriteToc(ArchiveHandle *AH); extern void WriteToc(ArchiveHandle *AH);
extern void ReadToc(ArchiveHandle *AH); extern void ReadToc(ArchiveHandle *AH);
extern void WriteDataChunks(ArchiveHandle *AH, DumpOptions *dopt, struct ParallelState *pstate); extern void WriteDataChunks(ArchiveHandle *AH, struct ParallelState *pstate);
extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, DumpOptions *dopt, TocEntry *te); extern void WriteDataChunksForTocEntry(ArchiveHandle *AH, TocEntry *te);
extern ArchiveHandle *CloneArchive(ArchiveHandle *AH); extern ArchiveHandle *CloneArchive(ArchiveHandle *AH);
extern void DeCloneArchive(ArchiveHandle *AH); extern void DeCloneArchive(ArchiveHandle *AH);

View File

@ -42,9 +42,9 @@ static int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *); static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, 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 _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 _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te); static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _PrintExtraToc(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 * Print data for a given TOC entry
*/ */
static void static void
_PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) _PrintTocData(ArchiveHandle *AH, TocEntry *te)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
lclTocEntry *tctx = (lclTocEntry *) te->formatData; lclTocEntry *tctx = (lclTocEntry *) te->formatData;
@ -500,7 +500,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
break; break;
case BLK_BLOBS: case BLK_BLOBS:
_LoadBlobs(AH, ropt->dropSchema); _LoadBlobs(AH, AH->public.ropt->dropSchema);
break; break;
default: /* Always have a default */ default: /* Always have a default */
@ -695,7 +695,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
* *
*/ */
static void static void
_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) _CloseArchive(ArchiveHandle *AH)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
pgoff_t tpos; pgoff_t tpos;
@ -710,7 +710,7 @@ _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
strerror(errno)); strerror(errno));
WriteToc(AH); WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx); 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 * If possible, re-write the TOC in order to update the data offset

View File

@ -72,9 +72,9 @@ static int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *); static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, 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 _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 _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(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 _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
static void _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid); static void _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
static void _EndBlobs(ArchiveHandle *AH, TocEntry *te); 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 _Clone(ArchiveHandle *AH);
static void _DeClone(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, static int _MasterEndParallelItem(ArchiveHandle *AH, TocEntry *te,
const char *str, T_Action act); const char *str, T_Action act);
static char *_WorkerJobRestoreDirectory(ArchiveHandle *AH, TocEntry *te); 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, static void setFilePath(ArchiveHandle *AH, char *buf,
const char *relativeFilename); const char *relativeFilename);
@ -386,7 +386,7 @@ _EndData(ArchiveHandle *AH, TocEntry *te)
* Print data for a given file (can be a BLOB as well) * Print data for a given file (can be a BLOB as well)
*/ */
static void static void
_PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt) _PrintFileData(ArchiveHandle *AH, char *filename)
{ {
size_t cnt; size_t cnt;
char *buf; char *buf;
@ -418,7 +418,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
* Print data for a given TOC entry * Print data for a given TOC entry
*/ */
static void static void
_PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) _PrintTocData(ArchiveHandle *AH, TocEntry *te)
{ {
lclTocEntry *tctx = (lclTocEntry *) te->formatData; lclTocEntry *tctx = (lclTocEntry *) te->formatData;
@ -426,18 +426,18 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
return; return;
if (strcmp(te->desc, "BLOBS") == 0) if (strcmp(te->desc, "BLOBS") == 0)
_LoadBlobs(AH, ropt); _LoadBlobs(AH);
else else
{ {
char fname[MAXPGPATH]; char fname[MAXPGPATH];
setFilePath(AH, fname, tctx->filename); setFilePath(AH, fname, tctx->filename);
_PrintFileData(AH, fname, ropt); _PrintFileData(AH, fname);
} }
} }
static void static void
_LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt) _LoadBlobs(ArchiveHandle *AH)
{ {
Oid oid; Oid oid;
lclContext *ctx = (lclContext *) AH->formatData; 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", exit_horribly(modulename, "invalid line in large object TOC file \"%s\": \"%s\"\n",
fname, line); fname, line);
StartRestoreBlob(AH, oid, ropt->dropSchema); StartRestoreBlob(AH, oid, AH->public.ropt->dropSchema);
snprintf(path, MAXPGPATH, "%s/%s", ctx->directory, fname); snprintf(path, MAXPGPATH, "%s/%s", ctx->directory, fname);
_PrintFileData(AH, path, ropt); _PrintFileData(AH, path);
EndRestoreBlob(AH, oid); EndRestoreBlob(AH, oid);
} }
if (!cfeof(ctx->blobsTocFH)) if (!cfeof(ctx->blobsTocFH))
@ -567,7 +567,7 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
* WriteDataChunks to save all DATA & BLOBs. * WriteDataChunks to save all DATA & BLOBs.
*/ */
static void static void
_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) _CloseArchive(ArchiveHandle *AH)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
@ -579,7 +579,7 @@ _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
setFilePath(AH, fname, "toc.dat"); setFilePath(AH, fname, "toc.dat");
/* this will actually fork the processes for a parallel backup */ /* 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 */ /* The TOC is always created uncompressed */
tocFH = cfopen_write(fname, PG_BINARY_W, 0); tocFH = cfopen_write(fname, PG_BINARY_W, 0);
@ -600,7 +600,7 @@ _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
if (cfclose(tocFH) != 0) if (cfclose(tocFH) != 0)
exit_horribly(modulename, "could not close TOC file: %s\n", exit_horribly(modulename, "could not close TOC file: %s\n",
strerror(errno)); strerror(errno));
WriteDataChunks(AH, dopt, ctx->pstate); WriteDataChunks(AH, ctx->pstate);
ParallelBackupEnd(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. * function of the respective dump format.
*/ */
static char * 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 * 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 * succeed... A failure will be detected by the parent when the child dies
* unexpectedly. * unexpectedly.
*/ */
WriteDataChunksForTocEntry(AH, dopt, te); WriteDataChunksForTocEntry(AH, te);
snprintf(buf, buflen, "OK DUMP %d", te->dumpId); snprintf(buf, buflen, "OK DUMP %d", te->dumpId);

View File

@ -33,8 +33,8 @@ static void _WriteBlobData(ArchiveHandle *AH, const void *data, size_t dLen);
static void _EndData(ArchiveHandle *AH, TocEntry *te); static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i); static int _WriteByte(ArchiveHandle *AH, const int i);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt); static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
static void _StartBlobs(ArchiveHandle *AH, TocEntry *te); static void _StartBlobs(ArchiveHandle *AH, TocEntry *te);
static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid); static void _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid);
static void _EndBlob(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"); exit_horribly(NULL, "invalid OID for large object\n");
/* With an old archive we must do drop and create logic here */ /* 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); DropBlobIfExists(AH, oid);
if (old_blob_style) if (old_blob_style)
@ -192,20 +192,16 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te)
*------ *------
*/ */
static void static void
_PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) _PrintTocData(ArchiveHandle *AH, TocEntry *te)
{ {
if (te->dataDumper) if (te->dataDumper)
{ {
DumpOptions *dopt;
AH->currToc = te; AH->currToc = te;
if (strcmp(te->desc, "BLOBS") == 0) if (strcmp(te->desc, "BLOBS") == 0)
_StartBlobs(AH, te); _StartBlobs(AH, te);
dopt = dumpOptionsFromRestoreOptions(ropt); (*te->dataDumper) ((Archive *) AH, te->dataDumperArg);
(*te->dataDumper) ((Archive *) AH, dopt, te->dataDumperArg);
pg_free(dopt);
if (strcmp(te->desc, "BLOBS") == 0) if (strcmp(te->desc, "BLOBS") == 0)
_EndBlobs(AH, te); _EndBlobs(AH, te);
@ -229,7 +225,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
} }
static void static void
_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) _CloseArchive(ArchiveHandle *AH)
{ {
/* Nothing to do */ /* Nothing to do */
} }

View File

@ -47,8 +47,8 @@ static int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *); static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len); static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, 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 _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te); static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te); static void _ReadExtraToc(ArchiveHandle *AH, TocEntry *te);
static void _PrintExtraToc(ArchiveHandle *AH, TocEntry *te); static void _PrintExtraToc(ArchiveHandle *AH, TocEntry *te);
@ -100,7 +100,7 @@ typedef struct
/* translator: this is a module name */ /* translator: this is a module name */
static const char *modulename = gettext_noop("tar archiver"); 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 TAR_MEMBER *tarOpen(ArchiveHandle *AH, const char *filename, char mode);
static void tarClose(ArchiveHandle *AH, TAR_MEMBER *TH); static void tarClose(ArchiveHandle *AH, TAR_MEMBER *TH);
@ -632,7 +632,7 @@ _EndData(ArchiveHandle *AH, TocEntry *te)
* Print data for a given file * Print data for a given file
*/ */
static void static void
_PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt) _PrintFileData(ArchiveHandle *AH, char *filename)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
char buf[4096]; char buf[4096];
@ -659,7 +659,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
* Print data for a given TOC entry * Print data for a given TOC entry
*/ */
static void static void
_PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) _PrintTocData(ArchiveHandle *AH, TocEntry *te)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
lclTocEntry *tctx = (lclTocEntry *) te->formatData; lclTocEntry *tctx = (lclTocEntry *) te->formatData;
@ -708,13 +708,13 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
} }
if (strcmp(te->desc, "BLOBS") == 0) if (strcmp(te->desc, "BLOBS") == 0)
_LoadBlobs(AH, ropt); _LoadBlobs(AH);
else else
_PrintFileData(AH, tctx->filename, ropt); _PrintFileData(AH, tctx->filename);
} }
static void static void
_LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt) _LoadBlobs(ArchiveHandle *AH)
{ {
Oid oid; Oid oid;
lclContext *ctx = (lclContext *) AH->formatData; 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); 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) while ((cnt = tarRead(buf, 4095, th)) > 0)
{ {
@ -824,12 +824,13 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
} }
static void static void
_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt) _CloseArchive(ArchiveHandle *AH)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
TAR_MEMBER *th; TAR_MEMBER *th;
RestoreOptions *ropt; RestoreOptions *ropt;
RestoreOptions *savRopt; RestoreOptions *savRopt;
DumpOptions *savDopt;
int savVerbose, int savVerbose,
i; i;
@ -847,7 +848,7 @@ _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
/* /*
* Now send the data (tables & blobs) * 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 * 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; ctx->scriptTH = th;
ropt = NewRestoreOptions(); ropt = NewRestoreOptions();
memcpy(ropt, AH->ropt, sizeof(RestoreOptions)); memcpy(ropt, AH->public.ropt, sizeof(RestoreOptions));
ropt->filename = NULL; ropt->filename = NULL;
ropt->dropSchema = 1; ropt->dropSchema = 1;
ropt->compression = 0; ropt->compression = 0;
ropt->superuser = NULL; ropt->superuser = NULL;
ropt->suppressDumpWarnings = true; ropt->suppressDumpWarnings = true;
savRopt = AH->ropt; savDopt = AH->public.dopt;
AH->ropt = ropt; savRopt = AH->public.ropt;
SetArchiveOptions((Archive *) AH, NULL, ropt);
savVerbose = AH->public.verbose; savVerbose = AH->public.verbose;
AH->public.verbose = 0; AH->public.verbose = 0;
RestoreArchive((Archive *) AH); RestoreArchive((Archive *) AH);
AH->ropt = savRopt; SetArchiveOptions((Archive *) AH, savDopt, savRopt);
AH->public.verbose = savVerbose; AH->public.verbose = savVerbose;
tarClose(AH, th); tarClose(AH, th);

File diff suppressed because it is too large Load Diff

View File

@ -493,7 +493,7 @@ extern char g_opaque_type[10]; /* name for the opaque type */
* common utility functions * common utility functions
*/ */
extern TableInfo *getSchemaData(Archive *, DumpOptions *dopt, int *numTablesPtr); extern TableInfo *getSchemaData(Archive *fout, int *numTablesPtr);
extern void AssignDumpId(DumpableObject *dobj); extern void AssignDumpId(DumpableObject *dobj);
extern DumpId createDumpId(void); extern DumpId createDumpId(void);
@ -527,16 +527,16 @@ extern void sortDataAndIndexObjectsBySize(DumpableObject **objs, int numObjs);
* version specific routines * version specific routines
*/ */
extern NamespaceInfo *getNamespaces(Archive *fout, int *numNamespaces); 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 TypeInfo *getTypes(Archive *fout, int *numTypes);
extern FuncInfo *getFuncs(Archive *fout, DumpOptions *dopt, int *numFuncs); extern FuncInfo *getFuncs(Archive *fout, int *numFuncs);
extern AggInfo *getAggregates(Archive *fout, DumpOptions *dopt, int *numAggregates); extern AggInfo *getAggregates(Archive *fout, int *numAggregates);
extern OprInfo *getOperators(Archive *fout, int *numOperators); extern OprInfo *getOperators(Archive *fout, int *numOperators);
extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses); extern OpclassInfo *getOpclasses(Archive *fout, int *numOpclasses);
extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies); extern OpfamilyInfo *getOpfamilies(Archive *fout, int *numOpfamilies);
extern CollInfo *getCollations(Archive *fout, int *numCollations); extern CollInfo *getCollations(Archive *fout, int *numCollations);
extern ConvInfo *getConversions(Archive *fout, int *numConversions); 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 void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables);
extern InhInfo *getInherits(Archive *fout, int *numInherits); extern InhInfo *getInherits(Archive *fout, int *numInherits);
extern void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables); 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 RuleInfo *getRules(Archive *fout, int *numRules);
extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables); extern void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables);
extern ProcLangInfo *getProcLangs(Archive *fout, int *numProcLangs); 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 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 bool shouldPrintColumn(DumpOptions *dopt, TableInfo *tbinfo, int colno);
extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers); extern TSParserInfo *getTSParsers(Archive *fout, int *numTSParsers);
extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts); extern TSDictInfo *getTSDictionaries(Archive *fout, int *numTSDicts);
@ -556,8 +556,8 @@ extern FdwInfo *getForeignDataWrappers(Archive *fout,
int *numForeignDataWrappers); int *numForeignDataWrappers);
extern ForeignServerInfo *getForeignServers(Archive *fout, extern ForeignServerInfo *getForeignServers(Archive *fout,
int *numForeignServers); int *numForeignServers);
extern DefaultACLInfo *getDefaultACLs(Archive *fout, DumpOptions *dopt, int *numDefaultACLs); extern DefaultACLInfo *getDefaultACLs(Archive *fout, int *numDefaultACLs);
extern void getExtensionMembership(Archive *fout, DumpOptions *dopt, ExtensionInfo extinfo[], extern void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[],
int numExtensions); int numExtensions);
extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers); extern EventTriggerInfo *getEventTriggers(Archive *fout, int *numEventTriggers);
extern void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables); extern void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables);

View File

@ -377,6 +377,8 @@ main(int argc, char **argv)
AH = OpenArchive(inputFileSpec, opts->format); AH = OpenArchive(inputFileSpec, opts->format);
SetArchiveOptions(AH, NULL, opts);
/* /*
* We don't have a connection yet but that doesn't matter. The connection * 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 * 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; AH->exit_on_error = opts->exit_on_error;
if (opts->tocFile) if (opts->tocFile)
SortTocFromFile(AH, opts); SortTocFromFile(AH);
/* See comments in pg_dump.c */ /* See comments in pg_dump.c */
#ifdef WIN32 #ifdef WIN32
@ -408,10 +410,10 @@ main(int argc, char **argv)
AH->numWorkers = numWorkers; AH->numWorkers = numWorkers;
if (opts->tocSummary) if (opts->tocSummary)
PrintTOCSummary(AH, opts); PrintTOCSummary(AH);
else else
{ {
SetArchiveRestoreOptions(AH, opts); ProcessArchiveRestoreOptions(AH);
RestoreArchive(AH); RestoreArchive(AH);
} }
@ -423,7 +425,7 @@ main(int argc, char **argv)
/* AH may be freed in CloseArchive? */ /* AH may be freed in CloseArchive? */
exit_code = AH->n_errors ? 1 : 0; exit_code = AH->n_errors ? 1 : 0;
CloseArchive(AH, NULL); CloseArchive(AH);
return exit_code; return exit_code;
} }