Fix pg_dump/pg_restore's ExecuteSqlCommand() to behave suitably if PQexec
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 16 Aug 2008 02:25:38 +0000 (02:25 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 16 Aug 2008 02:25:38 +0000 (02:25 +0000)
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.

src/bin/pg_dump/pg_backup_db.c

index a2821b9786eed2582c266a97c5bfb114e45bfb19..7db2dcf23b07ce400720341bffed34ff7dbf4db6 100644 (file)
@@ -303,8 +303,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)
        {
@@ -317,7 +315,7 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
                }
                else
                        die_horribly(AH, modulename, "%s: %s",
-                                                desc, PQerrorMessage(AH->connection));
+                                                desc, PQerrorMessage(conn));
        }
 
        PQclear(res);