1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

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.
This commit is contained in:
Tom Lane
2003-08-13 18:56:21 +00:00
parent 0be731ad44
commit c01641f8ae
5 changed files with 66 additions and 20 deletions

View File

@ -1,4 +1,4 @@
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/protocol.sgml,v 1.39 2003/06/27 19:08:37 tgl Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/protocol.sgml,v 1.40 2003/08/13 18:56:21 tgl Exp $ -->
<chapter id="protocol">
<title>Frontend/Backend Protocol</title>
@ -919,8 +919,7 @@
<para>
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 <command>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.
</para>
<para>
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 <command>COPY FROM STDIN</>.)
</para>
<para>
Copy-out mode (data transfer from the server) is initiated when the
backend executes a <command>COPY TO STDOUT</> SQL statement. The backend