PostgreSQL Source Code  git master
pg_backup_null.c File Reference
#include "postgres_fe.h"
#include "fe_utils/string_utils.h"
#include "libpq/libpq-fs.h"
#include "pg_backup_archiver.h"
#include "pg_backup_utils.h"
Include dependency graph for pg_backup_null.c:

Go to the source code of this file.

Functions

static void _WriteData (ArchiveHandle *AH, const void *data, size_t dLen)
 
static void _WriteLOData (ArchiveHandle *AH, const void *data, size_t dLen)
 
static void _EndData (ArchiveHandle *AH, TocEntry *te)
 
static int _WriteByte (ArchiveHandle *AH, const int i)
 
static void _WriteBuf (ArchiveHandle *AH, const void *buf, size_t len)
 
static void _CloseArchive (ArchiveHandle *AH)
 
static void _PrintTocData (ArchiveHandle *AH, TocEntry *te)
 
static void _StartLOs (ArchiveHandle *AH, TocEntry *te)
 
static void _StartLO (ArchiveHandle *AH, TocEntry *te, Oid oid)
 
static void _EndLO (ArchiveHandle *AH, TocEntry *te, Oid oid)
 
static void _EndLOs (ArchiveHandle *AH, TocEntry *te)
 
void InitArchiveFmt_Null (ArchiveHandle *AH)
 

Function Documentation

◆ _CloseArchive()

static void _CloseArchive ( ArchiveHandle AH)
static

Definition at line 221 of file pg_backup_null.c.

222 {
223  /* Nothing to do */
224 }

Referenced by InitArchiveFmt_Null().

◆ _EndData()

static void _EndData ( ArchiveHandle AH,
TocEntry te 
)
static

Definition at line 110 of file pg_backup_null.c.

111 {
112  ahprintf(AH, "\n\n");
113 }
int ahprintf(ArchiveHandle *AH, const char *fmt,...)

References ahprintf().

Referenced by InitArchiveFmt_Null().

◆ _EndLO()

static void _EndLO ( ArchiveHandle AH,
TocEntry te,
Oid  oid 
)
static

Definition at line 165 of file pg_backup_null.c.

166 {
167  AH->WriteDataPtr = _WriteData;
168 
169  ahprintf(AH, "SELECT pg_catalog.lo_close(0);\n\n");
170 }
static void _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
WriteDataPtrType WriteDataPtr

References _WriteData(), ahprintf(), and _archiveHandle::WriteDataPtr.

Referenced by InitArchiveFmt_Null().

◆ _EndLOs()

static void _EndLOs ( ArchiveHandle AH,
TocEntry te 
)
static

Definition at line 178 of file pg_backup_null.c.

179 {
180  ahprintf(AH, "COMMIT;\n\n");
181 }

References ahprintf().

Referenced by _PrintTocData(), and InitArchiveFmt_Null().

◆ _PrintTocData()

static void _PrintTocData ( ArchiveHandle AH,
TocEntry te 
)
static

Definition at line 189 of file pg_backup_null.c.

190 {
191  if (te->dataDumper)
192  {
193  AH->currToc = te;
194 
195  if (strcmp(te->desc, "BLOBS") == 0)
196  _StartLOs(AH, te);
197 
198  te->dataDumper((Archive *) AH, te->dataDumperArg);
199 
200  if (strcmp(te->desc, "BLOBS") == 0)
201  _EndLOs(AH, te);
202 
203  AH->currToc = NULL;
204  }
205 }
static void _StartLOs(ArchiveHandle *AH, TocEntry *te)
static void _EndLOs(ArchiveHandle *AH, TocEntry *te)
struct _tocEntry * currToc
DataDumperPtr dataDumper
const void * dataDumperArg

References _EndLOs(), _StartLOs(), _archiveHandle::currToc, _tocEntry::dataDumper, _tocEntry::dataDumperArg, and _tocEntry::desc.

Referenced by InitArchiveFmt_Null().

◆ _StartLO()

static void _StartLO ( ArchiveHandle AH,
TocEntry te,
Oid  oid 
)
static

Definition at line 138 of file pg_backup_null.c.

139 {
140  bool old_lo_style = (AH->version < K_VERS_1_12);
141 
142  if (oid == 0)
143  pg_fatal("invalid OID for large object");
144 
145  /* With an old archive we must do drop and create logic here */
146  if (old_lo_style && AH->public.ropt->dropSchema)
147  DropLOIfExists(AH, oid);
148 
149  if (old_lo_style)
150  ahprintf(AH, "SELECT pg_catalog.lo_open(pg_catalog.lo_create('%u'), %d);\n",
151  oid, INV_WRITE);
152  else
153  ahprintf(AH, "SELECT pg_catalog.lo_open('%u', %d);\n",
154  oid, INV_WRITE);
155 
157 }
#define INV_WRITE
Definition: libpq-fs.h:21
void DropLOIfExists(ArchiveHandle *AH, Oid oid)
Definition: pg_backup_db.c:673
#define K_VERS_1_12
static void _WriteLOData(ArchiveHandle *AH, const void *data, size_t dLen)
#define pg_fatal(...)
RestoreOptions * ropt
Definition: pg_backup.h:215

