1/*-------------------------------------------------------------------------
5 * Implementation of an archive that is never saved; it is used by
6 * pg_dump to output a plain text SQL script instead of saving
9 * See the headers to pg_restore for more details.
11 * Copyright (c) 2000, Philip Warner
12 * Rights are granted to use this software in any way so long
13 * as this notice is not removed.
15 * The author is not responsible for loss or damages that may
16 * result from its use.
20 * src/bin/pg_dump/pg_backup_null.c
22 *-------------------------------------------------------------------------
50 /* Assuming static functions, this can be copied for each format. */
67 * Now prevent reading...
70 pg_fatal(
"this format cannot be read");
74 * - Start a new TOC entry
78 * Called by dumper via archiver from within a data dump routine
83 /* Just send it to output, ahwrite() already errors on failure */
88 * Called by dumper via archiver from within a data dump routine
89 * We substitute this for _WriteData while emitting a LO
99 (
const unsigned char *)
data,
103 ahprintf(AH,
"SELECT pg_catalog.lowrite(0, %s);\n",
buf->data);
116 * Called by the archiver when starting to save BLOB DATA (not schema).
117 * This routine should save whatever format-specific information is needed
118 * to read the LOs back into memory.
120 * It is called just prior to the dumper's DataDumper routine.
122 * Optional, but strongly recommended.
131 * Called by the archiver when the dumper calls StartLO.
135 * Must save the passed OID for retrieval at restore-time.
143 pg_fatal(
"invalid OID for large object");
145 /* With an old archive we must do drop and create logic here */
150 ahprintf(AH,
"SELECT pg_catalog.lo_open(pg_catalog.lo_create('%u'), %d);\n",
153 ahprintf(AH,
"SELECT pg_catalog.lo_open('%u', %d);\n",
160 * Called by the archiver when the dumper calls EndLO.
169 ahprintf(AH,
"SELECT pg_catalog.lo_close(0);\n\n");
173 * Called by the archiver when finishing saving BLOB DATA.
184 * Called as part of a RestoreArchive call; for the NULL archive, this
185 * just sends the data for a given TOC entry to the output.
195 if (strcmp(te->
desc,
"BLOBS") == 0)
200 if (strcmp(te->
desc,
"BLOBS") == 0)
210 /* Don't do anything */
217 /* Don't do anything */
void ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
int ahprintf(ArchiveHandle *AH, const char *fmt,...)
#define appendByteaLiteralAHX(buf, str, len, AH)
void DropLOIfExists(ArchiveHandle *AH, Oid oid)
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te)
void InitArchiveFmt_Null(ArchiveHandle *AH)
static void _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
static void _CloseArchive(ArchiveHandle *AH)
static void _StartLOs(ArchiveHandle *AH, TocEntry *te)
static void _EndLO(ArchiveHandle *AH, TocEntry *te, Oid oid)
static void _EndLOs(ArchiveHandle *AH, TocEntry *te)
static int _WriteByte(ArchiveHandle *AH, const int i)
static void _StartLO(ArchiveHandle *AH, TocEntry *te, Oid oid)
static void _WriteLOData(ArchiveHandle *AH, const void *data, size_t dLen)
static void _EndData(ArchiveHandle *AH, TocEntry *te)
static void _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
PQExpBuffer createPQExpBuffer(void)
void destroyPQExpBuffer(PQExpBuffer str)
DeClonePtrType DeClonePtr
StartLOsPtrType StartLOsPtr
WriteDataPtrType WriteDataPtr
StartLOPtrType StartLOPtr
WriteBufPtrType WriteBufPtr
PrintTocDataPtrType PrintTocDataPtr
struct _tocEntry * currToc
WriteBytePtrType WriteBytePtr
EndDataPtrType EndDataPtr
const void * dataDumperArg