summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2009-08-07 20:16:41 +0000
committerTom Lane2009-08-07 20:16:41 +0000
commit769222d0c7959667bc4cd408f25b1524c3962cba (patch)
tree93efcff08fa47df758c07ce377ec4b3c62226e9e
parentf5c2de263ec0fe865bc4d69b49fb4004306895b9 (diff)
Try to defend against the possibility that libpq is still in COPY_IN state
when we reach the post-COPY "pump it dry" error recovery code that was added 2006-11-24. Per a report from Neil Best, there is at least one code path in which this occurs, leading to an infinite loop in code that's supposed to be making it more robust not less so. A reasonable response seems to be to call PQputCopyEnd() again, so let's try that. Back-patch to all versions that contain the cleanup loop.
-rw-r--r--src/bin/psql/copy.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 572dcd1b717..402c401399e 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.55.4.1 2006/11/24 23:07:01 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.55.4.2 2009/08/07 20:16:41 tgl Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
@@ -577,6 +577,9 @@ do_copy(const char *args)
success = false;
psql_error("\\copy: unexpected response (%d)\n",
PQresultStatus(result));
+ /* if still in COPY IN state, try to get out of it */
+ if (PQresultStatus(result) == PGRES_COPY_IN)
+ PQputCopyEnd(pset.db, gettext("trying to exit copy mode"));
PQclear(result);
}