Thread: pgsql: Make sure we wait for protocol-level EOF when ending binary COPY

pgsql: Make sure we wait for protocol-level EOF when ending binary COPY

From
tgl@postgresql.org (Tom Lane)
Date:
Log Message:
-----------
Make sure we wait for protocol-level EOF when ending binary COPY IN.

The previous coding just terminated the COPY immediately after seeing
the EOF marker (-1 where a row field count is expected).  The expected
CopyDone or CopyFail message just got thrown away later, since we weren't
in COPY mode anymore.  This behavior complicated matters for the JDBC
driver, and arguably was the wrong thing in any case since a CopyFail
message after the marker wouldn't be honored.

Note that there is a behavioral change here: extra data after the EOF
marker was silently ignored before, but now it will cause an error.
Hence not back-patching, although this is arguably a bug.

Per report and patch by Kris Jurka.

Modified Files:
--------------
    pgsql/src/backend/commands:
        copy.c (r1.329 -> r1.330)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/copy.c?r1=1.329&r2=1.330)