From: Tom Lane Date: Sat, 16 Aug 2008 02:25:30 +0000 (+0000) Subject: Fix pg_dump/pg_restore's ExecuteSqlCommand() to behave suitably if PQexec X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=0f68f18bacf6e52160eeb1249f1d259fd6f76357;p=users%2Fbernd%2Fpostgres.git Fix pg_dump/pg_restore's ExecuteSqlCommand() to behave suitably if PQexec returns NULL instead of a PGresult. The former coding would fail, which is OK, but it neglected to give you the PQerrorMessage that might tell you why. In the oldest branches, there was another problem: it'd sometimes report PQerrorMessage from the wrong connection. --- diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c index 67a481a56e..65c0a6d834 100644 --- a/src/bin/pg_dump/pg_backup_db.c +++ b/src/bin/pg_dump/pg_backup_db.c @@ -309,8 +309,6 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc) /* fprintf(stderr, "Executing: '%s'\n\n", qry->data); */ res = PQexec(conn, qry->data); - if (!res) - die_horribly(AH, modulename, "%s: no result from server\n", desc); if (PQresultStatus(res) != PGRES_COMMAND_OK && PQresultStatus(res) != PGRES_TUPLES_OK) { @@ -332,8 +330,7 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc) errStmt[DB_MAX_ERR_STMT - 1] = '\0'; } warn_or_die_horribly(AH, modulename, "%s: %s Command was: %s\n", - desc, PQerrorMessage(AH->connection), - errStmt); + desc, PQerrorMessage(conn), errStmt); } }