Class PostgresDictionary

    • Field Detail

      • _timestampTypes

        protected java.util.Set<java.lang.String> _timestampTypes
      • allSequencesSQL

        public java.lang.String allSequencesSQL
        SQL statement to load all sequence schema,name pairs from all schemas.
      • namedSequencesFromAllSchemasSQL

        public java.lang.String namedSequencesFromAllSchemasSQL
        SQL statement to load schema,name pairs for all sequences with a certain name from all schemas.
      • allSequencesFromOneSchemaSQL

        public java.lang.String allSequencesFromOneSchemaSQL
        SQL statement to load schema,name pairs from a named schema.
      • namedSequenceFromOneSchemaSQL

        public java.lang.String namedSequenceFromOneSchemaSQL
        SQL statement to load a sequence's schema,name pair from one schema.
      • supportsSetFetchSize

        public boolean supportsSetFetchSize
        Some Postgres drivers do not support the Statement.setFetchSize(int) method.
      • isOwnedSequenceSQL

        public java.lang.String isOwnedSequenceSQL
        Statement used to determine whether a sequence is owned. Owned sequences are managed by the database and are considered system sequences. parm 1: '' parm 2: ''
    • Constructor Detail

      • PostgresDictionary

        public PostgresDictionary()
    • Method Detail

      • getDate

        public java.util.Date getDate​(java.sql.ResultSet rs,
                                      int column)
                               throws java.sql.SQLException
        Description copied from class: DBDictionary
        Convert the specified column of the SQL ResultSet to the proper java type. Converts the date from a Timestamp by default.
        Overrides:
        getDate in class DBDictionary
        Throws:
        java.sql.SQLException
      • getByte

        public byte getByte​(java.sql.ResultSet rs,
                            int column)
                     throws java.sql.SQLException
        Description copied from class: DBDictionary
        Convert the specified column of the SQL ResultSet to the proper java type.
        Overrides:
        getByte in class DBDictionary
        Throws:
        java.sql.SQLException
      • getShort

        public short getShort​(java.sql.ResultSet rs,
                              int column)
                       throws java.sql.SQLException
        Description copied from class: DBDictionary
        Convert the specified column of the SQL ResultSet to the proper java type.
        Overrides:
        getShort in class DBDictionary
        Throws:
        java.sql.SQLException
      • getInt

        public int getInt​(java.sql.ResultSet rs,
                          int column)
                   throws java.sql.SQLException
        Description copied from class: DBDictionary
        Convert the specified column of the SQL ResultSet to the proper java type.
        Overrides:
        getInt in class DBDictionary
        Throws:
        java.sql.SQLException
      • getLong

        public long getLong​(java.sql.ResultSet rs,
                            int column)
                     throws java.sql.SQLException
        Description copied from class: DBDictionary
        Convert the specified column of the SQL ResultSet to the proper java type.
        Overrides:
        getLong in class DBDictionary
        Throws:
        java.sql.SQLException
      • setNull

        public void setNull​(java.sql.PreparedStatement stmnt,
                            int idx,
                            int colType,
                            Column col)
                     throws java.sql.SQLException
        Handle XML and bytea/oid columns in a PostgreSQL way.
        Overrides:
        setNull in class DBDictionary
        Throws:
        java.sql.SQLException
      • appendSelectRange

        protected void appendSelectRange​(SQLBuffer buf,
                                         long start,
                                         long end,
                                         boolean subselect)
        Description copied from class: DBDictionary
        If this dictionary can select ranges, use this method to append the range SQL.
        Overrides:
        appendSelectRange in class DBDictionary
      • indexOf

        public void indexOf​(SQLBuffer buf,
                            FilterValue str,
                            FilterValue find,
                            FilterValue start)
        Description copied from class: DBDictionary
        Invoke this database's indexOf function.
        Overrides:
        indexOf in class DBDictionary
        Parameters:
        buf - the SQL buffer to write the indexOf invocation to
        str - a query value representing the target string
        find - a query value representing the search string
        start - a query value representing the start index, or null to start at the beginning
      • getSequencesSQL

        protected java.lang.String getSequencesSQL​(java.lang.String schemaName,
                                                   java.lang.String sequenceName)
        Description copied from class: DBDictionary
        Return the SQL needed to select the list of sequences.
        Overrides:
        getSequencesSQL in class DBDictionary
      • isSystemSequence

        public boolean isSystemSequence​(java.lang.String name,
                                        java.lang.String schema,
                                        boolean targetSchema)
        Description copied from class: DBDictionary
        This method is used to filter system sequences from database metadata. Return true if the given sequence represents a system sequence that should not appear in the schema definition. Returns true if system schema by default.
        Overrides:
        isSystemSequence in class DBDictionary
        Parameters:
        name - the table name
        schema - the table schema; may be null
        targetSchema - if true, then the given schema was listed by the user as one of his schemas
      • isSystemSequence

        public boolean isSystemSequence​(DBIdentifier name,
                                        DBIdentifier schema,
                                        boolean targetSchema)
        Description copied from class: DBDictionary
        This method is used to filter system sequences from database metadata. Return true if the given sequence represents a system sequence that should not appear in the schema definition. Returns true if system schema by default.
        Overrides:
        isSystemSequence in class DBDictionary
        Parameters:
        name - the table name
        schema - the table schema; may be null
        targetSchema - if true, then the given schema was listed by the user as one of his schemas
      • isSystemSequence

        public boolean isSystemSequence​(DBIdentifier name,
                                        DBIdentifier schema,
                                        boolean targetSchema,
                                        java.sql.Connection conn)
        Description copied from class: DBDictionary
        This method is used to filter system sequences from database metadata. Return true if the given sequence represents a system sequence that should not appear in the schema definition. Returns true if system schema by default.
        Overrides:
        isSystemSequence in class DBDictionary
        Parameters:
        name - the table name
        schema - the table schema; may be null
        targetSchema - if true, then the given schema was listed by the user as one of his schemas
        conn - connection to the database
      • isOwnedSequence

        public boolean isOwnedSequence​(DBIdentifier name,
                                       DBIdentifier schema,
                                       java.sql.Connection conn)
        Uses the native Postgres function pg_get_serial_sequence to determine whether a sequence is owned by the database. Column types such as bigserial use a system assigned sequence generator of the format: table_column_seq
      • isSystemTable

        public boolean isSystemTable​(java.lang.String name,
                                     java.lang.String schema,
                                     boolean targetSchema)
        Description copied from class: DBDictionary
        This method is used to filter system tables from database metadata. Return true if the given table name represents a system table that should not appear in the schema definition. By default, returns true only if the given table is in the internal list of system tables, or if the given schema is in the list of system schemas and is not the target schema.
        Overrides:
        isSystemTable in class DBDictionary
        Parameters:
        name - the table name
        schema - the table schema; may be null
        targetSchema - if true, then the given schema was listed by the user as one of his schemas
      • isSystemTable

        public boolean isSystemTable​(DBIdentifier name,
                                     DBIdentifier schema,
                                     boolean targetSchema)
        Description copied from class: DBDictionary
        This method is used to filter system tables from database metadata. Return true if the given table name represents a system table that should not appear in the schema definition. By default, returns true only if the given table is in the internal list of system tables, or if the given schema is in the list of system schemas and is not the target schema.
        Overrides:
        isSystemTable in class DBDictionary
        Parameters:
        name - the table name
        schema - the table schema; may be null
        targetSchema - if true, then the given schema was listed by the user as one of his schemas
      • isSystemIndex

        public boolean isSystemIndex​(java.lang.String name,
                                     Table table)
        Description copied from class: DBDictionary
        This method is used to filter system indexes from database metadata. Return true if the given index name represents a system index that should not appear in the schema definition. Returns false by default.
        Overrides:
        isSystemIndex in class DBDictionary
        Parameters:
        name - the index name
        table - the index table
      • isSystemIndex

        public boolean isSystemIndex​(DBIdentifier name,
                                     Table table)
        Description copied from class: DBDictionary
        This method is used to filter system indexes from database metadata. Return true if the given index name represents a system index that should not appear in the schema definition. Returns false by default.
        Overrides:
        isSystemIndex in class DBDictionary
        Parameters:
        name - the index name
        table - the index table
      • decorate

        public java.sql.Connection decorate​(java.sql.Connection conn)
                                     throws java.sql.SQLException
        Description copied from class: DBDictionary
        Decorate the given connection if needed. Some databases require special handling for JDBC bugs. This implementation issues any DBDictionary.initializationSQL that has been set for the dictionary but does not decorate the connection.
        Specified by:
        decorate in interface ConnectionDecorator
        Overrides:
        decorate in class DBDictionary
        Throws:
        java.sql.SQLException
      • getLOBStream

        public java.io.InputStream getLOBStream​(JDBCStore store,
                                                java.sql.ResultSet rs,
                                                int column)
                                         throws java.sql.SQLException
        Overrides:
        getLOBStream in class DBDictionary
        Throws:
        java.sql.SQLException
      • updateBlob

        public void updateBlob​(Select sel,
                               JDBCStore store,
                               java.io.InputStream is)
                        throws java.sql.SQLException
        Overrides:
        updateBlob in class DBDictionary
        Throws:
        java.sql.SQLException
      • getLocalDate

        public java.time.LocalDate getLocalDate​(java.sql.ResultSet rs,
                                                int column)
                                         throws java.sql.SQLException
        Description copied from class: DBDictionary
        Retrieve the specified column of the SQL ResultSet to the proper LocalDate java type.
        Overrides:
        getLocalDate in class DBDictionary
        Throws:
        java.sql.SQLException
      • getLocalTime

        public java.time.LocalTime getLocalTime​(java.sql.ResultSet rs,
                                                int column)
                                         throws java.sql.SQLException
        Description copied from class: DBDictionary
        Retrieve the specified column of the SQL ResultSet to the proper LocalTime java type.
        Overrides:
        getLocalTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • getLocalDateTime

        public java.time.LocalDateTime getLocalDateTime​(java.sql.ResultSet rs,
                                                        int column)
                                                 throws java.sql.SQLException
        Description copied from class: DBDictionary
        Retrieve the specified column of the SQL ResultSet to the proper LocalDateTime java type.
        Overrides:
        getLocalDateTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • getOffsetDateTime

        public java.time.OffsetDateTime getOffsetDateTime​(java.sql.ResultSet rs,
                                                          int column)
                                                   throws java.sql.SQLException
        Description copied from class: DBDictionary
        Retrieve the specified column of the SQL ResultSet to the proper OffsetDateTime java type.
        Overrides:
        getOffsetDateTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • setOffsetTime

        public void setOffsetTime​(java.sql.PreparedStatement stmnt,
                                  int idx,
                                  java.time.OffsetTime val,
                                  Column col)
                           throws java.sql.SQLException
        default column type for OffsetTime is 'time with time zone'. But opposed to the name PostgreSQL internally stores those values in UTC time without any timezone.
        Overrides:
        setOffsetTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • getOffsetTime

        public java.time.OffsetTime getOffsetTime​(java.sql.ResultSet rs,
                                                  int column)
                                           throws java.sql.SQLException
        Description copied from class: DBDictionary
        Retrieve the specified column of the SQL ResultSet to the proper OffsetTime java type.
        Overrides:
        getOffsetTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • setLocalDate

        public void setLocalDate​(java.sql.PreparedStatement stmnt,
                                 int idx,
                                 java.time.LocalDate val,
                                 Column col)
                          throws java.sql.SQLException
        Description copied from class: DBDictionary
        Set the given LocalDate value as a parameter to the statement.
        Overrides:
        setLocalDate in class DBDictionary
        Throws:
        java.sql.SQLException
      • setLocalTime

        public void setLocalTime​(java.sql.PreparedStatement stmnt,
                                 int idx,
                                 java.time.LocalTime val,
                                 Column col)
                          throws java.sql.SQLException
        Description copied from class: DBDictionary
        Set the given LocalTime value as a parameter to the statement.
        Overrides:
        setLocalTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • setLocalDateTime

        public void setLocalDateTime​(java.sql.PreparedStatement stmnt,
                                     int idx,
                                     java.time.LocalDateTime val,
                                     Column col)
                              throws java.sql.SQLException
        Description copied from class: DBDictionary
        Set the given LocalTime value as a parameter to the statement.
        Overrides:
        setLocalDateTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • setOffsetDateTime

        public void setOffsetDateTime​(java.sql.PreparedStatement stmnt,
                                      int idx,
                                      java.time.OffsetDateTime val,
                                      Column col)
                               throws java.sql.SQLException
        Description copied from class: DBDictionary
        Set the given LocalTime value as a parameter to the statement.
        Overrides:
        setOffsetDateTime in class DBDictionary
        Throws:
        java.sql.SQLException
      • connectedConfiguration

        public void connectedConfiguration​(java.sql.Connection conn)
                                    throws java.sql.SQLException
        Determine XML column support and backslash handling, etc
        Overrides:
        connectedConfiguration in class DBDictionary
        Throws:
        java.sql.SQLException
      • isFatalException

        public boolean isFatalException​(int subtype,
                                        java.sql.SQLException ex)
        Description copied from class: DBDictionary
        Determine if the given SQL Exception is fatal or recoverable (such as a timeout). This implementation always returns true (i.e. all exceptions are fatal). The current dictionary implementation can overwrite this method to mark certain exception conditions as recoverable error.
        Overrides:
        isFatalException in class DBDictionary
        Parameters:
        subtype - A constant indicating the category of error as defined in StoreException.
        ex - original SQL Exception as raised by the database driver.
        Returns:
        false if the error is fatal.
      • setClobString

        public void setClobString​(java.sql.PreparedStatement stmnt,
                                  int idx,
                                  java.lang.String val,
                                  Column col)
                           throws java.sql.SQLException
        If column is an XML column, PostgreSQL requires that its value is set by using PreparedStatement.setObject(int, Object, int) with Types.OTHER as the third argument.
        Overrides:
        setClobString in class DBDictionary
        Throws:
        java.sql.SQLException
      • getObject

        public java.lang.Object getObject​(java.sql.ResultSet rs,
                                          int column,
                                          java.util.Map map)
                                   throws java.sql.SQLException
        Override the getOjbect() method to handle the case where the latest Postgres JDBC driver returns a org.postgresql.util.PGobject instead of a java.sql.Timestamp
        Overrides:
        getObject in class DBDictionary
        Parameters:
        rs -
        column -
        map -
        Throws:
        java.sql.SQLException
      • appendXmlComparison

        public void appendXmlComparison​(SQLBuffer buf,
                                        java.lang.String op,
                                        FilterValue lhs,
                                        FilterValue rhs,
                                        boolean lhsxml,
                                        boolean rhsxml)
        Append XML comparison.
        Overrides:
        appendXmlComparison in class DBDictionary
        Parameters:
        buf - the SQL buffer to write the comparison
        op - the comparison operation to perform
        lhs - the left hand side of the comparison
        rhs - the right hand side of the comparison
        lhsxml - indicates whether the left operand maps to XML
        rhsxml - indicates whether the right operand maps to XML
      • getPlaceholderValueString

        public java.lang.String getPlaceholderValueString​(Column col)
        Return a SQL string to act as a placeholder for the given column.
        Overrides:
        getPlaceholderValueString in class DBDictionary
      • getLargeObjectManager

        protected org.postgresql.largeobject.LargeObjectManager getLargeObjectManager​(DelegatingConnection conn)
                                                                               throws java.sql.SQLException
        Get the native PostgreSQL Large Object Manager used for LOB handling.
        Throws:
        java.sql.SQLException
      • getPGConnection

        protected org.postgresql.PGConnection getPGConnection​(DelegatingConnection conn)
        Get the native PostgreSQL connection from the given connection. Various attempts of unwrapping are being performed.
      • getDbcpDelegate

        protected java.sql.Connection getDbcpDelegate​(java.sql.Connection conn)
        Get the delegated connection from the given DBCP connection.
        Parameters:
        conn - must be a DBCP connection
        Returns:
        connection the DBCP connection delegates to