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); ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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");
......
...@@ -46,8 +46,6 @@ static int piperead(int s, char *buf, int len); ...@@ -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); ...@@ -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) ...@@ -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, ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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]) ...@@ -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);
......
...@@ -76,9 +76,7 @@ extern int ReapWorkerStatus(ParallelState *pstate, int *status); ...@@ -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);
......
...@@ -58,35 +58,6 @@ typedef enum _teSection ...@@ -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 ...@@ -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 ...@@ -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); ...@@ -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 SetArchiveOptions(Archive *AH, DumpOptions *dopt, RestoreOptions *ropt);
extern void SetArchiveRestoreOptions(Archive *AH, 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, ...@@ -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); ...@@ -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);
......
This diff is collapsed.
...@@ -136,7 +136,7 @@ typedef enum T_Action ...@@ -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); ...@@ -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 ...@@ -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); ...@@ -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);
......
...@@ -42,9 +42,9 @@ static int _WriteByte(ArchiveHandle *AH, const int i); ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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
......
...@@ -72,9 +72,9 @@ static int _WriteByte(ArchiveHandle *AH, const int i); ...@@ -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); ...@@ -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 ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
......
...@@ -33,8 +33,8 @@ static void _WriteBlobData(ArchiveHandle *AH, const void *data, size_t dLen); ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 */
} }
...@@ -47,8 +47,8 @@ static int _WriteByte(ArchiveHandle *AH, const int i); ...@@ -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 ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
......
This diff is collapsed.
...@@ -493,7 +493,7 @@ extern char g_opaque_type[10]; /* name for the opaque type */ ...@@ -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); ...@@ -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); ...@@ -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, ...@@ -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);
......
...@@ -377,6 +377,8 @@ main(int argc, char **argv) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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;
} }
......
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