#include "pg_backup_archiver.h"
#include "pg_backup_utils.h"
#include "parallel.h"
#include <unistd.h>
#include "libpq/libpq-fs.h"
Go to the source code of this file.
Functions | |
static size_t | _WriteData (ArchiveHandle *AH, const void *data, size_t dLen) |
static size_t | _WriteBlobData (ArchiveHandle *AH, const void *data, size_t dLen) |
static void | _EndData (ArchiveHandle *AH, TocEntry *te) |
static int | _WriteByte (ArchiveHandle *AH, const int i) |
static size_t | _WriteBuf (ArchiveHandle *AH, const void *buf, size_t len) |
static void | _CloseArchive (ArchiveHandle *AH) |
static void | _PrintTocData (ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) |
static void | _StartBlobs (ArchiveHandle *AH, TocEntry *te) |
static void | _StartBlob (ArchiveHandle *AH, TocEntry *te, Oid oid) |
static void | _EndBlob (ArchiveHandle *AH, TocEntry *te, Oid oid) |
static void | _EndBlobs (ArchiveHandle *AH, TocEntry *te) |
void | InitArchiveFmt_Null (ArchiveHandle *AH) |
static void _CloseArchive | ( | ArchiveHandle * | AH | ) | [static] |
Definition at line 231 of file pg_backup_null.c.
{
/* Nothing to do */
}
static void _EndBlob | ( | ArchiveHandle * | AH, | |
TocEntry * | te, | |||
Oid | oid | |||
) | [static] |
Definition at line 174 of file pg_backup_null.c.
References ahprintf(), and _archiveHandle::WriteDataPtr.
{ AH->WriteDataPtr = _WriteData; ahprintf(AH, "SELECT pg_catalog.lo_close(0);\n\n"); }
static void _EndBlobs | ( | ArchiveHandle * | AH, | |
TocEntry * | te | |||
) | [static] |
Definition at line 187 of file pg_backup_null.c.
References ahprintf().
Referenced by _PrintTocData().
{ ahprintf(AH, "COMMIT;\n\n"); }
static void _EndData | ( | ArchiveHandle * | AH, | |
TocEntry * | te | |||
) | [static] |
static void _PrintTocData | ( | ArchiveHandle * | AH, | |
TocEntry * | te, | |||
RestoreOptions * | ropt | |||
) | [static] |
Definition at line 198 of file pg_backup_null.c.
References _EndBlobs(), _StartBlobs(), _archiveHandle::currToc, _tocEntry::dataDumper, _tocEntry::dataDumperArg, and _tocEntry::desc.
{ if (te->dataDumper) { AH->currToc = te; if (strcmp(te->desc, "BLOBS") == 0) _StartBlobs(AH, te); (*te->dataDumper) ((Archive *) AH, te->dataDumperArg); if (strcmp(te->desc, "BLOBS") == 0) _EndBlobs(AH, te); AH->currToc = NULL; } }
static void _StartBlob | ( | ArchiveHandle * | AH, | |
TocEntry * | te, | |||
Oid | oid | |||
) | [static] |
Definition at line 147 of file pg_backup_null.c.
References ahprintf(), DropBlobIfExists(), _restoreOptions::dropSchema, exit_horribly(), INV_WRITE, NULL, _archiveHandle::ropt, _archiveHandle::version, and _archiveHandle::WriteDataPtr.
{ bool old_blob_style = (AH->version < K_VERS_1_12); if (oid == 0) exit_horribly(NULL, "invalid OID for large object\n"); /* With an old archive we must do drop and create logic here */ if (old_blob_style && AH->ropt->dropSchema) DropBlobIfExists(AH, oid); if (old_blob_style) ahprintf(AH, "SELECT pg_catalog.lo_open(pg_catalog.lo_create('%u'), %d);\n", oid, INV_WRITE); else ahprintf(AH, "SELECT pg_catalog.lo_open('%u', %d);\n", oid, INV_WRITE); AH->WriteDataPtr = _WriteBlobData; }
static void _StartBlobs | ( | ArchiveHandle * | AH, | |
TocEntry * | te | |||
) | [static] |
Definition at line 134 of file pg_backup_null.c.
References ahprintf().
Referenced by _PrintTocData().
{ ahprintf(AH, "BEGIN;\n\n"); }
static size_t _WriteBlobData | ( | ArchiveHandle * | AH, | |
const void * | data, | |||
size_t | dLen | |||
) | [static] |
Definition at line 100 of file pg_backup_null.c.
References ahprintf(), appendByteaLiteralAHX, buf, createPQExpBuffer(), PQExpBufferData::data, and destroyPQExpBuffer().
{ if (dLen > 0) { PQExpBuffer buf = createPQExpBuffer(); appendByteaLiteralAHX(buf, (const unsigned char *) data, dLen, AH); ahprintf(AH, "SELECT pg_catalog.lowrite(0, %s);\n", buf->data); destroyPQExpBuffer(buf); } return dLen; }
static size_t _WriteBuf | ( | ArchiveHandle * | AH, | |
const void * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 224 of file pg_backup_null.c.
{ /* Don't do anything */ return len; }
static int _WriteByte | ( | ArchiveHandle * | AH, | |
const int | i | |||
) | [static] |
Definition at line 217 of file pg_backup_null.c.
{ /* Don't do anything */ return 0; }
static size_t _WriteData | ( | ArchiveHandle * | AH, | |
const void * | data, | |||
size_t | dLen | |||
) | [static] |
Definition at line 88 of file pg_backup_null.c.
References ahwrite().
{ /* Just send it to output */ ahwrite(data, 1, dLen, AH); return dLen; }
void InitArchiveFmt_Null | ( | ArchiveHandle * | AH | ) |
Definition at line 51 of file pg_backup_null.c.
References archModeRead, _archiveHandle::ClonePtr, _archiveHandle::ClosePtr, _archiveHandle::DeClonePtr, _archiveHandle::EndBlobPtr, _archiveHandle::EndBlobsPtr, _archiveHandle::EndDataPtr, exit_horribly(), _archiveHandle::lo_buf, _archiveHandle::lo_buf_size, LOBBUFSIZE, _archiveHandle::mode, NULL, pg_malloc(), _archiveHandle::PrintTocDataPtr, _archiveHandle::ReopenPtr, _archiveHandle::StartBlobPtr, _archiveHandle::StartBlobsPtr, _archiveHandle::WriteBufPtr, _archiveHandle::WriteBytePtr, and _archiveHandle::WriteDataPtr.
Referenced by _allocAH().
{ /* Assuming static functions, this can be copied for each format. */ AH->WriteDataPtr = _WriteData; AH->EndDataPtr = _EndData; AH->WriteBytePtr = _WriteByte; AH->WriteBufPtr = _WriteBuf; AH->ClosePtr = _CloseArchive; AH->ReopenPtr = NULL; AH->PrintTocDataPtr = _PrintTocData; AH->StartBlobsPtr = _StartBlobs; AH->StartBlobPtr = _StartBlob; AH->EndBlobPtr = _EndBlob; AH->EndBlobsPtr = _EndBlobs; AH->ClonePtr = NULL; AH->DeClonePtr = NULL; /* Initialize LO buffering */ AH->lo_buf_size = LOBBUFSIZE; AH->lo_buf = (void *) pg_malloc(LOBBUFSIZE); /* * Now prevent reading... */ if (AH->mode == archModeRead) exit_horribly(NULL, "this format cannot be read\n"); }