aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-10-15 16:44:21 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-10-15 16:44:21 +0000
commitf4a7c257dc6ebd376ba37bf51696caa33860168b (patch)
tree791921a58ac21f1c70a4219114e7007350035089 /src
parent3a2ef591168395149df9f2ad160d242ffe825e41 (diff)
downloadpostgresql-f4a7c257dc6ebd376ba37bf51696caa33860168b.tar.gz
postgresql-f4a7c257dc6ebd376ba37bf51696caa33860168b.zip
Fix unintentional breakage of COPY TO/FROM stdin. Mea culpa.
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/common.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 46186e55692..e74b8c2769f 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.47 2002/10/15 02:24:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.48 2002/10/15 16:44:21 tgl Exp $
*/
#include "postgres_fe.h"
@@ -236,19 +236,26 @@ PSQLexec(const char *query, bool ignore_command_ok)
if (var && strcmp(var, "noexec") == 0)
return NULL;
+ /* discard any uneaten results of past queries */
+ while ((newres = PQgetResult(pset.db)) != NULL)
+ PQclear(newres);
+
cancelConn = pset.db;
if (PQsendQuery(pset.db, query))
{
while ((newres = PQgetResult(pset.db)) != NULL)
{
- if (ignore_command_ok &&
- PQresultStatus(newres) == PGRES_COMMAND_OK)
+ rstatus = PQresultStatus(newres);
+ if (ignore_command_ok && rstatus == PGRES_COMMAND_OK)
{
PQclear(newres);
continue;
}
PQclear(res);
res = newres;
+ if (rstatus == PGRES_COPY_IN ||
+ rstatus == PGRES_COPY_OUT)
+ break;
}
}
rstatus = PQresultStatus(res);