*** ./src/bin/pg_dump/pg_backup.h.orig Wed Mar 24 17:19:43 2004 --- ./src/bin/pg_dump/pg_backup.h Fri Apr 9 18:39:50 2004 *************** *** 57,62 **** --- 57,67 ---- int remoteVersion; int minRemoteVersion; int maxRemoteVersion; + + /* error handling */ + bool die_on_errors; /* whether to die on sql errors... */ + int n_errors; /* number of errors (if no die) */ + /* The rest is private */ } Archive; *** ./src/bin/pg_dump/pg_backup_archiver.c.orig Wed Mar 24 17:19:43 2004 --- ./src/bin/pg_dump/pg_backup_archiver.c Fri Apr 9 19:10:26 2004 *************** *** 1197,1202 **** --- 1197,1218 ---- va_end(ap); } + /* on some error, we may decide to go on... */ + void + warn_or_die_horribly(ArchiveHandle *AH, + const char *modulename, const char *fmt, ...) + { + va_list ap; + va_start(ap, fmt); + if (AH->public.die_on_errors) + _die_horribly(AH, modulename, fmt, ap); + else + { + _write_msg(modulename, fmt, ap); + AH->public.n_errors++; + } + va_end(ap); + } static void _moveAfter(ArchiveHandle *AH, TocEntry *pos, TocEntry *te) *************** *** 1651,1656 **** --- 1667,1676 ---- die_horribly(AH, modulename, "unrecognized file format \"%d\"\n", fmt); } + /* sql error handling */ + AH->public.die_on_errors = true; + AH->public.n_errors = 0; + return AH; } *************** *** 2042,2049 **** res = PQexec(AH->connection, cmd->data); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) ! die_horribly(AH, modulename, "could not set default_with_oids: %s", ! PQerrorMessage(AH->connection)); PQclear(res); } --- 2062,2070 ---- res = PQexec(AH->connection, cmd->data); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) ! warn_or_die_horribly(AH, modulename, ! "could not set default_with_oids: %s", ! PQerrorMessage(AH->connection)); PQclear(res); } *************** *** 2181,2188 **** res = PQexec(AH->connection, qry->data); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) ! die_horribly(AH, modulename, "could not set search_path to \"%s\": %s", ! schemaName, PQerrorMessage(AH->connection)); PQclear(res); } --- 2202,2210 ---- res = PQexec(AH->connection, qry->data); if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) ! warn_or_die_horribly(AH, modulename, ! "could not set search_path to \"%s\": %s", ! schemaName, PQerrorMessage(AH->connection)); PQclear(res); } *** ./src/bin/pg_dump/pg_backup_archiver.h.orig Wed Mar 24 17:19:43 2004 --- ./src/bin/pg_dump/pg_backup_archiver.h Fri Apr 9 18:55:50 2004 *************** *** 281,286 **** --- 281,287 ---- extern const char *progname; extern void die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(printf, 3, 4))); + extern void warn_or_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); *** ./src/bin/pg_dump/pg_backup_db.c.orig Wed Mar 3 22:28:54 2004 --- ./src/bin/pg_dump/pg_backup_db.c Fri Apr 9 19:10:42 2004 *************** *** 316,323 **** AH->pgCopyIn = 1; } else ! die_horribly(AH, modulename, "%s: %s", ! desc, PQerrorMessage(AH->connection)); } PQclear(res); --- 316,323 ---- AH->pgCopyIn = 1; } else ! warn_or_die_horribly(AH, modulename, "%s: %s", ! desc, PQerrorMessage(AH->connection)); } PQclear(res); *** ./src/bin/pg_dump/pg_restore.c.orig Sat Dec 6 04:00:16 2003 --- ./src/bin/pg_dump/pg_restore.c Fri Apr 9 19:17:22 2004 *************** *** 322,327 **** --- 322,328 ---- /* Let the archiver know how noisy to be */ AH->verbose = opts->verbose; + AH->die_on_errors = false; if (opts->tocFile) SortTocFromFile(AH, opts); *************** *** 331,336 **** --- 332,343 ---- else RestoreArchive(AH, opts); + if (AH->n_errors) + /* translator: %s stands for "error" or "errors" */ + fprintf(stderr, _("warning: %d %s ignored on restore\n"), + /* translator: in sentence warning: 123 errors ignored... */ + AH->n_errors, AH->n_errors>1? _("errors"): _("error")); + CloseArchive(AH); return 0;