copyOut
Initiates a COPY OUT operation allowing manual chunk reading.
The connection stays in copy mode until the stream is drained or CopyOut.cancelCopy is called, and no ordinary query can run on it meanwhile. CopyOut is AutoCloseable and cancels on close, so use { } is the safe way to hold one.
Return
The handle to read chunks through.
Parameters
A COPY … TO STDOUT statement.
Throws
UNEXPECTED_RESULT if sql did not start a COPY OUT.
Reads all data from the COPY OUT operation and writes it to the provided OutputStream.
The transfer is aborted if anything goes wrong, so the connection is never left in copy mode. outputStream is neither flushed nor closed — that stays with the caller.
Return
The number of bytes written. PostgreSQL reports no row count for COPY OUT, so this is not the counterpart of what copyIn returns.
Parameters
A COPY … TO STDOUT statement.
Where the data is written.
Throws
UNEXPECTED_RESULT if sql did not start a COPY OUT.