diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-07 20:16:11 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-07 20:16:11 +0000 |
commit | e605fbcccdf4705de4afa7e23be5b8222e1cb00d (patch) | |
tree | 4d668691a943c8f559ec09bb00972bbb68563953 /src | |
parent | 87740caa01956db89afdd2f5934d550c939d3c57 (diff) | |
download | postgresql-e605fbcccdf4705de4afa7e23be5b8222e1cb00d.tar.gz postgresql-e605fbcccdf4705de4afa7e23be5b8222e1cb00d.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.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/psql/copy.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c index 01fe0f6c84d..5b91df26b40 100644 --- a/src/bin/psql/copy.c +++ b/src/bin/psql/copy.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.81 2009/07/25 17:04:19 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.82 2009/08/07 20:16:11 tgl Exp $ */ #include "postgres_fe.h" #include "copy.h" @@ -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); } |