CopyIn
A COPY ... FROM STDIN in progress: write chunks with writeToCopy, finish with endCopy.
The connection is in copy mode for the whole of it and will run nothing else, which is what makes the handle single-use — endCopy or cancelCopy ends the transfer and the handle with it, and the next one comes from the CopyManager again.
Errors in the data are the server's to find, and it finds them on its own schedule. What it can check as it reads a row - a value that does not parse, a wrong column count, NOT NULL, CHECK - ends the copy there and then, and the next writeToCopy reports it. Foreign keys are checked when the statement ends, so endCopy reports those, and a duplicate key surfaces when the server writes out the rows it has buffered, which on a small copy is the end as well.