public class CopyInImpl extends CopyOperationImpl implements CopyIn
COPY FROM STDIN operation.
Anticipated flow: CopyManager.copyIn() ->QueryExecutor.startCopy() - sends given query to server ->processCopyResults(): - receives CopyInResponse from Server - creates new CopyInImpl ->initCopy(): - receives copy metadata from server ->CopyInImpl.init() ->lock() connection for this operation - if query fails an exception is thrown - if query returns wrong CopyOperation, copyIn() cancels it before throwing exception <-return: new CopyInImpl holding lock on connection repeat CopyIn.writeToCopy() for all data ->CopyInImpl.writeToCopy() ->QueryExecutorImpl.writeToCopy() - sends given data ->processCopyResults() - parameterized not to block, just peek for new messages from server - on ErrorResponse, waits until protocol is restored and unlocks connection CopyIn.endCopy() ->CopyInImpl.endCopy() ->QueryExecutorImpl.endCopy() - sends CopyDone - processCopyResults() - on CommandComplete ->CopyOperationImpl.handleCommandComplete() - sets updatedRowCount when applicable - on ReadyForQuery unlock() connection for use by other operations <-return: CopyInImpl.getUpdatedRowCount()
Constructor and Description |
---|
CopyInImpl() |
Modifier and Type | Method and Description |
---|---|
long |
endCopy()
Finishes copy operation successfully.
|
void |
flushCopy()
Force any buffered output to be sent over the network to the backend.
|
protected void |
handleCopydata(byte[] data)
Consume received copy data.
|
void |
writeToCopy(byte[] data,
int off,
int siz)
Writes specified part of given byte array to an open and writable copy operation.
|
void |
writeToCopy(ByteStreamWriter from)
Writes a ByteStreamWriter to an open and writable copy operation.
|
cancelCopy, getFieldCount, getFieldFormat, getFormat, getHandledRowCount, getQueryExecutor, handleCommandStatus, isActive
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cancelCopy, getFieldCount, getFieldFormat, getFormat, getHandledRowCount, isActive
public void writeToCopy(byte[] data, int off, int siz) throws SQLException
CopyIn
writeToCopy
in interface CopyIn
data
- array of bytes to writeoff
- offset of first byte to write (normally zero)siz
- number of bytes to write (normally buf.length)SQLException
- if the operation failspublic void writeToCopy(ByteStreamWriter from) throws SQLException
CopyIn
writeToCopy
in interface CopyIn
from
- the source of bytes, e.g. a ByteBufferByteStreamWriterSQLException
- if the operation failspublic void flushCopy() throws SQLException
CopyIn
flushCopy
in interface CopyIn
SQLException
- if the operation fails.public long endCopy() throws SQLException
CopyIn
endCopy
in interface CopyIn
SQLException
- if the operation fails.protected void handleCopydata(byte[] data) throws PSQLException
CopyOperationImpl
handleCopydata
in class CopyOperationImpl
data
- data that was receive by copy protocolPSQLException
- if some internal problem occursCopyright © 1997-2020 PostgreSQL Global Development Group. All Rights Reserved.