public class QueryExecutorImpl extends QueryExecutorBase
datashareEnabled, enableMultiSqlSupport, enableStatementCache, isCrossDatasharingEnabled, logger, logServerErrorDetail, pgStream, properties, serverProtocolVersionMAX_SAVE_POINTS, QUERY_BOTH_ROWS_AND_STATUS, QUERY_DESCRIBE_ONLY, QUERY_DISALLOW_BATCHING, QUERY_EXECUTE_AS_SIMPLE, QUERY_FORCE_DESCRIBE_PORTAL, QUERY_FORWARD_CURSOR, QUERY_NO_BINARY_TRANSFER, QUERY_NO_METADATA, QUERY_NO_RESULTS, QUERY_ONESHOT, QUERY_READ_ONLY_HINT, QUERY_SUPPRESS_BEGIN| Constructor and Description |
|---|
QueryExecutorImpl(RedshiftStream pgStream,
String user,
String database,
int cancelSignalTimeout,
Properties info,
RedshiftLogger logger) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancelCopy(CopyOperationImpl op)
Finishes a copy operation and unlocks connection discarding any exchanged data.
|
void |
closeRingBufferThread(RedshiftRowsBlockingQueue<Tuple> queueRows,
Thread ringBufferThread)
Close the last active ring buffer thread.
|
void |
closeStatementAndPortal()
Close the statement and portal when statement get closed.
|
ParameterList |
createFastpathParameters(int count)
Create a new ParameterList implementation suitable for invoking a fastpath function via
QueryExecutor.fastpathCall(int, com.amazon.redshift.core.ParameterList, boolean). |
Query |
createSimpleQuery(String sql)
Create an unparameterized Query object suitable for execution by this QueryExecutor.
|
void |
doSubprotocolBegin() |
long |
endCopy(CopyOperationImpl op)
Finishes writing to copy and unlocks connection.
|
void |
execute(Query[] queries,
ParameterList[] parameterLists,
BatchResultHandler batchHandler,
int maxRows,
int fetchSize,
int flags)
Execute several Query, passing results to a provided ResultHandler.
|
void |
execute(Query query,
ParameterList parameters,
ResultHandler handler,
int maxRows,
int fetchSize,
int flags)
Execute a Query, passing results to a provided ResultHandler.
|
byte[] |
fastpathCall(int fnid,
ParameterList parameters,
boolean suppressBegin)
Invoke a backend function via the fastpath interface.
|
void |
fetch(ResultCursor cursor,
ResultHandler handler,
int fetchSize,
int initRowCount)
Fetch additional rows from a cursor.
|
void |
flushCopy(CopyOperationImpl op) |
String |
getApplicationName()
Returns application_name connection property.
|
long |
getBytesReadFromStream() |
boolean |
getIntegerDateTimes()
Returns true if server uses integer instead of double for binary date and time encodings.
|
int |
getProtocolVersion() |
ReplicationProtocol |
getReplicationProtocol() |
TimeZone |
getTimeZone()
Returns backend timezone in java format.
|
boolean |
isRingBufferThreadRunning()
Check for a running ring buffer thread.
|
void |
processNotifies()
Prior to attempting to retrieve notifications, we need to pull any recently received
notifications off of the network buffers.
|
void |
processNotifies(int timeoutMillis)
Prior to attempting to retrieve notifications, we need to pull any recently received
notifications off of the network buffers.
|
protected void |
processResults(ResultHandler handler,
int flags,
int fetchSize,
boolean subQueries,
int maxRows) |
protected void |
processResults(ResultHandler handler,
int flags,
int fetchSize,
boolean subQueries,
int initRowCount,
int maxRows) |
protected void |
processSyncOnClose() |
void |
readStartupMessages() |
void |
receiveParameterStatus() |
protected void |
sendCloseMessage() |
void |
sendQueryCancel()
Sends a query cancellation for this connection.
|
void |
setApplicationName(String applicationName) |
void |
setBinaryReceiveOids(Set<Integer> oids)
Sets the oids that should be received using binary encoding.
|
void |
setBinarySendOids(Set<Integer> oids)
Sets the oids that should be sent using binary encoding.
|
void |
setTimeZone(TimeZone timeZone) |
CopyOperation |
startCopy(String sql,
boolean suppressBegin)
Sends given query to BE to start, initialize and lock connection for a CopyOperation.
|
boolean |
useBinaryForReceive(int oid)
Returns if given oid should be received in binary format.
|
boolean |
useBinaryForSend(int oid)
Returns if given oid should be sent in binary format.
|
void |
waitForRingBufferThreadToFinish(boolean calledFromConnectionClose,
boolean calledFromResultsetClose,
boolean calledFromStatementClose,
RedshiftRowsBlockingQueue<Tuple> queueRows,
Thread ringBufferThread)
Wait for ring buffer thread to finish.
|
Query |
wrap(List<NativeQuery> queries)
Wrap given native query into a ready for execution format.
|
void |
writeToCopy(CopyOperationImpl op,
byte[] data,
int off,
int siz)
Sends data during a live COPY IN operation.
|
void |
writeToCopy(CopyOperationImpl op,
ByteStreamWriter from)
Sends data during a live COPY IN operation.
|
abort, addNotification, addWarning, borrowCallableQuery, borrowQuery, borrowQueryByKey, borrowReturningQuery, close, createQuery, createQueryByKey, createQueryKey, getAutoSave, getBackendPID, getDatabase, getEncoding, getEscapeSyntaxCallMode, getHostSpec, getNetworkTimeout, getNotifications, getParameterStatus, getParameterStatuses, getPreferQueryMode, getServerProtocolVersion, getServerVersion, getServerVersionNum, getStandardConformingStrings, getTransactionState, getUser, getWarnings, hasNotifications, isClosed, isColumnSanitiserDisabled, isCrossDatasharingEnabled, isDatashareEnabled, isFlushCacheOnDeallocate, isMultiSqlSupport, isRaiseExceptionOnSilentRollback, isReWriteBatchedInsertsEnabled, onParameterStatus, releaseQuery, setAutoSave, setBackendKeyData, setCrossDatasharingEnabled, setDatashareEnabled, setEncoding, setFlushCacheOnDeallocate, setNetworkTimeout, setRaiseExceptionOnSilentRollback, setServerProtocolVersion, setServerVersion, setServerVersionNum, setStandardConformingStrings, setTransactionState, willHealOnRetry, willHealViaReparsepublic QueryExecutorImpl(RedshiftStream pgStream, String user, String database, int cancelSignalTimeout, Properties info, RedshiftLogger logger) throws SQLException, IOException
SQLExceptionIOExceptionpublic int getProtocolVersion()
public long getBytesReadFromStream()
public Query createSimpleQuery(String sql) throws SQLException
QueryExecutorQuery.createParameterList() of the returned object will always return an empty
ParameterList.sql - the SQL for the query to createSQLException - if something goes wrongpublic Query wrap(List<NativeQuery> queries)
QueryExecutorqueries - list of queries in native to database syntaxpublic void execute(Query query, ParameterList parameters, ResultHandler handler, int maxRows, int fetchSize, int flags) throws SQLException
QueryExecutorquery - the query to execute; must be a query returned from calling
QueryExecutor.wrap(List) on this QueryExecutor object.parameters - the parameters for the query. Must be non-null if the query
takes parameters. Must be a parameter object returned by
Query.createParameterList().handler - a ResultHandler responsible for handling results generated by this querymaxRows - the maximum number of rows to retrievefetchSize - if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve
before suspendingflags - a combination of QUERY_* flags indicating how to handle the query.SQLException - if query execution failspublic void execute(Query[] queries, ParameterList[] parameterLists, BatchResultHandler batchHandler, int maxRows, int fetchSize, int flags) throws SQLException
QueryExecutorqueries - the queries to execute; each must be a query returned from calling
QueryExecutor.wrap(List) on this QueryExecutor object.parameterLists - the parameter lists for the queries. The parameter lists correspond 1:1
to the queries passed in the queries array. Each must be non-
null if the corresponding query takes parameters, and must be a parameter
object returned by Query.createParameterList() created by
the corresponding query.batchHandler - a ResultHandler responsible for handling results generated by this querymaxRows - the maximum number of rows to retrievefetchSize - if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve
before suspendingflags - a combination of QUERY_* flags indicating how to handle the query.SQLException - if query execution failspublic byte[] fastpathCall(int fnid,
ParameterList parameters,
boolean suppressBegin)
throws SQLException
QueryExecutorfnid - the OID of the backend function to invokeparameters - a ParameterList returned from QueryExecutor.createFastpathParameters(int) containing the
parameters to pass to the backend functionsuppressBegin - if begin should be suppressednull if a void result
was returnedSQLException - if an error occurs while executing the fastpath callpublic void doSubprotocolBegin()
throws SQLException
SQLExceptionpublic ParameterList createFastpathParameters(int count)
QueryExecutorQueryExecutor.fastpathCall(int, com.amazon.redshift.core.ParameterList, boolean).count - the number of parameters the fastpath call will takeQueryExecutor.fastpathCall(int, com.amazon.redshift.core.ParameterList, boolean).public void processNotifies()
throws SQLException
QueryExecutorSQLException - if and error occurs while fetching notificationspublic void processNotifies(int timeoutMillis)
throws SQLException
QueryExecutortimeoutMillis - when > 0, block for this time
when =0, block forever
when < 0, don't blockSQLException - if and error occurs while fetching notificationspublic CopyOperation startCopy(String sql, boolean suppressBegin) throws SQLException
sql - COPY FROM STDIN / COPY TO STDOUT statementsuppressBegin - if begin should be suppressedSQLException - on failurepublic void cancelCopy(CopyOperationImpl op) throws SQLException
op - the copy operation presumably currently holding lock on this connectionSQLException - on any additional failurepublic long endCopy(CopyOperationImpl op) throws SQLException
op - the copy operation presumably currently holding lock on this connectionSQLException - on failurepublic void writeToCopy(CopyOperationImpl op, byte[] data, int off, int siz) throws SQLException
op - the CopyIn operation presumably currently holding lock on this connectiondata - bytes to sendoff - index of first byte to send (usually 0)siz - number of bytes to send (usually data.length)SQLException - on failurepublic void writeToCopy(CopyOperationImpl op, ByteStreamWriter from) throws SQLException
op - the CopyIn operation presumably currently holding lock on this connectionfrom - the source of bytes, e.g. a ByteBufferByteStreamWriterSQLException - on failurepublic void flushCopy(CopyOperationImpl op) throws SQLException
SQLExceptionpublic void closeStatementAndPortal()
QueryExecutorcloseStatementAndPortal in interface QueryExecutorcloseStatementAndPortal in class QueryExecutorBasepublic boolean isRingBufferThreadRunning()
isRingBufferThreadRunning in interface QueryExecutorisRingBufferThreadRunning in class QueryExecutorBasepublic void closeRingBufferThread(RedshiftRowsBlockingQueue<Tuple> queueRows, Thread ringBufferThread)
closeRingBufferThread in interface QueryExecutorcloseRingBufferThread in class QueryExecutorBasequeueRows - the blocking queue rowsringBufferThread - the thread fetching rows in the blocking queue.public void sendQueryCancel()
throws SQLException
QueryExecutorsendQueryCancel in interface QueryExecutorsendQueryCancel in class QueryExecutorBaseSQLException - if something goes wrong.protected void processSyncOnClose()
throws IOException,
SQLException
IOExceptionSQLExceptionprotected void processResults(ResultHandler handler, int flags, int fetchSize, boolean subQueries, int maxRows) throws IOException
IOExceptionprotected void processResults(ResultHandler handler, int flags, int fetchSize, boolean subQueries, int initRowCount, int maxRows) throws IOException
IOExceptionpublic void fetch(ResultCursor cursor, ResultHandler handler, int fetchSize, int initRowCount) throws SQLException
QueryExecutorcursor - the cursor to fetch fromhandler - the handler to feed results tofetchSize - the preferred number of rows to retrieve before suspendinginitRowCount - the number of rows already fetchedSQLException - if query execution failsprotected void sendCloseMessage()
throws IOException
sendCloseMessage in class QueryExecutorBaseIOExceptionpublic void readStartupMessages()
throws IOException,
SQLException
IOExceptionSQLExceptionpublic void receiveParameterStatus()
throws IOException,
SQLException
IOExceptionSQLExceptionpublic void setTimeZone(TimeZone timeZone)
public TimeZone getTimeZone()
QueryExecutorpublic void setApplicationName(String applicationName)
public String getApplicationName()
QueryExecutorpublic ReplicationProtocol getReplicationProtocol()
public boolean useBinaryForReceive(int oid)
TypeTransferModeRegistryoid - type oidpublic void setBinaryReceiveOids(Set<Integer> oids)
QueryExecutoroids - The oids to request with binary encoding.public boolean useBinaryForSend(int oid)
TypeTransferModeRegistryoid - type oidpublic void setBinarySendOids(Set<Integer> oids)
QueryExecutoroids - The oids to send with binary encoding.public boolean getIntegerDateTimes()
QueryExecutorpublic void waitForRingBufferThreadToFinish(boolean calledFromConnectionClose,
boolean calledFromResultsetClose,
boolean calledFromStatementClose,
RedshiftRowsBlockingQueue<Tuple> queueRows,
Thread ringBufferThread)
calledFromConnectionClose - true, if it called from connection.close(), false otherwise.calledFromResultsetClose - true, if it called from resultset.close(), false otherwise.queueRows - the blocking queue rowsringBufferThread - the thread manage the blocking queueCopyright © 2024 Amazon.com Inc.. All rights reserved.