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, isActiveclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcancelCopy, getFieldCount, getFieldFormat, getFormat, getHandledRowCount, isActivepublic void writeToCopy(byte[] data,
int off,
int siz)
throws SQLException
CopyInwriteToCopy in interface CopyIndata - 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
CopyInwriteToCopy in interface CopyInfrom - the source of bytes, e.g. a ByteBufferByteStreamWriterSQLException - if the operation failspublic void flushCopy()
throws SQLException
CopyInflushCopy in interface CopyInSQLException - if the operation fails.public long endCopy()
throws SQLException
CopyInendCopy in interface CopyInSQLException - if the operation fails.protected void handleCopydata(byte[] data)
throws PSQLException
CopyOperationImplhandleCopydata in class CopyOperationImpldata - data that was receive by copy protocolPSQLException - if some internal problem occursCopyright © 1997-2020 PostgreSQL Global Development Group. All Rights Reserved.