Class PostgresDatabase

All Implemented Interfaces:
AutoCloseable, Database, PrioritizedService
Direct Known Subclasses:
CockroachDatabase, EnterpriseDBDatabase

public class PostgresDatabase extends AbstractPostgresDatabase
Encapsulates PostgreSQL database support.
  • Field Details

    • PRODUCT_NAME

      public static final String PRODUCT_NAME
      See Also:
    • MINIMUM_DBMS_MAJOR_VERSION

      public static final int MINIMUM_DBMS_MAJOR_VERSION
      See Also:
    • MINIMUM_DBMS_MINOR_VERSION

      public static final int MINIMUM_DBMS_MINOR_VERSION
      See Also:
    • VALID_AUTO_INCREMENT_COLUMN_TYPE_NAMES

      public static final List<String> VALID_AUTO_INCREMENT_COLUMN_TYPE_NAMES
      The data type names which are valid for auto-increment columns.
  • Constructor Details

    • PostgresDatabase

      public PostgresDatabase()
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class AbstractJdbcDatabase
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractJdbcDatabase
    • getShortName

      public String getShortName()
      Description copied from interface: Database
      Returns an all-lower-case short name of the product. Used for end-user selecting of database type such as the DBMS precondition.
    • getDefaultDatabaseProductName

      protected String getDefaultDatabaseProductName()
      Specified by:
      getDefaultDatabaseProductName in class AbstractJdbcDatabase
    • getDefaultPort

      public Integer getDefaultPort()
    • getPriority

      public int getPriority()
    • supportsInitiallyDeferrableColumns

      public boolean supportsInitiallyDeferrableColumns()
      Description copied from interface: Database
      Returns whether this database support initially deferrable columns.
    • isCorrectDatabaseImplementation

      public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException
      Description copied from interface: Database
      Is this AbstractDatabase subclass the correct one to use for the given connection.
      Throws:
      DatabaseException
    • getDefaultDriver

      public String getDefaultDriver(String url)
      Description copied from interface: Database
      If this database understands the given url, return the default driver class name. Otherwise return null.
    • supportsSequences

      public boolean supportsSequences()
      Description copied from class: AbstractJdbcDatabase
      Does the database type support sequence.
      Specified by:
      supportsSequences in interface Database
      Overrides:
      supportsSequences in class AbstractJdbcDatabase
    • setConnection

      public void setConnection(DatabaseConnection conn)
      Specified by:
      setConnection in interface Database
      Overrides:
      setConnection in class AbstractJdbcDatabase
    • supportsTablespaces

      public boolean supportsTablespaces()
    • getAutoIncrementClause

      public String getAutoIncrementClause()
      Overrides:
      getAutoIncrementClause in class AbstractJdbcDatabase
    • getAutoIncrementClause

      protected String getAutoIncrementClause(String generationType, Boolean defaultOnNull)
      Description copied from class: AbstractJdbcDatabase
      Default implementation. Intended for override in database specific cases
      Overrides:
      getAutoIncrementClause in class AbstractJdbcDatabase
    • generateAutoIncrementStartWith

      public boolean generateAutoIncrementStartWith(BigInteger startWith)
      Overrides:
      generateAutoIncrementStartWith in class AbstractJdbcDatabase
    • generateAutoIncrementBy

      public boolean generateAutoIncrementBy(BigInteger incrementBy)
      Overrides:
      generateAutoIncrementBy in class AbstractJdbcDatabase
    • generatePrimaryKeyName

      public String generatePrimaryKeyName(String tableName)
      Generates PK following PostgreSQL conventions:
    • Postgres PK size is limited with 63 bytes.
    • Postgres PK is suffixed with '_pkey'.
    • Specified by:
      generatePrimaryKeyName in interface Database
      Overrides:
      generatePrimaryKeyName in class AbstractJdbcDatabase
      Parameters:
      tableName - Table name as the base name for the generated PK.
      Returns:
      PK name.
    • getMaxFractionalDigitsForTimestamp

      public int getMaxFractionalDigitsForTimestamp()
      Description copied from class: AbstractJdbcDatabase
      Most relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.
      Specified by:
      getMaxFractionalDigitsForTimestamp in interface Database
      Overrides:
      getMaxFractionalDigitsForTimestamp in class AbstractJdbcDatabase
      Returns:
      the maximum number of supported fractional digits in TIMESTAMP columns
    • rollback

      public void rollback() throws DatabaseException
      Specified by:
      rollback in interface Database
      Overrides:
      rollback in class AbstractJdbcDatabase
      Throws:
      DatabaseException
    • saveSearchPath

      public void saveSearchPath(String searchPath)
    • restoreSearchPath

      public void restoreSearchPath() throws DatabaseException
      Throws:
      DatabaseException
    • supportsCreateIfNotExists

      public boolean supportsCreateIfNotExists(Class<? extends DatabaseObject> type)
      Description copied from interface: Database
      Does the database support the "if not exits" syntax?
      Parameters:
      type - the DatabaseObject type to be checked.
      Returns:
      true if the "if not exists" syntax is supported, false otherwise.
    • supportsDatabaseChangeLogHistory

      public boolean supportsDatabaseChangeLogHistory()
      Description copied from interface: Database
      Does the particular database implementation support the database changelog history feature and associated table?
      Returns:
      true if supported, false otherwise
    • supportsEnumTypeSnapshot

      public boolean supportsEnumTypeSnapshot()
      Description copied from class: AbstractPostgresDatabase
      Whether PostgreSQL-style enumerated types (CREATE TYPE ... AS ENUM (...)) on this database can be read by the standard enum-type snapshot generator. Named for snapshot-ability, not raw SQL capability.
      Overrides:
      supportsEnumTypeSnapshot in class AbstractPostgresDatabase
      Returns:
      true if enum types on this database are snapshot-able via the standard generator
    • supportsCompositeTypeSnapshot

      public boolean supportsCompositeTypeSnapshot()
      Description copied from class: AbstractPostgresDatabase
      Whether PostgreSQL-style composite types (CREATE TYPE ... AS (...)) on this database can be read by the standard composite-type snapshot generator. Named for snapshot-ability, not raw SQL capability: a variant may accept the DDL yet return false here because the standard generator cannot read its catalog.
      Overrides:
      supportsCompositeTypeSnapshot in class AbstractPostgresDatabase
      Returns:
      true if composite types on this database are snapshot-able via the standard generator
    • supportsCheckConstraintSnapshot

      public boolean supportsCheckConstraintSnapshot()
      Description copied from class: AbstractPostgresDatabase
      Whether check constraints on this database can be read by the standard check-constraint snapshot service. Named for snapshot-ability, not enforcement: e.g. Redshift accepts CHECK in DDL but never enforces it and exposes no usable catalog for it, so it returns false. (Cross-family concept; non-Postgres families still gate via instanceof in StandardCheckConstraintService until the 6.1+ sweep.)
      Overrides:
      supportsCheckConstraintSnapshot in class AbstractPostgresDatabase
      Returns:
      true if check constraints on this database are snapshot-able via the standard service
    • supportsStoredLogicSnapshot

      public boolean supportsStoredLogicSnapshot()
      Description copied from class: AbstractPostgresDatabase
      Whether stored database logic (functions, procedures, packages, triggers) can be snapshotted from this database via the standard stored-logic snapshot generators. (Cross-family concept; non-Postgres families still gate via instanceof until the 6.1+ sweep.)
      Overrides:
      supportsStoredLogicSnapshot in class AbstractPostgresDatabase
      Returns:
      true if stored logic on this database is snapshot-able via the standard generators