The docs currently say (introduced in commit 91fa853):
"In the event of a backend-detected error during copy-both mode, the
backend will issue an ErrorResponse message, discard frontend messages
until a Sync message is received, and then issue ReadyForQuery and
return to normal processing."
But that doesn't seem to be correct: Sync is only used for the extended
query protocol, and CopyBoth can only be initiated with the simple
query protocol. So the actual behavior seems to be more like a "COPY
FROM STDIN" initiated with the simple query protocol:
"In the event of a backend-detected error during copy-in mode
(including receipt of a CopyFail message), the backend will issue an
ErrorResponse message. ... If the COPY command was issued in a simple
Query message, the rest of that message is discarded and ReadyForQuery
is issued ... any subsequent CopyData, CopyDone, or CopyFail messages
issued by the frontend will simply be dropped."
If the client does send a Sync, it results in an extra ReadyForQuery
message.
Diagnosed and reported by Petros Angelatos (petrosagg on Github).
Regards,
Jeff Davis