endCopy
Ends the COPY IN operation and returns the number of rows affected.
This is where the server reports what it made of the data, so a malformed row anywhere in the transfer surfaces here rather than from the writeToCopy that sent it. The connection leaves copy mode either way.
Return
The number of rows the server accepted.
Throws
RESOURCE_CLOSED if the operation has already finished.