Commit 7ab0ceb8 authored by Bryan Henderson's avatar Bryan Henderson

Check that PQendcopy succeeded. Issue error message if not.

parent 765dd2a4
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.20 1996/12/28 22:44:58 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.21 1996/12/30 23:05:16 bryanh Exp $
* *
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
* *
...@@ -161,8 +161,8 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids) { ...@@ -161,8 +161,8 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids) {
} else { } else {
copydone = false; copydone = false;
while (!copydone) { while (!copydone) {
ret = PQgetline(res->conn, copybuf, COPYBUFSIZ); ret = PQgetline(res->conn, copybuf, COPYBUFSIZ);
if (copybuf[0] == '\\' && if (copybuf[0] == '\\' &&
copybuf[1] == '.' && copybuf[1] == '.' &&
copybuf[2] == '\0') { copybuf[2] == '\0') {
...@@ -184,7 +184,16 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids) { ...@@ -184,7 +184,16 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids) {
fprintf(fout, "\\.\n"); fprintf(fout, "\\.\n");
} }
PQclear(res); PQclear(res);
PQendcopy(res->conn); ret = PQendcopy(res->conn);
if (ret != 0) {
fprintf(stderr, "SQL query to dump the contents of Table %s "
"did not execute correctly. After we read all the "
"table contents from the backend, PQendcopy() failed. "
"Explanation from backend: '%s'.\n"
"The query was: '%s'.\n",
classname, PQerrorMessage(g_conn), query);
exit_nicely(g_conn);
}
} }
} }
...@@ -287,8 +296,7 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE *fout, ...@@ -287,8 +296,7 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE *fout,
int i; int i;
char *all_only; char *all_only;
if (onlytable == NULL) if (onlytable == NULL) all_only = "all";
all_only = "all";
else all_only = "one"; else all_only = "one";
if (g_verbose) if (g_verbose)
...@@ -297,7 +305,7 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE *fout, ...@@ -297,7 +305,7 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE *fout,
for(i = 0; i < numTables; i++) { for(i = 0; i < numTables; i++) {
const char *classname = tblinfo[i].relname; const char *classname = tblinfo[i].relname;
if (!onlytable || (!strcmp(classname,onlytable))) { if (!onlytable || (!strcmp(classname,onlytable))) {
if (g_verbose) if (g_verbose)
fprintf(stderr, "%s dumping out the contents of Table %s %s\n", fprintf(stderr, "%s dumping out the contents of Table %s %s\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment