From c01641f8aed00642163b7eb8748a297668a990de Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 13 Aug 2003 18:56:21 +0000 Subject: libpq failed to cope with COPY FROM STDIN if the command was issued via extended query protocol, because it sends Sync right after Execute without realizing that the command to be executed is COPY. There seems to be no reasonable way for it to realize that, either, so the best fix seems to be to make the backend ignore Sync during copy-in mode. Bit of a wart on the protocol, but little alternative. Also, libpq must send another Sync after terminating the COPY, if the command was issued via Execute. --- doc/src/sgml/protocol.sgml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml index 75fe6b3982e..c4605a13efc 100644 --- a/doc/src/sgml/protocol.sgml +++ b/doc/src/sgml/protocol.sgml @@ -1,4 +1,4 @@ - + Frontend/Backend Protocol @@ -919,8 +919,7 @@ In the event of a backend-detected error during copy-in mode (including - receipt of a CopyFail message, or indeed any frontend message other than - CopyData or CopyDone), the backend will issue an ErrorResponse + receipt of a CopyFail message), the backend will issue an ErrorResponse message. If the COPY command was issued via an extended-query message, the backend will now discard frontend messages until a Sync message is received, then it will issue ReadyForQuery and return to normal @@ -930,6 +929,15 @@ messages issued by the frontend will simply be dropped. + + The backend will ignore Flush and Sync messages received during copy-in + mode. Receipt of any other non-copy message type constitutes an error + that will abort the copy-in state as described above. (The exception for + Flush and Sync is for the convenience of client libraries that always + send Flush or Sync after an Execute message, without checking whether + the command to be executed is a COPY FROM STDIN.) + + Copy-out mode (data transfer from the server) is initiated when the backend executes a COPY TO STDOUT SQL statement. The backend -- cgit v1.2.3