aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-08-16 02:25:30 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-08-16 02:25:30 +0000
commitaf3f5293ef64a3f981e8b2e736b5f18b0501ef9e (patch)
tree0a7c9b2c0a9dbb61fc357e2705a53bdffe7def1a
parent1848ea720044dcff70d5eb9e4c90d533e0cdded6 (diff)
downloadpostgresql-af3f5293ef64a3f981e8b2e736b5f18b0501ef9e.tar.gz
postgresql-af3f5293ef64a3f981e8b2e736b5f18b0501ef9e.zip
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.
-rw-r--r--src/bin/pg_dump/pg_backup_db.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c
index b417128111f..b4bf2820beb 100644
--- a/src/bin/pg_dump/pg_backup_db.c
+++ b/src/bin/pg_dump/pg_backup_db.c
@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.61.4.3 2006/02/09 18:28:43 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.61.4.4 2008/08/16 02:25:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -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);
}
}