Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e605fbc

Browse files
committed
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.
1 parent 87740ca commit e605fbc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/bin/psql/copy.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2009, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.81 2009/07/25 17:04:19 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.82 2009/08/07 20:16:11 tgl Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "copy.h"
@@ -571,6 +571,9 @@ do_copy(const char *args)
571571
success = false;
572572
psql_error("\\copy: unexpected response (%d)\n",
573573
PQresultStatus(result));
574+
/* if still in COPY IN state, try to get out of it */
575+
if (PQresultStatus(result) == PGRES_COPY_IN)
576+
PQputCopyEnd(pset.db, _("trying to exit copy mode"));
574577
PQclear(result);
575578
}
576579

0 commit comments

Comments
 (0)