public abstract class QueryExecutorBase extends java.lang.Object implements QueryExecutor
Modifier and Type | Field and Description |
---|---|
protected QueryExecutorCloseAction |
closeAction |
protected ResourceLock |
lock |
protected java.util.concurrent.locks.Condition |
lockCondition |
protected boolean |
logServerErrorDetail |
protected PGStream |
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
Modifier | Constructor and Description |
---|---|
protected |
QueryExecutorBase(PGStream pgStream,
int cancelSignalTimeout,
java.util.Properties info) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort at network level without sending the Terminate message to the backend.
|
void |
addNotification(PGNotification notification) |
void |
addWarning(java.sql.SQLWarning newWarning) |
CachedQuery |
borrowCallableQuery(java.lang.String sql) |
CachedQuery |
borrowQuery(java.lang.String sql) |
CachedQuery |
borrowQueryByKey(java.lang.Object key) |
CachedQuery |
borrowReturningQuery(java.lang.String sql,
java.lang.String[] columnNames) |
void |
close()
Close this connection cleanly.
|
protected QueryExecutorCloseAction |
createCloseAction() |
CachedQuery |
createQuery(java.lang.String sql,
boolean escapeProcessing,
boolean isParameterized,
java.lang.String... columnNames) |
CachedQuery |
createQueryByKey(java.lang.Object key) |
java.lang.Object |
createQueryKey(java.lang.String sql,
boolean escapeProcessing,
boolean isParameterized,
java.lang.String... columnNames) |
AutoSave |
getAutoSave() |
int |
getBackendPID()
Return the process ID (PID) of the backend server process handling this connection.
|
java.io.Closeable |
getCloseAction()
Returns an action that would close the connection cleanly.
|
java.lang.String |
getDatabase() |
Encoding |
getEncoding() |
EscapeSyntaxCallMode |
getEscapeSyntaxCallMode() |
HostSpec |
getHostSpec() |
int |
getNetworkTimeout() |
PGNotification[] |
getNotifications()
Retrieve and clear the set of asynchronous notifications pending on this connection.
|
java.lang.String |
getParameterStatus(java.lang.String parameterName) |
java.util.Map<java.lang.String,java.lang.String> |
getParameterStatuses() |
PreferQueryMode |
getPreferQueryMode() |
boolean |
getQuoteReturningIdentifiers() |
java.lang.String |
getServerVersion()
Return the server version from the server_version GUC.
|
int |
getServerVersionNum()
Get a machine-readable server version.
|
boolean |
getStandardConformingStrings()
Returns whether the server treats string-literals according to the SQL standard or if it uses
traditional PostgreSQL escaping rules.
|
TransactionState |
getTransactionState()
Get the current transaction state of this connection.
|
java.lang.String |
getUser() |
java.sql.SQLWarning |
getWarnings()
Retrieve and clear the chain of warnings accumulated on this connection.
|
protected boolean |
hasNotifications() |
boolean |
isClosed()
Check if this connection is closed.
|
boolean |
isColumnSanitiserDisabled() |
boolean |
isFlushCacheOnDeallocate() |
boolean |
isReWriteBatchedInsertsEnabled() |
protected void |
onParameterStatus(java.lang.String parameterName,
java.lang.String parameterStatus)
Update the parameter status map in response to a new ParameterStatus
wire protocol message.
|
void |
releaseQuery(CachedQuery cachedQuery) |
protected abstract void |
sendCloseMessage()
Deprecated.
use
getCloseAction() instead |
void |
sendQueryCancel()
Sends a query cancellation for this connection.
|
void |
setAutoSave(AutoSave autoSave) |
void |
setBackendKeyData(int cancelPid,
int cancelKey) |
void |
setEncoding(Encoding encoding) |
void |
setFlushCacheOnDeallocate(boolean flushCacheOnDeallocate)
By default, the connection resets statement cache in case deallocate all/discard all
message is observed.
|
void |
setNetworkTimeout(int milliseconds) |
void |
setPreferQueryMode(PreferQueryMode mode) |
void |
setServerVersion(java.lang.String serverVersion) |
void |
setServerVersionNum(int serverVersionNum) |
void |
setStandardConformingStrings(boolean value) |
void |
setTransactionState(TransactionState state) |
boolean |
willHealOnRetry(java.sql.SQLException e) |
protected boolean |
willHealViaReparse(java.sql.SQLException e) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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, wrap
useBinaryForReceive, useBinaryForSend
protected final PGStream pgStream
protected final QueryExecutorCloseAction closeAction
protected final boolean logServerErrorDetail
protected final ResourceLock lock
protected final java.util.concurrent.locks.Condition lockCondition
protected QueryExecutorBase(PGStream pgStream, int cancelSignalTimeout, java.util.Properties info) throws java.sql.SQLException
java.sql.SQLException
protected QueryExecutorCloseAction createCloseAction()
@Deprecated protected abstract void sendCloseMessage() throws java.io.IOException
getCloseAction()
insteadjava.io.IOException
- in case connection termination failspublic void setNetworkTimeout(int milliseconds) throws java.io.IOException
setNetworkTimeout
in interface QueryExecutor
java.io.IOException
public int getNetworkTimeout() throws java.io.IOException
getNetworkTimeout
in interface QueryExecutor
java.io.IOException
public HostSpec getHostSpec()
getHostSpec
in interface QueryExecutor
public java.lang.String getUser()
getUser
in interface QueryExecutor
public java.lang.String getDatabase()
getDatabase
in interface QueryExecutor
public void setBackendKeyData(int cancelPid, int cancelKey)
public int getBackendPID()
QueryExecutor
getBackendPID
in interface QueryExecutor
public void abort()
QueryExecutor
abort
in interface QueryExecutor
public java.io.Closeable getCloseAction()
QueryExecutor
QueryExecutor
.getCloseAction
in interface QueryExecutor
public void close()
QueryExecutor
close
in interface QueryExecutor
public boolean isClosed()
QueryExecutor
isClosed
in interface QueryExecutor
public void sendQueryCancel() throws java.sql.SQLException
QueryExecutor
sendQueryCancel
in interface QueryExecutor
java.sql.SQLException
- if something goes wrong.public void addWarning(java.sql.SQLWarning newWarning)
public void addNotification(PGNotification notification)
public PGNotification[] getNotifications() throws java.sql.SQLException
QueryExecutor
getNotifications
in interface QueryExecutor
java.sql.SQLException
- if and error occurs while fetching notificationspublic java.sql.SQLWarning getWarnings()
QueryExecutor
getWarnings
in interface QueryExecutor
public java.lang.String getServerVersion()
QueryExecutor
Return 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.
getServerVersion
in interface QueryExecutor
public int getServerVersionNum()
QueryExecutor
Get 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.
getServerVersionNum
in interface QueryExecutor
public void setServerVersion(java.lang.String serverVersion)
public void setServerVersionNum(int serverVersionNum)
public void setTransactionState(TransactionState state)
public void setStandardConformingStrings(boolean value)
public boolean getStandardConformingStrings()
QueryExecutor
standard_conforming_strings
server variable.getStandardConformingStrings
in interface QueryExecutor
public boolean getQuoteReturningIdentifiers()
getQuoteReturningIdentifiers
in interface QueryExecutor
public TransactionState getTransactionState()
QueryExecutor
getTransactionState
in interface QueryExecutor
public void setEncoding(Encoding encoding) throws java.io.IOException
java.io.IOException
public Encoding getEncoding()
getEncoding
in interface QueryExecutor
public boolean isReWriteBatchedInsertsEnabled()
isReWriteBatchedInsertsEnabled
in interface QueryExecutor
public final CachedQuery borrowQuery(java.lang.String sql) throws java.sql.SQLException
borrowQuery
in interface QueryExecutor
java.sql.SQLException
public final CachedQuery borrowCallableQuery(java.lang.String sql) throws java.sql.SQLException
borrowCallableQuery
in interface QueryExecutor
java.sql.SQLException
public final CachedQuery borrowReturningQuery(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
borrowReturningQuery
in interface QueryExecutor
java.sql.SQLException
public CachedQuery borrowQueryByKey(java.lang.Object key) throws java.sql.SQLException
borrowQueryByKey
in interface QueryExecutor
java.sql.SQLException
public void releaseQuery(CachedQuery cachedQuery)
releaseQuery
in interface QueryExecutor
public final java.lang.Object createQueryKey(java.lang.String sql, boolean escapeProcessing, boolean isParameterized, java.lang.String... columnNames)
createQueryKey
in interface QueryExecutor
public CachedQuery createQueryByKey(java.lang.Object key) throws java.sql.SQLException
createQueryByKey
in interface QueryExecutor
java.sql.SQLException
public final CachedQuery createQuery(java.lang.String sql, boolean escapeProcessing, boolean isParameterized, java.lang.String... columnNames) throws java.sql.SQLException
createQuery
in interface QueryExecutor
java.sql.SQLException
public boolean isColumnSanitiserDisabled()
isColumnSanitiserDisabled
in interface QueryExecutor
public EscapeSyntaxCallMode getEscapeSyntaxCallMode()
getEscapeSyntaxCallMode
in interface QueryExecutor
public PreferQueryMode getPreferQueryMode()
getPreferQueryMode
in interface QueryExecutor
public void setPreferQueryMode(PreferQueryMode mode)
setPreferQueryMode
in interface QueryExecutor
public AutoSave getAutoSave()
getAutoSave
in interface QueryExecutor
public void setAutoSave(AutoSave autoSave)
setAutoSave
in interface QueryExecutor
protected boolean willHealViaReparse(java.sql.SQLException e)
public boolean willHealOnRetry(java.sql.SQLException e)
willHealOnRetry
in interface QueryExecutor
public boolean isFlushCacheOnDeallocate()
public void setFlushCacheOnDeallocate(boolean flushCacheOnDeallocate)
QueryExecutor
setFlushCacheOnDeallocate
in interface QueryExecutor
flushCacheOnDeallocate
- true if statement cache should be reset when "deallocate/discard" message observedprotected boolean hasNotifications()
public final java.util.Map<java.lang.String,java.lang.String> getParameterStatuses()
getParameterStatuses
in interface QueryExecutor
public final java.lang.String getParameterStatus(java.lang.String parameterName)
getParameterStatus
in interface QueryExecutor
protected void onParameterStatus(java.lang.String parameterName, java.lang.String parameterStatus)
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.
parameterName
- case-insensitive case-preserving name of parameter to create or updateparameterStatus
- new value of parameterPGConnection.getParameterStatuses()
,
PGConnection.getParameterStatus(java.lang.String)
Copyright © 2024 PostgreSQL Global Development Group. All rights reserved.