References _WriteLOData(), ahprintf(), DropLOIfExists(), _restoreOptions::dropSchema, INV_WRITE, K_VERS_1_12, pg_fatal, _archiveHandle::public, Archive::ropt, _archiveHandle::version, and _archiveHandle::WriteDataPtr.

Referenced by InitArchiveFmt_Null().

◆ _StartLOs()

static void _StartLOs ( ArchiveHandle AH,
TocEntry te 
)
static

Definition at line 125 of file pg_backup_null.c.

126 {
127  ahprintf(AH, "BEGIN;\n\n");
128 }

References ahprintf().

Referenced by _PrintTocData(), and InitArchiveFmt_Null().

◆ _WriteBuf()

static void _WriteBuf ( ArchiveHandle AH,
const void *  buf,
size_t  len 
)
static

Definition at line 215 of file pg_backup_null.c.

216 {
217  /* Don't do anything */
218 }

Referenced by InitArchiveFmt_Null().

◆ _WriteByte()

static int _WriteByte ( ArchiveHandle AH,
const int  i 
)
static

Definition at line 208 of file pg_backup_null.c.

209 {
210  /* Don't do anything */
211  return 0;
212 }

Referenced by InitArchiveFmt_Null().

◆ _WriteData()

static void _WriteData ( ArchiveHandle AH,
const void *  data,
size_t  dLen 
)
static

Definition at line 81 of file pg_backup_null.c.

82 {
83  /* Just send it to output, ahwrite() already errors on failure */
84  ahwrite(data, 1, dLen, AH);
85 }
void ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
const void * data

References ahwrite(), and data.

Referenced by _EndLO(), and InitArchiveFmt_Null().

◆ _WriteLOData()

static void _WriteLOData ( ArchiveHandle AH,
const void *  data,
size_t  dLen 
)
static

Definition at line 92 of file pg_backup_null.c.

93 {
94  if (dLen > 0)
95  {
97 
99  (const unsigned char *) data,
100  dLen,
101  AH);
102 
103  ahprintf(AH, "SELECT pg_catalog.lowrite(0, %s);\n", buf->data);
104 
106  }
107 }
#define appendByteaLiteralAHX(buf, str, len, AH)
static char * buf
Definition: pg_test_fsync.c:73
PQExpBuffer createPQExpBuffer(void)
Definition: pqexpbuffer.c:72
void destroyPQExpBuffer(PQExpBuffer str)
Definition: pqexpbuffer.c:114

References ahprintf(), appendByteaLiteralAHX, buf, createPQExpBuffer(), data, and destroyPQExpBuffer().

Referenced by _StartLO().

◆ InitArchiveFmt_Null()

void InitArchiveFmt_Null ( ArchiveHandle AH)

Definition at line 48 of file pg_backup_null.c.

49 {
50  /* Assuming static functions, this can be copied for each format. */
52  AH->EndDataPtr = _EndData;
54  AH->WriteBufPtr = _WriteBuf;
55  AH->ClosePtr = _CloseArchive;
56  AH->ReopenPtr = NULL;
58 
59  AH->StartLOsPtr = _StartLOs;
60  AH->StartLOPtr = _StartLO;
61  AH->EndLOPtr = _EndLO;
62  AH->EndLOsPtr = _EndLOs;
63  AH->ClonePtr = NULL;
64  AH->DeClonePtr = NULL;
65 
66  /*
67  * Now prevent reading...
68  */
69  if (AH->mode == archModeRead)
70  pg_fatal("this format cannot be read");
71 }
@ archModeRead
Definition: pg_backup.h:52
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te)
static void _CloseArchive(ArchiveHandle *AH)
static void _EndLO(ArchiveHandle *AH, TocEntry *te, Oid oid)
static int _WriteByte(ArchiveHandle *AH, const int i)
static void _StartLO(ArchiveHandle *AH, TocEntry *te, Oid oid)
static void _EndData(ArchiveHandle *AH, TocEntry *te)
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
DeClonePtrType DeClonePtr
EndLOsPtrType EndLOsPtr
StartLOsPtrType StartLOsPtr
StartLOPtrType StartLOPtr
ClonePtrType ClonePtr
WriteBufPtrType WriteBufPtr
EndLOPtrType EndLOPtr
PrintTocDataPtrType PrintTocDataPtr
WriteBytePtrType WriteBytePtr
ReopenPtrType ReopenPtr
EndDataPtrType EndDataPtr
ClosePtrType ClosePtr

References _CloseArchive(), _EndData(), _EndLO(), _EndLOs(), _PrintTocData(), _StartLO(), _StartLOs(), _WriteBuf(), _WriteByte(), _WriteData(), archModeRead, _archiveHandle::ClonePtr, _archiveHandle::ClosePtr, _archiveHandle::DeClonePtr, _archiveHandle::EndDataPtr, _archiveHandle::EndLOPtr, _archiveHandle::EndLOsPtr, _archiveHandle::mode, pg_fatal, _archiveHandle::PrintTocDataPtr, _archiveHandle::ReopenPtr, _archiveHandle::StartLOPtr, _archiveHandle::StartLOsPtr, _archiveHandle::WriteBufPtr, _archiveHandle::WriteBytePtr, and _archiveHandle::WriteDataPtr.

Referenced by _allocAH().