Commit f4a7c257 authored by Tom Lane's avatar Tom Lane

Fix unintentional breakage of COPY TO/FROM stdin. Mea culpa.

parent 3a2ef591
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * 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" #include "postgres_fe.h"
...@@ -236,19 +236,26 @@ PSQLexec(const char *query, bool ignore_command_ok) ...@@ -236,19 +236,26 @@ PSQLexec(const char *query, bool ignore_command_ok)
if (var && strcmp(var, "noexec") == 0) if (var && strcmp(var, "noexec") == 0)
return NULL; return NULL;
/* discard any uneaten results of past queries */
while ((newres = PQgetResult(pset.db)) != NULL)
PQclear(newres);
cancelConn = pset.db; cancelConn = pset.db;
if (PQsendQuery(pset.db, query)) if (PQsendQuery(pset.db, query))
{ {
while ((newres = PQgetResult(pset.db)) != NULL) while ((newres = PQgetResult(pset.db)) != NULL)
{ {
if (ignore_command_ok && rstatus = PQresultStatus(newres);
PQresultStatus(newres) == PGRES_COMMAND_OK) if (ignore_command_ok && rstatus == PGRES_COMMAND_OK)
{ {
PQclear(newres); PQclear(newres);
continue; continue;
} }
PQclear(res); PQclear(res);
res = newres; res = newres;
if (rstatus == PGRES_COPY_IN ||
rstatus == PGRES_COPY_OUT)
break;
} }
} }
rstatus = PQresultStatus(res); rstatus = PQresultStatus(res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment