Class QueryExecutorBase
- All Implemented Interfaces:
QueryExecutor,TypeTransferModeRegistry
- Direct Known Subclasses:
QueryExecutorImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final QueryExecutorCloseActionprotected final ResourceLockprotected final Conditionprotected final booleanprotected final PGStreamprotected ProtocolVersionFields inherited from interface org.postgresql.core.QueryExecutor
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 Summary
ConstructorsModifierConstructorDescriptionprotectedQueryExecutorBase(PGStream pgStream, int cancelSignalTimeout, Properties info) -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Abort at network level without sending the Terminate message to the backend.voidaddNotification(PGNotification notification) voidaddWarning(SQLWarning newWarning) final CachedQueryfinal CachedQueryborrowQuery(String sql) borrowQueryByKey(Object key) final CachedQueryborrowReturningQuery(String sql, String @Nullable [] columnNames) voidclose()Close this connection cleanly.protected QueryExecutorCloseActionfinal CachedQuerycreateQuery(String sql, boolean escapeProcessing, boolean isParameterized, String @Nullable ... columnNames) createQueryByKey(Object key) final ObjectcreateQueryKey(String sql, boolean escapeProcessing, boolean isParameterized, String @Nullable ... columnNames) intReturn the process ID (PID) of the backend server process handling this connection.Returns an action that would close the connection cleanly.intRetrieve and clear the set of asynchronous notifications pending on this connection.final @Nullable StringgetParameterStatus(String parameterName) booleanReturn the server version from the server_version GUC.intGet a machine-readable server version.booleanReturns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules.Get the current transaction state of this connection.getUser()@Nullable SQLWarningRetrieve and clear the chain of warnings accumulated on this connection.protected booleanbooleanisClosed()Check if this connection is closed.booleanbooleanbooleanprotected voidonParameterStatus(String parameterName, String parameterStatus) Update the parameter status map in response to a new ParameterStatus wire protocol message.voidreleaseQuery(CachedQuery cachedQuery) protected abstract voidDeprecated.voidSends a query cancellation for this connection.voidsetAutoSave(AutoSave autoSave) voidsetBackendKeyData(int cancelPid, byte[] cancelKey) voidsetEncoding(Encoding encoding) voidsetFlushCacheOnDeallocate(boolean flushCacheOnDeallocate) By default, the connection resets statement cache in case deallocate all/discard all message is observed.voidsetNetworkTimeout(int milliseconds) voidvoidsetServerVersion(String serverVersion) voidsetServerVersionNum(int serverVersionNum) voidsetStandardConformingStrings(boolean value) voidbooleanprotected booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.postgresql.core.QueryExecutor
addBinaryReceiveOid, addBinarySendOid, addQueryToAdaptiveFetchCache, createFastpathParameters, createSimpleQuery, execute, execute, execute, execute, fastpathCall, fetch, getAdaptiveFetch, getAdaptiveFetchSize, getApplicationName, getBinaryReceiveOids, getBinarySendOids, getIntegerDateTimes, getProtocolVersion, getReplicationProtocol, getTimeZone, processNotifies, processNotifies, removeBinaryReceiveOid, removeBinarySendOid, removeQueryFromAdaptiveFetchCache, setAdaptiveFetch, setBinaryReceiveOids, setBinarySendOids, startCopy, wrapMethods inherited from interface org.postgresql.core.v3.TypeTransferModeRegistry
useBinaryForReceive, useBinaryForSend
-
Field Details
-
pgStream
-
protocolVersion
-
closeAction
-
logServerErrorDetail
protected final boolean logServerErrorDetail -
lock
-
lockCondition
-
-
Constructor Details
-
QueryExecutorBase
protected QueryExecutorBase(PGStream pgStream, int cancelSignalTimeout, Properties info) throws SQLException - Throws:
SQLException
-
-
Method Details
-
createCloseAction
-
sendCloseMessage
Deprecated.usegetCloseAction()insteadSends "terminate connection" message to the backend.- Throws:
IOException- in case connection termination fails
-
setNetworkTimeout
- Specified by:
setNetworkTimeoutin interfaceQueryExecutor- Throws:
IOException
-
getNetworkTimeout
- Specified by:
getNetworkTimeoutin interfaceQueryExecutor- Throws:
IOException
-
getHostSpec
- Specified by:
getHostSpecin interfaceQueryExecutor- Returns:
- the host and port this connection is connected to.
-
getUser
- Specified by:
getUserin interfaceQueryExecutor- Returns:
- the user this connection authenticated as.
-
getDatabase
- Specified by:
getDatabasein interfaceQueryExecutor- Returns:
- the database this connection is connected to.
-
setBackendKeyData
public void setBackendKeyData(int cancelPid, byte[] cancelKey) -
getBackendPID
public int getBackendPID()Description copied from interface:QueryExecutorReturn the process ID (PID) of the backend server process handling this connection.- Specified by:
getBackendPIDin interfaceQueryExecutor- Returns:
- process ID (PID) of the backend server process handling this connection
-
abort
public void abort()Description copied from interface:QueryExecutorAbort at network level without sending the Terminate message to the backend.- Specified by:
abortin interfaceQueryExecutor
-
getCloseAction
Description copied from interface:QueryExecutorReturns an action that would close the connection cleanly. The returned object should refer only the minimum subset of objects required for proper resource cleanup. For instance, it should better not hold a strong reference toQueryExecutor.- Specified by:
getCloseActionin interfaceQueryExecutor- Returns:
- action that would close the connection cleanly.
-
close
public void close()Description copied from interface:QueryExecutorClose this connection cleanly.- Specified by:
closein interfaceQueryExecutor
-
isClosed
public boolean isClosed()Description copied from interface:QueryExecutorCheck if this connection is closed.- Specified by:
isClosedin interfaceQueryExecutor- Returns:
- true iff the connection is closed.
-
sendQueryCancel
Description copied from interface:QueryExecutorSends a query cancellation for this connection.- Specified by:
sendQueryCancelin interfaceQueryExecutor- Throws:
SQLException- if something goes wrong.
-
addWarning
-
addNotification
-
getNotifications
Description copied from interface:QueryExecutorRetrieve and clear the set of asynchronous notifications pending on this connection.- Specified by:
getNotificationsin interfaceQueryExecutor- Returns:
- an array of notifications; if there are no notifications, an empty array is returned.
- Throws:
SQLException- if and error occurs while fetching notifications
-
getWarnings
Description copied from interface:QueryExecutorRetrieve and clear the chain of warnings accumulated on this connection.- Specified by:
getWarningsin interfaceQueryExecutor- Returns:
- the first SQLWarning in the chain; subsequent warnings can be found via SQLWarning.getNextWarning().
-
getServerVersion
Description copied from interface:QueryExecutorReturn the server version from the server_version GUC.Note that there's no requirement for this to be numeric or of the form x.y.z. PostgreSQL development releases usually have the format x.ydevel e.g. 9.4devel; betas usually x.ybetan e.g. 9.4beta1. The --with-extra-version configure option may add an arbitrary string to this.
Don't use this string for logic, only use it when displaying the server version to the user. Prefer getServerVersionNum() for all logic purposes.
- Specified by:
getServerVersionin interfaceQueryExecutor- Returns:
- the server version string from the server_version GUC
-
getServerVersionNum
public int getServerVersionNum()Description copied from interface:QueryExecutorGet a machine-readable server version.This returns the value of the server_version_num GUC. If no such GUC exists, it falls back on attempting to parse the text server version for the major version. If there's no minor version (e.g. a devel or beta release) then the minor version is set to zero. If the version could not be parsed, zero is returned.
- Specified by:
getServerVersionNumin interfaceQueryExecutor- Returns:
- the server version in numeric XXYYZZ form, eg 090401, from server_version_num
-
setServerVersion
-
setServerVersionNum
public void setServerVersionNum(int serverVersionNum) -
setTransactionState
-
setStandardConformingStrings
public void setStandardConformingStrings(boolean value) -
getStandardConformingStrings
public boolean getStandardConformingStrings()Description copied from interface:QueryExecutorReturns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules. Versions up to 8.1 always treated backslashes as escape characters in string-literals. Since 8.2, this depends on the value of thestandard_conforming_stringsserver variable.- Specified by:
getStandardConformingStringsin interfaceQueryExecutor- Returns:
- true if the server treats string literals according to the SQL standard
-
getQuoteReturningIdentifiers
public boolean getQuoteReturningIdentifiers()- Specified by:
getQuoteReturningIdentifiersin interfaceQueryExecutor- Returns:
- true if we are going to quote identifier provided in the returning array default is true
-
getTransactionState
Description copied from interface:QueryExecutorGet the current transaction state of this connection.- Specified by:
getTransactionStatein interfaceQueryExecutor- Returns:
- a ProtocolConnection.TRANSACTION_* constant.
-
setEncoding
- Throws:
IOException
-
getEncoding
- Specified by:
getEncodingin interfaceQueryExecutor- Returns:
- the current encoding in use by this connection
-
isReWriteBatchedInsertsEnabled
public boolean isReWriteBatchedInsertsEnabled()- Specified by:
isReWriteBatchedInsertsEnabledin interfaceQueryExecutor
-
borrowQuery
- Specified by:
borrowQueryin interfaceQueryExecutor- Throws:
SQLException
-
borrowCallableQuery
- Specified by:
borrowCallableQueryin interfaceQueryExecutor- Throws:
SQLException
-
borrowReturningQuery
public final CachedQuery borrowReturningQuery(String sql, String @Nullable [] columnNames) throws SQLException - Specified by:
borrowReturningQueryin interfaceQueryExecutor- Throws:
SQLException
-
borrowQueryByKey
- Specified by:
borrowQueryByKeyin interfaceQueryExecutor- Throws:
SQLException
-
releaseQuery
- Specified by:
releaseQueryin interfaceQueryExecutor
-
createQueryKey
public final Object createQueryKey(String sql, boolean escapeProcessing, boolean isParameterized, String @Nullable ... columnNames) - Specified by:
createQueryKeyin interfaceQueryExecutor
-
createQueryByKey
- Specified by:
createQueryByKeyin interfaceQueryExecutor- Throws:
SQLException
-
createQuery
public final CachedQuery createQuery(String sql, boolean escapeProcessing, boolean isParameterized, String @Nullable ... columnNames) throws SQLException - Specified by:
createQueryin interfaceQueryExecutor- Throws:
SQLException
-
isColumnSanitiserDisabled
public boolean isColumnSanitiserDisabled()- Specified by:
isColumnSanitiserDisabledin interfaceQueryExecutor
-
getEscapeSyntaxCallMode
- Specified by:
getEscapeSyntaxCallModein interfaceQueryExecutor
-
getPreferQueryMode
- Specified by:
getPreferQueryModein interfaceQueryExecutor
-
setPreferQueryMode
- Specified by:
setPreferQueryModein interfaceQueryExecutor
-
getAutoSave
- Specified by:
getAutoSavein interfaceQueryExecutor
-
setAutoSave
- Specified by:
setAutoSavein interfaceQueryExecutor
-
willHealViaReparse
-
willHealOnRetry
- Specified by:
willHealOnRetryin interfaceQueryExecutor
-
isFlushCacheOnDeallocate
public boolean isFlushCacheOnDeallocate() -
setFlushCacheOnDeallocate
public void setFlushCacheOnDeallocate(boolean flushCacheOnDeallocate) Description copied from interface:QueryExecutorBy default, the connection resets statement cache in case deallocate all/discard all message is observed. This API allows to disable that feature for testing purposes.- Specified by:
setFlushCacheOnDeallocatein interfaceQueryExecutor- Parameters:
flushCacheOnDeallocate- true if statement cache should be reset when "deallocate/discard" message observed
-
hasNotifications
protected boolean hasNotifications() -
getParameterStatuses
- Specified by:
getParameterStatusesin interfaceQueryExecutor
-
getParameterStatus
- Specified by:
getParameterStatusin interfaceQueryExecutor
-
onParameterStatus
Update the parameter status map in response to a new ParameterStatus wire protocol message.The server sends ParameterStatus messages when GUC_REPORT settings are initially assigned and whenever they change.
A future version may invoke a client-defined listener class at this point, so this should be the only access path.
Keys are case-insensitive and case-preserving.
The server doesn't provide a way to report deletion of a reportable parameter so we don't expose one here.
- Parameters:
parameterName- case-insensitive case-preserving name of parameter to create or updateparameterStatus- new value of parameter- See Also:
-
getCloseAction()instead