summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2009-08-07 20:16:11 +0000
committerTom Lane2009-08-07 20:16:11 +0000
commit46cd3b380943e3db817802e757434a26b42e5091 (patch)
treee24c2ef543fdf0dfef7322846929c42676802e58
parent22fef1891e5db147d5691140f719a2fafd71ca35 (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.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index 2c88520b87..97a1cb1c44 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -571,6 +571,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);
}