public class QueryExecutorImpl extends QueryExecutorBase
closeAction, lock, lockCondition, logServerErrorDetail, pgStream
MAX_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(PGStream pgStream,
int cancelSignalTimeout,
java.util.Properties info) |
Modifier and Type | Method and Description |
---|---|
void |
addBinaryReceiveOid(int oid)
Adds a single oid that should be received using binary encoding.
|
void |
addBinarySendOid(int oid)
Adds a single oid that should be sent using binary encoding.
|
void |
addQueryToAdaptiveFetchCache(boolean adaptiveFetch,
ResultCursor cursor)
Add query to adaptive fetch cache inside QueryExecutor.
|
void |
cancelCopy(CopyOperationImpl op)
Finishes a copy operation and unlocks connection discarding any exchanged data.
|
ParameterList |
createFastpathParameters(int count)
Create a new ParameterList implementation suitable for invoking a fastpath function via
QueryExecutor.fastpathCall(int, org.postgresql.core.ParameterList, boolean) . |
Query |
createSimpleQuery(java.lang.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[] queries,
ParameterList[] parameterLists,
BatchResultHandler batchHandler,
int maxRows,
int fetchSize,
int flags,
boolean adaptiveFetch)
Execute several Query with adaptive fetch, 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.
|
void |
execute(Query query,
ParameterList parameters,
ResultHandler handler,
int maxRows,
int fetchSize,
int flags,
boolean adaptiveFetch)
Execute a Query with adaptive fetch, 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,
boolean adaptiveFetch)
Fetch additional rows from a cursor.
|
void |
flushCopy(CopyOperationImpl op) |
boolean |
getAdaptiveFetch()
Get state of adaptive fetch inside QueryExecutor.
|
int |
getAdaptiveFetchSize(boolean adaptiveFetch,
ResultCursor cursor)
Get fetch size computed by adaptive fetch size for given query.
|
java.lang.String |
getApplicationName()
Returns application_name connection property.
|
java.util.Set<? extends java.lang.Integer> |
getBinaryReceiveOids()
Gets the oids that should be received using binary encoding.
|
java.util.Set<? extends java.lang.Integer> |
getBinarySendOids()
Gets the oids that should be sent using binary encoding.
|
boolean |
getIntegerDateTimes()
Returns true if server uses integer instead of double for binary date and time encodings.
|
int |
getProtocolVersion() |
ReplicationProtocol |
getReplicationProtocol() |
java.util.TimeZone |
getTimeZone()
Returns backend timezone in java format.
|
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) |
protected void |
processResults(ResultHandler handler,
int flags,
boolean adaptiveFetch) |
void |
readStartupMessages() |
void |
receiveParameterStatus() |
void |
removeBinaryReceiveOid(int oid)
Remove given oid from the list of oids for binary receive encoding.
|
void |
removeBinarySendOid(int oid)
Remove given oid from the list of oids for binary send encoding.
|
void |
removeQueryFromAdaptiveFetchCache(boolean adaptiveFetch,
ResultCursor cursor)
Remove query from adaptive fetch cache inside QueryExecutor
|
protected void |
sendCloseMessage()
Sends "terminate connection" message to the backend.
|
void |
setAdaptiveFetch(boolean adaptiveFetch)
Set state of adaptive fetch inside QueryExecutor.
|
void |
setApplicationName(java.lang.String applicationName) |
void |
setBinaryReceiveOids(java.util.Set<java.lang.Integer> oids)
Sets the oids that should be received using binary encoding.
|
void |
setBinarySendOids(java.util.Set<java.lang.Integer> oids)
Sets the oids that should be sent using binary encoding.
|
void |
setTimeZone(java.util.TimeZone timeZone) |
CopyOperation |
startCopy(java.lang.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.
|
Query |
wrap(java.util.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, createCloseAction, createQuery, createQueryByKey, createQueryKey, getAutoSave, getBackendPID, getCloseAction, getDatabase, getEncoding, getEscapeSyntaxCallMode, getHostSpec, getNetworkTimeout, getNotifications, getParameterStatus, getParameterStatuses, getPreferQueryMode, getQuoteReturningIdentifiers, getServerVersion, getServerVersionNum, getStandardConformingStrings, getTransactionState, getUser, getWarnings, hasNotifications, isClosed, isColumnSanitiserDisabled, isFlushCacheOnDeallocate, isReWriteBatchedInsertsEnabled, onParameterStatus, releaseQuery, sendQueryCancel, setAutoSave, setBackendKeyData, setEncoding, setFlushCacheOnDeallocate, setNetworkTimeout, setPreferQueryMode, setServerVersion, setServerVersionNum, setStandardConformingStrings, setTransactionState, willHealOnRetry, willHealViaReparse
public QueryExecutorImpl(PGStream pgStream, int cancelSignalTimeout, java.util.Properties info) throws java.sql.SQLException, java.io.IOException
java.sql.SQLException
java.io.IOException
public int getProtocolVersion()
public Query createSimpleQuery(java.lang.String sql) throws java.sql.SQLException
QueryExecutor
Query.createParameterList()
of the returned object will always return an empty
ParameterList.sql
- the SQL for the query to createjava.sql.SQLException
- if something goes wrongpublic Query wrap(java.util.List<NativeQuery> queries)
QueryExecutor
queries
- list of queries in native to database syntaxpublic void execute(Query query, ParameterList parameters, ResultHandler handler, int maxRows, int fetchSize, int flags) throws java.sql.SQLException
QueryExecutor
query
- 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.java.sql.SQLException
- if query execution failspublic void execute(Query query, ParameterList parameters, ResultHandler handler, int maxRows, int fetchSize, int flags, boolean adaptiveFetch) throws java.sql.SQLException
QueryExecutor
query
- 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.adaptiveFetch
- state of adaptiveFetch to use during executionjava.sql.SQLException
- if query execution failspublic void execute(Query[] queries, ParameterList[] parameterLists, BatchResultHandler batchHandler, int maxRows, int fetchSize, int flags) throws java.sql.SQLException
QueryExecutor
queries
- 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.java.sql.SQLException
- if query execution failspublic void execute(Query[] queries, ParameterList[] parameterLists, BatchResultHandler batchHandler, int maxRows, int fetchSize, int flags, boolean adaptiveFetch) throws java.sql.SQLException
QueryExecutor
queries
- 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.adaptiveFetch
- state of adaptiveFetch to use during executionjava.sql.SQLException
- if query execution failspublic byte[] fastpathCall(int fnid, ParameterList parameters, boolean suppressBegin) throws java.sql.SQLException
QueryExecutor
fnid
- 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 returnedjava.sql.SQLException
- if an error occurs while executing the fastpath callpublic void doSubprotocolBegin() throws java.sql.SQLException
java.sql.SQLException
public ParameterList createFastpathParameters(int count)
QueryExecutor
QueryExecutor.fastpathCall(int, org.postgresql.core.ParameterList, boolean)
.count
- the number of parameters the fastpath call will takeQueryExecutor.fastpathCall(int, org.postgresql.core.ParameterList, boolean)
.public void processNotifies() throws java.sql.SQLException
QueryExecutor
java.sql.SQLException
- if and error occurs while fetching notificationspublic void processNotifies(int timeoutMillis) throws java.sql.SQLException
QueryExecutor
timeoutMillis
- when > 0, block for this time
when =0, block forever
when < 0, don't blockjava.sql.SQLException
- if and error occurs while fetching notificationspublic CopyOperation startCopy(java.lang.String sql, boolean suppressBegin) throws java.sql.SQLException
sql
- COPY FROM STDIN / COPY TO STDOUT statementsuppressBegin
- if begin should be suppressedjava.sql.SQLException
- on failurepublic void cancelCopy(CopyOperationImpl op) throws java.sql.SQLException
op
- the copy operation presumably currently holding lock on this connectionjava.sql.SQLException
- on any additional failurepublic long endCopy(CopyOperationImpl op) throws java.sql.SQLException
op
- the copy operation presumably currently holding lock on this connectionjava.sql.SQLException
- on failurepublic void writeToCopy(CopyOperationImpl op, byte[] data, int off, int siz) throws java.sql.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)java.sql.SQLException
- on failurepublic void writeToCopy(CopyOperationImpl op, ByteStreamWriter from) throws java.sql.SQLException
op
- the CopyIn operation presumably currently holding lock on this connectionfrom
- the source of bytes, e.g. a ByteBufferByteStreamWriterjava.sql.SQLException
- on failurepublic void flushCopy(CopyOperationImpl op) throws java.sql.SQLException
java.sql.SQLException
protected void processResults(ResultHandler handler, int flags) throws java.io.IOException
java.io.IOException
protected void processResults(ResultHandler handler, int flags, boolean adaptiveFetch) throws java.io.IOException
java.io.IOException
public void fetch(ResultCursor cursor, ResultHandler handler, int fetchSize, boolean adaptiveFetch) throws java.sql.SQLException
QueryExecutor
cursor
- the cursor to fetch fromhandler
- the handler to feed results tofetchSize
- the preferred number of rows to retrieve before suspendingadaptiveFetch
- state of adaptiveFetch to use during fetchingjava.sql.SQLException
- if query execution failspublic int getAdaptiveFetchSize(boolean adaptiveFetch, ResultCursor cursor)
QueryExecutor
adaptiveFetch
- state of adaptive fetch, which should be used during retrievingcursor
- Cursor used by resultSet, containing query, have to be able to cast to
Portal class.public void setAdaptiveFetch(boolean adaptiveFetch)
QueryExecutor
adaptiveFetch
- desired state of adaptive fetchpublic boolean getAdaptiveFetch()
QueryExecutor
public void addQueryToAdaptiveFetchCache(boolean adaptiveFetch, ResultCursor cursor)
QueryExecutor
adaptiveFetch
- state of adaptive fetch used during adding querycursor
- Cursor used by resultSet, containing query, have to be able to cast to
Portal class.public void removeQueryFromAdaptiveFetchCache(boolean adaptiveFetch, ResultCursor cursor)
QueryExecutor
adaptiveFetch
- state of adaptive fetch used during removing querycursor
- Cursor used by resultSet, containing query, have to be able to cast to
Portal class.protected void sendCloseMessage() throws java.io.IOException
QueryExecutorBase
sendCloseMessage
in class QueryExecutorBase
java.io.IOException
- in case connection termination failspublic void readStartupMessages() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void receiveParameterStatus() throws java.io.IOException, java.sql.SQLException
java.io.IOException
java.sql.SQLException
public void setTimeZone(java.util.TimeZone timeZone)
public java.util.TimeZone getTimeZone()
QueryExecutor
public void setApplicationName(java.lang.String applicationName)
public java.lang.String getApplicationName()
QueryExecutor
public ReplicationProtocol getReplicationProtocol()
public void addBinaryReceiveOid(int oid)
QueryExecutor
oid
- The oid to request with binary encoding.public void removeBinaryReceiveOid(int oid)
QueryExecutor
Note: the binary receive for the oid can be re-activated later.
oid
- The oid to request with binary encoding.public java.util.Set<? extends java.lang.Integer> getBinaryReceiveOids()
QueryExecutor
Note: this returns an unmodifiable set, and its contents might not reflect the current state.
public boolean useBinaryForReceive(int oid)
TypeTransferModeRegistry
oid
- type oidpublic void setBinaryReceiveOids(java.util.Set<java.lang.Integer> oids)
QueryExecutor
oids
- The oids to request with binary encoding.public void addBinarySendOid(int oid)
QueryExecutor
oid
- The oid to send with binary encoding.public void removeBinarySendOid(int oid)
QueryExecutor
Note: the binary send for the oid can be re-activated later.
oid
- The oid to send with binary encoding.public java.util.Set<? extends java.lang.Integer> getBinarySendOids()
QueryExecutor
Note: this returns an unmodifiable set, and its contents might not reflect the current state.
public boolean useBinaryForSend(int oid)
TypeTransferModeRegistry
oid
- type oidpublic void setBinarySendOids(java.util.Set<java.lang.Integer> oids)
QueryExecutor
oids
- The oids to send with binary encoding.public boolean getIntegerDateTimes()
QueryExecutor
Copyright © 2024 PostgreSQL Global Development Group. All rights reserved.