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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final StringThe 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, unquotedObjectsAreUppercasedFields inherited from interface liquibase.database.Database
COMPLETE_SQL_SCOPE_KEY, IGNORE_MISSING_REFERENCES_KEYFields inherited from interface liquibase.servicelocator.PrioritizedService
COMPARATOR, PRIORITY_DATABASE, PRIORITY_DEFAULT -
Constructor Summary
Constructors -
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.booleanescapeObjectName(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.booleangenerateAutoIncrementBy(BigInteger incrementBy) booleangenerateAutoIncrementStartWith(BigInteger startWith) generatePrimaryKeyName(String tableName) Generates PK followingPostgreSQLconventions: Postgres PK size is limited with 63 bytes.protected StringgetAutoIncrementClause(String generationType, Boolean defaultOnNull) Default implementation.protected SqlStatementUsed to obtain the connection schema name through a statement Override this method to change the statement.protected StringgetDefaultDriver(String url) If this database understands the given url, return the default driver class name.intMost relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.intThis logic is used when db support catalogsReturns an all-lower-case short name of the product.Returns system (undroppable) views.inthashCode()protected booleanhasMixedCase(String tableName) booleanIs this AbstractDatabase subclass the correct one to use for the given connection.booleanisReservedWord(String tableName) booleanisSystemObject(DatabaseObject example) voidrollback()voidvoidsetDefaultCatalogName(String defaultCatalogName) booleansupportsCatalogInObjectName(Class<? extends DatabaseObject> type) booleansupportsCreateIfNotExists(Class<? extends DatabaseObject> type) Does the database support the "if not exits" syntax?booleanDoes the particular database implementation support the database changelog history feature and associated table?booleanReturns whether this database support initially deferrable columns.booleanDoes the database type support sequence.booleanunescapeDataTypeName(String dataTypeName) booleanShould 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, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface liquibase.database.Database
addCompleteSqlToScope, afterUpdate, checkDatabaseConnection, dropDatabaseObjects, escapeForLike, 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:
equalsin classAbstractJdbcDatabase
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractJdbcDatabase
-
getShortName
Description copied from interface:DatabaseReturns 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:
getDefaultDatabaseProductNamein classAbstractJdbcDatabase
-
getDefaultPort
-
getSystemViews
Description copied from class:AbstractJdbcDatabaseReturns system (undroppable) views.- Overrides:
getSystemViewsin classAbstractJdbcDatabase
-
getPriority
public int getPriority() -
supportsInitiallyDeferrableColumns
public boolean supportsInitiallyDeferrableColumns()Description copied from interface:DatabaseReturns whether this database support initially deferrable columns. -
isCorrectDatabaseImplementation
Description copied from interface:DatabaseIs this AbstractDatabase subclass the correct one to use for the given connection.- Throws:
DatabaseException
-
getDefaultDriver
Description copied from interface:DatabaseIf this database understands the given url, return the default driver class name. Otherwise return null. -
supportsCatalogInObjectName
- Specified by:
supportsCatalogInObjectNamein interfaceDatabase- Overrides:
supportsCatalogInObjectNamein classAbstractJdbcDatabase
-
supportsSequences
public boolean supportsSequences()Description copied from class:AbstractJdbcDatabaseDoes the database type support sequence.- Specified by:
supportsSequencesin interfaceDatabase- Overrides:
supportsSequencesin classAbstractJdbcDatabase
-
getDatabaseChangeLogTableName
- Specified by:
getDatabaseChangeLogTableNamein interfaceDatabase- Overrides:
getDatabaseChangeLogTableNamein classAbstractJdbcDatabase
-
getDatabaseChangeLogLockTableName
- Specified by:
getDatabaseChangeLogLockTableNamein interfaceDatabase- Overrides:
getDatabaseChangeLogLockTableNamein classAbstractJdbcDatabase
-
setConnection
- Specified by:
setConnectionin interfaceDatabase- Overrides:
setConnectionin classAbstractJdbcDatabase
-
unescapeDataTypeName
- Specified by:
unescapeDataTypeNamein interfaceDatabase- Overrides:
unescapeDataTypeNamein classAbstractJdbcDatabase
-
isSystemObject
- Specified by:
isSystemObjectin interfaceDatabase- Overrides:
isSystemObjectin classAbstractJdbcDatabase
-
supportsTablespaces
public boolean supportsTablespaces() -
getAutoIncrementClause
- Overrides:
getAutoIncrementClausein classAbstractJdbcDatabase
-
useSerialDatatypes
public boolean useSerialDatatypes()Should the database use "serial" datatypes vs. "generated by default as identity" -
getAutoIncrementClause
Description copied from class:AbstractJdbcDatabaseDefault implementation. Intended for override in database specific cases- Overrides:
getAutoIncrementClausein classAbstractJdbcDatabase
-
generateAutoIncrementStartWith
- Overrides:
generateAutoIncrementStartWithin classAbstractJdbcDatabase
-
generateAutoIncrementBy
- Overrides:
generateAutoIncrementByin 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:
escapeObjectNamein interfaceDatabase- Overrides:
escapeObjectNamein classAbstractJdbcDatabase
-
correctObjectName
Description copied from interface:DatabaseFix the object name to the format the database expects, handling changes in case, etc.- Specified by:
correctObjectNamein interfaceDatabase- Overrides:
correctObjectNamein classAbstractJdbcDatabase
-
hasMixedCase
-
isReservedWord
- Specified by:
isReservedWordin interfaceDatabase- Overrides:
isReservedWordin classAbstractJdbcDatabase
-
getConnectionSchemaNameCallStatement
Description copied from class:AbstractJdbcDatabaseUsed 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:
getConnectionSchemaNameCallStatementin classAbstractJdbcDatabase- See Also:
-
generatePrimaryKeyName
Generates PK followingPostgreSQLconventions:- Postgres PK size is limited with 63 bytes.
- Postgres PK is suffixed with '_pkey'.
- Specified by:
generatePrimaryKeyNamein interfaceDatabase- Overrides:
generatePrimaryKeyNamein classAbstractJdbcDatabase- Parameters:
tableName- Table name as the base name for the generated PK.- Returns:
- PK name.
-
getMaxFractionalDigitsForTimestamp
public int getMaxFractionalDigitsForTimestamp()Description copied from class:AbstractJdbcDatabaseMost relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.- Specified by:
getMaxFractionalDigitsForTimestampin interfaceDatabase- Overrides:
getMaxFractionalDigitsForTimestampin classAbstractJdbcDatabase- Returns:
- the maximum number of supported fractional digits in TIMESTAMP columns
-
getSchemaAndCatalogCase
Description copied from class:AbstractJdbcDatabaseThis logic is used when db support catalogs- Specified by:
getSchemaAndCatalogCasein interfaceDatabase- Overrides:
getSchemaAndCatalogCasein classAbstractJdbcDatabase- Returns:
- UPPER_CASE by default
-
rollback
- Specified by:
rollbackin interfaceDatabase- Overrides:
rollbackin classAbstractJdbcDatabase- Throws:
DatabaseException
-
setDefaultCatalogName
- Specified by:
setDefaultCatalogNamein interfaceDatabase- Overrides:
setDefaultCatalogNamein classAbstractJdbcDatabase
-
supportsCreateIfNotExists
Description copied from interface:DatabaseDoes 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:DatabaseDoes the particular database implementation support the database changelog history feature and associated table?- Returns:
- true if supported, false otherwise
-