*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.93 2004/08/20 04:20:22 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.94 2004/08/20 20:00:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool defnDumped;
AH->ropt = ropt;
+ AH->stage = STAGE_INITIALIZING;
/*
* Check for nonsensical option combinations.
ConnectDatabase(AHX, ropt->dbname,
ropt->pghost, ropt->pgport, ropt->username,
ropt->requirePassword, ropt->ignoreVersion);
+ /* If we're talking to the DB directly, don't send comments since they obscure SQL when displaying errors */
+ AH->noTocComments = 1;
}
/*
*/
_doSetFixedOutputState(AH);
+ AH->stage = STAGE_PROCESSING;
+
/*
* Drop the items at the start, in reverse order
*/
if (ropt->dropSchema)
{
te = AH->toc->prev;
+ AH->currentTE = te;
+
while (te != AH->toc)
{
reqs = _tocEntryRequired(te, ropt, false);
te = AH->toc->next;
while (te != AH->toc)
{
+ AH->currentTE = te;
+
/* Work out what, if anything, we want from this entry */
reqs = _tocEntryRequired(te, ropt, false);
te = AH->toc->next;
while (te != AH->toc)
{
+ AH->currentTE = te;
+
/* Work out what, if anything, we want from this entry */
reqs = _tocEntryRequired(te, ropt, true);
/*
* Clean up & we're done.
*/
+ AH->stage = STAGE_FINALIZING;
+
if (ropt->filename || ropt->compression)
ResetOutput(AH, sav);
const char *modulename, const char *fmt, ...)
{
va_list ap;
+
+ switch(AH->stage) {
+
+ case STAGE_NONE:
+ /* Do nothing special */
+ break;
+
+ case STAGE_INITIALIZING:
+ if (AH->stage != AH->lastErrorStage) {
+ write_msg(modulename, "Error while INITIALIZING:\n");
+ }
+ break;
+
+ case STAGE_PROCESSING:
+ if (AH->stage != AH->lastErrorStage) {
+ write_msg(modulename, "Error while PROCESSING TOC:\n");
+ }
+ break;
+
+ case STAGE_FINALIZING:
+ if (AH->stage != AH->lastErrorStage) {
+ write_msg(modulename, "Error while FINALIZING:\n");
+ }
+ break;
+ }
+ if (AH->currentTE != NULL && AH->currentTE != AH->lastErrorTE) {
+ write_msg(modulename, "Error from TOC Entry %d; %u %u %s %s %s\n", AH->currentTE->dumpId,
+ AH->currentTE->catalogId.tableoid, AH->currentTE->catalogId.oid,
+ AH->currentTE->desc, AH->currentTE->tag, AH->currentTE->owner);
+ }
+ AH->lastErrorStage = AH->stage;
+ AH->lastErrorTE = AH->currentTE;
+
va_start(ap, fmt);
if (AH->public.exit_on_error)
{
/* Make sure function checking is disabled */
ahprintf(AH, "SET check_function_bodies = false;\n");
+ /* Avoid annoying notices etc */
+ ahprintf(AH, "SET client_min_messages = warning;\n");
+
ahprintf(AH, "\n");
}
return;
}
+ if (AH->noTocComments)
+ return;
+
/*
* Avoid dumping the public schema, as it will already be created ...
* unless we are using --clean mode, in which case it's been deleted
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.54 2004/08/20 16:07:15 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.55 2004/08/20 20:00:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
static int _isIdentChar(char c);
static int _isDQChar(char c, int atStart);
+#define DB_MAX_ERR_STMT 128
+
static int
_parse_version(ArchiveHandle *AH, const char *versionString)
{
_executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
{
PGresult *res;
+ char errStmt[DB_MAX_ERR_STMT];
/* fprintf(stderr, "Executing: '%s'\n\n", qry->data); */
res = PQexec(conn, qry->data);
AH->pgCopyIn = 1;
}
else
- warn_or_die_horribly(AH, modulename, "%s: %s",
- desc, PQerrorMessage(AH->connection));
+ {
+ strncpy(errStmt, qry->data, DB_MAX_ERR_STMT);
+ if (errStmt[DB_MAX_ERR_STMT-1] != '\0') {
+ errStmt[DB_MAX_ERR_STMT-4] = '.';
+ errStmt[DB_MAX_ERR_STMT-3] = '.';
+ errStmt[DB_MAX_ERR_STMT-2] = '.';
+ errStmt[DB_MAX_ERR_STMT-1] = '\0';
+ }
+ warn_or_die_horribly(AH, modulename, "%s: %s Command was: %s\n",
+ desc, PQerrorMessage(AH->connection),
+ errStmt);
+ }
}
PQclear(res);