diff options
author | Philip Warner <pjw@rhyme.com.au> | 2000-07-21 11:43:26 +0000 |
---|---|---|
committer | Philip Warner <pjw@rhyme.com.au> | 2000-07-21 11:43:26 +0000 |
commit | c3e18804ff14f690a6d8c31b452476d0f8fcec28 (patch) | |
tree | f5ebfec9d67a2469c4dfda81fb214e87508eb609 /src/bin/pg_dump/pg_backup_null.c | |
parent | e8f69be054e9343b3c41d7e77cc142913ee55439 (diff) | |
download | postgresql-c3e18804ff14f690a6d8c31b452476d0f8fcec28.tar.gz postgresql-c3e18804ff14f690a6d8c31b452476d0f8fcec28.zip |
- Support for TAR output
- Support for BLOB output from pg_dump and input via pg_restore
- Support for direct DB connection in pg_restore
- Fixes in support for --insert flag
- pg_dump now outputs in modified OID order
Diffstat (limited to 'src/bin/pg_dump/pg_backup_null.c')
-rw-r--r-- | src/bin/pg_dump/pg_backup_null.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/src/bin/pg_dump/pg_backup_null.c b/src/bin/pg_dump/pg_backup_null.c new file mode 100644 index 00000000000..e6f81bb31f2 --- /dev/null +++ b/src/bin/pg_dump/pg_backup_null.c @@ -0,0 +1,114 @@ +/*------------------------------------------------------------------------- + * + * pg_backup_null.c + * + * Implementation of an archive that is never saved; it is used by + * pg_dump to output output a plain text SQL script instead of save + * a real archive. + * + * See the headers to pg_restore for more details. + * + * Copyright (c) 2000, Philip Warner + * Rights are granted to use this software in any way so long + * as this notice is not removed. + * + * The author is not responsible for loss or damages that may + * result from it's use. + * + * + * IDENTIFICATION + * + * Modifications - 09-Jul-2000 - pjw@rhyme.com.au + * + * Initial version. + * + *------------------------------------------------------------------------- + */ + +#include <stdlib.h> +#include <string.h> +#include <unistd.h> /* for dup */ +#include "pg_backup.h" +#include "pg_backup_archiver.h" + +static int _WriteData(ArchiveHandle* AH, const void* data, int dLen); +static void _EndData(ArchiveHandle* AH, TocEntry* te); +static int _WriteByte(ArchiveHandle* AH, const int i); +static int _WriteBuf(ArchiveHandle* AH, const void* buf, int len); +static void _CloseArchive(ArchiveHandle* AH); +static void _PrintTocData(ArchiveHandle* AH, TocEntry* te, RestoreOptions *ropt); + +/* + * Initializer + */ +void InitArchiveFmt_Null(ArchiveHandle* AH) +{ + /* 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->PrintTocDataPtr = _PrintTocData; + + /* + * Now prevent reading... + */ + if (AH->mode == archModeRead) + die_horribly(AH, "%s: This format can not be read\n"); + +} + +/* + * - Start a new TOC entry + */ + +/*------ + * Called by dumper via archiver from within a data dump routine + * As at V1.3, this is only called for COPY FROM dfata, and BLOB data + *------ + */ +static int _WriteData(ArchiveHandle* AH, const void* data, int dLen) +{ + /* Just send it to output */ + ahwrite(data, 1, dLen, AH); + return dLen; +} + +static void _EndData(ArchiveHandle* AH, TocEntry* te) +{ + ahprintf(AH, "\n\n"); +} + +/*------ + * Called as part of a RestoreArchive call; for the NULL archive, this + * just sends the data for a given TOC entry to the output. + *------ + */ +static void _PrintTocData(ArchiveHandle* AH, TocEntry* te, RestoreOptions *ropt) +{ + if (*te->dataDumper) + { + AH->currToc = te; + (*te->dataDumper)((Archive*)AH, te->oid, te->dataDumperArg); + AH->currToc = NULL; + } +} + +static int _WriteByte(ArchiveHandle* AH, const int i) +{ + /* Don't do anything */ + return 0; +} + +static int _WriteBuf(ArchiveHandle* AH, const void* buf, int len) +{ + /* Don't do anything */ + return len; +} + +static void _CloseArchive(ArchiveHandle* AH) +{ + /* Nothing to do */ +} + |