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,13 +483,13 @@ flagInhAttrs(TableInfo *tblinfo, int numTables, ...@@ -477,13 +483,13 @@ 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);
}; };
......
# German message translation file for pg_dump and friends
# Peter Eisentraut <peter_e@gmx.net>, 2001.
#
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/de.po,v 1.1 2001/06/27 21:21:37 petere Exp $
#
# Use these quotes: %s
#
msgid ""
msgstr ""
"Project-Id-Version: pg_dump (PostgreSQL) 7.2\n"
"POT-Creation-Date: 2001-06-27 21:58+0200\n"
"PO-Revision-Date: 2001-06-27 22:02+0200\n"
"Last-Translator: Peter Eisentraut <peter_e@gmx.net>\n"
"Language-Team: German <de@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
#: pg_dump.c:243
#, c-format
msgid ""
"%s dumps a database as a text file or to other formats.\n"
"\n"
msgstr ""
#: pg_dump.c:244
msgid "Usage:"
msgstr "Benutzung:"
#: pg_dump.c:245
#, c-format
msgid ""
" %s [options] dbname\n"
"\n"
msgstr ""
" %s [Optionen] DB-Name\n"
"\n"
#: pg_dump.c:246
msgid "Options:"
msgstr "Optionen:"
#: pg_dump.c:250
msgid ""
" -a, --data-only dump only the data, not the schema\n"
" -b, --blobs include BLOB data in dump\n"
" -c, --clean clean (drop) schema prior to create\n"
" -C, --create include commands to create database in dump\n"
" -d, --inserts dump data as INSERT, rather than COPY, commands\n"
" -D, --attribute-inserts dump data as INSERT commands with column names\n"
" -f, --file=FILENAME output file name\n"
" -F, --format {c|t|p} output file format (custom, tar, plain text)\n"
" -h, --host=HOSTNAME database server host name\n"
" -i, --ignore-version proceed even when server version mismatches\n"
" pg_dump version\n"
" -n, --no-quotes suppress most quotes around identifiers\n"
" -N, --quotes enable most quotes around identifiers\n"
" -o, --oids include oids in dump\n"
" -O, --no-owner do not output \\connect commands in plain\n"
" text format\n"
" -p, --port=PORT database server port number\n"
" -R, --no-reconnect disable ALL reconnections to the database in\n"
" plain text format\n"
" -s, --schema-only dump only the schema, no data\n"
" -S, --superuser=NAME specify the superuser user name to use in\n"
" plain text format\n"
" -t, --table=TABLE dump this table only (* for all)\n"
" -U, --username=NAME connect as specified database user\n"
" -v, --verbose verbose mode\n"
" -W, --password force password prompt (should happen "
"automatically)\n"
" -x, --no-acl do not dump privileges (grant/revoke)\n"
" -Z, --compress {0-9} compression level for compressed formats\n"
msgstr ""
#: pg_dump.c:281
msgid ""
" -a dump only the data, not the schema\n"
" -b include BLOB data in dump\n"
" -c clean (drop) schema prior to create\n"
" -C include commands to create database in dump\n"
" -d dump data as INSERT, rather than COPY, commands\n"
" -D dump data as INSERT commands with column names\n"
" -f FILENAME output file name\n"
" -F {c|t|p} output file format (custom, tar, plain text)\n"
" -h HOSTNAME database server host name\n"
" -i proceed even when server version mismatches\n"
" pg_dump version\n"
" -n suppress most quotes around identifiers\n"
" -N enable most quotes around identifiers\n"
" -o include oids in dump\n"
" -O do not output \\connect commands in plain\n"
" text format\n"
" -p PORT database server port number\n"
" -R disable ALL reconnections to the database in\n"
" plain text format\n"
" -s dump only the schema, no data\n"
" -S NAME specify the superuser user name to use in\n"
" plain text format\n"
" -t TABLE dump this table only (* for all)\n"
" -U NAME connect as specified database user\n"
" -v verbose mode\n"
" -W force password prompt (should happen "
"automatically)\n"
" -x do not dump privileges (grant/revoke)\n"
" -Z {0-9} compression level for compressed formats\n"
msgstr ""
#: pg_dump.c:311
msgid ""
"If no database name is not supplied, then the PGDATABASE environment\n"
"variable value is used.\n"
"\n"
"Report bugs to <pgsql-bugs@postgresql.org>."
msgstr ""
"Wenn kein Datenbankname angegeben wird, dann wird die Umgebungsvariable\n"
"PGDATABASE verwendet.\n"
"\n"
"Berichten Sie Fehler an <pgsql-bugs@postgresql.org>."
#: pg_dump.c:380
#, c-format
msgid "SQL command to dump the contents of table \"%s\" failed\n"
msgstr ""
#: pg_dump.c:382 pg_dump.c:478 pg_dump.c:511 pg_dump.c:1183
#, c-format
msgid "Error message from server: %s"
msgstr "Fehlermeldung vom Server: %s"
#: pg_dump.c:383 pg_dump.c:394 pg_dump.c:479 pg_dump.c:512 pg_dump.c:1184
#, c-format
msgid "The command was: %s\n"
msgstr "Die Anweisung war: %s\n"
#: pg_dump.c:390
#, c-format
msgid "SQL command to dump the contents of table \"%s\" executed abnormally.\n"
msgstr ""
#: pg_dump.c:392
#, c-format
msgid "The server returned status %d when %d was expected.\n"
msgstr "Der Server gab Status %d zurck, aber %d wurde erwartet.\n"
#: pg_dump.c:477
#, c-format
msgid ""
"SQL command to dump the contents of table \"%s\" failed: PQendcopy() "
"failed.\n"
msgstr ""
#: pg_dump.c:510
msgid "dumpClasses(): SQL command failed\n"
msgstr "dumpClasses(): SQL-Anweisung schlug fehl\n"
#: pg_dump.c:924 pg_restore.c:251
msgid "Username: "
msgstr "Benutzername: "
#: pg_dump.c:955
#, c-format
msgid ""
"%s was compiled without support for long options.\n"
"Use --help for help on invocation options.\n"
msgstr ""
"%s wurde ohne Untersttzung fr lange Optionen kompiliert.\n"
"Verwenden Sie --help fr Hilfe.\n"
#: pg_dump.c:962 pg_restore.c:270
#, c-format
msgid "Try '%s --help' for more information.\n"
msgstr "Versuchen Sie %s --help fr weitere Informationen.\n"
#: pg_dump.c:970
#, c-format
msgid ""
"%s: too many command line options (first is '%s')\n"
"Try '%s --help' for more information.\n"
msgstr ""
"%s: zu Viele Kommandozeilenoptionen (die Erste ist %s)\n"
"Versuchen Sie %s --help fr weitere Informationen.\n"
#: pg_backup_db.c:353 pg_dump.c:983
msgid "no database name specified\n"
msgstr "kein Datenbankname angegeben\n"
#: pg_dump.c:989
msgid "'Schema only' and 'data only' are incompatible options.\n"
msgstr ""
#: pg_dump.c:995
msgid "BLOB output is not supported for a single table.\n"
msgstr ""
#: pg_dump.c:996
msgid "Use all tables or a full dump instead.\n"
msgstr ""
#: pg_dump.c:1002
msgid "INSERT (-d, -D) and OID (-o) options cannot be used together.\n"
msgstr ""
"Die Optionen INSERT (-d, -D) und OID (-o) knnen nicht zusammen verwendet "
"werden.\n"
#: pg_dump.c:1003
msgid "(The INSERT command cannot set oids.)\n"
msgstr "(Die INSERT-Anweisung kann Oids nicht setzen.)\n"
#: pg_dump.c:1009
msgid "BLOB output is not supported for plain text dump files.\n"
msgstr ""
#: pg_dump.c:1010
msgid "(Use a different output format.)\n"
msgstr ""
#: pg_dump.c:1040
#, c-format
msgid "invalid output format '%s' specified\n"
msgstr "ungltiges Ausgabeformat %s angegeben\n"
#: pg_dump.c:1046
#, c-format
msgid "could not open output file %s for writing\n"
msgstr "konnte Ausgabedatei %s nicht zum Schreiben ffnen\n"
#: pg_dump.c:1069
#, c-format
msgid "BEGIN command failed: %s"
msgstr "BEGIN-Anweisung schlug fehl: %s"
#: pg_dump.c:1075
#, c-format
msgid "could not set transaction isolation level to serializable: %s"
msgstr ""
#: pg_dump.c:1182
msgid "SQL command failed\n"
msgstr "SQL-Anweisung schlug fehl\n"
#: pg_dump.c:1192
#, c-format
msgid "missing pg_database entry for database \"%s\"\n"
msgstr "fehlender pg_database-Eintrag fr Datenbank %s\n"
#: pg_dump.c:1198
#, c-format
msgid ""
"query returned more than one (%d) pg_database entry for database \"%s\"\n"
msgstr ""
#: pg_dump.c:1253
#, c-format
msgid "dumpBlobs(): cursor declaration failed: %s"
msgstr ""
#: pg_dump.c:1268
#, c-format
msgid "dumpBlobs(): fetch from cursor failed: %s"
msgstr ""
#: pg_dump.c:1281
#, c-format
msgid "dumpBlobs(): could not open large object: %s"
msgstr ""
#: pg_dump.c:1294
#, c-format
msgid "dumpBlobs(): error reading large object: %s"
msgstr ""
#: pg_dump.c:1379
#, c-format
msgid "query to obtain list of data types failed: %s"
msgstr ""
#: pg_dump.c:1423
#, c-format
msgid "WARNING: owner of data type %s appears to be invalid\n"
msgstr "WARNUNG: Eigentmer des Datentypen %s scheint ungltig zu sein\n"
#: pg_dump.c:1497
#, c-format
msgid "query to obtain list of operators failed: %s"
msgstr ""
#: pg_dump.c:1539
#, c-format
msgid "WARNING: owner of operator \"%s\" appears to be invalid\n"
msgstr "WARNUNG: Eigentmer des Operatoren %s scheint ungltig zu sein\n"
#: pg_dump.c:1861
#, c-format
msgid "query to obtain list of aggregate functions failed: %s\n"
msgstr ""
#: pg_dump.c:1892
#, c-format
msgid "WARNING: owner of aggregate function \"%s\" appears to be invalid\n"
msgstr ""
#: pg_dump.c:1962
#, c-format
msgid "query to obtain list of functions failed: %s"
msgstr "Abfrage um Liste der Funktionen zu ermitteln schlug fehl: %s"
#: pg_dump.c:2005
#, c-format
msgid "WARNING: owner of function \"%s\" appears to be invalid\n"
msgstr ""
#: pg_dump.c:2010
#, c-format
msgid ""
"failed sanity check: function %s has more than %d (namely %d) arguments\n"
msgstr ""
#: pg_dump.c:2105
#, c-format
msgid "query to obtain list of tables failed: %s"
msgstr "Abfrage um Liste der Tabellen zu ermitteln schlug fehl: %s"
#: pg_dump.c:2136
#, c-format
msgid "WARNING: owner of table \"%s\" appears to be invalid\n"
msgstr ""
#: pg_dump.c:2156
#, c-format
msgid "query to obtain definition of view \"%s\" failed: %s"
msgstr ""
#: pg_dump.c:2164
#, c-format
msgid "query to obtain definition of view \"%s\" returned no data\n"
msgstr ""
#: pg_dump.c:2167
#, c-format
msgid ""
"query to obtain definition of view \"%s\" returned more than one definition\n"
msgstr ""
#: pg_dump.c:2174
#, c-format
msgid "query to obtain definition of view \"%s\" returned NULL oid\n"
msgstr ""
#: pg_dump.c:2184
#, c-format
msgid "definition of view \"%s\" appears to be empty (length zero)\n"
msgstr ""
#: pg_dump.c:2232
#, c-format
msgid "query to obtain check constraints failed: %s"
msgstr ""
#: pg_dump.c:2238
#, c-format
msgid "expected %d check constraints on table \"%s\" but found %d\n"
msgstr ""
#: pg_dump.c:2240
msgid "(The system catalogs might be corrupted.)\n"
msgstr ""
#: pg_dump.c:2281
#, c-format
msgid "query to obtain primary key of table \"%s\" failed: %s"
msgstr ""
#: pg_dump.c:2288
#, c-format
msgid ""
"query to obtain primary key of table \"%s\" produced more than one result\n"
msgstr ""
#: pg_dump.c:2338
#, c-format
msgid "query to obtain name of primary key of table \"%s\" failed: %s"
msgstr ""
#: pg_dump.c:2346
#, c-format
msgid ""
"query to obtain name of primary key of table \"%s\" did not return exactly "
"one result\n"
msgstr ""
#: pg_dump.c:2354
#, c-format
msgid "name of primary key of table \"%s\" returned NULL value\n"
msgstr ""
#: pg_backup_archiver.c:620 pg_backup_archiver.c:1030
#: pg_backup_archiver.c:1150 pg_backup_archiver.c:1436
#: pg_backup_archiver.c:1578 pg_backup_archiver.c:1607 pg_backup_custom.c:149
#: pg_backup_custom.c:154 pg_backup_custom.c:169 pg_backup_custom.c:564
#: pg_backup_db.c:284 pg_backup_db.c:376 pg_backup_tar.c:992 pg_dump.c:2363
msgid "out of memory\n"
msgstr "Speicher aufgebraucht\n"
#: pg_dump.c:2409
#, c-format
msgid "query to obtain list of triggers failed: %s"
msgstr ""
#: pg_dump.c:2415
#, c-format
msgid "expected %d triggers on table \"%s\" but found %d\n"
msgstr ""
#: pg_dump.c:2495
#, c-format
msgid "query to obtain procedure name for trigger \"%s\" failed: %s"
msgstr ""
#: pg_dump.c:2504
#, c-format
msgid ""
"query to obtain procedure name for trigger \"%s\" did not return exactly one "
"result\n"
msgstr ""
#: pg_dump.c:2567
#, c-format
msgid ""
"query produced NULL referenced table name for trigger \"%s\" on table \"%s"
"\" (oid was %s)\n"
msgstr ""
#: pg_dump.c:2597
#, c-format
msgid "bad argument string (%s) for trigger \"%s\" on table \"%s\"\n"
msgstr ""
#: pg_dump.c:2685
#, c-format
msgid "query to obtain inheritance relationships failed: %s"
msgstr ""
#: pg_dump.c:2788
#, c-format
msgid "query to get table columns failed: %s"
msgstr ""
#: pg_dump.c:2820
#, c-format
msgid "query produced NULL name for data type of column %d of table %s\n"
msgstr ""
#: pg_dump.c:2855
#, c-format
msgid "query to get column default value failed: %s"
msgstr ""
#: pg_dump.c:2864
#, c-format
msgid ""
"query to get default value for column \"%s\" returned %d rows; expected 1\n"
msgstr ""
#: pg_dump.c:2937
#, c-format
msgid "query to obtain list of indexes failed: %s"
msgstr ""
#: pg_dump.c:3017
#, c-format
msgid "query to get comment on oid %s failed: %s"
msgstr ""
#: pg_dump.c:3072
#, c-format
msgid "query to get database oid failed: %s"
msgstr ""
#: pg_dump.c:3172
#, c-format
msgid "Notice: array type %s - type for elements (oid %s) is not dumped.\n"
msgstr ""
#: pg_dump.c:3239
#, c-format
msgid "query to obtain list of procedural languages failed: %s"
msgstr ""
#: pg_dump.c:3267
#, c-format
msgid "handler procedure for procedural language %s not found\n"
msgstr ""
#: pg_dump.c:3357
#, c-format
msgid "query to get name of procedural language failed: %s"
msgstr ""
#: pg_dump.c:3364
#, c-format
msgid "procedural language for function %s not found\n"
msgstr ""
#: pg_dump.c:3406 pg_dump.c:3435
#, c-format
msgid "Notice: function \"%s\" not dumped\n"
msgstr ""
#: pg_dump.c:3409
#, c-format
msgid "Reason: data type name of argument %d (oid %s) not found\n"
msgstr ""
#: pg_dump.c:3438
#, c-format
msgid "Reason: name of return data type (oid %s) not found\n"
msgstr ""
#: pg_dump.c:4108
#, c-format
msgid ""
"dumpTables(): failed sanity check, could not find index (%s) for primary key "
"constraint\n"
msgstr ""
#: pg_dump.c:4232
#, c-format
msgid "getAttrName(): invalid column number %d for table %s\n"
msgstr ""
#: pg_dump.c:4268
#, c-format
msgid "dumpIndexes(): failed sanity check, table %s was not found\n"
msgstr ""
#: pg_dump.c:4322
#, c-format
msgid "query to get function name of oid %s failed: %s"
msgstr ""
#: pg_dump.c:4331
#, c-format
msgid "query to get function name of oid %s returned %d rows; expected 1\n"
msgstr ""
#: pg_dump.c:4356
#, c-format
msgid "query to get operator class name of oid %u failed: %s"
msgstr ""
#: pg_dump.c:4365
#, c-format
msgid ""
"query to get operator class name of oid %u returned %d rows; expected 1\n"
msgstr ""
#: pg_dump.c:4376
#, c-format
msgid "There must be exactly one OpClass for functional index \"%s\".\n"
msgstr ""
#: pg_dump.c:4400
#, c-format
msgid "no operator class found for column \"%s\" of index \"%s\"\n"
msgstr ""
#: pg_dump.c:4542
#, c-format
msgid "could not create pgdump_oid table: %s"
msgstr ""
#: pg_dump.c:4550
#, c-format
msgid "could not insert into pgdump_oid table: %s"
msgstr ""
#: pg_dump.c:4556
msgid "inserted invalid oid\n"
msgstr ""
#: pg_dump.c:4564
#, c-format
msgid "could not drop pgdump_oid table: %s"
msgstr ""
#: pg_dump.c:4604
#, c-format
msgid "error in finding the last system oid: %s"
msgstr ""
#: pg_dump.c:4610
msgid "missing pg_database entry for this database\n"
msgstr ""
#: pg_dump.c:4615
msgid "found more than one pg_database entry for this database\n"
msgstr ""
#: pg_dump.c:4642
#, c-format
msgid "error in finding the template1 database: %s"
msgstr ""
#: pg_dump.c:4648
msgid "could not find template1 database entry in the pg_database table\n"
msgstr ""
#: pg_dump.c:4653
msgid "found more than one template1 database entry in the pg_database table\n"
msgstr ""
#: pg_dump.c:4684
#, c-format
msgid "query to get data of sequence \"%s\" failed: %s"
msgstr ""
#: pg_dump.c:4690
#, c-format
msgid "query to get data of sequence \"%s\" returned %d rows (expected 1)\n"
msgstr ""
#: pg_dump.c:4697
#, c-format
msgid "query to get data of sequence \"%s\" returned name \"%s\"\n"
msgstr ""
#: pg_dump.c:4840
#, c-format
msgid "query to get rules associated with table \"%s\" failed: %s"
msgstr ""
#: common.c:121
#, c-format
msgid "failed sanity check, operator with oid %s not found\n"
msgstr ""
#: common.c:173
#, c-format
msgid "failed sanity check, parent oid %s of table %s (oid %s) not found\n"
msgstr ""
#: common.c:178
#, c-format
msgid "failed sanity check, parent oid %s of table (oid %s) not found\n"
msgstr ""
#: common.c:221
msgid "parseNumericArray: too many numbers\n"
msgstr ""
#: common.c:236
msgid "parseNumericArray: bogus number\n"
msgstr ""
#: common.c:491
#, c-format
msgid "failed sanity check, table \"%s\" not found by flagInhAttrs\n"
msgstr ""
#: pg_backup_archiver.c:149
msgid "could not close the output file in CloseArchive\n"
msgstr ""
#: pg_backup_archiver.c:166
msgid "-C and -R are incompatible options\n"
msgstr ""
#: pg_backup_archiver.c:175
msgid "direct database connections are not supported in pre-1.3 archives\n"
msgstr ""
#: pg_backup_archiver.c:227
msgid ""
"WARNING:\n"
" Data restoration may fail because existing triggers cannot be disabled\n"
" (no superuser user name specified). This is only a problem when\n"
" restoring into a database with already existing triggers.\n"
msgstr ""
"WARNUNG:\n"
" Datenwiederherstellung knnte fehlschlagen, weil Trigger nicht "
"abgeschaltet\n"
" werden knnen (kein Superuser-Name angegeben). Das ist nur ein Problem,\n"
" wenn man die Wiederherstellung in eine Datenbank macht, die bereits "
"Trigger\n"
" enthlt.\n"
#: pg_backup_archiver.c:275 pg_backup_archiver.c:277
#, c-format
msgid "warning from original dump file: %s\n"
msgstr ""
#: pg_backup_archiver.c:317
msgid ""
"unable to restore from compressed archive (not configured for compression "
"support)\n"
msgstr ""
#: pg_backup_archiver.c:335
msgid "WARNING: skipping BLOB restoration\n"
msgstr ""
#: pg_backup_archiver.c:595
msgid ""
"WriteData cannot be called outside the context of a DataDumper routine\n"
msgstr ""
#: pg_backup_archiver.c:715
msgid "BLOB output not supported in chosen format\n"
msgstr ""
#: pg_backup_archiver.c:779
msgid "cannot restore BLOBs without a database connection"
msgstr ""
#: pg_backup_archiver.c:798
msgid "could not create BLOB\n"
msgstr ""
#: pg_backup_archiver.c:806
msgid "could not open BLOB\n"
msgstr ""
#: pg_backup_archiver.c:946
msgid "could not open TOC file\n"
msgstr ""
#: pg_backup_archiver.c:967
#, c-format
msgid "WARNING: line ignored: %s\n"
msgstr "WARNUNG: Zeile ignoriert: %s\n"
#: pg_backup_archiver.c:974
#, c-format
msgid "could not find entry for id %d\n"
msgstr ""
#: pg_backup_archiver.c:983 pg_backup_files.c:158 pg_backup_files.c:443
#, c-format
msgid "could not close TOC file: %s\n"
msgstr ""
#: pg_backup_archiver.c:1099 pg_backup_files.c:132
#, c-format
msgid "could not open output file: %s\n"
msgstr "konnte Ausgabedatei nicht ffnen: %s\n"
#: pg_backup_archiver.c:1115
#, c-format
msgid "could not close output file: %s\n"
msgstr "konnte Ausgabedatei nicht schlieen: %s\n"
#: pg_backup_archiver.c:1198
#, c-format
msgid "could not write to large object (result: %d, expected: %d)\n"
msgstr ""
#: pg_backup_archiver.c:1207
msgid "could not write to compressed archive\n"
msgstr "konnte nicht in komprimiertes Archiv schreiben\n"
#: pg_backup_archiver.c:1215
msgid "could not write to custom output routine\n"
msgstr ""
#: pg_backup_archiver.c:1231
#, c-format
msgid "could not write to output file (%d != %d)\n"
msgstr "konnte nicht in Ausgabedatei schreiben (%d != %d)\n"
#: pg_backup_archiver.c:1454
msgid "attempting to ascertain archive format\n"
msgstr ""
#: pg_backup_archiver.c:1474 pg_backup_files.c:150
#, c-format
msgid "could not open input file: %s\n"
msgstr "konnte Eingabedatei nicht ffnen: %s\n"
#: pg_backup_archiver.c:1481
#, c-format
msgid "could not read input file: %s\n"
msgstr "konnte nicht aus Eingabedatei lesen: %s\n"
#: pg_backup_archiver.c:1483
#, c-format
msgid "input file is too short (read %d, expected 5)\n"
msgstr "Eingabedatei ist zu kurz (gelesen: %d, erwartet: 5)\n"
#: pg_backup_archiver.c:1528
msgid "input file does not appear to be a valid archive (too short?)\n"
msgstr "Eingabedatei scheint kein gltiges Archiv zu sein (zu kurz?)\n"
#: pg_backup_archiver.c:1531
msgid "input file does not appear to be a valid archive\n"
msgstr "Eingabedatei scheint kein gltiges Archiv zu sein\n"
#: pg_backup_archiver.c:1550
#, c-format
msgid "read %d bytes into lookahead buffer\n"
msgstr ""
#: pg_backup_archiver.c:1556
#, c-format
msgid "could not close the input file after reading header: %s\n"
msgstr ""
#: pg_backup_archiver.c:1573
#, c-format
msgid "allocating AH for %s, format %d\n"
msgstr ""
#: pg_backup_archiver.c:1623
#, c-format
msgid "archive format is %d\n"
msgstr ""
#: pg_backup_archiver.c:1651
#, c-format
msgid "unrecognized file format '%d'\n"
msgstr ""
#: pg_backup_archiver.c:1765
msgid "failed sanity check (bad entry id) - perhaps a corrupt TOC\n"
msgstr ""
#: pg_backup_archiver.c:1797
#, c-format
msgid "read dependency for %s -> %s\n"
msgstr ""
#: pg_backup_archiver.c:1961
msgid ""
"WARNING: requested compression not available in this installation - archive "
"will be uncompressed\n"
msgstr ""
#: pg_backup_archiver.c:1994
msgid "did not find magic string in file header\n"
msgstr ""
#: pg_backup_archiver.c:2008
#, c-format
msgid "unsupported version (%d.%d) in file header\n"
msgstr ""
#: pg_backup_archiver.c:2013
#, c-format
msgid "sanity check on integer size (%d) failed\n"
msgstr ""
#: pg_backup_archiver.c:2016
msgid ""
"WARNING: archive was made on a machine with larger integers, some operations "
"may fail\n"
msgstr ""
#: pg_backup_archiver.c:2021
#, c-format
msgid "expected format (%d) differs from format found in file (%d)\n"
msgstr ""
#: pg_backup_archiver.c:2037
msgid ""
"WARNING: archive is compressed, but this installation does not support "
"compression - no data will be available\n"
msgstr ""
#: pg_backup_archiver.c:2055
msgid "WARNING: bad creation date in header\n"
msgstr ""
#: pg_backup_custom.c:183
#, c-format
msgid "could not open archive file %s: %s\n"
msgstr ""
#: pg_backup_custom.c:196
#, c-format
msgid "could not open archive file %s: %s"
msgstr ""
#: pg_backup_custom.c:389
msgid "invalid OID for BLOB\n"
msgstr ""
#: pg_backup_custom.c:449
msgid ""
"Dumping a specific TOC data block out of order is not supported without id "
"on this input stream (fseek required)\n"
msgstr ""
#: pg_backup_custom.c:468
#, c-format
msgid "unrecognized data block type (%d) while searching archive\n"
msgstr ""
#: pg_backup_custom.c:484
#, c-format
msgid "error during file seek: %s\n"
msgstr ""
#: pg_backup_custom.c:492
#, c-format
msgid "found unexpected block ID (%d) when reading data - expected %d\n"
msgstr ""
#: pg_backup_custom.c:506
msgid "BLOBs cannot be loaded without a database connection\n"
msgstr ""
#: pg_backup_custom.c:513
#, c-format
msgid "unrecognized data block type %d while restoring archive\n"
msgstr ""
#: pg_backup_custom.c:550 pg_backup_custom.c:907
#, c-format
msgid "could not initialize compression library: %s\n"
msgstr ""
#: pg_backup_custom.c:572 pg_backup_custom.c:696
#, c-format
msgid "could not read data block - expected %d, got %d\n"
msgstr ""
#: pg_backup_custom.c:590 pg_backup_custom.c:622
#, c-format
msgid "unable to uncompress data: %s\n"
msgstr ""
#: pg_backup_custom.c:724
#, c-format
msgid "could not write byte: %s\n"
msgstr ""
#: pg_backup_custom.c:767 pg_backup_files.c:418
#, c-format
msgid "write error in _WriteBuf (%d != %d)\n"
msgstr ""
#: pg_backup_custom.c:837
#, c-format
msgid "could not close archive file: %s\n"
msgstr ""
#: pg_backup_custom.c:860
msgid "WARNING: ftell mismatch with filePos - filePos used\n"
msgstr ""
#: pg_backup_custom.c:940
#, c-format
msgid "could not compress data: %s\n"
msgstr "konnte Daten nicht komprimieren: %s\n"
#: pg_backup_custom.c:962
msgid "could not write compressed chunk\n"
msgstr ""
#: pg_backup_custom.c:976
msgid "could not write uncompressed chunk\n"
msgstr ""
#: pg_backup_custom.c:1025
#, c-format
msgid "could not close compression stream: %s\n"
msgstr ""
#: pg_backup_db.c:131
#, c-format
msgid "unable to parse version string \"%s\"\n"
msgstr ""
#: pg_backup_db.c:156
#, c-format
msgid "could not get version from server: %s"
msgstr "konnte Version des Servers nicht ermitteln: %s"
#: pg_backup_db.c:168
#, c-format
msgid "server version: %s, %s version: %s\n"
msgstr ""
#: pg_backup_db.c:171
msgid "proceeding despite version mismatch\n"
msgstr ""
#: pg_backup_db.c:173
msgid ""
"aborting because of version mismatch (Use the -i option to proceed "
"anyway.)\n"
msgstr ""
#: pg_backup_db.c:194
#, c-format
msgid "null result checking superuser status of %s\n"
msgstr ""
#: pg_backup_db.c:197
#, c-format
msgid "could not check superuser status of %s: %s"
msgstr ""
#: pg_backup_db.c:282 pg_backup_db.c:315 pg_backup_db.c:374 pg_backup_db.c:403
msgid "Password: "
msgstr "Pawort: "
#: pg_backup_db.c:294
msgid "failed to reconnect to database\n"
msgstr ""
#: pg_backup_db.c:318
#, c-format
msgid "could not reconnect to database: %s"
msgstr ""
#: pg_backup_db.c:350
msgid "already connected to database\n"
msgstr ""
#: pg_backup_db.c:393
msgid "failed to connect to database\n"
msgstr ""
#: pg_backup_db.c:412
#, c-format
msgid "connection to database \"%s\" failed: %s"
msgstr ""
#: pg_backup_db.c:452
#, c-format
msgid "%s: no result from backend\n"
msgstr ""
#: pg_backup_db.c:459
msgid "COPY command executed in non-primary connection\n"
msgstr ""
#: pg_backup_db.c:464
#, c-format
msgid "%s: %s"
msgstr "%s: %s"
#: pg_backup_db.c:547
msgid "error returned by PQputline\n"
msgstr ""
#: pg_backup_db.c:559
msgid "error returned by PQendcopy\n"
msgstr ""
#: pg_backup_db.c:608
msgid "could not execute query"
msgstr "konnte Abfrage nicht ausfhren"
#: pg_backup_db.c:698
#, c-format
msgid "could not find oid columns of table \"%s\": %s"
msgstr ""
#: pg_backup_db.c:733
#, c-format
msgid "could not update column \"%s\" of table \"%s\": %s"
msgstr ""
#: pg_backup_db.c:738
#, c-format
msgid "error while updating column \"%s\" of table \"%s\": %s"
msgstr ""
#: pg_backup_db.c:764
msgid "could not create BLOB cross reference table"
msgstr ""
#: pg_backup_db.c:769
msgid "could not create index on BLOB cross reference table"
msgstr ""
#: pg_backup_db.c:779
msgid "could not create BLOB cross reference entry"
msgstr ""
#: pg_backup_db.c:789
msgid "could not start database transaction"
msgstr ""
#: pg_backup_db.c:801
msgid "could not start transaction for BLOB cross references"
msgstr ""
#: pg_backup_db.c:812
msgid "could not commit database transaction"
msgstr ""
#: pg_backup_db.c:823
msgid "could not commit transaction for BLOB cross references"
msgstr ""
#: pg_backup_files.c:122
msgid ""
"WARNING:\n"
" This format is for demonstration purposes, it is not intended for\n"
" normal use. Files will be written in the current working directory.\n"
msgstr ""
#: pg_backup_files.c:248
msgid "could not open data file for output\n"
msgstr "konnte Datendatei nicht zur Ausgabe ffnen\n"
#: pg_backup_files.c:269
msgid "could not close data file\n"
msgstr "konnte Datendatei nicht schlieen\n"
#: pg_backup_files.c:293
msgid "could not open data file for input\n"
msgstr "konnte Dateindatei nicht zur Eingabe ffnen\n"
#: pg_backup_files.c:302
msgid "could not close data file after reading\n"
msgstr "konnte Datendatei nach dem Lesen nicht schlieen\n"
#: pg_backup_files.c:366
#, c-format
msgid "could not open BLOB TOC for input: %s\n"
msgstr ""
#: pg_backup_files.c:379 pg_backup_files.c:550
#, c-format
msgid "could not close BLOB TOC file: %s\n"
msgstr ""
#: pg_backup_files.c:391
msgid "could not write byte\n"
msgstr ""
#: pg_backup_files.c:477
#, c-format
msgid "could not open BLOB TOC for output: %s\n"
msgstr ""
#: pg_backup_files.c:498 pg_backup_tar.c:914
#, c-format
msgid "invalid OID for BLOB (%u)\n"
msgstr ""
#: pg_backup_files.c:517
msgid "could not open BLOB file\n"
msgstr ""
#: pg_backup_files.c:532
msgid "could not close BLOB file\n"
msgstr ""
#: pg_backup_null.c:66
msgid "this format cannot be read\n"
msgstr "dieses Format kann nicht gelesen werden\n"
#: pg_backup_tar.c:176
#, c-format
msgid "could not open TOC file for output: %s\n"
msgstr ""
#: pg_backup_tar.c:201
msgid "compression not supported by tar output format\n"
msgstr ""
#: pg_backup_tar.c:213
#, c-format
msgid "could not open TOC file for input: %s\n"
msgstr ""
#: pg_backup_tar.c:336
#, c-format
msgid "could not find file %s in archive\n"
msgstr "konnte Datei %s nicht im Archiv finden\n"
#: pg_backup_tar.c:347
msgid "compression support is disabled in this format\n"
msgstr ""
#: pg_backup_tar.c:364
#, c-format
msgid "could not generate temporary file name: %s\n"
msgstr ""
#: pg_backup_tar.c:373
msgid "could not gzdopen temporary file\n"
msgstr ""
#: pg_backup_tar.c:405
msgid "could not close tar member\n"
msgstr ""
#: pg_backup_tar.c:506
msgid "neither th nor fh specified in tarReadRaw() (internal error)\n"
msgstr ""
#: pg_backup_tar.c:510
#, c-format
msgid "requested %d bytes, got %d from lookahead and %d from file\n"
msgstr ""
#: pg_backup_tar.c:549
#, c-format
msgid "could not write to tar member (wrote %d, attempted %d)\n"
msgstr ""
#: pg_backup_tar.c:637
#, c-format
msgid "bad COPY statement - could not find \"copy\" in string \"%s\"\n"
msgstr ""
#: pg_backup_tar.c:655
#, c-format
msgid ""
"bad COPY statement - could not find \"from stdin\" in string \"%s\" starting "
"at position %d\n"
msgstr ""
#: pg_backup_tar.c:857
msgid "could not write null block at end of tar archive\n"
msgstr ""
#: pg_backup_tar.c:1052
#, c-format
msgid "write error appending to tar archive (wrote %d, attempted %d)\n"
msgstr ""
#: pg_backup_tar.c:1057
#, c-format
msgid "could not close tar member: %s\n"
msgstr ""
#: pg_backup_tar.c:1060
#, c-format
msgid "actual file length (%d) does not match expected (%d)\n"
msgstr ""
#: pg_backup_tar.c:1067
msgid "could not output padding at end of tar member\n"
msgstr ""
#: pg_backup_tar.c:1107 pg_backup_tar.c:1134
#, c-format
msgid "could not find header for file %s in tar archive\n"
msgstr ""
#: pg_backup_tar.c:1122
#, c-format
msgid ""
"dumping data out of order is not supported in this archive format: %s is "
"required, but comes before %s in the archive file.\n"
msgstr ""
#: pg_backup_tar.c:1163
#, c-format
msgid "mismatch in actual vs. predicted file position (%d vs. %d)\n"
msgstr ""
#: pg_backup_tar.c:1176
#, c-format
msgid "incomplete tar header found (%d bytes)\n"
msgstr ""
#: pg_backup_tar.c:1209
#, c-format
msgid ""
"corrupt tar header found in %s (expected %d (%o), computed %d (%o)) file "
"position %ld (%lx)\n"
msgstr ""
#: pg_backup_tar.c:1286
msgid "unable to write tar header\n"
msgstr ""
#: pg_restore.c:349
#, c-format
msgid ""
"%s restores a PostgreSQL database from an archive created by pg_dump.\n"
"\n"
"Usage:\n"
" %s [options] [file]\n"
"\n"
"Options:\n"
msgstr ""
#: pg_restore.c:355
msgid ""
" -a, --data-only restore only the data, no schema\n"
" -c, --clean clean (drop) schema prior to create\n"
" -C, --create output commands to create the database\n"
" -d, --dbname=NAME specify database name\n"
" -f, --file=FILENAME script output file name\n"
" -F, --format {c|f} specify backup file format\n"
" -h, --host HOSTNAME server host name\n"
" -i, --index[=NAME] restore indexes or named index\n"
" -l, --list dump summarized TOC for this file\n"
" -L, --use-list=FILENAME use specified table of contents for ordering\n"
" output from this file\n"
" -N, --orig-order restore in original dump order\n"
" -o, --oid-order restore in oid order\n"
" -O, --no-owner do not reconnect to database to match\n"
" object owner\n"
" -p, --port PORT server port number\n"
" -P, --function[=NAME] restore functions or named function\n"
" -r, --rearrange rearrange output to put indexes etc. at end\n"
" -R, --no-reconnect disallow ALL reconnections to the database\n"
" -s, --schema-only restore only the schema, no data\n"
" -S, --superuser=NAME specify the superuser user name to use for\n"
" disabling triggers\n"
" -t, --table[=TABLE] restore this table only\n"
" -T, --trigger[=NAME] restore triggers or named trigger\n"
" -U, --username=NAME connect as specified database user\n"
" -v, --verbose verbose\n"
" -W, --password force password prompt (should happen "
"automatically)\n"
" -x, --no-acl skip dumping of ACLs (grant/revoke)\n"
msgstr ""
#: pg_restore.c:388
msgid ""
" -a restore only the data, no schema\n"
" -c clean (drop) schema prior to create\n"
" -C output commands to create the database\n"
" -d NAME specify database name\n"
" -f FILENAME script output file name\n"
" -F {c|f} specify backup file format\n"
" -h HOSTNAME server host name\n"
" -i NAME restore indexes or named index\n"
" -l dump summarized TOC for this file\n"
" -L FILENAME use specified table of contents for ordering\n"
" output from this file\n"
" -N restore in original dump order\n"
" -o restore in oid order\n"
" -O do not output reconnect to database to match\n"
" object owner\n"
" -p PORT server port number\n"
" -P NAME restore functions or named function\n"
" -r rearrange output to put indexes etc at end\n"
" -R disallow ALL reconnections to the database\n"
" -s restore only the schema, no data\n"
" -S NAME specify the superuser user name to use for\n"
" disabling triggers\n"
" -t NAME restore this table only\n"
" -T NAME restore triggers or named trigger\n"
" -U NAME connect as specified database user\n"
" -v verbose\n"
" -W force password prompt (should happen "
"automatically)\n"
" -x skip dumping of ACLs (grant/revoke)\n"
msgstr ""
#: pg_restore.c:418
msgid "If no input file name is supplied, then standard input is used.\n"
msgstr "Wenn keine Eingabedatei angegeben ist, wird die Standardeingabe verwendet.\n"
#: pg_restore.c:419
msgid "Report bugs to <pgsql-bugs@postgresql.org>."
msgstr "Berichten Sie Fehler an <pgsql-bugs@postgresql.org>."
# $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);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.27 2001/05/17 21:12:48 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.28 2001/06/27 21:21:37 petere Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -64,13 +64,9 @@ ...@@ -64,13 +64,9 @@
#include "pg_backup_archiver.h" #include "pg_backup_archiver.h"
#include "pg_backup_db.h" #include "pg_backup_db.h"
#include <string.h> #include <errno.h>
#include <unistd.h> /* for dup */ #include <unistd.h> /* for dup */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "pqexpbuffer.h" #include "pqexpbuffer.h"
#include "libpq/libpq-fs.h" #include "libpq/libpq-fs.h"
...@@ -94,9 +90,11 @@ static int _discoverArchiveFormat(ArchiveHandle *AH); ...@@ -94,9 +90,11 @@ static int _discoverArchiveFormat(ArchiveHandle *AH);
static void _fixupOidInfo(TocEntry *te); static void _fixupOidInfo(TocEntry *te);
static Oid _findMaxOID(const char *((*deps)[])); static Oid _findMaxOID(const char *((*deps)[]));
static char *progname = "Archiver"; const char *progname;
static char *modulename = "archiver";
static void _die_horribly(ArchiveHandle *AH, const char *fmt, va_list ap); static void _write_msg(const char *modulename, const char *fmt, va_list ap);
static void _die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, va_list ap);
static int _canRestoreBlobs(ArchiveHandle *AH); static int _canRestoreBlobs(ArchiveHandle *AH);
static int _restoringToDB(ArchiveHandle *AH); static int _restoringToDB(ArchiveHandle *AH);
...@@ -148,7 +146,7 @@ CloseArchive(Archive *AHX) ...@@ -148,7 +146,7 @@ CloseArchive(Archive *AHX)
res = fclose(AH->OF); res = fclose(AH->OF);
if (res != 0) if (res != 0)
die_horribly(AH, "%s: could not close the output file in CloseArchive\n", progname); die_horribly(AH, modulename, "could not close the output file in CloseArchive\n");
} }
/* Public */ /* Public */
...@@ -165,7 +163,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -165,7 +163,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
AH->ropt = ropt; AH->ropt = ropt;
if (ropt->create && ropt->noReconnect) if (ropt->create && ropt->noReconnect)
die_horribly(AH, "%s: --create and --no-reconnect are incompatible options\n", progname); die_horribly(AH, modulename, "-C and -R are incompatible options\n");
/* /*
* If we're using a DB connection, then connect it. * If we're using a DB connection, then connect it.
...@@ -174,7 +172,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -174,7 +172,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
{ {
ahlog(AH, 1, "Connecting to database for restore\n"); ahlog(AH, 1, "Connecting to database for restore\n");
if (AH->version < K_VERS_1_3) if (AH->version < K_VERS_1_3)
die_horribly(AH, "Direct database connections are not supported in pre-1.3 archives"); die_horribly(AH, modulename, "direct database connections are not supported in pre-1.3 archives\n");
/* XXX Should get this from the archive */ /* XXX Should get this from the archive */
AHX->minRemoteVersion = 070100; AHX->minRemoteVersion = 070100;
...@@ -226,11 +224,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -226,11 +224,10 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
} }
if (!ropt->superuser) if (!ropt->superuser)
fprintf(stderr, "\n%s: ******** WARNING ******** \n" write_msg(modulename, "WARNING:\n"
" Data restoration may fail since any defined triggers\n" " Data restoration may fail because existing triggers cannot be disabled\n"
" can not be disabled (no superuser username specified).\n" " (no superuser user name specified). This is only a problem when\n"
" This is only a problem for restoration into a database\n" " restoring into a database with already existing triggers.\n");
" with triggers already defined.\n\n", progname);
/* /*
* Setup the output file if necessary. * Setup the output file if necessary.
...@@ -275,12 +272,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -275,12 +272,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
if (!ropt->suppressDumpWarnings && strcmp(te->desc, "WARNING") == 0) if (!ropt->suppressDumpWarnings && strcmp(te->desc, "WARNING") == 0)
{ {
if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0) if (!ropt->dataOnly && te->defn != NULL && strlen(te->defn) != 0)
{ write_msg(modulename, "warning from original dump file: %s\n", te->defn);
fprintf(stderr, "%s: Warning from original dump file:\n%s\n", progname, te->defn); else if (te->copyStmt != NULL && strlen(te->copyStmt) != 0)
} else if (te->copyStmt != NULL && strlen(te->copyStmt) != 0) write_msg(modulename, "warning from original dump file: %s\n", te->copyStmt);
{
fprintf(stderr, "%s: Warning from original dump file:\n%s\n", progname, te->copyStmt);
}
} }
defnDumped = false; defnDumped = false;
...@@ -320,8 +314,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -320,8 +314,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
{ {
#ifndef HAVE_LIBZ #ifndef HAVE_LIBZ
if (AH->compression != 0) if (AH->compression != 0)
die_horribly(AH, "%s: Unable to restore data from a compressed archive\n", die_horribly(AH, modulename, "unable to restore from compressed archive (not configured for compression support)\n");
progname);
#endif #endif
_printTocEntry(AH, te, ropt, true); _printTocEntry(AH, te, ropt, true);
...@@ -339,7 +332,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt) ...@@ -339,7 +332,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
* warnings. * warnings.
*/ */
if (!AH->CustomOutPtr) if (!AH->CustomOutPtr)
fprintf(stderr, "%s: WARNING - skipping BLOB restoration\n", progname); write_msg(modulename, "WARNING: skipping BLOB restoration\n");
} }
else else
...@@ -599,8 +592,7 @@ WriteData(Archive *AHX, const void *data, int dLen) ...@@ -599,8 +592,7 @@ WriteData(Archive *AHX, const void *data, int dLen)
ArchiveHandle *AH = (ArchiveHandle *) AHX; ArchiveHandle *AH = (ArchiveHandle *) AHX;
if (!AH->currToc) if (!AH->currToc)
die_horribly(AH, "%s: WriteData can not be called outside the context of " die_horribly(AH, modulename, "WriteData cannot be called outside the context of a DataDumper routine\n");
"a DataDumper routine\n", progname);
return (*AH->WriteDataPtr) (AH, data, dLen); return (*AH->WriteDataPtr) (AH, data, dLen);
} }
...@@ -625,7 +617,7 @@ ArchiveEntry(Archive *AHX, const char *oid, const char *name, ...@@ -625,7 +617,7 @@ ArchiveEntry(Archive *AHX, const char *oid, const char *name,
newToc = (TocEntry *) calloc(1, sizeof(TocEntry)); newToc = (TocEntry *) calloc(1, sizeof(TocEntry));
if (!newToc) if (!newToc)
die_horribly(AH, "Archiver: unable to allocate memory for TOC entry\n"); die_horribly(AH, modulename, "out of memory\n");
newToc->prev = AH->toc->prev; newToc->prev = AH->toc->prev;
newToc->next = AH->toc; newToc->next = AH->toc;
...@@ -720,7 +712,7 @@ StartBlob(Archive *AHX, Oid oid) ...@@ -720,7 +712,7 @@ StartBlob(Archive *AHX, Oid oid)
ArchiveHandle *AH = (ArchiveHandle *) AHX; ArchiveHandle *AH = (ArchiveHandle *) AHX;
if (!AH->StartBlobPtr) if (!AH->StartBlobPtr)
die_horribly(AH, "%s: BLOB output not supported in chosen format\n", progname); die_horribly(AH, modulename, "BLOB output not supported in chosen format\n");
(*AH->StartBlobPtr) (AH, AH->currToc, oid); (*AH->StartBlobPtr) (AH, AH->currToc, oid);
...@@ -784,7 +776,7 @@ StartRestoreBlob(ArchiveHandle *AH, Oid oid) ...@@ -784,7 +776,7 @@ StartRestoreBlob(ArchiveHandle *AH, Oid oid)
if (!AH->createdBlobXref) if (!AH->createdBlobXref)
{ {
if (!AH->connection) if (!AH->connection)
die_horribly(AH, "%s: can not restore BLOBs without a database connection", progname); die_horribly(AH, modulename, "cannot restore BLOBs without a database connection");
CreateBlobXrefTable(AH); CreateBlobXrefTable(AH);
AH->createdBlobXref = 1; AH->createdBlobXref = 1;
...@@ -803,7 +795,7 @@ StartRestoreBlob(ArchiveHandle *AH, Oid oid) ...@@ -803,7 +795,7 @@ StartRestoreBlob(ArchiveHandle *AH, Oid oid)
loOid = lo_creat(AH->connection, INV_READ | INV_WRITE); loOid = lo_creat(AH->connection, INV_READ | INV_WRITE);
if (loOid == 0) if (loOid == 0)
die_horribly(AH, "%s: unable to create BLOB\n", progname); die_horribly(AH, modulename, "could not create BLOB\n");
ahlog(AH, 2, "Restoring BLOB oid %d as %d\n", oid, loOid); ahlog(AH, 2, "Restoring BLOB oid %d as %d\n", oid, loOid);
...@@ -811,7 +803,7 @@ StartRestoreBlob(ArchiveHandle *AH, Oid oid) ...@@ -811,7 +803,7 @@ StartRestoreBlob(ArchiveHandle *AH, Oid oid)
AH->loFd = lo_open(AH->connection, loOid, INV_WRITE); AH->loFd = lo_open(AH->connection, loOid, INV_WRITE);
if (AH->loFd == -1) if (AH->loFd == -1)
die_horribly(AH, "%s: unable to open BLOB\n", progname); die_horribly(AH, modulename, "could not open BLOB\n");
AH->writingBlob = 1; AH->writingBlob = 1;
} }
...@@ -951,7 +943,7 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt) ...@@ -951,7 +943,7 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt)
/* Setup the file */ /* Setup the file */
fh = fopen(ropt->tocFile, PG_BINARY_R); fh = fopen(ropt->tocFile, PG_BINARY_R);
if (!fh) if (!fh)
die_horribly(AH, "%s: could not open TOC file\n", progname); die_horribly(AH, modulename, "could not open TOC file\n");
while (fgets(buf, 1024, fh) != NULL) while (fgets(buf, 1024, fh) != NULL)
{ {
...@@ -972,14 +964,14 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt) ...@@ -972,14 +964,14 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt)
id = strtol(buf, &endptr, 10); id = strtol(buf, &endptr, 10);
if (endptr == buf) if (endptr == buf)
{ {
fprintf(stderr, "%s: WARNING - line ignored: %s\n", progname, buf); write_msg(modulename, "WARNING: line ignored: %s\n", buf);
continue; continue;
} }
/* Find TOC entry */ /* Find TOC entry */
te = _getTocEntry(AH, id); te = _getTocEntry(AH, id);
if (!te) if (!te)
die_horribly(AH, "%s: could not find entry for id %d\n", progname, id); die_horribly(AH, modulename, "could not find entry for id %d\n", id);
ropt->idWanted[id - 1] = 1; ropt->idWanted[id - 1] = 1;
...@@ -988,7 +980,7 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt) ...@@ -988,7 +980,7 @@ SortTocFromFile(Archive *AHX, RestoreOptions *ropt)
} }
if (fclose(fh) != 0) if (fclose(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));
} }
/********************** /**********************
...@@ -1035,7 +1027,7 @@ archprintf(Archive *AH, const char *fmt,...) ...@@ -1035,7 +1027,7 @@ archprintf(Archive *AH, const char *fmt,...)
bSize *= 2; bSize *= 2;
p = (char *) malloc(bSize); p = (char *) malloc(bSize);
if (p == NULL) if (p == NULL)
exit_horribly(AH, "%s: could not allocate buffer for archprintf\n", progname); exit_horribly(AH, modulename, "out of memory\n");
va_start(ap, fmt); va_start(ap, fmt);
cnt = vsnprintf(p, bSize, fmt, ap); cnt = vsnprintf(p, bSize, fmt, ap);
va_end(ap); va_end(ap);
...@@ -1104,7 +1096,7 @@ SetOutput(ArchiveHandle *AH, char *filename, int compression) ...@@ -1104,7 +1096,7 @@ SetOutput(ArchiveHandle *AH, char *filename, int compression)
#endif #endif
if (!AH->OF) if (!AH->OF)
die_horribly(AH, "%s: could not set output\n", progname); die_horribly(AH, modulename, "could not open output file: %s\n", strerror(errno));
return sav; return sav;
} }
...@@ -1120,7 +1112,7 @@ ResetOutput(ArchiveHandle *AH, OutputContext sav) ...@@ -1120,7 +1112,7 @@ ResetOutput(ArchiveHandle *AH, OutputContext sav)
res = fclose(AH->OF); res = fclose(AH->OF);
if (res != 0) if (res != 0)
die_horribly(AH, "%s: could not reset the output file\n", progname); die_horribly(AH, modulename, "could not close output file: %s\n", strerror(errno));
AH->gzOut = sav.gzOut; AH->gzOut = sav.gzOut;
AH->OF = sav.OF; AH->OF = sav.OF;
...@@ -1155,7 +1147,7 @@ ahprintf(ArchiveHandle *AH, const char *fmt,...) ...@@ -1155,7 +1147,7 @@ ahprintf(ArchiveHandle *AH, const char *fmt,...)
bSize *= 2; bSize *= 2;
p = (char *) malloc(bSize); p = (char *) malloc(bSize);
if (p == NULL) if (p == NULL)
die_horribly(AH, "%s: could not allocate buffer for ahprintf\n", progname); die_horribly(AH, modulename, "out of memory\n");
va_start(ap, fmt); va_start(ap, fmt);
cnt = vsnprintf(p, bSize, fmt, ap); cnt = vsnprintf(p, bSize, fmt, ap);
va_end(ap); va_end(ap);
...@@ -1203,8 +1195,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) ...@@ -1203,8 +1195,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
res = lo_write(AH->connection, AH->loFd, (void *) ptr, size * nmemb); res = lo_write(AH->connection, AH->loFd, (void *) ptr, size * nmemb);
ahlog(AH, 5, "Wrote %d bytes of BLOB data (result = %d)\n", size * nmemb, res); ahlog(AH, 5, "Wrote %d bytes of BLOB data (result = %d)\n", size * nmemb, res);
if (res < size * nmemb) if (res < size * nmemb)
die_horribly(AH, "%s: could not write to large object (result = %d, expected %d)\n", die_horribly(AH, modulename, "could not write to large object (result: %d, expected: %d)\n",
progname, res, size * nmemb); res, size * nmemb);
return res; return res;
} }
...@@ -1212,7 +1204,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) ...@@ -1212,7 +1204,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
{ {
res = GZWRITE((void *) ptr, size, nmemb, AH->OF); res = GZWRITE((void *) ptr, size, nmemb, AH->OF);
if (res != (nmemb * size)) if (res != (nmemb * size))
die_horribly(AH, "%s: could not write to archive\n", progname); die_horribly(AH, modulename, "could not write to compressed archive\n");
return res; return res;
} }
else if (AH->CustomOutPtr) else if (AH->CustomOutPtr)
...@@ -1220,7 +1212,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) ...@@ -1220,7 +1212,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
res = AH->CustomOutPtr (AH, ptr, size * nmemb); res = AH->CustomOutPtr (AH, ptr, size * nmemb);
if (res != (nmemb * size)) if (res != (nmemb * size))
die_horribly(AH, "%s: could not write to custom output routine\n", progname); die_horribly(AH, modulename, "could not write to custom output routine\n");
return res; return res;
} }
else else
...@@ -1236,7 +1228,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) ...@@ -1236,7 +1228,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
{ {
res = fwrite((void *) ptr, size, nmemb, AH->OF); res = fwrite((void *) ptr, size, nmemb, AH->OF);
if (res != nmemb) if (res != nmemb)
die_horribly(AH, "%s: could not write to output file (%d != %d)\n", progname, res, nmemb); die_horribly(AH, modulename, "could not write to output file (%d != %d)\n", res, nmemb);
return res; return res;
} }
} }
...@@ -1244,9 +1236,30 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) ...@@ -1244,9 +1236,30 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
/* Common exit code */ /* Common exit code */
static void static void
_die_horribly(ArchiveHandle *AH, const char *fmt, va_list ap) _write_msg(const char *modulename, const char *fmt, va_list ap)
{ {
vfprintf(stderr, fmt, ap); if (modulename)
fprintf(stderr, "%s[%s]: ", progname, gettext(modulename));
else
fprintf(stderr, "%s: ", progname);
vfprintf(stderr, gettext(fmt), ap);
}
void
write_msg(const char *modulename, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
_write_msg(modulename, fmt, ap);
va_end(ap);
}
static void
_die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, va_list ap)
{
_write_msg(modulename, fmt, ap);
if (AH) if (AH)
if (AH->connection) if (AH->connection)
...@@ -1259,22 +1272,22 @@ _die_horribly(ArchiveHandle *AH, const char *fmt, va_list ap) ...@@ -1259,22 +1272,22 @@ _die_horribly(ArchiveHandle *AH, const char *fmt, va_list ap)
/* External use */ /* External use */
void void
exit_horribly(Archive *AH, const char *fmt,...) exit_horribly(Archive *AH, const char *modulename, const char *fmt,...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
_die_horribly((ArchiveHandle *) AH, fmt, ap); _die_horribly((ArchiveHandle *) AH, modulename, fmt, ap);
} }
/* Archiver use (just different arg declaration) */ /* Archiver use (just different arg declaration) */
void void
die_horribly(ArchiveHandle *AH, const char *fmt,...) die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
_die_horribly(AH, fmt, ap); _die_horribly(AH, modulename, fmt, ap);
} }
...@@ -1420,7 +1433,7 @@ ReadStr(ArchiveHandle *AH) ...@@ -1420,7 +1433,7 @@ ReadStr(ArchiveHandle *AH)
{ {
buf = (char *) malloc(l + 1); buf = (char *) malloc(l + 1);
if (!buf) if (!buf)
die_horribly(AH, "%s: Unable to allocate sufficient memory in ReadStr - " "requested %d (0x%x) bytes\n", progname, l, l); die_horribly(AH, modulename, "out of memory\n");
(*AH->ReadBufPtr) (AH, (void *) buf, l); (*AH->ReadBufPtr) (AH, (void *) buf, l);
buf[l] = '\0'; buf[l] = '\0';
...@@ -1437,10 +1450,9 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1437,10 +1450,9 @@ _discoverArchiveFormat(ArchiveHandle *AH)
int cnt; int cnt;
int wantClose = 0; int wantClose = 0;
/* #if 0
* fprintf(stderr, "%s: Attempting to ascertain archive format\n", write_msg(modulename, "attempting to ascertain archive format\n");
* progname); #endif
*/
if (AH->lookahead) if (AH->lookahead)
free(AH->lookahead); free(AH->lookahead);
...@@ -1459,13 +1471,17 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1459,13 +1471,17 @@ _discoverArchiveFormat(ArchiveHandle *AH)
fh = stdin; fh = stdin;
if (!fh) if (!fh)
die_horribly(AH, "Archiver: could not open input file\n"); die_horribly(AH, modulename, "could not open input file: %s\n", strerror(errno));
cnt = fread(sig, 1, 5, fh); cnt = fread(sig, 1, 5, fh);
if (cnt != 5) if (cnt != 5)
die_horribly(AH, "%s: input file is too short, or is unreadable (read %d, expected 5)\n", {
progname, cnt); if (ferror(fh))
die_horribly(AH, modulename, "could not read input file: %s\n", strerror(errno));
else
die_horribly(AH, modulename, "input file is too short (read %d, expected 5)\n", cnt);
}
/* Save it, just in case we need it later */ /* Save it, just in case we need it later */
strncpy(&AH->lookahead[0], sig, 5); strncpy(&AH->lookahead[0], sig, 5);
...@@ -1509,11 +1525,10 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1509,11 +1525,10 @@ _discoverArchiveFormat(ArchiveHandle *AH)
AH->lookaheadLen += cnt; AH->lookaheadLen += cnt;
if (AH->lookaheadLen != 512) if (AH->lookaheadLen != 512)
die_horribly(AH, "%s: input file does not appear to be a valid archive (too short?)\n", die_horribly(AH, modulename, "input file does not appear to be a valid archive (too short?)\n");
progname);
if (!isValidTarHeader(AH->lookahead)) if (!isValidTarHeader(AH->lookahead))
die_horribly(AH, "%s: input file does not appear to be a valid archive\n", progname); die_horribly(AH, modulename, "input file does not appear to be a valid archive\n");
AH->format = archTar; AH->format = archTar;
} }
...@@ -1531,15 +1546,15 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1531,15 +1546,15 @@ _discoverArchiveFormat(ArchiveHandle *AH)
else else
AH->lookaheadLen = 0; /* Don't bother since we've reset the file */ AH->lookaheadLen = 0; /* Don't bother since we've reset the file */
/* #if 0
* fprintf(stderr, "%s: read %d bytes into lookahead buffer\n", write_msg(modulename, "read %d bytes into lookahead buffer\n", AH->lookaheadLen);
* progname, AH->lookaheadLen); #endif
*/
/* Close the file */ /* Close the file */
if (wantClose) if (wantClose)
if (fclose(fh) != 0) if (fclose(fh) != 0)
die_horribly(AH, "%s: could not close the input file after reading header\n", progname); die_horribly(AH, modulename, "could not close the input file after reading header: %s\n",
strerror(errno));
return AH->format; return AH->format;
} }
...@@ -1554,14 +1569,13 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt, ...@@ -1554,14 +1569,13 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
{ {
ArchiveHandle *AH; ArchiveHandle *AH;
/* #if 0
* fprintf(stderr, "%s: allocating AH for %s, format %d\n", progname, write_msg(modulename, "allocating AH for %s, format %d\n", FileSpec, fmt);
* FileSpec, fmt); #endif
*/
AH = (ArchiveHandle *) calloc(1, sizeof(ArchiveHandle)); AH = (ArchiveHandle *) calloc(1, sizeof(ArchiveHandle));
if (!AH) if (!AH)
die_horribly(AH, "Archiver: Could not allocate archive handle\n"); die_horribly(AH, modulename, "out of memory\n");
AH->vmaj = K_VERS_MAJOR; AH->vmaj = K_VERS_MAJOR;
AH->vmin = K_VERS_MINOR; AH->vmin = K_VERS_MINOR;
...@@ -1590,7 +1604,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt, ...@@ -1590,7 +1604,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
AH->toc = (TocEntry *) calloc(1, sizeof(TocEntry)); AH->toc = (TocEntry *) calloc(1, sizeof(TocEntry));
if (!AH->toc) if (!AH->toc)
die_horribly(AH, "Archiver: Could not allocate TOC header\n"); die_horribly(AH, modulename, "out of memory\n");
AH->toc->next = AH->toc; AH->toc->next = AH->toc;
AH->toc->prev = AH->toc; AH->toc->prev = AH->toc;
...@@ -1605,9 +1619,9 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt, ...@@ -1605,9 +1619,9 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
AH->gzOut = 0; AH->gzOut = 0;
AH->OF = stdout; AH->OF = stdout;
/* #if 0
* fprintf(stderr, "%s: archive format is %d\n", progname, fmt); write_msg(modulename, "archive format is %d\n", fmt);
*/ #endif
if (fmt == archUnknown) if (fmt == archUnknown)
AH->format = _discoverArchiveFormat(AH); AH->format = _discoverArchiveFormat(AH);
...@@ -1634,7 +1648,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt, ...@@ -1634,7 +1648,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
break; break;
default: default:
die_horribly(AH, "Archiver: Unrecognized file format '%d'\n", fmt); die_horribly(AH, modulename, "unrecognized file format '%d'\n", fmt);
} }
return AH; return AH;
...@@ -1748,7 +1762,7 @@ ReadToc(ArchiveHandle *AH) ...@@ -1748,7 +1762,7 @@ ReadToc(ArchiveHandle *AH)
/* Sanity check */ /* Sanity check */
if (te->id <= 0 || te->id > AH->tocCount) if (te->id <= 0 || te->id > AH->tocCount)
die_horribly(AH, "Archiver: failed sanity check (bad entry id) - perhaps a corrupt TOC\n"); die_horribly(AH, modulename, "failed sanity check (bad entry id) - perhaps a corrupt TOC\n");
te->hadDumper = ReadInt(AH); te->hadDumper = ReadInt(AH);
te->oid = ReadStr(AH); te->oid = ReadStr(AH);
...@@ -1778,22 +1792,20 @@ ReadToc(ArchiveHandle *AH) ...@@ -1778,22 +1792,20 @@ ReadToc(ArchiveHandle *AH)
deps = realloc(deps, sizeof(char*) * depSize); deps = realloc(deps, sizeof(char*) * depSize);
} }
(*deps)[depIdx] = ReadStr(AH); (*deps)[depIdx] = ReadStr(AH);
/* #if 0
* if ((*deps)[depIdx]) if ((*deps)[depIdx])
* fprintf(stderr, "Read Dependency for %s -> %s\n", te->name, (*deps)[depIdx]); write_msg(modulename, "read dependency for %s -> %s\n",
*/ te->name, (*deps)[depIdx]);
#endif
} while ( (*deps)[depIdx++] != NULL); } while ( (*deps)[depIdx++] != NULL);
if (depIdx > 1) /* We have a non-null entry */ if (depIdx > 1) /* We have a non-null entry */
{ te->depOid = realloc(deps, sizeof(char*) * depIdx); /* trim it */
/* Trim it */ else
te->depOid = realloc(deps, sizeof(char*) * depIdx); te->depOid = NULL; /* no deps */
} else { /* No deps */
te->depOid = NULL;
}
} else {
te->depOid = NULL;
} }
else
te->depOid = NULL;
/* Set maxOidVal etc for use in sorting */ /* Set maxOidVal etc for use in sorting */
_fixupOidInfo(te); _fixupOidInfo(te);
...@@ -1946,11 +1958,10 @@ WriteHead(ArchiveHandle *AH) ...@@ -1946,11 +1958,10 @@ WriteHead(ArchiveHandle *AH)
#ifndef HAVE_LIBZ #ifndef HAVE_LIBZ
if (AH->compression != 0) if (AH->compression != 0)
fprintf(stderr, "%s: WARNING - requested compression not available in this installation - " write_msg(modulename, "WARNING: requested compression not available in this "
"archive will be uncompressed \n", progname); "installation - archive will be uncompressed\n");
AH->compression = 0; AH->compression = 0;
#endif #endif
WriteInt(AH, AH->compression); WriteInt(AH, AH->compression);
...@@ -1980,7 +1991,7 @@ ReadHead(ArchiveHandle *AH) ...@@ -1980,7 +1991,7 @@ ReadHead(ArchiveHandle *AH)
(*AH->ReadBufPtr) (AH, tmpMag, 5); (*AH->ReadBufPtr) (AH, tmpMag, 5);
if (strncmp(tmpMag, "PGDMP", 5) != 0) if (strncmp(tmpMag, "PGDMP", 5) != 0)
die_horribly(AH, "Archiver: Did not fing magic PGDMP in file header\n"); die_horribly(AH, modulename, "did not find magic string in file header\n");
AH->vmaj = (*AH->ReadBytePtr) (AH); AH->vmaj = (*AH->ReadBytePtr) (AH);
AH->vmin = (*AH->ReadBytePtr) (AH); AH->vmin = (*AH->ReadBytePtr) (AH);
...@@ -1994,22 +2005,21 @@ ReadHead(ArchiveHandle *AH) ...@@ -1994,22 +2005,21 @@ ReadHead(ArchiveHandle *AH)
if (AH->version < K_VERS_1_0 || AH->version > K_VERS_MAX) if (AH->version < K_VERS_1_0 || AH->version > K_VERS_MAX)
die_horribly(AH, "%s: unsupported version (%d.%d) in file header\n", die_horribly(AH, modulename, "unsupported version (%d.%d) in file header\n",
progname, AH->vmaj, AH->vmin); AH->vmaj, AH->vmin);
AH->intSize = (*AH->ReadBytePtr) (AH); AH->intSize = (*AH->ReadBytePtr) (AH);
if (AH->intSize > 32) if (AH->intSize > 32)
die_horribly(AH, "Archiver: sanity check on integer size (%d) failes\n", AH->intSize); die_horribly(AH, modulename, "sanity check on integer size (%d) failed\n", AH->intSize);
if (AH->intSize > sizeof(int)) if (AH->intSize > sizeof(int))
fprintf(stderr, "\n%s: WARNING - archive was made on a machine with larger integers, " write_msg(modulename, "WARNING: archive was made on a machine with larger integers, some operations may fail\n");
"some operations may fail\n", progname);
fmt = (*AH->ReadBytePtr) (AH); fmt = (*AH->ReadBytePtr) (AH);
if (AH->format != fmt) if (AH->format != fmt)
die_horribly(AH, "%s: expected format (%d) differs from format found in file (%d)\n", die_horribly(AH, modulename, "expected format (%d) differs from format found in file (%d)\n",
progname, AH->format, fmt); AH->format, fmt);
} }
if (AH->version >= K_VERS_1_2) if (AH->version >= K_VERS_1_2)
...@@ -2024,8 +2034,7 @@ ReadHead(ArchiveHandle *AH) ...@@ -2024,8 +2034,7 @@ ReadHead(ArchiveHandle *AH)
#ifndef HAVE_LIBZ #ifndef HAVE_LIBZ
if (AH->compression != 0) if (AH->compression != 0)
fprintf(stderr, "%s: WARNING - archive is compressed - any data will not be available\n", write_msg(modulename, "WARNING: archive is compressed, but this installation does not support compression - no data will be available\n");
progname);
#endif #endif
if (AH->version >= K_VERS_1_4) if (AH->version >= K_VERS_1_4)
...@@ -2043,7 +2052,7 @@ ReadHead(ArchiveHandle *AH) ...@@ -2043,7 +2052,7 @@ ReadHead(ArchiveHandle *AH)
AH->createDate = mktime(&crtm); AH->createDate = mktime(&crtm);
if (AH->createDate == (time_t) -1) if (AH->createDate == (time_t) -1)
fprintf(stderr, "%s: WARNING - bad creation date in header\n", progname); write_msg(modulename, "WARNING: bad creation date in header\n");
} }
} }
......
...@@ -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
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver. * Implements the basic DB functions used by the archiver.
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.19 2001/05/17 21:12:48 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.20 2001/06/27 21:21:37 petere Exp $
* *
* NOTES * NOTES
* *
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include "strdup.h" #include "strdup.h"
#endif #endif
static const char *progname = "Archiver(db)"; static const char *modulename = "archiver (db)";
static void _check_database_version(ArchiveHandle *AH, bool ignoreVersion); static void _check_database_version(ArchiveHandle *AH, bool ignoreVersion);
static PGconn *_connectDB(ArchiveHandle *AH, const char *newdbname, char *newUser); static PGconn *_connectDB(ArchiveHandle *AH, const char *newdbname, char *newUser);
...@@ -73,7 +73,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo) ...@@ -73,7 +73,7 @@ simple_prompt(const char *prompt, int maxlen, bool echo)
if (!destination) if (!destination)
return NULL; return NULL;
if (prompt) if (prompt)
fputs(prompt, stderr); fputs(gettext(prompt), stderr);
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
if (!echo) if (!echo)
...@@ -128,7 +128,7 @@ _parse_version(ArchiveHandle *AH, const char* versionString) ...@@ -128,7 +128,7 @@ _parse_version(ArchiveHandle *AH, const char* versionString)
if (cnt < 2) if (cnt < 2)
{ {
die_horribly(AH, "Unable to parse version string: %s\n", versionString); die_horribly(AH, modulename, "unable to parse version string \"%s\"\n", versionString);
} }
if (cnt == 2) if (cnt == 2)
...@@ -148,13 +148,12 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion) ...@@ -148,13 +148,12 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
myversion = _parse_version(AH, PG_VERSION); myversion = _parse_version(AH, PG_VERSION);
res = PQexec(conn, "SELECT version()"); res = PQexec(conn, "SELECT version();");
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK || PQresultStatus(res) != PGRES_TUPLES_OK ||
PQntuples(res) != 1) PQntuples(res) != 1)
die_horribly(AH, "check_database_version(): command failed. " die_horribly(AH, modulename, "could not get version from server: %s", PQerrorMessage(conn));
"Explanation from backend: '%s'.\n", PQerrorMessage(conn));
remoteversion_str = PQgetvalue(res, 0, 0); remoteversion_str = PQgetvalue(res, 0, 0);
remoteversion = _parse_version(AH, remoteversion_str + 11); remoteversion = _parse_version(AH, remoteversion_str + 11);
...@@ -166,13 +165,12 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion) ...@@ -166,13 +165,12 @@ _check_database_version(ArchiveHandle *AH, bool ignoreVersion)
if (myversion != remoteversion if (myversion != remoteversion
&& (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion) ) && (remoteversion < AH->public.minRemoteVersion || remoteversion > AH->public.maxRemoteVersion) )
{ {
fprintf(stderr, "Database version: %s\n%s version: %s\n", write_msg(NULL, "server version: %s, %s version: %s\n",
remoteversion_str, progname, PG_VERSION); remoteversion_str, progname, PG_VERSION);
if (ignoreVersion) if (ignoreVersion)
fprintf(stderr, "Proceeding despite version mismatch.\n"); write_msg(NULL, "proceeding despite version mismatch\n");
else else
die_horribly(AH, "Aborting because of version mismatch.\n" die_horribly(AH, NULL, "aborting because of version mismatch (Use the -i option to proceed anyway.)\n");
"Use --ignore-version if you think it's safe to proceed anyway.\n");
} }
} }
...@@ -193,12 +191,11 @@ UserIsSuperuser(ArchiveHandle *AH, char *user) ...@@ -193,12 +191,11 @@ UserIsSuperuser(ArchiveHandle *AH, char *user)
res = PQexec(AH->connection, qry->data); res = PQexec(AH->connection, qry->data);
if (!res) if (!res)
die_horribly(AH, "%s: null result checking superuser status of %s.\n", die_horribly(AH, modulename, "null result checking superuser status of %s\n", user);
progname, user);
if (PQresultStatus(res) != PGRES_TUPLES_OK) if (PQresultStatus(res) != PGRES_TUPLES_OK)
die_horribly(AH, "%s: Could not check superuser status of %s. Explanation from backend: %s\n", die_horribly(AH, modulename, "could not check superuser status of %s: %s",
progname, user, PQerrorMessage(AH->connection)); user, PQerrorMessage(AH->connection));
ntups = PQntuples(res); ntups = PQntuples(res);
...@@ -284,7 +281,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, char *requser) ...@@ -284,7 +281,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, char *requser)
{ {
password = simple_prompt("Password: ", 100, false); password = simple_prompt("Password: ", 100, false);
if (password == NULL) if (password == NULL)
die_horribly(AH, "out of memory"); die_horribly(AH, modulename, "out of memory\n");
} }
do do
...@@ -294,7 +291,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, char *requser) ...@@ -294,7 +291,7 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, char *requser)
NULL, NULL, newdb, NULL, NULL, newdb,
newuser, password); newuser, password);
if (!newConn) if (!newConn)
die_horribly(AH, "%s: Failed to reconnect (PQsetdbLogin failed).\n", progname); die_horribly(AH, modulename, "failed to reconnect to database\n");
if (PQstatus(newConn) == CONNECTION_BAD) if (PQstatus(newConn) == CONNECTION_BAD)
{ {
...@@ -318,8 +315,8 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, char *requser) ...@@ -318,8 +315,8 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, char *requser)
password = simple_prompt("Password: ", 100, false); password = simple_prompt("Password: ", 100, false);
} }
else else
die_horribly(AH, "%s: Could not reconnect. %s\n", die_horribly(AH, modulename, "could not reconnect to database: %s",
progname, PQerrorMessage(newConn)); PQerrorMessage(newConn));
} }
} while (need_pass); } while (need_pass);
...@@ -350,10 +347,10 @@ ConnectDatabase(Archive *AHX, ...@@ -350,10 +347,10 @@ ConnectDatabase(Archive *AHX,
bool need_pass = false; bool need_pass = false;
if (AH->connection) if (AH->connection)
die_horribly(AH, "%s: already connected to database\n", progname); die_horribly(AH, modulename, "already connected to database\n");
if (!dbname && !(dbname = getenv("PGDATABASE"))) if (!dbname && !(dbname = getenv("PGDATABASE")))
die_horribly(AH, "%s: no database name specified\n", progname); die_horribly(AH, modulename, "no database name specified\n");
AH->dbname = strdup(dbname); AH->dbname = strdup(dbname);
...@@ -376,7 +373,7 @@ ConnectDatabase(Archive *AHX, ...@@ -376,7 +373,7 @@ ConnectDatabase(Archive *AHX,
{ {
password = simple_prompt("Password: ", 100, false); password = simple_prompt("Password: ", 100, false);
if (password == NULL) if (password == NULL)
die_horribly(AH, "out of memory"); die_horribly(AH, modulename, "out of memory\n");
AH->requirePassword = true; AH->requirePassword = true;
} }
else else
...@@ -393,8 +390,7 @@ ConnectDatabase(Archive *AHX, ...@@ -393,8 +390,7 @@ ConnectDatabase(Archive *AHX,
AH->dbname, AH->username, password); AH->dbname, AH->username, password);
if (!AH->connection) if (!AH->connection)
die_horribly(AH, "%s: Failed to connect (PQsetdbLogin failed).\n", die_horribly(AH, modulename, "failed to connect to database\n");
progname);
if (PQstatus(AH->connection) == CONNECTION_BAD && if (PQstatus(AH->connection) == CONNECTION_BAD &&
strcmp(PQerrorMessage(AH->connection), "fe_sendauth: no password supplied\n") == 0 && strcmp(PQerrorMessage(AH->connection), "fe_sendauth: no password supplied\n") == 0 &&
...@@ -413,7 +409,7 @@ ConnectDatabase(Archive *AHX, ...@@ -413,7 +409,7 @@ ConnectDatabase(Archive *AHX,
/* check to see that the backend connection was successfully made */ /* check to see that the backend connection was successfully made */
if (PQstatus(AH->connection) == CONNECTION_BAD) if (PQstatus(AH->connection) == CONNECTION_BAD)
die_horribly(AH, "Connection to database '%s' failed.\n%s\n", die_horribly(AH, modulename, "connection to database \"%s\" failed: %s",
AH->dbname, PQerrorMessage(AH->connection)); AH->dbname, PQerrorMessage(AH->connection));
/* check for version mismatch */ /* check for version mismatch */
...@@ -432,9 +428,12 @@ ConnectDatabase(Archive *AHX, ...@@ -432,9 +428,12 @@ ConnectDatabase(Archive *AHX,
/* Public interface */ /* Public interface */
/* Convenience function to send a query. Monitors result to handle COPY statements */ /* Convenience function to send a query. Monitors result to handle COPY statements */
int int
ExecuteSqlCommand(ArchiveHandle *AH, PQExpBuffer qry, char *desc) ExecuteSqlCommand(ArchiveHandle *AH, PQExpBuffer qry, char *desc, bool use_blob)
{ {
return _executeSqlCommand(AH, AH->connection, qry, desc); if (use_blob)
return _executeSqlCommand(AH, AH->blobConnection, qry, desc);
else
return _executeSqlCommand(AH, AH->connection, qry, desc);
} }
/* /*
...@@ -450,20 +449,20 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc) ...@@ -450,20 +449,20 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
/* fprintf(stderr, "Executing: '%s'\n\n", qry->data); */ /* fprintf(stderr, "Executing: '%s'\n\n", qry->data); */
res = PQexec(conn, qry->data); res = PQexec(conn, qry->data);
if (!res) if (!res)
die_horribly(AH, "%s: %s. No result from backend.\n", progname, desc); die_horribly(AH, modulename, "%s: no result from backend\n", desc);
if (PQresultStatus(res) != PGRES_COMMAND_OK && PQresultStatus(res) != PGRES_TUPLES_OK) if (PQresultStatus(res) != PGRES_COMMAND_OK && PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
if (PQresultStatus(res) == PGRES_COPY_IN) if (PQresultStatus(res) == PGRES_COPY_IN)
{ {
if (conn != AH->connection) if (conn != AH->connection)
die_horribly(AH, "%s: COPY command execute in non-primary connection.\n", progname); die_horribly(AH, modulename, "COPY command executed in non-primary connection\n");
AH->pgCopyIn = 1; AH->pgCopyIn = 1;
} }
else else
die_horribly(AH, "%s: %s. Code = %d. Explanation from backend: '%s'.\n", die_horribly(AH, modulename, "%s: %s",
progname, desc, PQresultStatus(res), PQerrorMessage(AH->connection)); desc, PQerrorMessage(AH->connection));
} }
PQclear(res); PQclear(res);
...@@ -545,7 +544,7 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen) ...@@ -545,7 +544,7 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
*/ */
if (PQputline(AH->connection, AH->pgCopyBuf->data) != 0) if (PQputline(AH->connection, AH->pgCopyBuf->data) != 0)
die_horribly(AH, "%s: error returned by PQputline\n", progname); die_horribly(AH, modulename, "error returned by PQputline\n");
resetPQExpBuffer(AH->pgCopyBuf); resetPQExpBuffer(AH->pgCopyBuf);
...@@ -557,7 +556,7 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen) ...@@ -557,7 +556,7 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
if (isEnd) if (isEnd)
{ {
if (PQendcopy(AH->connection) != 0) if (PQendcopy(AH->connection) != 0)
die_horribly(AH, "%s: error returned by PQendcopy\n", progname); die_horribly(AH, modulename, "error returned by PQendcopy\n");
AH->pgCopyIn = 0; AH->pgCopyIn = 0;
break; break;
...@@ -606,7 +605,7 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen) ...@@ -606,7 +605,7 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
* fprintf(stderr, " sending: '%s'\n\n", * fprintf(stderr, " sending: '%s'\n\n",
* AH->sqlBuf->data); * AH->sqlBuf->data);
*/ */
ExecuteSqlCommand(AH, AH->sqlBuf, "Could not execute query"); ExecuteSqlCommand(AH, AH->sqlBuf, "could not execute query", false);
resetPQExpBuffer(AH->sqlBuf); resetPQExpBuffer(AH->sqlBuf);
AH->sqlparse.lastChar = '\0'; AH->sqlparse.lastChar = '\0';
} }
...@@ -696,8 +695,8 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename) ...@@ -696,8 +695,8 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
res = PQexec(AH->blobConnection, tblQry->data); res = PQexec(AH->blobConnection, tblQry->data);
if (!res) if (!res)
die_horribly(AH, "%s: could not find OID attrs of %s. Explanation from backend '%s'\n", die_horribly(AH, modulename, "could not find oid columns of table \"%s\": %s",
progname, tablename, PQerrorMessage(AH->connection)); tablename, PQerrorMessage(AH->connection));
if ((n = PQntuples(res)) == 0) if ((n = PQntuples(res)) == 0)
{ {
...@@ -730,14 +729,14 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename) ...@@ -730,14 +729,14 @@ FixupBlobRefs(ArchiveHandle *AH, char *tablename)
uRes = PQexec(AH->blobConnection, tblQry->data); uRes = PQexec(AH->blobConnection, tblQry->data);
if (!uRes) if (!uRes)
die_horribly(AH, "%s: could not update attr %s of table %s. Explanation from backend '%s'\n", die_horribly(AH, modulename,
progname, attr, tablename, PQerrorMessage(AH->blobConnection)); "could not update column \"%s\" of table \"%s\": %s",
attr, tablename, PQerrorMessage(AH->blobConnection));
if (PQresultStatus(uRes) != PGRES_COMMAND_OK) if (PQresultStatus(uRes) != PGRES_COMMAND_OK)
die_horribly(AH, "%s: error while updating attr %s of table %s (result = %d)." die_horribly(AH, modulename,
" Explanation from backend '%s'\n", "error while updating column \"%s\" of table \"%s\": %s",
progname, attr, tablename, PQresultStatus(uRes), attr, tablename, PQerrorMessage(AH->blobConnection));
PQerrorMessage(AH->blobConnection));
PQclear(uRes); PQclear(uRes);
} }
...@@ -762,12 +761,12 @@ CreateBlobXrefTable(ArchiveHandle *AH) ...@@ -762,12 +761,12 @@ CreateBlobXrefTable(ArchiveHandle *AH)
appendPQExpBuffer(qry, "Create Temporary Table %s(oldOid oid, newOid oid);", BLOB_XREF_TABLE); appendPQExpBuffer(qry, "Create Temporary Table %s(oldOid oid, newOid oid);", BLOB_XREF_TABLE);
_executeSqlCommand(AH, AH->blobConnection, qry, "can not create BLOB xref table '" BLOB_XREF_TABLE "'"); ExecuteSqlCommand(AH, qry, "could not create BLOB cross reference table", true);
resetPQExpBuffer(qry); resetPQExpBuffer(qry);
appendPQExpBuffer(qry, "Create Unique Index %s_ix on %s(oldOid)", BLOB_XREF_TABLE, BLOB_XREF_TABLE); appendPQExpBuffer(qry, "Create Unique Index %s_ix on %s(oldOid)", BLOB_XREF_TABLE, BLOB_XREF_TABLE);
_executeSqlCommand(AH, AH->blobConnection, qry, "can not create index on BLOB xref table '" BLOB_XREF_TABLE "'"); ExecuteSqlCommand(AH, qry, "could not create index on BLOB cross reference table", true);
} }
void void
...@@ -777,7 +776,7 @@ InsertBlobXref(ArchiveHandle *AH, int old, int new) ...@@ -777,7 +776,7 @@ InsertBlobXref(ArchiveHandle *AH, int old, int new)
appendPQExpBuffer(qry, "Insert Into %s(oldOid, newOid) Values (%d, %d);", BLOB_XREF_TABLE, old, new); appendPQExpBuffer(qry, "Insert Into %s(oldOid, newOid) Values (%d, %d);", BLOB_XREF_TABLE, old, new);
_executeSqlCommand(AH, AH->blobConnection, qry, "can not create BLOB xref entry"); ExecuteSqlCommand(AH, qry, "could not create BLOB cross reference entry", true);
} }
void void
...@@ -787,7 +786,7 @@ StartTransaction(ArchiveHandle *AH) ...@@ -787,7 +786,7 @@ StartTransaction(ArchiveHandle *AH)
appendPQExpBuffer(qry, "Begin;"); appendPQExpBuffer(qry, "Begin;");
ExecuteSqlCommand(AH, qry, "can not start database transaction"); ExecuteSqlCommand(AH, qry, "could not start database transaction", false);
AH->txActive = true; AH->txActive = true;
} }
...@@ -798,7 +797,8 @@ StartTransactionXref(ArchiveHandle *AH) ...@@ -798,7 +797,8 @@ StartTransactionXref(ArchiveHandle *AH)
appendPQExpBuffer(qry, "Begin;"); appendPQExpBuffer(qry, "Begin;");
_executeSqlCommand(AH, AH->blobConnection, qry, "can not start BLOB xref transaction"); ExecuteSqlCommand(AH, qry,
"could not start transaction for BLOB cross references", true);
AH->blobTxActive = true; AH->blobTxActive = true;
} }
...@@ -809,7 +809,7 @@ CommitTransaction(ArchiveHandle *AH) ...@@ -809,7 +809,7 @@ CommitTransaction(ArchiveHandle *AH)
appendPQExpBuffer(qry, "Commit;"); appendPQExpBuffer(qry, "Commit;");
ExecuteSqlCommand(AH, qry, "can not commit database transaction"); ExecuteSqlCommand(AH, qry, "could not commit database transaction", false);
AH->txActive = false; AH->txActive = false;
} }
...@@ -820,6 +820,6 @@ CommitTransactionXref(ArchiveHandle *AH) ...@@ -820,6 +820,6 @@ CommitTransactionXref(ArchiveHandle *AH)
appendPQExpBuffer(qry, "Commit;"); appendPQExpBuffer(qry, "Commit;");
_executeSqlCommand(AH, AH->blobConnection, qry, "can not commit BLOB xref transaction"); ExecuteSqlCommand(AH, qry, "could not commit transaction for BLOB cross references", true);
AH->blobTxActive = false; AH->blobTxActive = false;
} }
...@@ -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");
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.15 2001/04/25 07:03:19 pjw Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.16 2001/06/27 21:21:37 petere Exp $
* *
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au * Modifications - 28-Jun-2000 - pjw@rhyme.com.au
* *
...@@ -101,7 +101,7 @@ typedef struct ...@@ -101,7 +101,7 @@ typedef struct
char *filename; char *filename;
} lclTocEntry; } lclTocEntry;
static char *progname = "Archiver(tar)"; static char *modulename = "tar archiver";
static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt); static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt);
...@@ -172,7 +172,8 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) ...@@ -172,7 +172,8 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
ctx->tarFH = stdout; ctx->tarFH = stdout;
if (ctx->tarFH == NULL) if (ctx->tarFH == NULL)
die_horribly(NULL, "%s: Could not open TOC file for output.\n", progname); die_horribly(NULL, modulename,
"could not open TOC file for output: %s\n", strerror(errno));
ctx->tarFHpos = 0; ctx->tarFHpos = 0;
...@@ -197,7 +198,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) ...@@ -197,7 +198,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
* screws file positioning. * screws file positioning.
*/ */
if (AH->compression != 0) if (AH->compression != 0)
die_horribly(NULL, "%s: Compression not supported in TAR output\n", progname); die_horribly(NULL, modulename, "compression not supported by tar output format\n");
} }
else else
...@@ -209,7 +210,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH) ...@@ -209,7 +210,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
ctx->tarFH = stdin; ctx->tarFH = stdin;
if (ctx->tarFH == NULL) if (ctx->tarFH == NULL)
die_horribly(NULL, "%s: Could not open TOC file for input\n", progname); die_horribly(NULL, modulename, "could not open TOC file for input: %s\n", strerror(errno));
/* /*
* Make unbuffered since we will dup() it, and the buffers screw * Make unbuffered since we will dup() it, and the buffers screw
...@@ -332,7 +333,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) ...@@ -332,7 +333,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
{ {
if (filename) /* Couldn't find the requested file. if (filename) /* Couldn't find the requested file.
* Future: DO SEEK(0) and retry. */ * Future: DO SEEK(0) and retry. */
die_horribly(AH, "%s: unable to find file '%s' in archive\n", progname, filename); die_horribly(AH, modulename, "could not find file %s in archive\n", filename);
else else
/* Any file OK, non left, so return NULL */ /* Any file OK, non left, so return NULL */
return NULL; return NULL;
...@@ -343,7 +344,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) ...@@ -343,7 +344,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
if (AH->compression == 0) if (AH->compression == 0)
tm->nFH = ctx->tarFH; tm->nFH = ctx->tarFH;
else else
die_horribly(AH, "%s: compression support is disabled in this format\n", progname); die_horribly(AH, modulename, "compression support is disabled in this format\n");
/* tm->zFH = gzdopen(dup(fileno(ctx->tarFH)), "rb"); */ /* tm->zFH = gzdopen(dup(fileno(ctx->tarFH)), "rb"); */
#else #else
...@@ -360,7 +361,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) ...@@ -360,7 +361,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
tm->tmpFH = tmpfile(); tm->tmpFH = tmpfile();
if (tm->tmpFH == NULL) if (tm->tmpFH == NULL)
die_horribly(AH, "%s: could not generate temp file name.\n", progname); die_horribly(AH, modulename, "could not generate temporary file name: %s\n", strerror(errno));
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
...@@ -369,7 +370,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode) ...@@ -369,7 +370,7 @@ tarOpen(ArchiveHandle *AH, const char *filename, char mode)
sprintf(fmode, "wb%d", AH->compression); sprintf(fmode, "wb%d", AH->compression);
tm->zFH = gzdopen(dup(fileno(tm->tmpFH)), fmode); tm->zFH = gzdopen(dup(fileno(tm->tmpFH)), fmode);
if (tm->zFH == NULL) if (tm->zFH == NULL)
die_horribly(AH, "%s: could not gzdopen temp file.\n", progname); die_horribly(AH, modulename, "could not gzdopen temporary file\n");
} }
else else
...@@ -401,7 +402,7 @@ tarClose(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -401,7 +402,7 @@ tarClose(ArchiveHandle *AH, TAR_MEMBER *th)
*/ */
if (AH->compression != 0) if (AH->compression != 0)
if (GZCLOSE(th->zFH) != 0) if (GZCLOSE(th->zFH) != 0)
die_horribly(AH, "%s: could not close tar member\n", progname); die_horribly(AH, modulename, "could not close tar member\n");
if (th->mode == 'w') if (th->mode == 'w')
_tarAddFile(AH, th); /* This will close the temp file */ _tarAddFile(AH, th); /* This will close the temp file */
...@@ -502,13 +503,13 @@ _tarReadRaw(ArchiveHandle *AH, void *buf, int len, TAR_MEMBER *th, FILE *fh) ...@@ -502,13 +503,13 @@ _tarReadRaw(ArchiveHandle *AH, void *buf, int len, TAR_MEMBER *th, FILE *fh)
res = fread(&((char *) buf)[used], 1, len, th->nFH); res = fread(&((char *) buf)[used], 1, len, th->nFH);
} }
else else
die_horribly(AH, "%s: neither th nor fh specified in tarReadRaw\n", progname); die_horribly(AH, modulename, "neither th nor fh specified in tarReadRaw() (internal error)\n");
} }
/* #if 0
* fprintf(stderr, "%s: requested %d bytes, got %d from lookahead and write_msg(modulename, "requested %d bytes, got %d from lookahead and %d from file\n",
* %d from file\n", progname, reqLen, used, res); reqLen, used, res);
*/ #endif
ctx->tarFHpos += res + used; ctx->tarFHpos += res + used;
...@@ -544,7 +545,8 @@ tarWrite(const void *buf, int len, TAR_MEMBER *th) ...@@ -544,7 +545,8 @@ tarWrite(const void *buf, int len, TAR_MEMBER *th)
res = fwrite(buf, 1, len, th->nFH); res = fwrite(buf, 1, len, th->nFH);
if (res != len) if (res != len)
die_horribly(th->AH, "%s: could not write to tar member (%d != %d)\n", progname, res, len); die_horribly(th->AH, modulename,
"could not write to tar member (wrote %d, attempted %d)\n", res, len);
th->pos += res; th->pos += res;
return res; return res;
...@@ -631,7 +633,8 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -631,7 +633,8 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
* OIDS, so we search the string for it in a paranoid sort of way. * OIDS, so we search the string for it in a paranoid sort of way.
*/ */
if (strncmp(tmpCopy, "copy ", 5) != 0) if (strncmp(tmpCopy, "copy ", 5) != 0)
die_horribly(AH, "%s: COPY statment badly formatted - could not find 'copy' in '%s'\n", progname, tmpCopy); die_horribly(AH, modulename,
"bad COPY statement - could not find \"copy\" in string \"%s\"\n", tmpCopy);
pos1 = 5; pos1 = 5;
for (pos1 = 5; pos1 < strlen(tmpCopy); pos1++) for (pos1 = 5; pos1 < strlen(tmpCopy); pos1++)
...@@ -648,8 +651,9 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -648,8 +651,9 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
break; break;
if (pos2 >= strlen(tmpCopy)) if (pos2 >= strlen(tmpCopy))
die_horribly(AH, "%s: COPY statment badly formatted - could not find 'from stdin' in '%s' starting at %d\n", die_horribly(AH, modulename,
progname, tmpCopy, pos1); "bad COPY statement - could not find \"from stdin\" in string \"%s\" starting at position %d\n",
tmpCopy, pos1);
ahwrite(tmpCopy, 1, pos2, AH); /* 'copy "table" [with oids]' */ ahwrite(tmpCopy, 1, pos2, AH); /* 'copy "table" [with oids]' */
ahprintf(AH, " from '$$PATH$$/%s' %s", tctx->filename, &tmpCopy[pos2 + 10]); ahprintf(AH, " from '$$PATH$$/%s' %s", tctx->filename, &tmpCopy[pos2 + 10]);
...@@ -849,7 +853,8 @@ _CloseArchive(ArchiveHandle *AH) ...@@ -849,7 +853,8 @@ _CloseArchive(ArchiveHandle *AH)
for (i = 0; i < 512; i++) for (i = 0; i < 512; i++)
{ {
if (fputc(0, ctx->tarFH) == EOF) if (fputc(0, ctx->tarFH) == EOF)
die_horribly(AH, "%s: could not write null block at end of TAR archive.\n", progname); die_horribly(AH, modulename,
"could not write null block at end of tar archive\n");
} }
} }
...@@ -906,7 +911,7 @@ _StartBlob(ArchiveHandle *AH, TocEntry *te, Oid oid) ...@@ -906,7 +911,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";
...@@ -984,7 +989,7 @@ tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...) ...@@ -984,7 +989,7 @@ tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...)
bSize *= 2; bSize *= 2;
p = (char *) malloc(bSize); p = (char *) malloc(bSize);
if (p == NULL) if (p == NULL)
die_horribly(AH, "%s: could not allocate buffer for tarPrintf\n", progname); die_horribly(AH, modulename, "out of memory\n");
va_start(ap, fmt); va_start(ap, fmt);
cnt = vsnprintf(p, bSize, fmt, ap); cnt = vsnprintf(p, bSize, fmt, ap);
va_end(ap); va_end(ap);
...@@ -1044,22 +1049,22 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -1044,22 +1049,22 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
{ {
res = fwrite(&buf[0], 1, cnt, th->tarFH); res = fwrite(&buf[0], 1, cnt, th->tarFH);
if (res != cnt) if (res != cnt)
die_horribly(AH, "%s: write error appending to TAR archive (%d != %d).\n", progname, res, cnt); die_horribly(AH, modulename, "write error appending to tar archive (wrote %d, attempted %d)\n", res, cnt);
len += res; len += res;
} }
if (fclose(tmp) != 0) /* This *should* delete it... */ if (fclose(tmp) != 0) /* This *should* delete it... */
die_horribly(AH, "%s: Could not close tar member (fclose failed).\n", progname); die_horribly(AH, modulename, "could not close tar member: %s\n", strerror(errno));
if (len != th->fileLen) if (len != th->fileLen)
die_horribly(AH, "%s: Actual file length does not match expected (%d vs. %d).\n", die_horribly(AH, modulename, "actual file length (%d) does not match expected (%d)\n",
progname, len, th->pos); len, th->pos);
pad = ((len + 511) & ~511) - len; pad = ((len + 511) & ~511) - len;
for (i = 0; i < pad; i++) for (i = 0; i < pad; i++)
{ {
if (fputc('\0', th->tarFH) == EOF) if (fputc('\0', th->tarFH) == EOF)
die_horribly(AH, "%s: Could not output padding at end of tar member.\n", progname); die_horribly(AH, modulename, "could not output padding at end of tar member\n");
} }
ctx->tarFHpos += len + pad; ctx->tarFHpos += len + pad;
...@@ -1099,7 +1104,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) ...@@ -1099,7 +1104,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
if (!_tarGetHeader(AH, th)) if (!_tarGetHeader(AH, th))
{ {
if (filename) if (filename)
die_horribly(AH, "%s: unable to find header for %s\n", progname, filename); die_horribly(AH, modulename, "could not find header for file %s in tar archive\n", filename);
else else
/* We're just scanning the archibe for the next file, so return null */ /* We're just scanning the archibe for the next file, so return null */
{ {
...@@ -1114,9 +1119,9 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) ...@@ -1114,9 +1119,9 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
id = atoi(th->targetFile); id = atoi(th->targetFile);
if ((TocIDRequired(AH, id, AH->ropt) & 2) != 0) if ((TocIDRequired(AH, id, AH->ropt) & 2) != 0)
die_horribly(AH, "%s: dumping data out of order is not supported in this archive format: " die_horribly(AH, modulename, "dumping data out of order is not supported in this archive format: "
"%s is required, but comes before %s in the archive file.\n", "%s is required, but comes before %s in the archive file.\n",
progname, th->targetFile, filename); th->targetFile, filename);
/* Header doesn't match, so read to next header */ /* Header doesn't match, so read to next header */
len = ((th->fileLen + 511) & ~511); /* Padded length */ len = ((th->fileLen + 511) & ~511); /* Padded length */
...@@ -1126,7 +1131,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename) ...@@ -1126,7 +1131,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
_tarReadRaw(AH, &header[0], 512, NULL, ctx->tarFH); _tarReadRaw(AH, &header[0], 512, NULL, ctx->tarFH);
if (!_tarGetHeader(AH, th)) if (!_tarGetHeader(AH, th))
die_horribly(AH, "%s: unable to find header for %s\n", progname, filename); die_horribly(AH, modulename, "could not find header for file %s in tar archive\n", filename);
} }
...@@ -1152,12 +1157,12 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -1152,12 +1157,12 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
while (!gotBlock) while (!gotBlock)
{ {
#if 0
/* if (ftell(ctx->tarFH) != ctx->tarFHpos)
* if ( ftell(ctx->tarFH) != ctx->tarFHpos) die_horribly(AH, "%s: die_horribly(AH, modulename,
* mismatch in actual vs. predicted file pos - %d vs. %d\n", "mismatch in actual vs. predicted file position (%d vs. %d)\n",
* progname, ftell(ctx->tarFH), ctx->tarFHpos); ftell(ctx->tarFH), ctx->tarFHpos);
*/ #endif
/* Save the pos for reporting purposes */ /* Save the pos for reporting purposes */
hPos = ctx->tarFHpos; hPos = ctx->tarFHpos;
...@@ -1168,7 +1173,7 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -1168,7 +1173,7 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
return 0; return 0;
if (len != 512) if (len != 512)
die_horribly(AH, "%s: incomplete tar header found (%d bytes)\n", progname, len); die_horribly(AH, modulename, "incomplete tar header found (%d bytes)\n", len);
/* Calc checksum */ /* Calc checksum */
chk = _tarChecksum(&h[0]); chk = _tarChecksum(&h[0]);
...@@ -1200,9 +1205,10 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th) ...@@ -1200,9 +1205,10 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
ahlog(AH, 3, "TOC Entry %s at %d (len=%d, chk=%d)\n", &name[0], hPos, len, sum); ahlog(AH, 3, "TOC Entry %s at %d (len=%d, chk=%d)\n", &name[0], hPos, len, sum);
if (chk != sum) if (chk != sum)
die_horribly(AH, "%s: corrupt tar header found in %s " die_horribly(AH, modulename,
"(expected %d (%o), computed %d (%o)) file position %d (%x)\n", "corrupt tar header found in %s "
progname, &name[0], sum, sum, chk, chk, ftell(ctx->tarFH), ftell(ctx->tarFH)); "(expected %d (%o), computed %d (%o)) file position %ld (%lx)\n",
&name[0], sum, sum, chk, chk, ftell(ctx->tarFH), ftell(ctx->tarFH));
th->targetFile = strdup(name); th->targetFile = strdup(name);
th->fileLen = len; th->fileLen = len;
...@@ -1277,6 +1283,6 @@ _tarWriteHeader(TAR_MEMBER *th) ...@@ -1277,6 +1283,6 @@ _tarWriteHeader(TAR_MEMBER *th)
} }
if (fwrite(h, 1, 512, th->tarFH) != 512) if (fwrite(h, 1, 512, th->tarFH) != 512)
die_horribly(th->AH, "%s: unable to write tar header\n", progname); die_horribly(th->AH, modulename, "unable to write tar header\n");
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,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
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.211 2001/06/01 16:09:55 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.212 2001/06/27 21:21:37 petere Exp $
* *
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
* *
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
* *
* Modifications - 6/1/97 - igor@sba.miami.edu * Modifications - 6/1/97 - igor@sba.miami.edu
* - Added functions to free allocated memory used for retrieving * - Added functions to free allocated memory used for retrieving
* indices,tables,inheritance,types,functions and aggregates. * indexes,tables,inheritance,types,functions and aggregates.
* No more leaks reported by Purify. * No more leaks reported by Purify.
* *
* *
...@@ -145,9 +145,9 @@ ...@@ -145,9 +145,9 @@
#include <unistd.h> /* for getopt() */ #include <unistd.h> /* for getopt() */
#include <ctype.h> #include <ctype.h>
#ifdef ENABLE_NLS
#include "pg_backup.h" #include <locale.h>
#endif
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif
...@@ -155,6 +155,10 @@ ...@@ -155,6 +155,10 @@
#include <termios.h> #include <termios.h>
#endif #endif
#ifndef HAVE_STRDUP
#include "strdup.h"
#endif
#include "access/attnum.h" #include "access/attnum.h"
#include "access/htup.h" #include "access/htup.h"
#include "catalog/pg_class.h" #include "catalog/pg_class.h"
...@@ -163,12 +167,10 @@ ...@@ -163,12 +167,10 @@
#include "libpq-fe.h" #include "libpq-fe.h"
#include "libpq/libpq-fs.h" #include "libpq/libpq-fs.h"
#ifndef HAVE_STRDUP
#include "strdup.h"
#endif
#include "pg_dump.h" #include "pg_dump.h"
#include "pg_backup.h" #include "pg_backup.h"
#include "pg_backup_archiver.h"
typedef enum _formatLiteralOptions typedef enum _formatLiteralOptions
{ {
...@@ -238,84 +240,77 @@ typedef struct _dumpContext ...@@ -238,84 +240,77 @@ typedef struct _dumpContext
static void static void
help(const char *progname) help(const char *progname)
{ {
printf("%s dumps a database as a text file.\n\n", progname); printf(gettext("%s dumps a database as a text file or to other formats.\n\n"), progname);
puts("Usage:"); puts(gettext("Usage:"));
printf(" %s [options] dbname\n\n", progname); printf(gettext(" %s [options] dbname\n\n"), progname);
puts("Options:"); puts(gettext("Options:"));
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
puts( puts(gettext(
" -a, --data-only dump out only the data, not the schema\n" " -a, --data-only dump only the data, not the schema\n"
" -b, --blobs dump out blob data\n" " -b, --blobs include BLOB data in dump\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 database\n" " -C, --create include commands to create database in dump\n"
" -d, --inserts dump data as INSERT, rather than COPY, commands\n" " -d, --inserts dump data as INSERT, rather than COPY, commands\n"
" -D, --attribute-inserts dump data as INSERT commands with attribute names\n" " -D, --attribute-inserts dump data as INSERT commands with column names\n"
" -f, --file=FILENAME specify output file name\n" " -f, --file=FILENAME output file name\n"
" -F, --format {c|t|p} output file format (custom, tar, plain text)\n" " -F, --format {c|t|p} output file format (custom, tar, plain text)\n"
" -h, --host=HOSTNAME server host name\n" " -h, --host=HOSTNAME database server host name\n"
" -i, --ignore-version proceed when database version != pg_dump version\n" " -i, --ignore-version proceed even when server version mismatches\n"
" -n, --no-quotes suppress most quotes around identifiers\n" " pg_dump version\n"
" -N, --quotes enable most quotes around identifiers\n" " -n, --no-quotes suppress most quotes around identifiers\n"
" -o, --oids dump object ids (oids)\n" " -N, --quotes enable most quotes around identifiers\n"
" -O, --no-owner do not output \\connect commands in plain text\n" " -o, --oids include oids in dump\n"
" format\n" " -O, --no-owner do not output \\connect commands in plain\n"
" -p, --port=PORT server port number\n" " text format\n"
" -R, --no-reconnect disable ALL reconnections to the database in\n" " -p, --port=PORT database server port number\n"
" plain text format\n" " -R, --no-reconnect disable ALL reconnections to the database in\n"
" -s, --schema-only dump out only the schema, no data\n" " plain text format\n"
" -S, --superuser=NAME specify the superuser user name to use in plain\n" " -s, --schema-only dump only the schema, no data\n"
" text format\n" " -S, --superuser=NAME specify the superuser user name to use in\n"
" -t, --table=TABLE dump for this table only (* for all)\n" " plain text format\n"
" -U, --username=NAME connect as specified database user\n" " -t, --table=TABLE dump this table only (* for all)\n"
" -v, --verbose verbose\n" " -U, --username=NAME connect as specified database user\n"
" -W, --password force password prompt (should happen automatically)\n" " -v, --verbose verbose mode\n"
" -x, --no-acl do not dump ACL's (grant/revoke)\n" " -W, --password force password prompt (should happen automatically)\n"
" -Z, --compress {0-9} compression level for compressed formats\n" " -x, --no-acl do not dump privileges (grant/revoke)\n"
); " -Z, --compress {0-9} compression level for compressed formats\n"
));
#else #else
puts( puts(gettext(
" -a dump out only the data, no schema\n" " -a dump only the data, not the schema\n"
" -b dump out blob data\n" " -b include BLOB data in dump\n"
" -c clean (drop) schema prior to create\n" " -c clean (drop) schema prior to create\n"
" -C output commands to create database\n" " -C include commands to create database in dump\n"
" -d dump data as INSERT, rather than COPY, commands\n" " -d dump data as INSERT, rather than COPY, commands\n"
" -D dump data as INSERT commands with attribute names\n" " -D dump data as INSERT commands with column names\n"
" -f FILENAME specify output file name\n" " -f FILENAME output file name\n"
" -F {c|t|p} output file format (custom, tar, plain text)\n" " -F {c|t|p} output file format (custom, tar, plain text)\n"
" -h HOSTNAME server host name\n" " -h HOSTNAME database server host name\n"
" -i proceed when database version != pg_dump version\n" " -i proceed even when server version mismatches\n"
" -n suppress most quotes around identifiers\n" " pg_dump version\n"
" -N enable most quotes around identifiers\n" " -n suppress most quotes around identifiers\n"
" -o dump object ids (oids)\n" " -N enable most quotes around identifiers\n"
" -O do not output \\connect commands in plain text\n" " -o include oids in dump\n"
" format\n" " -O do not output \\connect commands in plain\n"
" -p PORT server port number\n" " text format\n"
" -R disable ALL reconnections to the database in\n" " -p PORT database server port number\n"
" plain text format\n" " -R disable ALL reconnections to the database in\n"
" -s dump out only the schema, no data\n" " plain text format\n"
" -S NAME specify the superuser user name to use in plain\n" " -s dump only the schema, no data\n"
" text format\n" " -S NAME specify the superuser user name to use in\n"
" -t TABLE dump for this table only (* for all)\n" " plain text format\n"
" -U NAME connect as specified database user\n" " -t TABLE dump this table only (* for all)\n"
" -v verbose\n" " -U NAME connect as specified database user\n"
" -W force password prompt (should happen automatically)\n" " -v verbose mode\n"
" -x do not dump ACL's (grant/revoke)\n" " -W force password prompt (should happen automatically)\n"
" -Z {0-9} compression level for compressed formats\n" " -x do not dump privileges (grant/revoke)\n"
); " -Z {0-9} compression level for compressed formats\n"
));
#endif #endif
puts("If no database name is not supplied, then the PGDATABASE environment\nvariable value is used.\n"); puts(gettext("If no database name is not supplied, then the PGDATABASE environment\n"
puts("Report bugs to <pgsql-bugs@postgresql.org>."); "variable value is used.\n\n"
} "Report bugs to <pgsql-bugs@postgresql.org>."));
static void
version(void)
{
puts("pg_dump (PostgreSQL) " PG_VERSION);
puts("Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group");
puts("Portions Copyright (c) 1996 Regents of the University of California");
puts("Read the file COPYRIGHT to see the usage and distribution terms.");
} }
...@@ -362,7 +357,7 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv) ...@@ -362,7 +357,7 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv)
* *
*/ */
sprintf(query, "COPY %s WITH OIDS TO stdout;\n", sprintf(query, "COPY %s WITH OIDS TO stdout;",
fmtId(classname, force_quotes)); fmtId(classname, force_quotes));
} }
else else
...@@ -376,27 +371,27 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv) ...@@ -376,27 +371,27 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv)
* *
*/ */
sprintf(query, "COPY %s TO stdout;\n", fmtId(classname, force_quotes)); sprintf(query, "COPY %s TO stdout;", fmtId(classname, force_quotes));
} }
res = PQexec(g_conn, query); res = PQexec(g_conn, query);
if (!res || if (!res ||
PQresultStatus(res) == PGRES_FATAL_ERROR) PQresultStatus(res) == PGRES_FATAL_ERROR)
{ {
fprintf(stderr, "SQL query to dump the contents of Table '%s' " write_msg(NULL, "SQL command to dump the contents of table \"%s\" failed\n",
"did not execute. Explanation from backend: '%s'.\n" classname);
"The query was: '%s'.\n", write_msg(NULL, "Error message from server: %s", PQerrorMessage(g_conn));
classname, PQerrorMessage(g_conn), query); write_msg(NULL, "The command was: %s\n", query);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
else else
{ {
if (PQresultStatus(res) != PGRES_COPY_OUT) if (PQresultStatus(res) != PGRES_COPY_OUT)
{ {
fprintf(stderr, "SQL query to dump the contents of Table '%s' " write_msg(NULL, "SQL command to dump the contents of table \"%s\" executed abnormally.\n",
"executed abnormally.\n" classname);
"PQexec() returned status %d when %d was expected.\n" write_msg(NULL, "The server returned status %d when %d was expected.\n",
"The query was: '%s'.\n", PQresultStatus(res), PGRES_COPY_OUT);
classname, PQresultStatus(res), PGRES_COPY_OUT, query); write_msg(NULL, "The command was: %s\n", query);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
else else
...@@ -479,12 +474,9 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv) ...@@ -479,12 +474,9 @@ dumpClasses_nodumpData(Archive *fout, char *oid, void *dctxv)
ret = PQendcopy(g_conn); ret = PQendcopy(g_conn);
if (ret != 0) if (ret != 0)
{ {
fprintf(stderr, "SQL query to dump the contents of Table '%s' " write_msg(NULL, "SQL command to dump the contents of table \"%s\" failed: PQendcopy() failed.\n", classname);
"did not execute correctly. After we read all the " write_msg(NULL, "Error message from server: %s", PQerrorMessage(g_conn));
"table contents from the backend, PQendcopy() failed. " write_msg(NULL, "The command was: %s\n", query);
"Explanation from backend: '%s'.\n"
"The query was: '%s'.\n",
classname, PQerrorMessage(g_conn), query);
PQclear(res); PQclear(res);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -515,8 +507,9 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv) ...@@ -515,8 +507,9 @@ dumpClasses_dumpData(Archive *fout, char *oid, void *dctxv)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "dumpClasses(): command failed. Explanation from backend: '%s'.\n", write_msg(NULL, "dumpClasses(): SQL command failed\n");
PQerrorMessage(g_conn)); write_msg(NULL, "Error message from server: %s", PQerrorMessage(g_conn));
write_msg(NULL, "The command was: %s\n", q->data);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
for (tuple = 0; tuple < PQntuples(res); tuple++) for (tuple = 0; tuple < PQntuples(res); tuple++)
...@@ -707,7 +700,6 @@ int ...@@ -707,7 +700,6 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int c; int c;
const char *progname;
const char *filename = NULL; const char *filename = NULL;
const char *format = "p"; const char *format = "p";
const char *dbname = NULL; const char *dbname = NULL;
...@@ -764,6 +756,12 @@ main(int argc, char **argv) ...@@ -764,6 +756,12 @@ main(int argc, char **argv)
#endif #endif
#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
bindtextdomain("pg_dump", LOCALEDIR);
textdomain("pg_dump");
#endif
g_verbose = false; g_verbose = false;
force_quotes = true; force_quotes = true;
...@@ -794,7 +792,7 @@ main(int argc, char **argv) ...@@ -794,7 +792,7 @@ main(int argc, char **argv)
} }
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
{ {
version(); puts("pg_dump (PostgreSQL) " PG_VERSION);
exit(0); exit(0);
} }
} }
...@@ -946,20 +944,17 @@ main(int argc, char **argv) ...@@ -946,20 +944,17 @@ main(int argc, char **argv)
compressLevel = atoi(optarg); compressLevel = atoi(optarg);
break; break;
case 'V':
version();
exit(0);
break;
#ifndef HAVE_GETOPT_LONG #ifndef HAVE_GETOPT_LONG
case '-': case '-':
fprintf(stderr, "%s was compiled without support for long options.\n" fprintf(stderr,
"Use --help for help on invocation options.\n", progname); gettext("%s was compiled without support for long options.\n"
"Use --help for help on invocation options.\n"),
progname);
exit(1); exit(1);
break; break;
#endif #endif
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);
} }
} }
...@@ -967,9 +962,9 @@ main(int argc, char **argv) ...@@ -967,9 +962,9 @@ main(int argc, char **argv)
if (optind < (argc - 1)) if (optind < (argc - 1))
{ {
fprintf(stderr, fprintf(stderr,
"%s: extra parameters found on command line after '%s' (first is '%s').\n" gettext("%s: too many command line options (first is '%s')\n"
"Please respecify command.\nUse --help for help on invocation options.\n", "Try '%s --help' for more information.\n"),
progname, argv[optind], argv[optind + 1]); progname, argv[optind + 1], progname);
exit(1); exit(1);
} }
...@@ -980,41 +975,34 @@ main(int argc, char **argv) ...@@ -980,41 +975,34 @@ main(int argc, char **argv)
dbname = getenv("PGDATABASE"); dbname = getenv("PGDATABASE");
if (!dbname) if (!dbname)
{ {
fprintf(stderr, write_msg(NULL, "no database name specified\n");
"%s: no database name specified\n",
progname);
exit(1); exit(1);
} }
if (dataOnly && schemaOnly) if (dataOnly && schemaOnly)
{ {
fprintf(stderr, write_msg(NULL, "'Schema only' and 'data only' are incompatible options.\n");
"%s: 'Schema Only' and 'Data Only' are incompatible options.\n",
progname);
exit(1); exit(1);
} }
if (outputBlobs && tablename != NULL && strlen(tablename) > 0) if (outputBlobs && tablename != NULL && strlen(tablename) > 0)
{ {
fprintf(stderr, write_msg(NULL, "BLOB output is not supported for a single table.\n");
"%s: BLOB output is not supported for a single table. Use all tables or a full dump instead.\n", write_msg(NULL, "Use all tables or a full dump instead.\n");
progname);
exit(1); exit(1);
} }
if (dumpData == true && oids == true) if (dumpData == true && oids == true)
{ {
fprintf(stderr, write_msg(NULL, "INSERT (-d, -D) and OID (-o) options cannot be used together.\n");
"%s: INSERT's can not set oids, so INSERT and OID options can not be used together.\n", write_msg(NULL, "(The INSERT command cannot set oids.)\n");
progname);
exit(1); exit(1);
} }
if (outputBlobs == true && (format[0] == 'p' || format[0] == 'P')) if (outputBlobs == true && (format[0] == 'p' || format[0] == 'P'))
{ {
fprintf(stderr, write_msg(NULL, "BLOB output is not supported for plain text dump files.\n");
"%s: BLOB output is not supported for plain text dump files. Use a different output format.\n", write_msg(NULL, "(Use a different output format.)\n");
progname);
exit(1); exit(1);
} }
...@@ -1044,16 +1032,13 @@ main(int argc, char **argv) ...@@ -1044,16 +1032,13 @@ main(int argc, char **argv)
break; break;
default: default:
fprintf(stderr, write_msg(NULL, "invalid output format '%s' specified\n", format);
"%s: invalid output format '%s' specified\n", progname, format);
exit(1); exit(1);
} }
if (g_fout == NULL) if (g_fout == NULL)
{ {
fprintf(stderr, write_msg(NULL, "could not open output file %s for writing\n", filename);
"%s: could not open output file named %s for writing\n",
progname, filename);
exit(1); exit(1);
} }
...@@ -1076,13 +1061,13 @@ main(int argc, char **argv) ...@@ -1076,13 +1061,13 @@ main(int argc, char **argv)
res = PQexec(g_conn, "begin"); res = PQexec(g_conn, "begin");
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
exit_horribly(g_fout, "BEGIN command failed. Explanation from backend: '%s'.\n", exit_horribly(g_fout, NULL, "BEGIN command failed: %s",
PQerrorMessage(g_conn)); PQerrorMessage(g_conn));
PQclear(res); PQclear(res);
res = PQexec(g_conn, "set transaction isolation level serializable"); res = PQexec(g_conn, "set transaction isolation level serializable");
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
exit_horribly(g_fout, "SET TRANSACTION command failed. Explanation from backend: '%s'.\n", exit_horribly(g_fout, NULL, "could not set transaction isolation level to serializable: %s",
PQerrorMessage(g_conn)); PQerrorMessage(g_conn));
PQclear(res); PQclear(res);
...@@ -1189,16 +1174,24 @@ dumpDatabase(Archive *AH) ...@@ -1189,16 +1174,24 @@ dumpDatabase(Archive *AH)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getDatabase(): SELECT failed. Explanation from backend: '%s'.\n", write_msg(NULL, "SQL command failed\n");
PQerrorMessage(g_conn)); write_msg(NULL, "Error message from server: %s", PQerrorMessage(g_conn));
write_msg(NULL, "The command was: %s\n", dbQry->data);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
ntups = PQntuples(res); ntups = PQntuples(res);
if (ntups <= 0)
{
write_msg(NULL, "missing pg_database entry for database \"%s\"\n", PQdb(g_conn));
exit_nicely(g_conn);
}
if (ntups != 1) if (ntups != 1)
{ {
fprintf(stderr, "getDatabase(): SELECT returned %d databases.\n", ntups); write_msg(NULL, "query returned more than one (%d) pg_database entry for database \"%s\"\n",
ntups, PQdb(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -1252,8 +1245,7 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal) ...@@ -1252,8 +1245,7 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal)
res = PQexec(g_conn, oidQry->data); res = PQexec(g_conn, oidQry->data);
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
{ {
fprintf(stderr, "dumpBlobs(): Declare Cursor failed. Explanation from backend: '%s'.\n", write_msg(NULL, "dumpBlobs(): cursor declaration failed: %s", PQerrorMessage(g_conn));
PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -1268,7 +1260,8 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal) ...@@ -1268,7 +1260,8 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal)
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "dumpBlobs(): Fetch Cursor failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn)); write_msg(NULL, "dumpBlobs(): fetch from cursor failed: %s",
PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -1280,8 +1273,8 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal) ...@@ -1280,8 +1273,8 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal)
loFd = lo_open(g_conn, blobOid, INV_READ); loFd = lo_open(g_conn, blobOid, INV_READ);
if (loFd == -1) if (loFd == -1)
{ {
fprintf(stderr, "dumpBlobs(): Could not open large object. " write_msg(NULL, "dumpBlobs(): could not open large object: %s",
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn)); PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -1293,8 +1286,8 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal) ...@@ -1293,8 +1286,8 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal)
cnt = lo_read(g_conn, loFd, buf, loBufSize); cnt = lo_read(g_conn, loFd, buf, loBufSize);
if (cnt < 0) if (cnt < 0)
{ {
fprintf(stderr, "dumpBlobs(): Error reading large object. " write_msg(NULL, "dumpBlobs(): error reading large object: %s",
" Explanation from backend: '%s'.\n", PQerrorMessage(g_conn)); PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -1378,7 +1371,7 @@ getTypes(int *numTypes) ...@@ -1378,7 +1371,7 @@ getTypes(int *numTypes)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getTypes(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn)); write_msg(NULL, "query to obtain list of data types failed: %s", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -1422,7 +1415,8 @@ getTypes(int *numTypes) ...@@ -1422,7 +1415,8 @@ getTypes(int *numTypes)
tinfo[i].typedefn = strdup(PQgetvalue(res, i, i_typedefn)); tinfo[i].typedefn = strdup(PQgetvalue(res, i, i_typedefn));
if (strlen(tinfo[i].usename) == 0) if (strlen(tinfo[i].usename) == 0)
fprintf(stderr, "WARNING: owner of type '%s' appears to be invalid\n", tinfo[i].typname); write_msg(NULL, "WARNING: owner of data type %s appears to be invalid\n",
tinfo[i].typname);
if (strcmp(PQgetvalue(res, i, i_typbyval), "f") == 0) if (strcmp(PQgetvalue(res, i, i_typbyval), "f") == 0)
tinfo[i].passedbyvalue = 0; tinfo[i].passedbyvalue = 0;
...@@ -1495,7 +1489,7 @@ getOperators(int *numOprs) ...@@ -1495,7 +1489,7 @@ getOperators(int *numOprs)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getOperators(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn)); write_msg(NULL, "query to obtain list of operators failed: %s", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -1537,8 +1531,8 @@ getOperators(int *numOprs) ...@@ -1537,8 +1531,8 @@ getOperators(int *numOprs)
oprinfo[i].usename = strdup(PQgetvalue(res, i, i_usename)); oprinfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
if (strlen(oprinfo[i].usename) == 0) if (strlen(oprinfo[i].usename) == 0)
fprintf(stderr, "WARNING: owner of operator '%s' appears to be invalid\n", write_msg(NULL, "WARNING: owner of operator \"%s\" appears to be invalid\n",
oprinfo[i].oprname); oprinfo[i].oprname);
} }
...@@ -1745,14 +1739,14 @@ clearOprInfo(OprInfo *opr, int numOprs) ...@@ -1745,14 +1739,14 @@ clearOprInfo(OprInfo *opr, int numOprs)
} }
void void
clearIndInfo(IndInfo *ind, int numIndices) clearIndInfo(IndInfo *ind, int numIndexes)
{ {
int i, int i,
a; a;
if (!ind) if (!ind)
return; return;
for (i = 0; i < numIndices; ++i) for (i = 0; i < numIndexes; ++i)
{ {
if (ind[i].indoid) if (ind[i].indoid)
free(ind[i].indoid); free(ind[i].indoid);
...@@ -1859,8 +1853,8 @@ getAggregates(int *numAggs) ...@@ -1859,8 +1853,8 @@ getAggregates(int *numAggs)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getAggregates(): SELECT failed. Explanation from backend: '%s'.\n", write_msg(NULL, "query to obtain list of aggregate functions failed: %s\n",
PQerrorMessage(g_conn)); PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -1890,8 +1884,8 @@ getAggregates(int *numAggs) ...@@ -1890,8 +1884,8 @@ getAggregates(int *numAggs)
agginfo[i].agginitval = strdup(PQgetvalue(res, i, i_agginitval)); agginfo[i].agginitval = strdup(PQgetvalue(res, i, i_agginitval));
agginfo[i].usename = strdup(PQgetvalue(res, i, i_usename)); agginfo[i].usename = strdup(PQgetvalue(res, i, i_usename));
if (strlen(agginfo[i].usename) == 0) if (strlen(agginfo[i].usename) == 0)
fprintf(stderr, "WARNING: owner of aggregate '%s' appears to be invalid\n", write_msg(NULL, "WARNING: owner of aggregate function \"%s\" appears to be invalid\n",
agginfo[i].aggname); agginfo[i].aggname);
agginfo[i].convertok = (PQgetvalue(res, i, i_convertok)[0] == 't'); agginfo[i].convertok = (PQgetvalue(res, i, i_convertok)[0] == 't');
...@@ -1960,8 +1954,8 @@ getFuncs(int *numFuncs) ...@@ -1960,8 +1954,8 @@ getFuncs(int *numFuncs)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getFuncs(): SELECT failed. Explanation from backend: '%s'.\n", write_msg(NULL, "query to obtain list of functions failed: %s",
PQerrorMessage(g_conn)); PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2003,13 +1997,13 @@ getFuncs(int *numFuncs) ...@@ -2003,13 +1997,13 @@ getFuncs(int *numFuncs)
finfo[i].isstrict = (strcmp(PQgetvalue(res, i, i_isstrict), "t") == 0); finfo[i].isstrict = (strcmp(PQgetvalue(res, i, i_isstrict), "t") == 0);
if (strlen(finfo[i].usename) == 0) if (strlen(finfo[i].usename) == 0)
fprintf(stderr, "WARNING: owner of function '%s' appears to be invalid\n", write_msg(NULL, "WARNING: owner of function \"%s\" appears to be invalid\n",
finfo[i].proname); finfo[i].proname);
if (finfo[i].nargs < 0 || finfo[i].nargs > FUNC_MAX_ARGS) if (finfo[i].nargs < 0 || finfo[i].nargs > FUNC_MAX_ARGS)
{ {
fprintf(stderr, "getFuncs(): failed sanity check: %s has %d args\n", write_msg(NULL, "failed sanity check: function %s has more than %d (namely %d) arguments\n",
finfo[i].proname, finfo[i].nargs); finfo[i].proname, FUNC_MAX_ARGS, finfo[i].nargs);
exit(1); exit(1);
} }
parseNumericArray(PQgetvalue(res, i, i_proargtypes), parseNumericArray(PQgetvalue(res, i, i_proargtypes),
...@@ -2026,7 +2020,7 @@ getFuncs(int *numFuncs) ...@@ -2026,7 +2020,7 @@ getFuncs(int *numFuncs)
/* /*
* getTables * getTables
* read all the user-defined tables (no indices, no catalogs) * read all the user-defined tables (no indexes, no catalogs)
* in the system catalogs return them in the TableInfo* structure * in the system catalogs return them in the TableInfo* structure
* *
* numTables is set to the number of tables read in * numTables is set to the number of tables read in
...@@ -2058,7 +2052,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2058,7 +2052,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
relkindview[1] = '\0'; relkindview[1] = '\0';
/* /*
* find all the user-defined tables (no indices and no catalogs), * find all the user-defined tables (no indexes and no catalogs),
* ordering by oid is important so that we always process the parent * ordering by oid is important so that we always process the parent
* tables before the child tables when traversing the tblinfo* * tables before the child tables when traversing the tblinfo*
* *
...@@ -2103,8 +2097,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2103,8 +2097,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getTables(): SELECT failed. Explanation from backend: '%s'.\n", write_msg(NULL, "query to obtain list of tables failed: %s",
PQerrorMessage(g_conn)); PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2134,8 +2128,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2134,8 +2128,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
tblinfo[i].ntrig = atoi(PQgetvalue(res, i, i_reltriggers)); tblinfo[i].ntrig = atoi(PQgetvalue(res, i, i_reltriggers));
if (strlen(tblinfo[i].usename) == 0) if (strlen(tblinfo[i].usename) == 0)
fprintf(stderr, "WARNING: owner of table '%s' appears to be invalid\n", write_msg(NULL, "WARNING: owner of table \"%s\" appears to be invalid\n",
tblinfo[i].relname); tblinfo[i].relname);
/* Get view definition */ /* Get view definition */
if (strcmp(PQgetvalue(res, i, i_relkind), relkindview) == 0) if (strcmp(PQgetvalue(res, i, i_relkind), relkindview) == 0)
...@@ -2154,31 +2148,26 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2154,31 +2148,26 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
res2 = PQexec(g_conn, query->data); res2 = PQexec(g_conn, query->data);
if (!res2 || PQresultStatus(res2) != PGRES_TUPLES_OK) if (!res2 || PQresultStatus(res2) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getTables(): SELECT (for VIEW DEFINITION) failed. " write_msg(NULL, "query to obtain definition of view \"%s\" failed: %s",
"Explanation from backend: %s", tblinfo[i].relname, PQerrorMessage(g_conn));
PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
if (PQntuples(res2) != 1) if (PQntuples(res2) != 1)
{ {
if (PQntuples(res2) < 1) if (PQntuples(res2) < 1)
{ write_msg(NULL, "query to obtain definition of view \"%s\" returned no data\n",
fprintf(stderr, "getTables(): SELECT (for VIEW %s) returned no definitions\n", tblinfo[i].relname);
tblinfo[i].relname);
}
else else
{ write_msg(NULL, "query to obtain definition of view \"%s\" returned more than one definition\n",
fprintf(stderr, "getTables(): SELECT (for VIEW %s) returned more than 1 definition\n",
tblinfo[i].relname); tblinfo[i].relname);
}
exit_nicely(g_conn); exit_nicely(g_conn);
} }
if (PQgetisnull(res2, 0, 1)) if (PQgetisnull(res2, 0, 1))
{ {
fprintf(stderr, "getTables(): SELECT (for VIEW %s) returned NULL oid\n", tblinfo[i].relname); write_msg(NULL, "query to obtain definition of view \"%s\" returned NULL oid\n",
fprintf(stderr, "SELECT was: %s\n", query->data); tblinfo[i].relname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2187,8 +2176,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2187,8 +2176,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
if (strlen(tblinfo[i].viewdef) == 0) if (strlen(tblinfo[i].viewdef) == 0)
{ {
fprintf(stderr, "getTables(): SELECT (for VIEW %s) returned empty definition", write_msg(NULL, "definition of view \"%s\" appears to be empty (length zero)\n",
tblinfo[i].relname); tblinfo[i].relname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
} }
...@@ -2235,16 +2224,15 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2235,16 +2224,15 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
if (!res2 || if (!res2 ||
PQresultStatus(res2) != PGRES_TUPLES_OK) PQresultStatus(res2) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getTables(): SELECT (for CHECK) failed. " write_msg(NULL, "query to obtain check constraints failed: %s", PQerrorMessage(g_conn));
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
ntups2 = PQntuples(res2); ntups2 = PQntuples(res2);
if (ntups2 > tblinfo[i].ncheck) if (ntups2 > tblinfo[i].ncheck)
{ {
fprintf(stderr, "getTables(): relation '%s': a maximum of %d CHECKs " write_msg(NULL, "expected %d check constraints on table \"%s\" but found %d\n",
"were expected, but got %d\n", tblinfo[i].ncheck, tblinfo[i].relname, ntups2);
tblinfo[i].relname, tblinfo[i].ncheck, ntups2); write_msg(NULL, "(The system catalogs might be corrupted.)\n");
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2285,14 +2273,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2285,14 +2273,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
res2 = PQexec(g_conn, query->data); res2 = PQexec(g_conn, query->data);
if (!res2 || PQresultStatus(res2) != PGRES_TUPLES_OK) if (!res2 || PQresultStatus(res2) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getTables(): SELECT (for PRIMARY KEY) failed on table %s. Explanation from backend: %s\n", write_msg(NULL, "query to obtain primary key of table \"%s\" failed: %s",
tblinfo[i].relname, PQerrorMessage(g_conn)); tblinfo[i].relname, PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
if (PQntuples(res2) > 1) if (PQntuples(res2) > 1)
{ {
fprintf(stderr, "getTables(): SELECT (for PRIMARY KEY) produced more than one row on table %s.\n", write_msg(NULL, "query to obtain primary key of table \"%s\" produced more than one result\n",
tblinfo[i].relname); tblinfo[i].relname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2342,28 +2330,24 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2342,28 +2330,24 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
res2 = PQexec(g_conn, query->data); res2 = PQexec(g_conn, query->data);
if (!res2 || PQresultStatus(res2) != PGRES_TUPLES_OK) if (!res2 || PQresultStatus(res2) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getTables(): SELECT (for PRIMARY KEY NAME) failed for table %s. Explanation from backend: %s", write_msg(NULL, "query to obtain name of primary key of table \"%s\" failed: %s",
tblinfo[i].relname, PQerrorMessage(g_conn)); tblinfo[i].relname, PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
n = PQntuples(res2); n = PQntuples(res2);
if (n != 1) if (n != 1)
{ {
fprintf(stderr, write_msg(NULL, "query to obtain name of primary key of table \"%s\" did not return exactly one result\n",
"getTables(): SELECT (for PRIMARY KEY NAME) failed for table %s. " tblinfo[i].relname);
"This is impossible but object with OID == %s have %d primary keys.\n",
tblinfo[i].relname,
tblinfo[i].oid,
n);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
/* Sanity check on LOJ */ /* Sanity check on LOJ */
if (PQgetisnull(res2, 0, 0)) if (PQgetisnull(res2, 0, 0))
{ {
fprintf(stderr, "getTables(): SELECT (for PRIMARY KEY NAME) on table %s returned NULL value.\n", write_msg(NULL, "name of primary key of table \"%s\" returned NULL value\n",
tblinfo[i].relname); tblinfo[i].relname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2371,7 +2355,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2371,7 +2355,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
strdup(fmtId(PQgetvalue(res2, 0, 0), force_quotes)); strdup(fmtId(PQgetvalue(res2, 0, 0), force_quotes));
if (tblinfo[i].primary_key_name == NULL) if (tblinfo[i].primary_key_name == NULL)
{ {
perror("strdup"); write_msg(NULL, "out of memory\n");
exit(1); exit(1);
} }
} }
...@@ -2417,15 +2401,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2417,15 +2401,14 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
if (!res2 || if (!res2 ||
PQresultStatus(res2) != PGRES_TUPLES_OK) PQresultStatus(res2) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getTables(): SELECT (for TRIGGER) failed. " write_msg(NULL, "query to obtain list of triggers failed: %s", PQerrorMessage(g_conn));
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
ntups2 = PQntuples(res2); ntups2 = PQntuples(res2);
if (ntups2 != tblinfo[i].ntrig) if (ntups2 != tblinfo[i].ntrig)
{ {
fprintf(stderr, "getTables(): relation '%s': %d Triggers were expected, but got %d\n", write_msg(NULL, "expected %d triggers on table \"%s\" but found %d\n",
tblinfo[i].relname, tblinfo[i].ntrig, ntups2); tblinfo[i].ntrig, tblinfo[i].relname, ntups2);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
i_tgname = PQfnumber(res2, "tgname"); i_tgname = PQfnumber(res2, "tgname");
...@@ -2504,8 +2487,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2504,8 +2487,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
r = PQexec(g_conn, query->data); r = PQexec(g_conn, query->data);
if (!r || PQresultStatus(r) != PGRES_TUPLES_OK) if (!r || PQresultStatus(r) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getTables(): SELECT (funcname) failed for trigger %s. Explanation from backend: '%s'.\n", write_msg(NULL, "query to obtain procedure name for trigger \"%s\" failed: %s",
tgname, PQerrorMessage(g_conn)); tgname, PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2513,8 +2496,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2513,8 +2496,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
numFuncs = PQntuples(r); numFuncs = PQntuples(r);
if (numFuncs != 1) if (numFuncs != 1)
{ {
fprintf(stderr, "getTables(): SELECT (funcname) for trigger %s returned %d tuples. Expected 1.\n", write_msg(NULL, "query to obtain procedure name for trigger \"%s\" did not return exactly one result\n",
tgname, numFuncs); tgname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2576,9 +2559,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2576,9 +2559,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
if (PQgetisnull(res2, i2, i_tgconstrrelname)) if (PQgetisnull(res2, i2, i_tgconstrrelname))
{ {
fprintf(stderr, "getTables(): SELECT produced NULL referenced table name " write_msg(NULL, "query produced NULL referenced table name for trigger \"%s\" on table \"%s\" (oid was %s)\n",
"for trigger '%s' on relation '%s' (oid was %s).\n", tgname, tblinfo[i].relname, tgconstrrelid);
tgname, tblinfo[i].relname, tgconstrrelid);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2607,11 +2589,10 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -2607,11 +2589,10 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
p = strchr(p, '\\'); p = strchr(p, '\\');
if (p == NULL) if (p == NULL)
{ {
fprintf(stderr, "getTables(): relation '%s': bad argument " write_msg(NULL, "bad argument string (%s) for trigger \"%s\" on table \"%s\"\n",
"string (%s) for trigger '%s'\n", PQgetvalue(res2, i2, i_tgargs),
tblinfo[i].relname, tgname,
PQgetvalue(res2, i2, i_tgargs), tblinfo[i].relname);
tgname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
p++; p++;
...@@ -2696,8 +2677,8 @@ getInherits(int *numInherits) ...@@ -2696,8 +2677,8 @@ getInherits(int *numInherits)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getInherits(): SELECT failed. Explanation from backend: '%s'.\n", write_msg(NULL, "query to obtain inheritance relationships failed: %s",
PQerrorMessage(g_conn)); PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2799,8 +2780,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -2799,8 +2780,7 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getTableAttrs(): SELECT failed. " write_msg(NULL, "query to get table columns failed: %s", PQerrorMessage(g_conn));
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2829,12 +2809,11 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -2829,12 +2809,11 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
tblinfo[i].numParents = 0; tblinfo[i].numParents = 0;
for (j = 0; j < ntups; j++) for (j = 0; j < ntups; j++)
{ {
/* Sanity check on LOJ */ /* Sanity check on LOJ */
if (PQgetisnull(res, j, i_typname)) if (PQgetisnull(res, j, i_typname))
{ {
fprintf(stderr, "getTableAttrs(): SELECT produced NULL attribute type name for attr %d on table %s.\n", write_msg(NULL, "query produced NULL name for data type of column %d of table %s\n",
j, tblinfo[i].relname); j+1, tblinfo[i].relname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2868,8 +2847,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -2868,8 +2847,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
if (!res2 || if (!res2 ||
PQresultStatus(res2) != PGRES_TUPLES_OK) PQresultStatus(res2) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getTableAttrs(): SELECT (for DEFAULT) failed. " write_msg(NULL, "query to get column default value failed: %s",
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn)); PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2877,8 +2856,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -2877,8 +2856,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
numAttr = PQntuples(res2); numAttr = PQntuples(res2);
if (numAttr != 1) if (numAttr != 1)
{ {
fprintf(stderr, "getTableAttrs(): SELECT (for DEFAULT) for attr %s returned %d tuples. Expected 1.\n", write_msg(NULL, "query to get default value for column \"%s\" returned %d rows; expected 1\n",
tblinfo[i].attnames[j], numAttr); tblinfo[i].attnames[j], numAttr);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -2894,16 +2873,16 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -2894,16 +2873,16 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
/* /*
* getIndices * getIndexes
* read all the user-defined indices information * read all the user-defined indexes information
* from the system catalogs return them in the InhInfo* structure * from the system catalogs return them in the InhInfo* structure
* *
* numIndices is set to the number of indices read in * numIndexes is set to the number of indexes read in
* *
* *
*/ */
IndInfo * IndInfo *
getIndices(int *numIndices) getIndexes(int *numIndexes)
{ {
int i; int i;
PQExpBuffer query = createPQExpBuffer(); PQExpBuffer query = createPQExpBuffer();
...@@ -2923,10 +2902,10 @@ getIndices(int *numIndices) ...@@ -2923,10 +2902,10 @@ getIndices(int *numIndices)
int i_indisprimary; int i_indisprimary;
/* /*
* find all the user-defined indices. We do not handle partial * find all the user-defined indexes. We do not handle partial
* indices. * indexes.
* *
* Notice we skip indices on system classes * Notice we skip indexes on system classes
* *
* this is a 4-way join !! * this is a 4-way join !!
* *
...@@ -2950,14 +2929,13 @@ getIndices(int *numIndices) ...@@ -2950,14 +2929,13 @@ getIndices(int *numIndices)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "getIndices(): SELECT failed. " write_msg(NULL, "query to obtain list of indexes failed: %s", PQerrorMessage(g_conn));
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
ntups = PQntuples(res); ntups = PQntuples(res);
*numIndices = ntups; *numIndexes = ntups;
indinfo = (IndInfo *) malloc(ntups * sizeof(IndInfo)); indinfo = (IndInfo *) malloc(ntups * sizeof(IndInfo));
...@@ -3031,8 +3009,8 @@ dumpComment(Archive *fout, const char *target, const char *oid) ...@@ -3031,8 +3009,8 @@ dumpComment(Archive *fout, const char *target, const char *oid)
res = PQexec(g_conn, query->data); res = PQexec(g_conn, query->data);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "DumpComment: SELECT failed: '%s'.\n", write_msg(NULL, "query to get comment on oid %s failed: %s",
PQerrorMessage(g_conn)); oid, PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -3086,8 +3064,8 @@ dumpDBComment(Archive *fout) ...@@ -3086,8 +3064,8 @@ dumpDBComment(Archive *fout)
res = PQexec(g_conn, query->data); res = PQexec(g_conn, query->data);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "dumpDBComment: SELECT failed: '%s'.\n", write_msg(NULL, "query to get database oid failed: %s",
PQerrorMessage(g_conn)); PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -3186,8 +3164,8 @@ dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs, ...@@ -3186,8 +3164,8 @@ dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
elemType = findTypeByOid(tinfo, numTypes, tinfo[i].typelem, zeroAsOpaque); elemType = findTypeByOid(tinfo, numTypes, tinfo[i].typelem, zeroAsOpaque);
if (elemType == NULL) if (elemType == NULL)
{ {
fprintf(stderr, "Notice: array type %s - type for elements (oid %s) is not dumped.\n", write_msg(NULL, "Notice: array type %s - type for elements (oid %s) is not dumped.\n",
tinfo[i].typname, tinfo[i].typelem); tinfo[i].typname, tinfo[i].typelem);
resetPQExpBuffer(q); resetPQExpBuffer(q);
resetPQExpBuffer(delq); resetPQExpBuffer(delq);
continue; continue;
...@@ -3253,7 +3231,8 @@ dumpProcLangs(Archive *fout, FuncInfo *finfo, int numFuncs, ...@@ -3253,7 +3231,8 @@ dumpProcLangs(Archive *fout, FuncInfo *finfo, int numFuncs,
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "dumpProcLangs(): SELECT failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn)); write_msg(NULL, "query to obtain list of procedural languages failed: %s",
PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
ntups = PQntuples(res); ntups = PQntuples(res);
...@@ -3280,8 +3259,8 @@ dumpProcLangs(Archive *fout, FuncInfo *finfo, int numFuncs, ...@@ -3280,8 +3259,8 @@ dumpProcLangs(Archive *fout, FuncInfo *finfo, int numFuncs,
} }
if (fidx >= numFuncs) if (fidx >= numFuncs)
{ {
fprintf(stderr, "dumpProcLangs(): handler procedure for " write_msg(NULL, "handler procedure for procedural language %s not found\n",
"language %s not found\n", PQgetvalue(res, i, i_lanname)); PQgetvalue(res, i, i_lanname));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -3370,14 +3349,14 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i, ...@@ -3370,14 +3349,14 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "dumpOneFunc(): SELECT for procedural language failed. Explanation from backend: '%s'.\n", PQerrorMessage(g_conn)); write_msg(NULL, "query to get name of procedural language failed: %s", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
nlangs = PQntuples(res); nlangs = PQntuples(res);
if (nlangs != 1) if (nlangs != 1)
{ {
fprintf(stderr, "dumpOneFunc(): procedural language for function %s not found\n", finfo[i].proname); write_msg(NULL, "procedural language for function %s not found\n", finfo[i].proname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -3419,11 +3398,11 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i, ...@@ -3419,11 +3398,11 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j], zeroAsOpaque); typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j], zeroAsOpaque);
if (typname == NULL) if (typname == NULL)
{ {
fprintf(stderr, "Notice: function \"%s\" is not dumped.\n", write_msg(NULL, "Notice: function \"%s\" not dumped\n",
finfo[i].proname); finfo[i].proname);
fprintf(stderr, "Reason: the %d th argument type name (oid %s) not found.\n", write_msg(NULL, "Reason: data type name of argument %d (oid %s) not found\n",
j, finfo[i].argtypes[j]); j, finfo[i].argtypes[j]);
resetPQExpBuffer(q); resetPQExpBuffer(q);
resetPQExpBuffer(fn); resetPQExpBuffer(fn);
resetPQExpBuffer(delqry); resetPQExpBuffer(delqry);
...@@ -3448,11 +3427,11 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i, ...@@ -3448,11 +3427,11 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
if (rettypename == NULL) if (rettypename == NULL)
{ {
fprintf(stderr, "Notice: function \"%s\" is not dumped.\n", write_msg(NULL, "Notice: function \"%s\" not dumped\n",
finfo[i].proname); finfo[i].proname);
fprintf(stderr, "Reason: return type name (oid %s) not found.\n", write_msg(NULL, "Reason: name of return data type (oid %s) not found\n",
finfo[i].prorettype); finfo[i].prorettype);
resetPQExpBuffer(q); resetPQExpBuffer(q);
resetPQExpBuffer(fn); resetPQExpBuffer(fn);
resetPQExpBuffer(delqry); resetPQExpBuffer(delqry);
...@@ -3988,7 +3967,7 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q) ...@@ -3988,7 +3967,7 @@ _dumpTableAttr70(Archive *fout, TableInfo *tblinfo, int i, int j, PQExpBuffer q)
void void
dumpTables(Archive *fout, TableInfo *tblinfo, int numTables, dumpTables(Archive *fout, TableInfo *tblinfo, 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 aclsSkip, const bool oids, const bool aclsSkip, const bool oids,
...@@ -4113,16 +4092,16 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables, ...@@ -4113,16 +4092,16 @@ dumpTables(Archive *fout, TableInfo *tblinfo, int numTables,
PQExpBuffer consDef; PQExpBuffer consDef;
/* Find the corresponding index */ /* Find the corresponding index */
for (k = 0; k < numIndices; k++) for (k = 0; k < numIndexes; k++)
{ {
if (strcmp(indinfo[k].oid, tblinfo[i].pkIndexOid) == 0) if (strcmp(indinfo[k].oid, tblinfo[i].pkIndexOid) == 0)
break; break;
} }
if (k >= numIndices) if (k >= numIndexes)
{ {
fprintf(stderr, "dumpTables(): failed sanity check, could not find index (%s) for PK constraint\n", write_msg(NULL, "dumpTables(): failed sanity check, could not find index (%s) for primary key constraint\n",
tblinfo[i].pkIndexOid); tblinfo[i].pkIndexOid);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -4245,18 +4224,18 @@ getAttrName(int attrnum, TableInfo *tblInfo) ...@@ -4245,18 +4224,18 @@ getAttrName(int attrnum, TableInfo *tblInfo)
case TableOidAttributeNumber: case TableOidAttributeNumber:
return "tableoid"; return "tableoid";
} }
fprintf(stderr, "getAttrName(): Invalid attribute number %d for table %s\n", write_msg(NULL, "getAttrName(): invalid column number %d for table %s\n",
attrnum, tblInfo->relname); attrnum, tblInfo->relname);
exit_nicely(g_conn); exit_nicely(g_conn);
return NULL; /* keep compiler quiet */ return NULL; /* keep compiler quiet */
} }
/* /*
* dumpIndices: * dumpIndexes:
* write out to fout all the user-define indices * write out to fout all the user-define indexes
*/ */
void void
dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices, dumpIndexes(Archive *fout, IndInfo *indinfo, int numIndexes,
TableInfo *tblinfo, int numTables, const char *tablename) TableInfo *tblinfo, int numTables, const char *tablename)
{ {
int i, int i,
...@@ -4275,14 +4254,14 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices, ...@@ -4275,14 +4254,14 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices,
id2 = createPQExpBuffer(); id2 = createPQExpBuffer();
PGresult *res; PGresult *res;
for (i = 0; i < numIndices; i++) for (i = 0; i < numIndexes; i++)
{ {
tableInd = findTableByName(tblinfo, numTables, tableInd = findTableByName(tblinfo, numTables,
indinfo[i].indrelname); indinfo[i].indrelname);
if (tableInd < 0) if (tableInd < 0)
{ {
fprintf(stderr, "dumpIndices(): failed sanity check, table %s was not found\n", write_msg(NULL, "dumpIndexes(): failed sanity check, table %s was not found\n",
indinfo[i].indrelname); indinfo[i].indrelname);
exit(1); exit(1);
} }
...@@ -4335,8 +4314,8 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices, ...@@ -4335,8 +4314,8 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices,
res = PQexec(g_conn, q->data); res = PQexec(g_conn, q->data);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "dumpIndices(): SELECT (funcname) failed. " write_msg(NULL, "query to get function name of oid %s failed: %s",
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn)); indinfo[i].indproc, PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -4344,8 +4323,8 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices, ...@@ -4344,8 +4323,8 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices,
numFuncs = PQntuples(res); numFuncs = PQntuples(res);
if (numFuncs != 1) if (numFuncs != 1)
{ {
fprintf(stderr, "dumpIndices(): SELECT (funcname) for index %s returned %d tuples. Expected 1.\n", write_msg(NULL, "query to get function name of oid %s returned %d rows; expected 1\n",
indinfo[i].indrelname, numFuncs); indinfo[i].indproc, numFuncs);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -4369,8 +4348,8 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices, ...@@ -4369,8 +4348,8 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices,
res = PQexec(g_conn, q->data); res = PQexec(g_conn, q->data);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "dumpIndices(): SELECT (classname) failed. " write_msg(NULL, "query to get operator class name of oid %u failed: %s",
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn)); indclass, PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -4378,8 +4357,8 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices, ...@@ -4378,8 +4357,8 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices,
numRows = PQntuples(res); numRows = PQntuples(res);
if (numRows != 1) if (numRows != 1)
{ {
fprintf(stderr, "dumpIndices(): SELECT (classname) for index %s returned %d tuples. Expected 1.\n", write_msg(NULL, "query to get operator class name of oid %u returned %d rows; expected 1\n",
indinfo[i].indrelname, numRows); indclass, numRows);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -4389,8 +4368,8 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices, ...@@ -4389,8 +4368,8 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices,
if (funcname && nclass != 1) if (funcname && nclass != 1)
{ {
fprintf(stderr, "dumpIndices(): Must be exactly one OpClass " write_msg(NULL, "There must be exactly one OpClass for functional index \"%s\".\n",
"for functional index %s\n", indinfo[i].indexrelname); indinfo[i].indexrelname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -4413,8 +4392,7 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices, ...@@ -4413,8 +4392,7 @@ dumpIndices(Archive *fout, IndInfo *indinfo, int numIndices,
{ {
if (k >= nclass) if (k >= nclass)
{ {
fprintf(stderr, "dumpIndices(): OpClass not found for " write_msg(NULL, "no operator class found for column \"%s\" of index \"%s\"\n",
"attribute '%s' of index '%s'\n",
attname, indinfo[i].indexrelname); attname, indinfo[i].indexrelname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -4551,14 +4529,12 @@ setMaxOid(Archive *fout) ...@@ -4551,14 +4529,12 @@ setMaxOid(Archive *fout)
PGresult *res; PGresult *res;
Oid max_oid; Oid max_oid;
char sql[1024]; char sql[1024];
int pos;
res = PQexec(g_conn, "CREATE TEMPORARY TABLE pgdump_oid (dummy int4)"); res = PQexec(g_conn, "CREATE TEMPORARY TABLE pgdump_oid (dummy int4)");
if (!res || if (!res ||
PQresultStatus(res) != PGRES_COMMAND_OK) PQresultStatus(res) != PGRES_COMMAND_OK)
{ {
fprintf(stderr, "Can not create pgdump_oid table. " write_msg(NULL, "could not create pgdump_oid table: %s", PQerrorMessage(g_conn));
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
PQclear(res); PQclear(res);
...@@ -4566,14 +4542,13 @@ setMaxOid(Archive *fout) ...@@ -4566,14 +4542,13 @@ setMaxOid(Archive *fout)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_COMMAND_OK) PQresultStatus(res) != PGRES_COMMAND_OK)
{ {
fprintf(stderr, "Can not insert into pgdump_oid table. " write_msg(NULL, "could not insert into pgdump_oid table: %s", PQerrorMessage(g_conn));
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
max_oid = atol(PQoidStatus(res)); max_oid = atol(PQoidStatus(res));
if (max_oid == 0) if (max_oid == 0)
{ {
fprintf(stderr, "Invalid max id in setMaxOid\n"); write_msg(NULL, "inserted invalid oid\n");
exit_nicely(g_conn); exit_nicely(g_conn);
} }
PQclear(res); PQclear(res);
...@@ -4581,19 +4556,20 @@ setMaxOid(Archive *fout) ...@@ -4581,19 +4556,20 @@ setMaxOid(Archive *fout)
if (!res || if (!res ||
PQresultStatus(res) != PGRES_COMMAND_OK) PQresultStatus(res) != PGRES_COMMAND_OK)
{ {
fprintf(stderr, "Can not drop pgdump_oid table. " write_msg(NULL, "could not drop pgdump_oid table: %s", PQerrorMessage(g_conn));
"Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
PQclear(res); PQclear(res);
if (g_verbose) if (g_verbose)
fprintf(stderr, "%s maximum system oid is %u %s\n", fprintf(stderr, "%s maximum system oid is %u %s\n",
g_comment_start, max_oid, g_comment_end); g_comment_start, max_oid, g_comment_end);
pos = snprintf(sql, 1024, "CREATE TEMPORARY TABLE pgdump_oid (dummy int4);\n"); snprintf(sql, 1024,
pos = pos + snprintf(sql + pos, 1024 - pos, "COPY pgdump_oid WITH OIDS FROM stdin;\n"); "CREATE TEMPORARY TABLE pgdump_oid (dummy int4);\n"
pos = pos + snprintf(sql + pos, 1024 - pos, "%-d\t0\n", max_oid); "COPY pgdump_oid WITH OIDS FROM stdin;\n"
pos = pos + snprintf(sql + pos, 1024 - pos, "\\.\n"); "%-d\t0\n"
pos = pos + snprintf(sql + pos, 1024 - pos, "DROP TABLE pgdump_oid;\n"); "\\.\n"
"DROP TABLE pgdump_oid;\n",
max_oid);
ArchiveEntry(fout, "0", "Max OID", "<Init>", NULL, sql, "", "", "", NULL, NULL); ArchiveEntry(fout, "0", "Max OID", "<Init>", NULL, sql, "", "", "", NULL, NULL);
} }
...@@ -4620,21 +4596,18 @@ findLastBuiltinOid_V71(const char *dbname) ...@@ -4620,21 +4596,18 @@ findLastBuiltinOid_V71(const char *dbname)
if (res == NULL || if (res == NULL ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "pg_dump: error in finding the last system OID. "); write_msg(NULL, "error in finding the last system oid: %s", PQerrorMessage(g_conn));
fprintf(stderr, "Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
ntups = PQntuples(res); ntups = PQntuples(res);
if (ntups < 1) if (ntups < 1)
{ {
fprintf(stderr, "pg_dump: couldn't find the pg_database entry.\n"); write_msg(NULL, "missing pg_database entry for this database\n");
fprintf(stderr, "There is no entry in the 'pg_database' table for this database.\n");
exit_nicely(g_conn); exit_nicely(g_conn);
} }
if (ntups > 1) if (ntups > 1)
{ {
fprintf(stderr, "pg_dump: found more than one matching database.\n"); write_msg(NULL, "found more than one pg_database entry for this database\n");
fprintf(stderr, "There is more than one entry for this database in the 'pg_database' table\n");
exit_nicely(g_conn); exit_nicely(g_conn);
} }
last_oid = atooid(PQgetvalue(res, 0, PQfnumber(res, "datlastsysoid"))); last_oid = atooid(PQgetvalue(res, 0, PQfnumber(res, "datlastsysoid")));
...@@ -4661,21 +4634,18 @@ findLastBuiltinOid_V70(void) ...@@ -4661,21 +4634,18 @@ findLastBuiltinOid_V70(void)
if (res == NULL || if (res == NULL ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "pg_dump error in finding the template1 database."); write_msg(NULL, "error in finding the template1 database: %s", PQerrorMessage(g_conn));
fprintf(stderr, "Explanation from backend: '%s'.\n", PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
ntups = PQntuples(res); ntups = PQntuples(res);
if (ntups < 1) if (ntups < 1)
{ {
fprintf(stderr, "pg_dump: couldn't find the template1 database.\n"); write_msg(NULL, "could not find template1 database entry in the pg_database table\n");
fprintf(stderr, "There is no 'template1' entry in the 'pg_database' table.\n");
exit_nicely(g_conn); exit_nicely(g_conn);
} }
if (ntups > 1) if (ntups > 1)
{ {
fprintf(stderr, "pg_dump: found more than one template1 database.\n"); write_msg(NULL, "found more than one template1 database entry in the pg_database table\n");
fprintf(stderr, "There is more than one 'template1' entry in the 'pg_database' table\n");
exit_nicely(g_conn); exit_nicely(g_conn);
} }
last_oid = atooid(PQgetvalue(res, 0, PQfnumber(res, "oid"))); last_oid = atooid(PQgetvalue(res, 0, PQfnumber(res, "oid")));
...@@ -4706,23 +4676,21 @@ dumpSequence(Archive *fout, TableInfo tbinfo, const bool schemaOnly, const bool ...@@ -4706,23 +4676,21 @@ dumpSequence(Archive *fout, TableInfo tbinfo, const bool schemaOnly, const bool
res = PQexec(g_conn, query->data); res = PQexec(g_conn, query->data);
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "dumpSequence(%s): SELECT failed. " write_msg(NULL, "query to get data of sequence \"%s\" failed: %s", tbinfo.relname, PQerrorMessage(g_conn));
"Explanation from backend: '%s'.\n", tbinfo.relname, PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
if (PQntuples(res) != 1) if (PQntuples(res) != 1)
{ {
fprintf(stderr, "dumpSequence(%s): %d (!= 1) tuples returned by SELECT\n", write_msg(NULL, "query to get data of sequence \"%s\" returned %d rows (expected 1)\n",
tbinfo.relname, PQntuples(res)); tbinfo.relname, PQntuples(res));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
if (strcmp(PQgetvalue(res, 0, 0), tbinfo.relname) != 0) if (strcmp(PQgetvalue(res, 0, 0), tbinfo.relname) != 0)
{ {
fprintf(stderr, "dumpSequence(%s): different sequence name " write_msg(NULL, "query to get data of sequence \"%s\" returned name \"%s\"\n",
"returned by SELECT: %s\n", tbinfo.relname, PQgetvalue(res, 0, 0));
tbinfo.relname, PQgetvalue(res, 0, 0));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
...@@ -4864,8 +4832,8 @@ dumpRules(Archive *fout, const char *tablename, ...@@ -4864,8 +4832,8 @@ dumpRules(Archive *fout, const char *tablename,
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
{ {
fprintf(stderr, "dumpRules(): SELECT failed for rules associated with table \"%s\".\n\tExplanation from backend: '%s'.\n", write_msg(NULL, "query to get rules associated with table \"%s\" failed: %s",
tblinfo[t].relname, PQerrorMessage(g_conn)); tblinfo[t].relname, PQerrorMessage(g_conn));
exit_nicely(g_conn); exit_nicely(g_conn);
} }
......
...@@ -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();
progname = argv[0]; if (!strrchr(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,75 +345,78 @@ main(int argc, char **argv) ...@@ -335,75 +345,78 @@ 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(
"Usage:\n %s [options] [file]\n\n" "%s restores a PostgreSQL database from an archive created by pg_dump.\n\n"
"Options:\n", "Usage:\n %s [options] [file]\n\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"
" -d, --dbname=NAME specify database name\n" " -d, --dbname=NAME specify database name\n"
" -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"
" -N, --orig-order restore in original dump order\n" " -N, --orig-order restore in original dump order\n"
" -o, --oid-order restore in oid order\n" " -o, --oid-order restore in oid order\n"
" -O, --no-owner do not reconnect to database to match\n" " -O, --no-owner do not reconnect to database to match\n"
" object owner\n" " object owner\n"
" -p, --port PORT server port number\n" " -p, --port PORT server port number\n"
" -P, --function[=NAME] restore functions or named function\n" " -P, --function[=NAME] restore functions or named function\n"
" -r, --rearrange rearrange output to put indexes etc. at end\n" " -r, --rearrange rearrange output to put indexes etc. at end\n"
" -R, --no-reconnect disallow ALL reconnections to the database\n" " -R, --no-reconnect disallow ALL reconnections to the database\n"
" -s, --schema-only restore only the schema, no data\n" " -s, --schema-only restore only the schema, no data\n"
" -S, --superuser=NAME specify the superuser user name to use for\n" " -S, --superuser=NAME specify the superuser user name to use for\n"
" disabling triggers\n" " disabling triggers\n"
" -t, --table[=TABLE] restore this table only\n" " -t, --table[=TABLE] restore this table only\n"
" -T, --trigger[=NAME] restore triggers or named trigger\n" " -T, --trigger[=NAME] restore triggers or named trigger\n"
" -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(
" -a restore only the data, no schema\n" puts(gettext(
" -c clean (drop) schema prior to create\n" " -a restore only the data, no schema\n"
" -C output commands to create the database\n" " -c clean (drop) schema prior to create\n"
" -d NAME specify database name\n" " -C output commands to create the database\n"
" -f FILENAME script output file name\n" " -d NAME specify database name\n"
" -F {c|f} specify backup file format\n" " -f FILENAME script output file name\n"
" -h HOSTNAME server host name\n" " -F {c|f} specify backup file format\n"
" -i NAME restore indices or named index\n" " -h HOSTNAME server host name\n"
" -l dump summarized TOC for this file\n" " -i NAME restore indexes or named index\n"
" -L FILENAME use specified table of contents for ordering\n" " -l dump summarized TOC for this file\n"
" output from this file\n" " -L FILENAME use specified table of contents for ordering\n"
" -N restore in original dump order\n" " output from this file\n"
" -o restore in oid order\n" " -N restore in original dump order\n"
" -O do not output reconnect to database to match\n" " -o restore in oid order\n"
" object owner\n" " -O do not output reconnect to database to match\n"
" -p PORT server port number\n" " object owner\n"
" -P NAME restore functions or named function\n" " -p PORT server port number\n"
" -r rearrange output to put indexes etc at end\n" " -P NAME restore functions or named function\n"
" -R disallow ALL reconnections to the database\n" " -r rearrange output to put indexes etc at end\n"
" -s restore only the schema, no data\n" " -R disallow ALL reconnections to the database\n"
" -S NAME specify the superuser user name to use for\n" " -s restore only the schema, no data\n"
" disabling triggers\n" " -S NAME specify the superuser user name to use for\n"
" -t NAME restore this table only\n" " disabling triggers\n"
" -T NAME restore triggers or named trigger\n" " -t NAME restore this table only\n"
" -U NAME connect as specified database user\n" " -T NAME restore triggers or named trigger\n"
" -v verbose\n" " -U NAME connect as specified database user\n"
" -W force password prompt (should happen automatically)\n" " -v verbose\n"
" -x skip dumping of ACLs (grant/revoke)\n"); " -W force password prompt (should happen automatically)\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