aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-08-07 20:16:22 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-08-07 20:16:22 +0000
commitd9a00ebbbac84b417b616b5a8eaaa9331736f2c8 (patch)
tree4596b4120953b0e5cdf930d2b16e9745050f52ae
parentb1fc543b5d864858f0c21f95e814c9964c9322d4 (diff)
downloadpostgresql-d9a00ebbbac84b417b616b5a8eaaa9331736f2c8.tar.gz
postgresql-d9a00ebbbac84b417b616b5a8eaaa9331736f2c8.zip
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 9933b02fb33..4f5fe13a2ed 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.77 2008/01/01 19:45:55 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.77.2.1 2009/08/07 20:16:22 tgl Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
@@ -563,6 +563,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, _("trying to exit copy mode"));
PQclear(result);
}