diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-01-13 17:48:33 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-01-13 17:48:33 -0500 |
commit | 5b5fea2a11741e651f7c25e981dd29b610a08426 (patch) | |
tree | a1c894f26ca809c8e9a6b10a9c974d641a0b2c40 /src/bin/pg_dump/parallel.c | |
parent | 26905e009babe6020fddcf3820e57e2f87c5539c (diff) | |
download | postgresql-5b5fea2a11741e651f7c25e981dd29b610a08426.tar.gz postgresql-5b5fea2a11741e651f7c25e981dd29b610a08426.zip |
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.
Diffstat (limited to 'src/bin/pg_dump/parallel.c')
-rw-r--r-- | src/bin/pg_dump/parallel.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c index ce5e4723475..d8bd9a9e378 100644 --- a/src/bin/pg_dump/parallel.c +++ b/src/bin/pg_dump/parallel.c @@ -46,8 +46,6 @@ static int piperead(int s, char *buf, int len); typedef struct { ArchiveHandle *AH; - RestoreOptions *ropt; - DumpOptions *dopt; int worker; int pipeRead; int pipeWrite; @@ -87,13 +85,11 @@ static void WaitForTerminatingWorkers(ParallelState *pstate); #ifndef WIN32 static void sigTermHandler(int signum); #endif -static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker, - DumpOptions *dopt, - RestoreOptions *ropt); +static void SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker); static bool HasEveryWorkerTerminated(ParallelState *pstate); static void lockTableNoWait(ArchiveHandle *AH, TocEntry *te); -static void WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]); +static void WaitForCommands(ArchiveHandle *AH, int pipefd[2]); static char *getMessageFromMaster(int pipefd[2]); static void sendMessageToMaster(int pipefd[2], const char *str); static int select_loop(int maxFd, fd_set *workerset); @@ -435,9 +431,7 @@ sigTermHandler(int signum) * worker process. */ static void -SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker, - DumpOptions *dopt, - RestoreOptions *ropt) +SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker) { /* * Call the setup worker function that's defined in the ArchiveHandle. @@ -446,11 +440,11 @@ SetupWorker(ArchiveHandle *AH, int pipefd[2], int worker, * properly when we shut down. This happens only that way when it is * brought down because of an error. */ - (AH->SetupWorkerPtr) ((Archive *) AH, dopt, ropt); + (AH->SetupWorkerPtr) ((Archive *) AH); Assert(AH->connection != NULL); - WaitForCommands(AH, dopt, pipefd); + WaitForCommands(AH, pipefd); closesocket(pipefd[PIPE_READ]); closesocket(pipefd[PIPE_WRITE]); @@ -463,13 +457,11 @@ init_spawned_worker_win32(WorkerInfo *wi) ArchiveHandle *AH; int pipefd[2] = {wi->pipeRead, wi->pipeWrite}; int worker = wi->worker; - DumpOptions *dopt = wi->dopt; - RestoreOptions *ropt = wi->ropt; AH = CloneArchive(wi->AH); free(wi); - SetupWorker(AH, pipefd, worker, dopt, ropt); + SetupWorker(AH, pipefd, worker); DeCloneArchive(AH); _endthreadex(0); @@ -483,7 +475,7 @@ init_spawned_worker_win32(WorkerInfo *wi) * of threads while it does a fork() on Unix. */ ParallelState * -ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt) +ParallelBackupStart(ArchiveHandle *AH) { ParallelState *pstate; int i; @@ -545,8 +537,6 @@ ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt) /* Allocate a new structure for every worker */ wi = (WorkerInfo *) pg_malloc(sizeof(WorkerInfo)); - wi->ropt = ropt; - wi->dopt = dopt; wi->worker = i; wi->AH = AH; wi->pipeRead = pstate->parallelSlot[i].pipeRevRead = pipeMW[PIPE_READ]; @@ -601,7 +591,7 @@ ParallelBackupStart(ArchiveHandle *AH, DumpOptions *dopt, RestoreOptions *ropt) closesocket(pstate->parallelSlot[j].pipeWrite); } - SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i, dopt, ropt); + SetupWorker(pstate->parallelSlot[i].args->AH, pipefd, i); exit(0); } @@ -859,7 +849,7 @@ lockTableNoWait(ArchiveHandle *AH, TocEntry *te) * exit. */ static void -WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]) +WaitForCommands(ArchiveHandle *AH, int pipefd[2]) { char *command; DumpId dumpId; @@ -899,7 +889,7 @@ WaitForCommands(ArchiveHandle *AH, DumpOptions *dopt, int pipefd[2]) * The message we return here has been pg_malloc()ed and we are * responsible for free()ing it. */ - str = (AH->WorkerJobDumpPtr) (AH, dopt, te); + str = (AH->WorkerJobDumpPtr) (AH, te); Assert(AH->connection != NULL); sendMessageToMaster(pipefd, str); free(str); |