Commit 5eb7c4d3 authored by Robert Haas's avatar Robert Haas

libpq: Fix a few bits that didn't get the memo about COPY BOTH.

There's probably no real bug here at present, so not backpatching.
But it seems good to make these bits consistent with the rest of
libpq, so as to avoid future surprises.

Patch by me.  Review by Tom Lane.
parent c3d09b3b
...@@ -1566,7 +1566,8 @@ pqGetline3(PGconn *conn, char *s, int maxlen) ...@@ -1566,7 +1566,8 @@ pqGetline3(PGconn *conn, char *s, int maxlen)
int status; int status;
if (conn->sock < 0 || if (conn->sock < 0 ||
conn->asyncStatus != PGASYNC_COPY_OUT || (conn->asyncStatus != PGASYNC_COPY_OUT &&
conn->asyncStatus != PGASYNC_COPY_BOTH) ||
conn->copy_is_binary) conn->copy_is_binary)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
...@@ -1617,7 +1618,8 @@ pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize) ...@@ -1617,7 +1618,8 @@ pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize)
int msgLength; int msgLength;
int avail; int avail;
if (conn->asyncStatus != PGASYNC_COPY_OUT) if (conn->asyncStatus != PGASYNC_COPY_OUT
&& conn->asyncStatus != PGASYNC_COPY_BOTH)
return -1; /* we are not doing a copy... */ return -1; /* we are not doing a copy... */
/* /*
...@@ -1671,7 +1673,8 @@ pqEndcopy3(PGconn *conn) ...@@ -1671,7 +1673,8 @@ pqEndcopy3(PGconn *conn)
PGresult *result; PGresult *result;
if (conn->asyncStatus != PGASYNC_COPY_IN && if (conn->asyncStatus != PGASYNC_COPY_IN &&
conn->asyncStatus != PGASYNC_COPY_OUT) conn->asyncStatus != PGASYNC_COPY_OUT &&
conn->asyncStatus != PGASYNC_COPY_BOTH)
{ {
printfPQExpBuffer(&conn->errorMessage, printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("no COPY in progress\n")); libpq_gettext("no COPY in progress\n"));
...@@ -1679,7 +1682,8 @@ pqEndcopy3(PGconn *conn) ...@@ -1679,7 +1682,8 @@ pqEndcopy3(PGconn *conn)
} }
/* Send the CopyDone message if needed */ /* Send the CopyDone message if needed */
if (conn->asyncStatus == PGASYNC_COPY_IN) if (conn->asyncStatus == PGASYNC_COPY_IN ||
conn->asyncStatus == PGASYNC_COPY_BOTH)
{ {
if (pqPutMsgStart('c', false, conn) < 0 || if (pqPutMsgStart('c', false, conn) < 0 ||
pqPutMsgEnd(conn) < 0) pqPutMsgEnd(conn) < 0)
......
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