Commit b5593821 authored by Peter Eisentraut's avatar Peter Eisentraut

National language support for pg_dump and pg_restore. Combined with big

message clean up.
parent 14807a3c
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.55 2001/04/03 08:52:59 pjw Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.56 2001/06/27 21:21:36 petere Exp $
* *
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
* *
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "postgres_fe.h"
#include "pg_dump.h" #include "pg_dump.h"
#include "pg_backup_archiver.h"
#include <ctype.h> #include <ctype.h>
...@@ -44,7 +46,7 @@ static char **findParentsByOid(TableInfo *tbinfo, int numTables, ...@@ -44,7 +46,7 @@ static char **findParentsByOid(TableInfo *tbinfo, int numTables,
InhInfo *inhinfo, int numInherits, InhInfo *inhinfo, int numInherits,
const char *oid, const char *oid,
int *numParents, int *numParents,
int (**parentIndices)[]); int (**parentIndexes)[]);
static int findTableByOid(TableInfo *tbinfo, int numTables, const char *oid); static int findTableByOid(TableInfo *tbinfo, int numTables, const char *oid);
static void flagInhAttrs(TableInfo *tbinfo, int numTables, static void flagInhAttrs(TableInfo *tbinfo, int numTables,
InhInfo *inhinfo, int numInherits); InhInfo *inhinfo, int numInherits);
...@@ -116,8 +118,7 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid) ...@@ -116,8 +118,7 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid)
} }
/* should never get here */ /* should never get here */
fprintf(stderr, "failed sanity check, opr with oid %s was not found\n", write_msg(NULL, "failed sanity check, operator with oid %s not found\n", oid);
oid);
/* no suitable operator name was found */ /* no suitable operator name was found */
return (NULL); return (NULL);
...@@ -127,7 +128,7 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid) ...@@ -127,7 +128,7 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid)
/* /*
* findParentsByOid * findParentsByOid
* given the oid of a class, return the names of its parent classes * given the oid of a class, return the names of its parent classes
* and assign the number of parents, and parent indices to the last arguments. * and assign the number of parents, and parent indexes to the last arguments.
* *
* *
* returns NULL if none * returns NULL if none
...@@ -136,7 +137,7 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid) ...@@ -136,7 +137,7 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid)
static char ** static char **
findParentsByOid(TableInfo *tblinfo, int numTables, findParentsByOid(TableInfo *tblinfo, int numTables,
InhInfo *inhinfo, int numInherits, const char *oid, InhInfo *inhinfo, int numInherits, const char *oid,
int *numParentsPtr, int (**parentIndices)[]) int *numParentsPtr, int (**parentIndexes)[])
{ {
int i, int i,
j; j;
...@@ -157,7 +158,7 @@ findParentsByOid(TableInfo *tblinfo, int numTables, ...@@ -157,7 +158,7 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
if (numParents > 0) if (numParents > 0)
{ {
result = (char **) malloc(sizeof(char *) * numParents); result = (char **) malloc(sizeof(char *) * numParents);
(*parentIndices) = malloc(sizeof(int) * numParents); (*parentIndexes) = malloc(sizeof(int) * numParents);
j = 0; j = 0;
for (i = 0; i < numInherits; i++) for (i = 0; i < numInherits; i++)
{ {
...@@ -168,14 +169,19 @@ findParentsByOid(TableInfo *tblinfo, int numTables, ...@@ -168,14 +169,19 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
if (parentInd < 0) if (parentInd < 0)
{ {
selfInd = findTableByOid(tblinfo, numTables, oid); selfInd = findTableByOid(tblinfo, numTables, oid);
fprintf(stderr, if (selfInd >= 0)
"failed sanity check, parent oid %s of table %s (oid %s) was not found\n", write_msg(NULL, "failed sanity check, parent oid %s of table %s (oid %s) not found\n",
inhinfo[i].inhparent, inhinfo[i].inhparent,
(selfInd >= 0) ? tblinfo[selfInd].relname : "", tblinfo[selfInd].relname,
oid); oid);
else
write_msg(NULL, "failed sanity check, parent oid %s of table (oid %s) not found\n",
inhinfo[i].inhparent,
oid);
exit(2); exit(2);
} }
(**parentIndices)[j] = parentInd; (**parentIndexes)[j] = parentInd;
result[j++] = tblinfo[parentInd].relname; result[j++] = tblinfo[parentInd].relname;
} }
} }
...@@ -183,7 +189,7 @@ findParentsByOid(TableInfo *tblinfo, int numTables, ...@@ -183,7 +189,7 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
} }
else else
{ {
(*parentIndices) = NULL; (*parentIndexes) = NULL;
return NULL; return NULL;
} }
} }
...@@ -212,7 +218,7 @@ parseNumericArray(const char *str, char **array, int arraysize) ...@@ -212,7 +218,7 @@ parseNumericArray(const char *str, char **array, int arraysize)
{ {
if (argNum >= arraysize) if (argNum >= arraysize)
{ {
fprintf(stderr, "parseNumericArray: too many numbers\n"); write_msg(NULL, "parseNumericArray: too many numbers\n");
exit(2); exit(2);
} }
temp[j] = '\0'; temp[j] = '\0';
...@@ -227,7 +233,7 @@ parseNumericArray(const char *str, char **array, int arraysize) ...@@ -227,7 +233,7 @@ parseNumericArray(const char *str, char **array, int arraysize)
if (!(isdigit((unsigned char) s) || s == '-') || if (!(isdigit((unsigned char) s) || s == '-') ||
j >= sizeof(temp) - 1) j >= sizeof(temp) - 1)
{ {
fprintf(stderr, "parseNumericArray: bogus number\n"); write_msg(NULL, "parseNumericArray: bogus number\n");
exit(2); exit(2);
} }
temp[j++] = s; temp[j++] = s;
...@@ -281,7 +287,7 @@ dumpSchema(Archive *fout, ...@@ -281,7 +287,7 @@ dumpSchema(Archive *fout,
int numInherits; int numInherits;
int numAggregates; int numAggregates;
int numOperators; int numOperators;
int numIndices; int numIndexes;
TypeInfo *tinfo = NULL; TypeInfo *tinfo = NULL;
FuncInfo *finfo = NULL; FuncInfo *finfo = NULL;
AggInfo *agginfo = NULL; AggInfo *agginfo = NULL;
...@@ -316,9 +322,9 @@ dumpSchema(Archive *fout, ...@@ -316,9 +322,9 @@ dumpSchema(Archive *fout,
tblinfo = getTables(&numTables, finfo, numFuncs); tblinfo = getTables(&numTables, finfo, numFuncs);
if (g_verbose) if (g_verbose)
fprintf(stderr, "%s reading indices information %s\n", fprintf(stderr, "%s reading indexes information %s\n",
g_comment_start, g_comment_end); g_comment_start, g_comment_end);
indinfo = getIndices(&numIndices); indinfo = getIndexes(&numIndexes);
if (g_verbose) if (g_verbose)
fprintf(stderr, "%s reading table inheritance information %s\n", fprintf(stderr, "%s reading table inheritance information %s\n",
...@@ -355,15 +361,15 @@ dumpSchema(Archive *fout, ...@@ -355,15 +361,15 @@ dumpSchema(Archive *fout,
fprintf(stderr, "%s dumping out tables %s\n", fprintf(stderr, "%s dumping out tables %s\n",
g_comment_start, g_comment_end); g_comment_start, g_comment_end);
dumpTables(fout, tblinfo, numTables, indinfo, numIndices, inhinfo, numInherits, dumpTables(fout, tblinfo, numTables, indinfo, numIndexes, inhinfo, numInherits,
tinfo, numTypes, tablename, aclsSkip, oids, schemaOnly, dataOnly); tinfo, numTypes, tablename, aclsSkip, oids, schemaOnly, dataOnly);
if (fout && !dataOnly) if (fout && !dataOnly)
{ {
if (g_verbose) if (g_verbose)
fprintf(stderr, "%s dumping out indices %s\n", fprintf(stderr, "%s dumping out indexes %s\n",
g_comment_start, g_comment_end); g_comment_start, g_comment_end);
dumpIndices(fout, indinfo, numIndices, tblinfo, numTables, tablename); dumpIndexes(fout, indinfo, numIndexes, tblinfo, numTables, tablename);
} }
if (!tablename && !dataOnly) if (!tablename && !dataOnly)
...@@ -404,7 +410,7 @@ dumpSchema(Archive *fout, ...@@ -404,7 +410,7 @@ dumpSchema(Archive *fout,
clearTypeInfo(tinfo, numTypes); clearTypeInfo(tinfo, numTypes);
clearFuncInfo(finfo, numFuncs); clearFuncInfo(finfo, numFuncs);
clearInhInfo(inhinfo, numInherits); clearInhInfo(inhinfo, numInherits);
clearIndInfo(indinfo, numIndices); clearIndInfo(indinfo, numIndexes);
return tblinfo; return tblinfo;
} }
...@@ -426,7 +432,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, ...@@ -426,7 +432,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
k; k;
int parentInd; int parentInd;
int inhAttrInd; int inhAttrInd;
int (*parentIndices)[]; int (*parentIndexes)[];
bool foundAttr; /* Attr was found in a parent */ bool foundAttr; /* Attr was found in a parent */
bool foundNotNull; /* Attr was NOT NULL in a parent */ bool foundNotNull; /* Attr was NOT NULL in a parent */
bool defaultsMatch; /* All non-empty defaults match */ bool defaultsMatch; /* All non-empty defaults match */
...@@ -451,7 +457,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, ...@@ -451,7 +457,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
inhinfo, numInherits, inhinfo, numInherits,
tblinfo[i].oid, tblinfo[i].oid,
&tblinfo[i].numParents, &tblinfo[i].numParents,
&parentIndices); &parentIndexes);
/* /*
* For each attr, check the parent info: if no parent has * For each attr, check the parent info: if no parent has
...@@ -477,12 +483,12 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, ...@@ -477,12 +483,12 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
for (k = 0; k < tblinfo[i].numParents; k++) for (k = 0; k < tblinfo[i].numParents; k++)
{ {
parentInd = (*parentIndices)[k]; parentInd = (*parentIndexes)[k];
if (parentInd < 0) if (parentInd < 0)
{ {
/* shouldn't happen unless findParentsByOid is broken */ /* shouldn't happen unless findParentsByOid is broken */
fprintf(stderr, "failed sanity check, table %s not found by flagInhAttrs\n", write_msg(NULL, "failed sanity check, table \"%s\" not found by flagInhAttrs\n",
tblinfo[i].parentRels[k]); tblinfo[i].parentRels[k]);
exit(2); exit(2);
}; };
......
This diff is collapsed.
# $Header: /cvsroot/pgsql/src/bin/pg_dump/nls.mk,v 1.1 2001/06/27 21:21:37 petere Exp $
CATALOG_NAME := pg_dump
AVAIL_LANGUAGES := de
GETTEXT_FILES := pg_dump.c common.c pg_backup_archiver.c pg_backup_custom.c \
pg_backup_db.c pg_backup_files.c pg_backup_null.c \
pg_backup_tar.c pg_restore.c
GETTEXT_TRIGGERS:= write_msg:2 die_horribly:3 exit_horribly:3 simple_prompt \
ExecuteSqlCommand:3
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.12 2001/05/17 21:12:48 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.13 2001/06/27 21:21:37 petere Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -129,7 +129,7 @@ typedef struct _restoreOptions ...@@ -129,7 +129,7 @@ typedef struct _restoreOptions
* Main archiver interface. * Main archiver interface.
*/ */
extern void exit_horribly(Archive *AH, const char *fmt,...); extern void exit_horribly(Archive *AH, const char *modulename, const char *fmt, ...) __attribute__((format(printf,3,4)));
extern char * extern char *
simple_prompt(const char *prompt, int maxlen, bool echo); simple_prompt(const char *prompt, int maxlen, bool echo);
......
This diff is collapsed.
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.34 2001/05/17 21:12:48 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.35 2001/06/27 21:21:37 petere Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* - Initial version. * - Initial version.
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "postgres_fe.h" #include "postgres_fe.h"
#include <time.h> #include <time.h>
#include <errno.h>
#include "pqexpbuffer.h" #include "pqexpbuffer.h"
...@@ -271,7 +272,9 @@ typedef struct _tocEntry ...@@ -271,7 +272,9 @@ typedef struct _tocEntry
} TocEntry; } TocEntry;
/* Used everywhere */ /* Used everywhere */
extern void die_horribly(ArchiveHandle *AH, const char *fmt,...); extern const char *progname;
extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, ...) __attribute__((format(printf,3,4)));
extern void write_msg(const char *modulename, const char *fmt, ...) __attribute__((format(printf,2,3)));
extern void WriteTOC(ArchiveHandle *AH); extern void WriteTOC(ArchiveHandle *AH);
extern void ReadTOC(ArchiveHandle *AH); extern void ReadTOC(ArchiveHandle *AH);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.11 2001/04/25 07:03:19 pjw Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.12 2001/06/27 21:21:37 petere Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "pg_backup.h" #include "pg_backup.h"
#include "pg_backup_archiver.h" #include "pg_backup_archiver.h"
#include <stdlib.h>
#include <errno.h> #include <errno.h>
/*-------- /*--------
...@@ -103,7 +102,7 @@ static void _EndDataCompressor(ArchiveHandle *AH, TocEntry *te); ...@@ -103,7 +102,7 @@ static void _EndDataCompressor(ArchiveHandle *AH, TocEntry *te);
static int _getFilePos(ArchiveHandle *AH, lclContext *ctx); static int _getFilePos(ArchiveHandle *AH, lclContext *ctx);
static int _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush); static int _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush);
static char *progname = "Archiver(custom)"; static char *modulename = "custom archiver";
...@@ -147,12 +146,12 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) ...@@ -147,12 +146,12 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
*/ */
ctx = (lclContext *) malloc(sizeof(lclContext)); ctx = (lclContext *) malloc(sizeof(lclContext));
if (ctx == NULL) if (ctx == NULL)
die_horribly(AH, "%s: Unable to allocate archive context", progname); die_horribly(AH, modulename, "out of memory\n");
AH->formatData = (void *) ctx; AH->formatData = (void *) ctx;
ctx->zp = (z_streamp) malloc(sizeof(z_stream)); ctx->zp = (z_streamp) malloc(sizeof(z_stream));
if (ctx->zp == NULL) if (ctx->zp == NULL)
die_horribly(AH, "%s: unable to allocate zlib stream archive context", progname); die_horribly(AH, modulename, "out of memory\n");
/* /*
* zlibOutSize is the buffer size we tell zlib it can output to. We * zlibOutSize is the buffer size we tell zlib it can output to. We
...@@ -167,7 +166,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) ...@@ -167,7 +166,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
ctx->filePos = 0; ctx->filePos = 0;
if (ctx->zlibOut == NULL || ctx->zlibIn == NULL) if (ctx->zlibOut == NULL || ctx->zlibIn == NULL)
die_horribly(AH, "%s: unable to allocate buffers in archive context", progname); die_horribly(AH, modulename, "out of memory\n");
/* /*
* Now open the file * Now open the file
...@@ -181,7 +180,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) ...@@ -181,7 +180,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
AH->FH = stdout; AH->FH = stdout;
if (!AH->FH) if (!AH->FH)
die_horribly(AH, "%s: unable to open archive file %s", progname, AH->fSpec); die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0);
...@@ -194,7 +193,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) ...@@ -194,7 +193,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
else else
AH->FH = stdin; AH->FH = stdin;
if (!AH->FH) if (!AH->FH)
die_horribly(AH, "%s: unable to open archive file %s", progname, AH->fSpec); die_horribly(AH, modulename, "could not open archive file %s: %s", AH->fSpec, strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0);
...@@ -387,7 +386,7 @@ static void ...@@ -387,7 +386,7 @@ static void
_StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid) _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
{ {
if (oid == 0) if (oid == 0)
die_horribly(AH, "%s: illegal OID for BLOB (%d)\n", progname, oid); die_horribly(AH, modulename, "invalid OID for BLOB\n");
WriteInt(AH, oid); WriteInt(AH, oid);
_StartDataCompressor(AH, te); _StartDataCompressor(AH, te);
...@@ -446,8 +445,9 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -446,8 +445,9 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
{ {
if ((TocIDRequired(AH, id, ropt) & 2) != 0) if ((TocIDRequired(AH, id, ropt) & 2) != 0)
die_horribly(AH, "%s: Dumping a specific TOC data block out of order is not supported" die_horribly(AH, modulename,
" without on this input stream (fseek required)\n", progname); "Dumping a specific TOC data block out of order is not supported"
" without id on this input stream (fseek required)\n");
switch (blkType) switch (blkType)
{ {
...@@ -464,8 +464,9 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -464,8 +464,9 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
default: /* Always have a default */ default: /* Always have a default */
die_horribly(AH, "%s: unrecognized data block type while searching archive %d\n", die_horribly(AH, modulename,
progname, blkType); "unrecognized data block type (%d) while searching archive\n",
blkType);
break; break;
} }
...@@ -480,7 +481,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -480,7 +481,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
/* Grab it */ /* Grab it */
if (fseek(AH->FH, tctx->dataPos, SEEK_SET) != 0) if (fseek(AH->FH, tctx->dataPos, SEEK_SET) != 0)
die_horribly(AH, "%s: error %d in file seek\n", progname, errno); die_horribly(AH, modulename, "error during file seek: %s\n", strerror(errno));
_readBlockHeader(AH, &blkType, &id); _readBlockHeader(AH, &blkType, &id);
...@@ -488,8 +489,8 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -488,8 +489,8 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
/* Are we sane? */ /* Are we sane? */
if (id != te->id) if (id != te->id)
die_horribly(AH, "%s: Found unexpected block ID (%d) when reading data - expected %d\n", die_horribly(AH, modulename, "found unexpected block ID (%d) when reading data - expected %d\n",
progname, id, te->id); id, te->id);
switch (blkType) switch (blkType)
{ {
...@@ -502,15 +503,15 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -502,15 +503,15 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
case BLK_BLOBS: case BLK_BLOBS:
if (!AH->connection) if (!AH->connection)
die_horribly(AH, "%s: BLOBs can not be loaded without a database connection\n", progname); die_horribly(AH, modulename, "BLOBs cannot be loaded without a database connection\n");
_LoadBlobs(AH); _LoadBlobs(AH);
break; break;
default: /* Always have a default */ default: /* Always have a default */
die_horribly(AH, "%s: unrecognized data block type %d while restoring archive\n", die_horribly(AH, modulename, "unrecognized data block type %d while restoring archive\n",
progname, blkType); blkType);
break; break;
} }
...@@ -546,7 +547,7 @@ _PrintData(ArchiveHandle *AH) ...@@ -546,7 +547,7 @@ _PrintData(ArchiveHandle *AH)
zp->opaque = Z_NULL; zp->opaque = Z_NULL;
if (inflateInit(zp) != Z_OK) if (inflateInit(zp) != Z_OK)
die_horribly(AH, "%s: could not initialize compression library - %s\n", progname, zp->msg); die_horribly(AH, modulename, "could not initialize compression library: %s\n", zp->msg);
} }
#endif #endif
...@@ -560,7 +561,7 @@ _PrintData(ArchiveHandle *AH) ...@@ -560,7 +561,7 @@ _PrintData(ArchiveHandle *AH)
ctx->zlibIn = NULL; ctx->zlibIn = NULL;
ctx->zlibIn = (char *) malloc(blkLen + 1); ctx->zlibIn = (char *) malloc(blkLen + 1);
if (!ctx->zlibIn) if (!ctx->zlibIn)
die_horribly(AH, "%s: failed to allocate decompression buffer\n", progname); die_horribly(AH, modulename, "out of memory\n");
ctx->inSize = blkLen + 1; ctx->inSize = blkLen + 1;
in = ctx->zlibIn; in = ctx->zlibIn;
...@@ -568,7 +569,7 @@ _PrintData(ArchiveHandle *AH) ...@@ -568,7 +569,7 @@ _PrintData(ArchiveHandle *AH)
cnt = fread(in, 1, blkLen, AH->FH); cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen) if (cnt != blkLen)
die_horribly(AH, "%s: could not read data block - expected %d, got %d\n", progname, blkLen, cnt); die_horribly(AH, modulename, "could not read data block - expected %d, got %d\n", blkLen, cnt);
ctx->filePos += blkLen; ctx->filePos += blkLen;
...@@ -586,7 +587,7 @@ _PrintData(ArchiveHandle *AH) ...@@ -586,7 +587,7 @@ _PrintData(ArchiveHandle *AH)
zp->avail_out = zlibOutSize; zp->avail_out = zlibOutSize;
res = inflate(zp, 0); res = inflate(zp, 0);
if (res != Z_OK && res != Z_STREAM_END) if (res != Z_OK && res != Z_STREAM_END)
die_horribly(AH, "%s: unable to uncompress data - %s\n", progname, zp->msg); die_horribly(AH, modulename, "unable to uncompress data: %s\n", zp->msg);
out[zlibOutSize - zp->avail_out] = '\0'; out[zlibOutSize - zp->avail_out] = '\0';
ahwrite(out, 1, zlibOutSize - zp->avail_out, AH); ahwrite(out, 1, zlibOutSize - zp->avail_out, AH);
...@@ -618,7 +619,7 @@ _PrintData(ArchiveHandle *AH) ...@@ -618,7 +619,7 @@ _PrintData(ArchiveHandle *AH)
zp->avail_out = zlibOutSize; zp->avail_out = zlibOutSize;
res = inflate(zp, 0); res = inflate(zp, 0);
if (res != Z_OK && res != Z_STREAM_END) if (res != Z_OK && res != Z_STREAM_END)
die_horribly(AH, "%s: unable to uncompress data - %s\n", progname, zp->msg); die_horribly(AH, modulename, "unable to uncompress data: %s\n", zp->msg);
out[zlibOutSize - zp->avail_out] = '\0'; out[zlibOutSize - zp->avail_out] = '\0';
ahwrite(out, 1, zlibOutSize - zp->avail_out, AH); ahwrite(out, 1, zlibOutSize - zp->avail_out, AH);
...@@ -692,7 +693,7 @@ _skipData(ArchiveHandle *AH) ...@@ -692,7 +693,7 @@ _skipData(ArchiveHandle *AH)
} }
cnt = fread(in, 1, blkLen, AH->FH); cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen) if (cnt != blkLen)
die_horribly(AH, "%s: could not read data block - expected %d, got %d\n", progname, blkLen, cnt); die_horribly(AH, modulename, "could not read data block - expected %d, got %d\n", blkLen, cnt);
ctx->filePos += blkLen; ctx->filePos += blkLen;
...@@ -720,7 +721,7 @@ _WriteByte(ArchiveHandle *AH, const int i) ...@@ -720,7 +721,7 @@ _WriteByte(ArchiveHandle *AH, const int i)
if (res != EOF) if (res != EOF)
ctx->filePos += 1; ctx->filePos += 1;
else else
die_horribly(AH, "%s: could not write byte./n", progname); die_horribly(AH, modulename, "could not write byte: %s\n", strerror(errno));
return res; return res;
} }
...@@ -763,7 +764,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len) ...@@ -763,7 +764,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len)
res = fwrite(buf, 1, len, AH->FH); res = fwrite(buf, 1, len, AH->FH);
if (res != len) if (res != len)
die_horribly(AH, "%s: write error in _WriteBuf (%d != %d)\n", progname, res, len); die_horribly(AH, modulename, "write error in _WriteBuf (%d != %d)\n", res, len);
ctx->filePos += res; ctx->filePos += res;
return res; return res;
...@@ -833,7 +834,7 @@ _CloseArchive(ArchiveHandle *AH) ...@@ -833,7 +834,7 @@ _CloseArchive(ArchiveHandle *AH)
} }
if (fclose(AH->FH) != 0) if (fclose(AH->FH) != 0)
die_horribly(AH, "%s: could not close archive file\n", progname); die_horribly(AH, modulename, "could not close archive file: %s\n", strerror(errno));
AH->FH = NULL; AH->FH = NULL;
} }
...@@ -856,7 +857,7 @@ _getFilePos(ArchiveHandle *AH, lclContext *ctx) ...@@ -856,7 +857,7 @@ _getFilePos(ArchiveHandle *AH, lclContext *ctx)
pos = ftell(AH->FH); pos = ftell(AH->FH);
if (pos != ctx->filePos) if (pos != ctx->filePos)
{ {
fprintf(stderr, "Warning: ftell mismatch with filePos - filePos used\n"); write_msg(modulename, "WARNING: ftell mismatch with filePos - filePos used\n");
pos = ctx->filePos; pos = ctx->filePos;
} }
} }
...@@ -903,7 +904,7 @@ _StartDataCompressor(ArchiveHandle *AH, TocEntry *te) ...@@ -903,7 +904,7 @@ _StartDataCompressor(ArchiveHandle *AH, TocEntry *te)
zp->opaque = Z_NULL; zp->opaque = Z_NULL;
if (deflateInit(zp, AH->compression) != Z_OK) if (deflateInit(zp, AH->compression) != Z_OK)
die_horribly(AH, "%s: could not initialize compression library - %s\n", progname, zp->msg); die_horribly(AH, modulename, "could not initialize compression library: %s\n", zp->msg);
} }
#else #else
...@@ -936,7 +937,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush) ...@@ -936,7 +937,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
{ {
res = deflate(zp, flush); res = deflate(zp, flush);
if (res == Z_STREAM_ERROR) if (res == Z_STREAM_ERROR)
die_horribly(AH, "%s: could not compress data - %s\n", progname, zp->msg); die_horribly(AH, modulename, "could not compress data: %s\n", zp->msg);
if (((flush == Z_FINISH) && (zp->avail_out < zlibOutSize)) if (((flush == Z_FINISH) && (zp->avail_out < zlibOutSize))
|| (zp->avail_out == 0) || (zp->avail_out == 0)
...@@ -958,7 +959,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush) ...@@ -958,7 +959,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
*/ */
WriteInt(AH, zlibOutSize - zp->avail_out); WriteInt(AH, zlibOutSize - zp->avail_out);
if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out)) if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out))
die_horribly(AH, "%s: could not write compressed chunk\n", progname); die_horribly(AH, modulename, "could not write compressed chunk\n");
ctx->filePos += zlibOutSize - zp->avail_out; ctx->filePos += zlibOutSize - zp->avail_out;
} }
zp->next_out = out; zp->next_out = out;
...@@ -972,7 +973,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush) ...@@ -972,7 +973,7 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
{ {
WriteInt(AH, zp->avail_in); WriteInt(AH, zp->avail_in);
if (fwrite(zp->next_in, 1, zp->avail_in, AH->FH) != zp->avail_in) if (fwrite(zp->next_in, 1, zp->avail_in, AH->FH) != zp->avail_in)
die_horribly(AH, "%s: could not write uncompressed chunk\n", progname); die_horribly(AH, modulename, "could not write uncompressed chunk\n");
ctx->filePos += zp->avail_in; ctx->filePos += zp->avail_in;
zp->avail_in = 0; zp->avail_in = 0;
} }
...@@ -1021,7 +1022,7 @@ _EndDataCompressor(ArchiveHandle *AH, TocEntry *te) ...@@ -1021,7 +1022,7 @@ _EndDataCompressor(ArchiveHandle *AH, TocEntry *te)
} while (res != Z_STREAM_END); } while (res != Z_STREAM_END);
if (deflateEnd(zp) != Z_OK) if (deflateEnd(zp) != Z_OK)
die_horribly(AH, "%s: error closing compression stream - %s\n", progname, zp->msg); die_horribly(AH, modulename, "could not close compression stream: %s\n", zp->msg);
} }
#endif #endif
......
This diff is collapsed.
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
* Definitions for pg_backup_db.c * Definitions for pg_backup_db.c
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.h,v 1.4 2001/03/22 04:00:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.h,v 1.5 2001/06/27 21:21:37 petere Exp $
*/ */
#define BLOB_XREF_TABLE "dump_blob_xref" /* MUST be lower case */ #define BLOB_XREF_TABLE "dump_blob_xref" /* MUST be lower case */
extern void FixupBlobRefs(ArchiveHandle *AH, char *tablename); extern void FixupBlobRefs(ArchiveHandle *AH, char *tablename);
extern int ExecuteSqlCommand(ArchiveHandle *AH, PQExpBuffer qry, char *desc); extern int ExecuteSqlCommand(ArchiveHandle *AH, PQExpBuffer qry, char *desc, bool use_blob);
extern int ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qry, int bufLen); extern int ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qry, int bufLen);
extern void CreateBlobXrefTable(ArchiveHandle *AH); extern void CreateBlobXrefTable(ArchiveHandle *AH);
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.10 2001/04/01 05:42:51 pjw Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.11 2001/06/27 21:21:37 petere Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -36,9 +36,6 @@ ...@@ -36,9 +36,6 @@
#include "pg_backup.h" #include "pg_backup.h"
#include "pg_backup_archiver.h" #include "pg_backup_archiver.h"
#include <stdlib.h>
#include <string.h>
static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te); static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
static void _StartData(ArchiveHandle *AH, TocEntry *te); static void _StartData(ArchiveHandle *AH, TocEntry *te);
static int _WriteData(ArchiveHandle *AH, const void *data, int dLen); static int _WriteData(ArchiveHandle *AH, const void *data, int dLen);
...@@ -77,7 +74,7 @@ typedef struct ...@@ -77,7 +74,7 @@ typedef struct
char *filename; char *filename;
} lclTocEntry; } lclTocEntry;
static char *progname = "Archiver(files)"; static char *modulename = "file archiver";
static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt); static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt);
static void _getBlobTocEntry(ArchiveHandle *AH, int *oid, char *fname); static void _getBlobTocEntry(ArchiveHandle *AH, int *oid, char *fname);
...@@ -122,11 +119,9 @@ InitArchiveFmt_Files(ArchiveHandle *AH) ...@@ -122,11 +119,9 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
if (AH->mode == archModeWrite) if (AH->mode == archModeWrite)
{ {
fprintf(stderr, "\n*************************************************************\n" write_msg(modulename, "WARNING:\n"
"* WARNING: This format is for demonstration purposes. It is *\n" " This format is for demonstration purposes, it is not intended for\n"
"* not intended for general use. Files will be dumped *\n" " normal use. Files will be written in the current working directory.\n");
"* into the current working directory. *\n"
"***************************************************************\n\n");
if (AH->fSpec && strcmp(AH->fSpec, "") != 0) if (AH->fSpec && strcmp(AH->fSpec, "") != 0)
AH->FH = fopen(AH->fSpec, PG_BINARY_W); AH->FH = fopen(AH->fSpec, PG_BINARY_W);
...@@ -134,7 +129,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH) ...@@ -134,7 +129,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
AH->FH = stdout; AH->FH = stdout;
if (AH->FH == NULL) if (AH->FH == NULL)
die_horribly(NULL, "%s: Could not open output file\n", progname); die_horribly(NULL, modulename, "could not open output file: %s\n", strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0);
...@@ -152,7 +147,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH) ...@@ -152,7 +147,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
AH->FH = stdin; AH->FH = stdin;
if (AH->FH == NULL) if (AH->FH == NULL)
die_horribly(NULL, "%s: Could not open input file\n", progname); die_horribly(NULL, modulename, "could not open input file: %s\n", strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0);
...@@ -160,7 +155,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH) ...@@ -160,7 +155,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
ReadToc(AH); ReadToc(AH);
/* Nothing else in the file... */ /* Nothing else in the file... */
if (fclose(AH->FH) != 0) if (fclose(AH->FH) != 0)
die_horribly(AH, "%s: Could not close TOC file (fclose failed).\n", progname); die_horribly(AH, modulename, "could not close TOC file: %s\n", strerror(errno));
} }
} }
...@@ -250,7 +245,7 @@ _StartData(ArchiveHandle *AH, TocEntry *te) ...@@ -250,7 +245,7 @@ _StartData(ArchiveHandle *AH, TocEntry *te)
#endif #endif
if (tctx->FH == NULL) if (tctx->FH == NULL)
die_horribly(AH, "%s: Could not open data file for output\n", progname); die_horribly(AH, modulename, "could not open data file for output\n");
} }
...@@ -271,7 +266,7 @@ _EndData(ArchiveHandle *AH, TocEntry *te) ...@@ -271,7 +266,7 @@ _EndData(ArchiveHandle *AH, TocEntry *te)
/* Close the file */ /* Close the file */
if (GZCLOSE(tctx->FH) != 0) if (GZCLOSE(tctx->FH) != 0)
die_horribly(AH, "%s: could not close data file\n", progname); die_horribly(AH, modulename, "could not close data file\n");
tctx->FH = NULL; tctx->FH = NULL;
} }
...@@ -295,7 +290,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt) ...@@ -295,7 +290,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
#endif #endif
if (AH->FH == NULL) if (AH->FH == NULL)
die_horribly(AH, "%s: Could not open data file for input\n", progname); die_horribly(AH, modulename, "could not open data file for input\n");
while ((cnt = GZREAD(buf, 1, 4095, AH->FH)) > 0) while ((cnt = GZREAD(buf, 1, 4095, AH->FH)) > 0)
{ {
...@@ -304,7 +299,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt) ...@@ -304,7 +299,7 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
} }
if (GZCLOSE(AH->FH) != 0) if (GZCLOSE(AH->FH) != 0)
die_horribly(AH, "%s: could not close data file after reading\n", progname); die_horribly(AH, modulename, "could not close data file after reading\n");
} }
...@@ -368,7 +363,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt) ...@@ -368,7 +363,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
ctx->blobToc = fopen("blobs.toc", PG_BINARY_R); ctx->blobToc = fopen("blobs.toc", PG_BINARY_R);
if (ctx->blobToc == NULL) if (ctx->blobToc == NULL)
die_horribly(AH, "%s: Could not open BLOB TOC for input\n", progname); die_horribly(AH, modulename, "could not open BLOB TOC for input: %s\n", strerror(errno));
_getBlobTocEntry(AH, &oid, fname); _getBlobTocEntry(AH, &oid, fname);
...@@ -381,7 +376,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt) ...@@ -381,7 +376,7 @@ _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt)
} }
if (fclose(ctx->blobToc) != 0) if (fclose(ctx->blobToc) != 0)
die_horribly(AH, "%s: could not close BLOB TOC file\n", progname); die_horribly(AH, modulename, "could not close BLOB TOC file: %s\n", strerror(errno));
EndRestoreBlobs(AH); EndRestoreBlobs(AH);
} }
...@@ -393,7 +388,7 @@ _WriteByte(ArchiveHandle *AH, const int i) ...@@ -393,7 +388,7 @@ _WriteByte(ArchiveHandle *AH, const int i)
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
if (fputc(i, AH->FH) == EOF) if (fputc(i, AH->FH) == EOF)
die_horribly(AH, "%s: could not write byte\n", progname); die_horribly(AH, modulename, "could not write byte\n");
ctx->filePos += 1; ctx->filePos += 1;
...@@ -420,7 +415,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len) ...@@ -420,7 +415,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len)
res = fwrite(buf, 1, len, AH->FH); res = fwrite(buf, 1, len, AH->FH);
if (res != len) if (res != len)
die_horribly(AH, "%s: write error in _WriteBuf (%d != %d)\n", progname, res, len); die_horribly(AH, modulename, "write error in _WriteBuf (%d != %d)\n", res, len);
ctx->filePos += res; ctx->filePos += res;
return res; return res;
...@@ -445,7 +440,7 @@ _CloseArchive(ArchiveHandle *AH) ...@@ -445,7 +440,7 @@ _CloseArchive(ArchiveHandle *AH)
WriteHead(AH); WriteHead(AH);
WriteToc(AH); WriteToc(AH);
if (fclose(AH->FH) != 0) if (fclose(AH->FH) != 0)
die_horribly(AH, "%s: could not close TOC file\n", progname); die_horribly(AH, modulename, "could not close TOC file: %s\n", strerror(errno));
WriteDataChunks(AH); WriteDataChunks(AH);
} }
...@@ -478,7 +473,8 @@ _StartBlobs(ArchiveHandle *AH, TocEntry *te) ...@@ -478,7 +473,8 @@ _StartBlobs(ArchiveHandle *AH, TocEntry *te)
ctx->blobToc = fopen(fname, PG_BINARY_W); ctx->blobToc = fopen(fname, PG_BINARY_W);
if (ctx->blobToc == NULL) if (ctx->blobToc == NULL)
die_horribly(AH, "%s: could not open BLOB TOC for output\n", progname); die_horribly(AH, modulename,
"could not open BLOB TOC for output: %s\n", strerror(errno));
} }
...@@ -499,7 +495,7 @@ _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid) ...@@ -499,7 +495,7 @@ _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
char *sfx; char *sfx;
if (oid == 0) if (oid == 0)
die_horribly(AH, "%s: illegal OID for BLOB (%d)\n", progname, oid); die_horribly(AH, modulename, "invalid OID for BLOB (%u)\n", oid);
if (AH->compression != 0) if (AH->compression != 0)
sfx = ".gz"; sfx = ".gz";
...@@ -518,7 +514,7 @@ _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid) ...@@ -518,7 +514,7 @@ _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
#endif #endif
if (tctx->FH == NULL) if (tctx->FH == NULL)
die_horribly(AH, "%s: Could not open BLOB file\n", progname); die_horribly(AH, modulename, "could not open BLOB file\n");
} }
/* /*
...@@ -533,7 +529,7 @@ _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid) ...@@ -533,7 +529,7 @@ _EndBlob(ArchiveHandle *AH, TocEntry *te, Oid oid)
lclTocEntry *tctx = (lclTocEntry *) te->formatData; lclTocEntry *tctx = (lclTocEntry *) te->formatData;
if (GZCLOSE(tctx->FH) != 0) if (GZCLOSE(tctx->FH) != 0)
die_horribly(AH, "%s: could not close BLOB file\n", progname); die_horribly(AH, modulename, "could not close BLOB file\n");
} }
/* /*
...@@ -551,7 +547,7 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te) ...@@ -551,7 +547,7 @@ _EndBlobs(ArchiveHandle *AH, TocEntry *te)
/* WriteInt(AH, 0); */ /* WriteInt(AH, 0); */
if (fclose(ctx->blobToc) != 0) if (fclose(ctx->blobToc) != 0)
die_horribly(AH, "%s: could not close BLOB TOC file\n", progname); die_horribly(AH, modulename, "could not close BLOB TOC file: %s\n", strerror(errno));
} }
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.6 2001/03/24 23:11:14 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.7 2001/06/27 21:21:37 petere Exp $
* *
* Modifications - 09-Jul-2000 - pjw@rhyme.com.au * Modifications - 09-Jul-2000 - pjw@rhyme.com.au
* *
...@@ -63,7 +63,7 @@ InitArchiveFmt_Null(ArchiveHandle *AH) ...@@ -63,7 +63,7 @@ InitArchiveFmt_Null(ArchiveHandle *AH)
* Now prevent reading... * Now prevent reading...
*/ */
if (AH->mode == archModeRead) if (AH->mode == archModeRead)
die_horribly(AH, "%s: This format can not be read\n"); die_horribly(AH, NULL, "this format cannot be read\n");
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_dump.h,v 1.63 2001/04/25 07:03:20 pjw Exp $ * $Id: pg_dump.h,v 1.64 2001/06/27 21:21:37 petere Exp $
* *
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
* *
...@@ -254,7 +254,7 @@ extern OprInfo *getOperators(int *numOperators); ...@@ -254,7 +254,7 @@ extern OprInfo *getOperators(int *numOperators);
extern TableInfo *getTables(int *numTables, FuncInfo *finfo, int numFuncs); extern TableInfo *getTables(int *numTables, FuncInfo *finfo, int numFuncs);
extern InhInfo *getInherits(int *numInherits); extern InhInfo *getInherits(int *numInherits);
extern void getTableAttrs(TableInfo *tbinfo, int numTables); extern void getTableAttrs(TableInfo *tbinfo, int numTables);
extern IndInfo *getIndices(int *numIndices); extern IndInfo *getIndexes(int *numIndexes);
extern void dumpDBComment(Archive *outfile); extern void dumpDBComment(Archive *outfile);
extern void dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs, extern void dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
TypeInfo *tinfo, int numTypes); TypeInfo *tinfo, int numTypes);
...@@ -267,12 +267,12 @@ extern void dumpAggs(Archive *fout, AggInfo *agginfo, int numAggregates, ...@@ -267,12 +267,12 @@ extern void dumpAggs(Archive *fout, AggInfo *agginfo, int numAggregates,
extern void dumpOprs(Archive *fout, OprInfo *agginfo, int numOperators, extern void dumpOprs(Archive *fout, OprInfo *agginfo, int numOperators,
TypeInfo *tinfo, int numTypes); TypeInfo *tinfo, int numTypes);
extern void dumpTables(Archive *fout, TableInfo *tbinfo, int numTables, extern void dumpTables(Archive *fout, TableInfo *tbinfo, int numTables,
IndInfo *indinfo, int numIndices, IndInfo *indinfo, int numIndexes,
InhInfo *inhinfo, int numInherits, InhInfo *inhinfo, int numInherits,
TypeInfo *tinfo, int numTypes, const char *tablename, TypeInfo *tinfo, int numTypes, const char *tablename,
const bool acls, const bool oids, const bool acls, const bool oids,
const bool schemaOnly, const bool dataOnly); const bool schemaOnly, const bool dataOnly);
extern void dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices, extern void dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
TableInfo *tbinfo, int numTables, const char *tablename); TableInfo *tbinfo, int numTables, const char *tablename);
extern const char *fmtId(const char *identifier, bool force_quotes); extern const char *fmtId(const char *identifier, bool force_quotes);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* user-defined types * user-defined types
* user-defined functions * user-defined functions
* tables * tables
* indices * indexes
* aggregates * aggregates
* operators * operators
* ACL - grant/revoke * ACL - grant/revoke
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.20 2001/05/17 21:12:49 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.21 2001/06/27 21:21:37 petere Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -55,10 +55,8 @@ ...@@ -55,10 +55,8 @@
*/ */
#include "pg_backup.h" #include "pg_backup.h"
#include "pg_backup_archiver.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h> #include <ctype.h>
#ifndef HAVE_STRDUP #ifndef HAVE_STRDUP
...@@ -73,6 +71,10 @@ ...@@ -73,6 +71,10 @@
#include <getopt.h> #include <getopt.h>
#endif #endif
#ifdef ENABLE_NLS
#include <locale.h>
#endif
/* Forward decls */ /* Forward decls */
static void usage(const char *progname); static void usage(const char *progname);
static char *_cleanupName(char *name); static char *_cleanupName(char *name);
...@@ -116,16 +118,24 @@ int ...@@ -116,16 +118,24 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
RestoreOptions *opts; RestoreOptions *opts;
char *progname;
int c; int c;
Archive *AH; Archive *AH;
char *fileSpec = NULL; char *fileSpec = NULL;
extern int optind; extern int optind;
extern char *optarg; extern char *optarg;
#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
bindtextdomain("pg_dump", LOCALEDIR);
textdomain("pg_dump");
#endif
opts = NewRestoreOptions(); opts = NewRestoreOptions();
if (!strrchr(argv[0], '/'))
progname = argv[0]; progname = argv[0];
else
progname = strrchr(argv[0], '/') + 1;
if (argc > 1) if (argc > 1)
{ {
...@@ -257,7 +267,7 @@ main(int argc, char **argv) ...@@ -257,7 +267,7 @@ main(int argc, char **argv)
opts->aclsSkip = 1; opts->aclsSkip = 1;
break; break;
default: default:
fprintf(stderr, "Try '%s --help' for more information.\n", progname); fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname);
exit(1); exit(1);
} }
} }
...@@ -289,8 +299,8 @@ main(int argc, char **argv) ...@@ -289,8 +299,8 @@ main(int argc, char **argv)
break; break;
default: default:
fprintf(stderr, "%s: Unknown archive format '%s', please specify 't' or 'c'\n", write_msg("unrecognized archive format '%s'; please specify 't' or 'c'\n",
progname, opts->formatName); opts->formatName);
exit(1); exit(1);
} }
} }
...@@ -335,12 +345,13 @@ main(int argc, char **argv) ...@@ -335,12 +345,13 @@ main(int argc, char **argv)
static void static void
usage(const char *progname) usage(const char *progname)
{ {
printf("%s restores a PostgreSQL database from an archive created by pg_dump.\n\n" printf(gettext(
"%s restores a PostgreSQL database from an archive created by pg_dump.\n\n"
"Usage:\n %s [options] [file]\n\n" "Usage:\n %s [options] [file]\n\n"
"Options:\n", "Options:\n"),
progname, progname); progname, progname);
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
puts( puts(gettext(
" -a, --data-only restore only the data, no schema\n" " -a, --data-only restore only the data, no schema\n"
" -c, --clean clean (drop) schema prior to create\n" " -c, --clean clean (drop) schema prior to create\n"
" -C, --create output commands to create the database\n" " -C, --create output commands to create the database\n"
...@@ -348,7 +359,7 @@ usage(const char *progname) ...@@ -348,7 +359,7 @@ usage(const char *progname)
" -f, --file=FILENAME script output file name\n" " -f, --file=FILENAME script output file name\n"
" -F, --format {c|f} specify backup file format\n" " -F, --format {c|f} specify backup file format\n"
" -h, --host HOSTNAME server host name\n" " -h, --host HOSTNAME server host name\n"
" -i, --index[=NAME] restore indices or named index\n" " -i, --index[=NAME] restore indexes or named index\n"
" -l, --list dump summarized TOC for this file\n" " -l, --list dump summarized TOC for this file\n"
" -L, --use-list=FILENAME use specified table of contents for ordering\n" " -L, --use-list=FILENAME use specified table of contents for ordering\n"
" output from this file\n" " output from this file\n"
...@@ -368,11 +379,12 @@ usage(const char *progname) ...@@ -368,11 +379,12 @@ usage(const char *progname)
" -U, --username=NAME connect as specified database user\n" " -U, --username=NAME connect as specified database user\n"
" -v, --verbose verbose\n" " -v, --verbose verbose\n"
" -W, --password force password prompt (should happen automatically)\n" " -W, --password force password prompt (should happen automatically)\n"
" -x, --no-acl skip dumping of ACLs (grant/revoke)\n"); " -x, --no-acl skip dumping of ACLs (grant/revoke)\n"
));
#else /* not HAVE_GETOPT_LONG */ #else /* not HAVE_GETOPT_LONG */
puts( puts(gettext(
" -a restore only the data, no schema\n" " -a restore only the data, no schema\n"
" -c clean (drop) schema prior to create\n" " -c clean (drop) schema prior to create\n"
" -C output commands to create the database\n" " -C output commands to create the database\n"
...@@ -380,7 +392,7 @@ usage(const char *progname) ...@@ -380,7 +392,7 @@ usage(const char *progname)
" -f FILENAME script output file name\n" " -f FILENAME script output file name\n"
" -F {c|f} specify backup file format\n" " -F {c|f} specify backup file format\n"
" -h HOSTNAME server host name\n" " -h HOSTNAME server host name\n"
" -i NAME restore indices or named index\n" " -i NAME restore indexes or named index\n"
" -l dump summarized TOC for this file\n" " -l dump summarized TOC for this file\n"
" -L FILENAME use specified table of contents for ordering\n" " -L FILENAME use specified table of contents for ordering\n"
" output from this file\n" " output from this file\n"
...@@ -400,10 +412,11 @@ usage(const char *progname) ...@@ -400,10 +412,11 @@ usage(const char *progname)
" -U NAME connect as specified database user\n" " -U NAME connect as specified database user\n"
" -v verbose\n" " -v verbose\n"
" -W force password prompt (should happen automatically)\n" " -W force password prompt (should happen automatically)\n"
" -x skip dumping of ACLs (grant/revoke)\n"); " -x skip dumping of ACLs (grant/revoke)\n"
));
#endif #endif
puts("If [file] is not supplied, then standard input is used.\n"); puts(gettext("If no input file name is supplied, then standard input is used.\n"));
puts("Report bugs to <pgsql-bugs@postgresql.org>."); puts(gettext("Report bugs to <pgsql-bugs@postgresql.org>."));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment