1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-25 13:17:41 +03:00

pg_dump: Reduce use of global variables

Most pg_dump.c global variables, which were passed down individually to
dumping routines, are now grouped as members of the new DumpOptions
struct, which is used as a local variable and passed down into routines
that need it.  This helps future development efforts; in particular it
is said to enable a mode in which a parallel pg_dump run can output
multiple streams, and have them restored in parallel.

Also take the opportunity to clean up the pg_dump header files somewhat,
to avoid circularity.

Author: Joachim Wieland, revised by Álvaro Herrera
Reviewed by Peter Eisentraut
This commit is contained in:
Alvaro Herrera
2014-10-14 15:00:55 -03:00
parent e0d97d77bf
commit 0eea8047bf
22 changed files with 758 additions and 675 deletions

View File

@@ -23,6 +23,7 @@
*
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
#include "compress_io.h"
#include "parallel.h"
@@ -41,7 +42,7 @@ static int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *);
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH);
static void _CloseArchive(ArchiveHandle *AH, DumpOptions *dopt);
static void _ReopenArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
@@ -687,14 +688,14 @@ _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
* the process of saving it to files. No data should be written prior
* to this point, since the user could sort the TOC after creating it.
*
* If an archive is to be written, this toutine must call:
* If an archive is to be written, this routine must call:
* WriteHead to save the archive header
* WriteToc to save the TOC entries
* WriteDataChunks to save all DATA & BLOBs.
*
*/
static void
_CloseArchive(ArchiveHandle *AH)
_CloseArchive(ArchiveHandle *AH, DumpOptions *dopt)
{
lclContext *ctx = (lclContext *) AH->formatData;
pgoff_t tpos;
@@ -709,7 +710,7 @@ _CloseArchive(ArchiveHandle *AH)
strerror(errno));
WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx);
WriteDataChunks(AH, NULL);
WriteDataChunks(AH, dopt, NULL);
/*
* If possible, re-write the TOC in order to update the data offset