CopyIn, CopyOperationpublic 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 | Description |
|---|---|
CopyInImpl() |
| Modifier and Type | Method | 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.
|
cancelCopy, getFieldCount, getFieldFormat, getFormat, getHandledRowCount, isActivecancelCopy, getFieldCount, getFieldFormat, getFormat, getHandledRowCount, handleCommandStatus, isActivepublic void writeToCopy(byte[] data,
int off,
int siz)
throws java.sql.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)java.sql.SQLException - if the operation failspublic void flushCopy()
throws java.sql.SQLException
CopyInpublic long endCopy()
throws java.sql.SQLException
CopyInprotected void handleCopydata(byte[] data)
throws PSQLException
CopyOperationImplhandleCopydata in class CopyOperationImpldata - data that was receive by copy protocolPSQLException - if some internal problem occursCopyright © 2018 PostgreSQL Global Development Group. All rights reserved.