Package liquibase.database.core
Class PostgresDatabase
java.lang.Object
liquibase.database.AbstractJdbcDatabase
liquibase.database.core.PostgresDatabase
- All Implemented Interfaces:
AutoCloseable
,Database
,PrioritizedService
- Direct Known Subclasses:
CockroachDatabase
,EnterpriseDBDatabase
Encapsulates PostgreSQL database support.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final String
The data type names which are valid for auto-increment columns.Fields inherited from class liquibase.database.AbstractJdbcDatabase
caseSensitive, currentDateTimeFunction, dateFunctions, defaultAutoIncrementBy, defaultAutoIncrementStartWith, defaultCatalogName, defaultSchemaName, quotingStrategy, sequenceCurrentValueFunction, sequenceNextValueFunction, unmodifiableDataTypes, unquotedObjectsAreUppercased
Fields inherited from interface liquibase.database.Database
COMPLETE_SQL_SCOPE_KEY
Fields inherited from interface liquibase.servicelocator.PrioritizedService
COMPARATOR, PRIORITY_DATABASE, PRIORITY_DEFAULT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncorrectObjectName
(String objectName, Class<? extends DatabaseObject> objectType) Fix the object name to the format the database expects, handling changes in case, etc.boolean
escapeObjectName
(String objectName, Class<? extends DatabaseObject> objectType) This has special case logic to handle NOT quoting column names if they are of type 'LiquibaseColumn' - columns in the DATABASECHANGELOG or DATABASECHANGELOGLOCK tables.boolean
generateAutoIncrementBy
(BigInteger incrementBy) boolean
generateAutoIncrementStartWith
(BigInteger startWith) generatePrimaryKeyName
(String tableName) Generates PK followingPostgreSQL
conventions: Postgres PK size is limited with 63 bytes.protected String
getAutoIncrementClause
(String generationType, Boolean defaultOnNull) Default implementation.protected SqlStatement
Used to obtain the connection schema name through a statement Override this method to change the statement.protected String
getDefaultDriver
(String url) If this database understands the given url, return the default driver class name.int
Most relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.int
This logic is used when db support catalogsReturns an all-lower-case short name of the product.Returns system (undroppable) views.int
hashCode()
protected boolean
hasMixedCase
(String tableName) boolean
Is this AbstractDatabase subclass the correct one to use for the given connection.boolean
isReservedWord
(String tableName) boolean
isSystemObject
(DatabaseObject example) void
rollback()
void
void
setDefaultCatalogName
(String defaultCatalogName) boolean
supportsCatalogInObjectName
(Class<? extends DatabaseObject> type) boolean
supportsCreateIfNotExists
(Class<? extends DatabaseObject> type) Does the database support the "if not exits" syntax?boolean
Does the particular database implementation support the database changelog history feature and associated table?boolean
Returns whether this database support initially deferrable columns.boolean
Does the database type support sequence.boolean
unescapeDataTypeName
(String dataTypeName) boolean
Should the database use "serial" datatypes vs.Methods inherited from class liquibase.database.AbstractJdbcDatabase
addReservedWords, canCreateChangeLogTable, close, commit, correctSchema, correctSchema, createsIndexesForForeignKeys, dataTypeIsNotModifiable, disableForeignKeyChecks, doesTagExist, dropDatabaseObjects, enableForeignKeyChecks, escapeColumnName, escapeColumnName, escapeColumnNameList, escapeConstraintName, escapeDataTypeName, escapeIndexName, escapeObjectName, escapeSequenceName, escapeStringForDatabase, escapeTableName, escapeViewName, execute, executeRollbackStatements, executeRollbackStatements, executeStatements, filterRollbackVisitors, generateDatabaseFunctionValue, get, getAutoCommitMode, getAutoIncrementByClause, getAutoIncrementClause, getAutoIncrementClosing, getAutoIncrementOpening, getAutoIncrementStartWithClause, getConcatSql, getConnection, getConnectionCatalogName, getConnectionSchemaName, getContainingObjects, getCurrentDateTimeFunction, getDatabaseMajorVersion, getDatabaseMinorVersion, getDatabaseProductName, getDatabaseProductVersion, getDataTypeMaxParameters, getDateFunctions, getDateLiteral, getDateLiteral, getDateLiteral, getDateTimeLiteral, getDefaultCatalogName, getDefaultFractionalDigitsForTimestamp, getDefaultScaleForNativeDataType, getDefaultSchema, getDefaultSchemaName, getFetchSize, getJdbcCatalogName, getJdbcCatalogName, getJdbcSchemaName, getJdbcSchemaName, getLineComment, getLiquibaseCatalogName, getLiquibaseSchemaName, getLiquibaseTablespaceName, getName, getObjectQuotingStrategy, getOutputDefaultCatalog, getOutputDefaultSchema, getQuotingEndCharacter, getQuotingEndReplacement, getQuotingStartCharacter, getRanChangeSet, getRanChangeSetList, getRanDate, getRawDatabaseChangeLogLockTableName, getRawDatabaseChangeLogTableName, getRunStatus, getSchemaFromJdbcInfo, getSystemSchema, getSystemTables, getTimeLiteral, getViewDefinition, isAutoCommit, isCaseSensitive, isCatalogOrSchemaType, isCurrentTimeFunction, isDateOnly, isDateTime, isDefaultCatalog, isDefaultSchema, isFunction, isLiquibaseObject, isSafeToRunUpdate, isSystemView, isTimeOnly, isTimestamp, jdbcCallsCatalogsSchemas, markChangeSetExecStatus, mustQuoteObjectName, parseDate, quoteObject, removeRanStatus, requiresExplicitNullForColumns, requiresPassword, requiresUsername, resetInternalState, saveRollbackStatement, saveStatements, set, setAutoCommit, setCanCacheLiquibaseTableInfo, setCaseSensitive, setCurrentDateTimeFunction, setDatabaseChangeLogLockTableName, setDatabaseChangeLogTableName, setDefaultSchemaName, setLiquibaseCatalogName, setLiquibaseSchemaName, setLiquibaseTablespaceName, setObjectQuotingStrategy, setOutputDefaultCatalog, setOutputDefaultSchema, setPreviousAutoCommit, startsWithNumeric, supportsAutoIncrement, supportsBatchUpdates, supportsCatalogs, supportsDDLInTransaction, supportsDropTableCascadeConstraints, supportsForeignKeyDisable, supportsNotNullConstraintNames, supportsPrimaryKeyNames, supportsRestrictForeignKeys, supportsSchemas, tag, toString, unescapeDataTypeString, validate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface liquibase.database.Database
addCompleteSqlToScope, afterUpdate, checkDatabaseConnection, dropDatabaseObjects, failOnDefferable, generateConnectCommandSuccessMessage, getDisplayName, supports, temporarilySetObjectQuotingStrategy
-
Field Details
-
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
The data type names which are valid for auto-increment columns.
-
-
Constructor Details
-
PostgresDatabase
public PostgresDatabase()
-
-
Method Details
-
equals
- Overrides:
equals
in classAbstractJdbcDatabase
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractJdbcDatabase
-
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
- Specified by:
getDefaultDatabaseProductName
in classAbstractJdbcDatabase
-
getDefaultPort
-
getSystemViews
Description copied from class:AbstractJdbcDatabase
Returns system (undroppable) views.- Overrides:
getSystemViews
in classAbstractJdbcDatabase
-
getPriority
public int getPriority() -
supportsInitiallyDeferrableColumns
public boolean supportsInitiallyDeferrableColumns()Description copied from interface:Database
Returns whether this database support initially deferrable columns. -
isCorrectDatabaseImplementation
Description copied from interface:Database
Is this AbstractDatabase subclass the correct one to use for the given connection.- Throws:
DatabaseException
-
getDefaultDriver
Description copied from interface:Database
If this database understands the given url, return the default driver class name. Otherwise return null. -
supportsCatalogInObjectName
- Specified by:
supportsCatalogInObjectName
in interfaceDatabase
- Overrides:
supportsCatalogInObjectName
in classAbstractJdbcDatabase
-
supportsSequences
public boolean supportsSequences()Description copied from class:AbstractJdbcDatabase
Does the database type support sequence.- Specified by:
supportsSequences
in interfaceDatabase
- Overrides:
supportsSequences
in classAbstractJdbcDatabase
-
getDatabaseChangeLogTableName
- Specified by:
getDatabaseChangeLogTableName
in interfaceDatabase
- Overrides:
getDatabaseChangeLogTableName
in classAbstractJdbcDatabase
-
getDatabaseChangeLogLockTableName
- Specified by:
getDatabaseChangeLogLockTableName
in interfaceDatabase
- Overrides:
getDatabaseChangeLogLockTableName
in classAbstractJdbcDatabase
-
setConnection
- Specified by:
setConnection
in interfaceDatabase
- Overrides:
setConnection
in classAbstractJdbcDatabase
-
unescapeDataTypeName
- Specified by:
unescapeDataTypeName
in interfaceDatabase
- Overrides:
unescapeDataTypeName
in classAbstractJdbcDatabase
-
isSystemObject
- Specified by:
isSystemObject
in interfaceDatabase
- Overrides:
isSystemObject
in classAbstractJdbcDatabase
-
supportsTablespaces
public boolean supportsTablespaces() -
getAutoIncrementClause
- Overrides:
getAutoIncrementClause
in classAbstractJdbcDatabase
-
useSerialDatatypes
public boolean useSerialDatatypes()Should the database use "serial" datatypes vs. "generated by default as identity" -
getAutoIncrementClause
Description copied from class:AbstractJdbcDatabase
Default implementation. Intended for override in database specific cases- Overrides:
getAutoIncrementClause
in classAbstractJdbcDatabase
-
generateAutoIncrementStartWith
- Overrides:
generateAutoIncrementStartWith
in classAbstractJdbcDatabase
-
generateAutoIncrementBy
- Overrides:
generateAutoIncrementBy
in classAbstractJdbcDatabase
-
escapeObjectName
This has special case logic to handle NOT quoting column names if they are of type 'LiquibaseColumn' - columns in the DATABASECHANGELOG or DATABASECHANGELOGLOCK tables.- Specified by:
escapeObjectName
in interfaceDatabase
- Overrides:
escapeObjectName
in classAbstractJdbcDatabase
-
correctObjectName
Description copied from interface:Database
Fix the object name to the format the database expects, handling changes in case, etc.- Specified by:
correctObjectName
in interfaceDatabase
- Overrides:
correctObjectName
in classAbstractJdbcDatabase
-
hasMixedCase
-
isReservedWord
- Specified by:
isReservedWord
in interfaceDatabase
- Overrides:
isReservedWord
in classAbstractJdbcDatabase
-
getConnectionSchemaNameCallStatement
Description copied from class:AbstractJdbcDatabase
Used to obtain the connection schema name through a statement Override this method to change the statement. Only override this if getConnectionSchemaName is left unchanged or is using this method.- Overrides:
getConnectionSchemaNameCallStatement
in classAbstractJdbcDatabase
- See Also:
-
generatePrimaryKeyName
Generates PK followingPostgreSQL
conventions:- Postgres PK size is limited with 63 bytes.
- Postgres PK is suffixed with '_pkey'.
- Specified by:
generatePrimaryKeyName
in interfaceDatabase
- Overrides:
generatePrimaryKeyName
in classAbstractJdbcDatabase
- 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 interfaceDatabase
- Overrides:
getMaxFractionalDigitsForTimestamp
in classAbstractJdbcDatabase
- Returns:
- the maximum number of supported fractional digits in TIMESTAMP columns
-
getSchemaAndCatalogCase
Description copied from class:AbstractJdbcDatabase
This logic is used when db support catalogs- Specified by:
getSchemaAndCatalogCase
in interfaceDatabase
- Overrides:
getSchemaAndCatalogCase
in classAbstractJdbcDatabase
- Returns:
- UPPER_CASE by default
-
rollback
- Specified by:
rollback
in interfaceDatabase
- Overrides:
rollback
in classAbstractJdbcDatabase
- Throws:
DatabaseException
-
setDefaultCatalogName
- Specified by:
setDefaultCatalogName
in interfaceDatabase
- Overrides:
setDefaultCatalogName
in classAbstractJdbcDatabase
-
supportsCreateIfNotExists
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
-