Class QueryExecutorBase

    • Field Detail

      • pgStream

        protected final PGStream pgStream
      • logServerErrorDetail

        protected final boolean logServerErrorDetail
    • Constructor Detail

      • QueryExecutorBase

        protected QueryExecutorBase​(PGStream pgStream,
                                    java.lang.String user,
                                    java.lang.String database,
                                    int cancelSignalTimeout,
                                    java.util.Properties info)
                             throws java.sql.SQLException
        Throws:
        java.sql.SQLException
    • Method Detail

      • sendCloseMessage

        protected abstract void sendCloseMessage()
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • setNetworkTimeout

        public void setNetworkTimeout​(int milliseconds)
                               throws java.io.IOException
        Specified by:
        setNetworkTimeout in interface QueryExecutor
        Throws:
        java.io.IOException
      • getNetworkTimeout

        public int getNetworkTimeout()
                              throws java.io.IOException
        Specified by:
        getNetworkTimeout in interface QueryExecutor
        Throws:
        java.io.IOException
      • getHostSpec

        public HostSpec getHostSpec()
        Specified by:
        getHostSpec in interface QueryExecutor
        Returns:
        the host and port this connection is connected to.
      • getUser

        public java.lang.String getUser()
        Specified by:
        getUser in interface QueryExecutor
        Returns:
        the user this connection authenticated as.
      • getDatabase

        public java.lang.String getDatabase()
        Specified by:
        getDatabase in interface QueryExecutor
        Returns:
        the database this connection is connected to.
      • setBackendKeyData

        public void setBackendKeyData​(int cancelPid,
                                      int cancelKey)
      • getBackendPID

        public int getBackendPID()
        Description copied from interface: QueryExecutor
        Return the process ID (PID) of the backend server process handling this connection.
        Specified by:
        getBackendPID in interface QueryExecutor
        Returns:
        process ID (PID) of the backend server process handling this connection
      • abort

        public void abort()
        Description copied from interface: QueryExecutor
        Abort at network level without sending the Terminate message to the backend.
        Specified by:
        abort in interface QueryExecutor
      • close

        public void close()
        Description copied from interface: QueryExecutor
        Close this connection cleanly.
        Specified by:
        close in interface QueryExecutor
      • isClosed

        public boolean isClosed()
        Description copied from interface: QueryExecutor
        Check if this connection is closed.
        Specified by:
        isClosed in interface QueryExecutor
        Returns:
        true iff the connection is closed.
      • sendQueryCancel

        public void sendQueryCancel()
                             throws java.sql.SQLException
        Description copied from interface: QueryExecutor
        Sends a query cancellation for this connection.
        Specified by:
        sendQueryCancel in interface QueryExecutor
        Throws:
        java.sql.SQLException - if something goes wrong.
      • addWarning

        public void addWarning​(java.sql.SQLWarning newWarning)
      • addNotification

        public void addNotification​(PGNotification notification)
      • getNotifications

        public PGNotification[] getNotifications()
                                          throws java.sql.SQLException
        Description copied from interface: QueryExecutor
        Retrieve and clear the set of asynchronous notifications pending on this connection.
        Specified by:
        getNotifications in interface QueryExecutor
        Returns:
        an array of notifications; if there are no notifications, an empty array is returned.
        Throws:
        java.sql.SQLException - if and error occurs while fetching notifications
      • getWarnings

        public java.sql.SQLWarning getWarnings()
        Description copied from interface: QueryExecutor
        Retrieve and clear the chain of warnings accumulated on this connection.
        Specified by:
        getWarnings in interface QueryExecutor
        Returns:
        the first SQLWarning in the chain; subsequent warnings can be found via SQLWarning.getNextWarning().
      • getServerVersion

        public java.lang.String getServerVersion()
        Description copied from interface: 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.

        Specified by:
        getServerVersion in interface QueryExecutor
        Returns:
        the server version string from the server_version guc
      • getServerVersionNum

        public int getServerVersionNum()
        Description copied from interface: 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.

        Specified by:
        getServerVersionNum in interface QueryExecutor
        Returns:
        the server version in numeric XXYYZZ form, eg 090401, from server_version_num
      • setServerVersion

        public void setServerVersion​(java.lang.String serverVersion)
      • setServerVersionNum

        public void setServerVersionNum​(int serverVersionNum)
      • setTransactionState

        public void setTransactionState​(TransactionState state)
      • setStandardConformingStrings

        public void setStandardConformingStrings​(boolean value)
      • getStandardConformingStrings

        public boolean getStandardConformingStrings()
        Description copied from interface: QueryExecutor
        Returns 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 the standard_conforming_strings server variable.
        Specified by:
        getStandardConformingStrings in interface QueryExecutor
        Returns:
        true if the server treats string literals according to the SQL standard
      • setEncoding

        public void setEncoding​(Encoding encoding)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • borrowQuery

        public final CachedQuery borrowQuery​(java.lang.String sql)
                                      throws java.sql.SQLException
        Specified by:
        borrowQuery in interface QueryExecutor
        Throws:
        java.sql.SQLException
      • borrowCallableQuery

        public final CachedQuery borrowCallableQuery​(java.lang.String sql)
                                              throws java.sql.SQLException
        Specified by:
        borrowCallableQuery in interface QueryExecutor
        Throws:
        java.sql.SQLException
      • borrowReturningQuery

        public final CachedQuery borrowReturningQuery​(java.lang.String sql,
                                                      java.lang.String[] columnNames)
                                               throws java.sql.SQLException
        Specified by:
        borrowReturningQuery in interface QueryExecutor
        Throws:
        java.sql.SQLException
      • borrowQueryByKey

        public CachedQuery borrowQueryByKey​(java.lang.Object key)
                                     throws java.sql.SQLException
        Specified by:
        borrowQueryByKey in interface QueryExecutor
        Throws:
        java.sql.SQLException
      • createQueryKey

        public final java.lang.Object createQueryKey​(java.lang.String sql,
                                                     boolean escapeProcessing,
                                                     boolean isParameterized,
                                                     java.lang.String... columnNames)
        Specified by:
        createQueryKey in interface QueryExecutor
      • createQueryByKey

        public CachedQuery createQueryByKey​(java.lang.Object key)
                                     throws java.sql.SQLException
        Specified by:
        createQueryByKey in interface QueryExecutor
        Throws:
        java.sql.SQLException
      • createQuery

        public final CachedQuery createQuery​(java.lang.String sql,
                                             boolean escapeProcessing,
                                             boolean isParameterized,
                                             java.lang.String... columnNames)
                                      throws java.sql.SQLException
        Specified by:
        createQuery in interface QueryExecutor
        Throws:
        java.sql.SQLException
      • willHealViaReparse

        protected boolean willHealViaReparse​(java.sql.SQLException e)
      • isFlushCacheOnDeallocate

        public boolean isFlushCacheOnDeallocate()
      • setFlushCacheOnDeallocate

        public void setFlushCacheOnDeallocate​(boolean flushCacheOnDeallocate)
        Description copied from interface: QueryExecutor
        By 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:
        setFlushCacheOnDeallocate in interface QueryExecutor
        Parameters:
        flushCacheOnDeallocate - true if statement cache should be reset when "deallocate/discard" message observed
      • hasNotifications

        protected boolean hasNotifications()
      • getParameterStatuses

        public final java.util.Map<java.lang.String,​java.lang.String> getParameterStatuses()
        Specified by:
        getParameterStatuses in interface QueryExecutor
      • getParameterStatus

        public final java.lang.String getParameterStatus​(java.lang.String parameterName)
        Specified by:
        getParameterStatus in interface QueryExecutor
      • onParameterStatus

        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.

        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 update
        parameterStatus - new value of parameter
        See Also:
        PGConnection.getParameterStatuses(), PGConnection.getParameterStatus(java.lang.String)