Package liquibase.database
Class AbstractJdbcDatabase
- java.lang.Object
-
- liquibase.database.AbstractJdbcDatabase
-
- All Implemented Interfaces:
AutoCloseable,Database,PrioritizedService
- Direct Known Subclasses:
AbstractDb2Database,DerbyDatabase,FirebirdDatabase,H2Database,HsqlDatabase,InformixDatabase,Ingres9Database,MSSQLDatabase,MySQLDatabase,OracleDatabase,PostgresDatabase,SnowflakeDatabase,SQLiteDatabase,SybaseASADatabase,SybaseDatabase,UnsupportedDatabase
public abstract class AbstractJdbcDatabase extends Object implements Database
AbstractJdbcDatabase is extended by all supported databases as a facade to the underlying database. The physical connection can be retrieved from the AbstractJdbcDatabase implementation, as well as any database-specific characteristics such as the datatype for "boolean" fields.
-
-
Field Summary
Fields Modifier and Type Field Description protected BooleancaseSensitiveprotected StringcurrentDateTimeFunctionprotected List<DatabaseFunction>dateFunctionsprotected BigIntegerdefaultAutoIncrementByprotected BigIntegerdefaultAutoIncrementStartWithprotected StringdefaultCatalogNameprotected StringdefaultSchemaNameprotected ObjectQuotingStrategyquotingStrategyprotected StringsequenceCurrentValueFunctionprotected StringsequenceNextValueFunctionThe sequence name will be substituted into the string e.g.protected List<String>unmodifiableDataTypesprotected BooleanunquotedObjectsAreUppercased-
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
Constructors Constructor Description AbstractJdbcDatabase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddReservedWords(Collection<String> words)protected booleancanCreateChangeLogTable()voidclose()voidcommit()StringcorrectObjectName(String objectName, Class<? extends DatabaseObject> objectType)Fix the object name to the format the database expects, handling changes in case, etc.CatalogAndSchemacorrectSchema(String catalog, String schema)Deprecated.CatalogAndSchemacorrectSchema(CatalogAndSchema schema)Deprecated.booleancreatesIndexesForForeignKeys()booleandataTypeIsNotModifiable(String typeName)Types like int4 in postgres cannot have a modifier.booleandisableForeignKeyChecks()booleandoesTagExist(String tag)voiddropDatabaseObjects(CatalogAndSchema schemaToDrop)Drops all objects in a specified schema.voidenableForeignKeyChecks()booleanequals(Object o)StringescapeColumnName(String catalogName, String schemaName, String tableName, String columnName)Escapes a single column name in a database-dependent manner so reserved words can be used as a column name (i.e.StringescapeColumnName(String catalogName, String schemaName, String tableName, String columnName, boolean quoteNamesThatMayBeFunctions)Similar toDatabase.escapeColumnName(String, String, String, String)but allows control over whether function-like names should be left unquoted.StringescapeColumnNameList(String columnNames)Escapes a list of column names in a database-dependent manner so reserved words can be used as a column name (i.e.StringescapeConstraintName(String constraintName)StringescapeDataTypeName(String dataTypeName)StringescapeIndexName(String catalogName, String schemaName, String indexName)StringescapeObjectName(String objectName, Class<? extends DatabaseObject> objectType)StringescapeObjectName(String catalogName, String schemaName, String objectName, Class<? extends DatabaseObject> objectType)StringescapeSequenceName(String catalogName, String schemaName, String sequenceName)StringescapeStringForDatabase(String string)StringescapeTableName(String catalogName, String schemaName, String tableName)StringescapeViewName(String catalogName, String schemaName, String viewName)voidexecute(SqlStatement[] statements, List<SqlVisitor> sqlVisitors)voidexecuteRollbackStatements(Change change, List<SqlVisitor> sqlVisitors)voidexecuteRollbackStatements(SqlStatement[] statements, List<SqlVisitor> sqlVisitors)voidexecuteStatements(Change change, DatabaseChangeLog changeLog, List<SqlVisitor> sqlVisitors)protected List<SqlVisitor>filterRollbackVisitors(List<SqlVisitor> visitors)Takes a list of SqlVisitors and returns a new list with only the SqlVisitors set to apply to rollbacksprotected booleangenerateAutoIncrementBy(BigInteger incrementBy)protected booleangenerateAutoIncrementStartWith(BigInteger startWith)StringgenerateDatabaseFunctionValue(DatabaseFunction databaseFunction)Some function names are placeholders that need to be replaced with the specific database value.StringgeneratePrimaryKeyName(String tableName)Objectget(String key)booleangetAutoCommitMode()Auto-commit mode to run inprotected StringgetAutoIncrementByClause()protected StringgetAutoIncrementClause()protected StringgetAutoIncrementClause(String generationType, Boolean defaultOnNull)Default implementation.StringgetAutoIncrementClause(BigInteger startWith, BigInteger incrementBy, String generationType, Boolean defaultOnNull)Returns database-specific auto-increment DDL clause.protected StringgetAutoIncrementClosing()protected StringgetAutoIncrementOpening()protected StringgetAutoIncrementStartWithClause()StringgetConcatSql(String... values)Returns SQL to concat the passed values.DatabaseConnectiongetConnection()protected StringgetConnectionCatalogName()protected StringgetConnectionSchemaName()Overwrite this method to get the default schema name for the connection.protected SqlStatementgetConnectionSchemaNameCallStatement()Used to obtain the connection schema name through a statement Override this method to change the statement.DatabaseObject[]getContainingObjects()StringgetCurrentDateTimeFunction()Returns database-specific function for generating the current date/time.StringgetDatabaseChangeLogLockTableName()StringgetDatabaseChangeLogTableName()intgetDatabaseMajorVersion()intgetDatabaseMinorVersion()StringgetDatabaseProductName()Returns the name of the database product according to the underlying database.StringgetDatabaseProductVersion()intgetDataTypeMaxParameters(String dataTypeName)List<DatabaseFunction>getDateFunctions()Returns list of database native date functionsStringgetDateLiteral(String isoDate)Return a date literal with the same value as a string formatted using ISO 8601.StringgetDateLiteral(Date date)StringgetDateLiteral(Date date)StringgetDateTimeLiteral(Timestamp date)StringgetDefaultCatalogName()protected abstract StringgetDefaultDatabaseProductName()intgetDefaultFractionalDigitsForTimestamp()SQL Standard (Foundation) says: "...ifis not specified, then 6 is implicit." IntegergetDefaultScaleForNativeDataType(String nativeDataType)Returns the default precision for a given native data type, e.g.CatalogAndSchemagetDefaultSchema()StringgetDefaultSchemaName()IntegergetFetchSize()StringgetJdbcCatalogName(CatalogAndSchema schema)StringgetJdbcCatalogName(Schema schema)StringgetJdbcSchemaName(CatalogAndSchema schema)StringgetJdbcSchemaName(Schema schema)StringgetLineComment()Returns database-specific line comment string.StringgetLiquibaseCatalogName()StringgetLiquibaseSchemaName()StringgetLiquibaseTablespaceName()intgetMaxFractionalDigitsForTimestamp()Most relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.StringgetName()ObjectQuotingStrategygetObjectQuotingStrategy()booleangetOutputDefaultCatalog()booleangetOutputDefaultSchema()Should the schema be included in identifiers even if it is the default schema?protected StringgetQuotingEndCharacter()protected StringgetQuotingEndReplacement()protected StringgetQuotingStartCharacter()RanChangeSetgetRanChangeSet(ChangeSet changeSet)List<RanChangeSet>getRanChangeSetList()Returns the ChangeSets that have been run against the current database.DategetRanDate(ChangeSet changeSet)protected StringgetRawDatabaseChangeLogLockTableName()Method used by extensions to get raw dbcll table nameprotected StringgetRawDatabaseChangeLogTableName()Method used by extensions to get raw dbcl table nameChangeSet.RunStatusgetRunStatus(ChangeSet changeSet)Returns the run status for the given ChangeSetCatalogAndSchema.CatalogAndSchemaCasegetSchemaAndCatalogCase()This logic is used when db support catalogsCatalogAndSchemagetSchemaFromJdbcInfo(String rawCatalogName, String rawSchemaName)StringgetSystemSchema()protected Set<String>getSystemTables()Returns system (undroppable) views.protected Set<String>getSystemViews()Returns system (undroppable) views.StringgetTimeLiteral(Time date)StringgetViewDefinition(CatalogAndSchema schema, String viewName)inthashCode()booleanisAutoCommit()booleanisCaseSensitive()protected booleanisCatalogOrSchemaType(Class<? extends DatabaseObject> objectType)protected booleanisCurrentTimeFunction(String functionValue)protected booleanisDateOnly(String isoDate)Returns true if the String conforms to an ISO 8601 date, e.g.protected booleanisDateTime(String isoDate)Returns true if the String conforms to an ISO 8601 date plus a time (hours, minutes, whole seconds and optionally fraction of a second) in UTC, e.g.booleanisDefaultCatalog(String catalog)If the database supports catalogs, test if a given catalog name equals to the default catalog of the current logged in user.booleanisDefaultSchema(String catalog, String schema)If the database supports schemas, test if a given combination of catalog and schema name equals to the default catalog and schema of the current logged in user.booleanisFunction(String string)booleanisLiquibaseObject(DatabaseObject object)booleanisReservedWord(String string)booleanisSafeToRunUpdate()Default implementation of theisSafeToRunUpdate()method.booleanisSystemObject(DatabaseObject example)booleanisSystemView(CatalogAndSchema schema, String viewName)protected booleanisTimeOnly(String isoDate)Returns true if the String conforms to an ISO 8601 time (hours, minutes and whole seconds) in UTC, e.g.protected booleanisTimestamp(String isoDate)Returns true if the String conforms to an ISO 8601 date plus a timestamp (hours, minutes, seconds and at least one decimal fraction) in UTC, e.g.booleanjdbcCallsCatalogsSchemas()voidmarkChangeSetExecStatus(ChangeSet changeSet, ChangeSet.ExecType execType)After the changeset has been ran against the database this method will update the change log table with the information.protected booleanmustQuoteObjectName(String objectName, Class<? extends DatabaseObject> objectType)DateparseDate(String dateAsString)StringquoteObject(String objectName, Class<? extends DatabaseObject> objectType)voidremoveRanStatus(ChangeSet changeSet)booleanrequiresExplicitNullForColumns()Does the database require explicit NULL for nullable columns?booleanrequiresPassword()booleanrequiresUsername()voidresetInternalState()voidrollback()voidsaveRollbackStatement(Change change, List<SqlVisitor> sqlVisitors, Writer writer)voidsaveStatements(Change change, List<SqlVisitor> sqlVisitors, Writer writer)AbstractJdbcDatabaseset(String key, Object value)voidsetAutoCommit(boolean b)voidsetCanCacheLiquibaseTableInfo(boolean canCacheLiquibaseTableInfo)voidsetCaseSensitive(Boolean caseSensitive)voidsetConnection(DatabaseConnection conn)voidsetCurrentDateTimeFunction(String function)voidsetDatabaseChangeLogLockTableName(String tableName)Set the table name of the change log lock to the given table namevoidsetDatabaseChangeLogTableName(String tableName)Sets the table name of the change log to the given table name.voidsetDefaultCatalogName(String defaultCatalogName)voidsetDefaultSchemaName(String schemaName)voidsetLiquibaseCatalogName(String catalogName)voidsetLiquibaseSchemaName(String schemaName)voidsetLiquibaseTablespaceName(String tablespace)voidsetObjectQuotingStrategy(ObjectQuotingStrategy quotingStrategy)voidsetOutputDefaultCatalog(boolean outputDefaultCatalog)voidsetOutputDefaultSchema(boolean outputDefaultSchema)Whether the default schema should be included in generated SQLprotected booleanstartsWithNumeric(String objectName)booleansupportsAutoIncrement()booleansupportsBatchUpdates()Does the database support batched DML (INSERT/UPDATE/DELETE/MERGE/...) statements sent in a single call to the database?booleansupportsCatalogInObjectName(Class<? extends DatabaseObject> type)booleansupportsCatalogs()booleansupportsDDLInTransaction()Determines if the database supports DDL within a transaction or not.booleansupportsDropTableCascadeConstraints()booleansupportsForeignKeyDisable()booleansupportsNotNullConstraintNames()Does this database treat NOT NULL as an own kind of CONSTRAINT (in addition of simply being a column property)? This will affect the CONSTRAINT clause SQL generators.booleansupportsPrimaryKeyNames()booleansupportsRestrictForeignKeys()booleansupportsSchemas()booleansupportsSequences()Does the database type support sequence.voidtag(String tagString)Tags the database changelog with the given string.StringtoString()StringunescapeDataTypeName(String dataTypeName)StringunescapeDataTypeString(String dataTypeString)ValidationErrorsvalidate()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface liquibase.database.Database
addCompleteSqlToScope, afterUpdate, dropDatabaseObjects, failOnDefferable, getDefaultDriver, getDefaultPort, getDisplayName, getShortName, isCorrectDatabaseImplementation, supportsCreateIfNotExists, supportsDatabaseChangeLogHistory, supportsInitiallyDeferrableColumns, supportsTablespaces, temporarilySetObjectQuotingStrategy
-
Methods inherited from interface liquibase.servicelocator.PrioritizedService
getPriority
-
-
-
-
Field Detail
-
defaultCatalogName
protected String defaultCatalogName
-
defaultSchemaName
protected String defaultSchemaName
-
currentDateTimeFunction
protected String currentDateTimeFunction
-
sequenceNextValueFunction
protected String sequenceNextValueFunction
The sequence name will be substituted into the string e.g. NEXTVAL('%s')
-
sequenceCurrentValueFunction
protected String sequenceCurrentValueFunction
-
dateFunctions
protected List<DatabaseFunction> dateFunctions
-
defaultAutoIncrementStartWith
protected BigInteger defaultAutoIncrementStartWith
-
defaultAutoIncrementBy
protected BigInteger defaultAutoIncrementBy
-
unquotedObjectsAreUppercased
protected Boolean unquotedObjectsAreUppercased
-
quotingStrategy
protected ObjectQuotingStrategy quotingStrategy
-
caseSensitive
protected Boolean caseSensitive
-
-
Method Detail
-
getName
public String getName()
-
requiresPassword
public boolean requiresPassword()
- Specified by:
requiresPasswordin interfaceDatabase
-
requiresUsername
public boolean requiresUsername()
- Specified by:
requiresUsernamein interfaceDatabase
-
getContainingObjects
public DatabaseObject[] getContainingObjects()
-
getConnection
public DatabaseConnection getConnection()
- Specified by:
getConnectionin interfaceDatabase
-
setConnection
public void setConnection(DatabaseConnection conn)
- Specified by:
setConnectionin interfaceDatabase
-
getAutoCommitMode
public boolean getAutoCommitMode()
Description copied from interface:DatabaseAuto-commit mode to run in- Specified by:
getAutoCommitModein interfaceDatabase
-
addReservedWords
public final void addReservedWords(Collection<String> words)
- Specified by:
addReservedWordsin interfaceDatabase
-
supportsDDLInTransaction
public boolean supportsDDLInTransaction()
Determines if the database supports DDL within a transaction or not.- Specified by:
supportsDDLInTransactionin interfaceDatabase- Returns:
- True if the database supports DDL within a transaction, otherwise false.
-
getDatabaseProductName
public String getDatabaseProductName()
Description copied from interface:DatabaseReturns the name of the database product according to the underlying database.- Specified by:
getDatabaseProductNamein interfaceDatabase
-
getDefaultDatabaseProductName
protected abstract String getDefaultDatabaseProductName()
-
getDatabaseProductVersion
public String getDatabaseProductVersion() throws DatabaseException
- Specified by:
getDatabaseProductVersionin interfaceDatabase- Throws:
DatabaseException
-
getDatabaseMajorVersion
public int getDatabaseMajorVersion() throws DatabaseException- Specified by:
getDatabaseMajorVersionin interfaceDatabase- Throws:
DatabaseException
-
getDatabaseMinorVersion
public int getDatabaseMinorVersion() throws DatabaseException- Specified by:
getDatabaseMinorVersionin interfaceDatabase- Throws:
DatabaseException
-
getDefaultCatalogName
public String getDefaultCatalogName()
- Specified by:
getDefaultCatalogNamein interfaceDatabase
-
setDefaultCatalogName
public void setDefaultCatalogName(String defaultCatalogName)
- Specified by:
setDefaultCatalogNamein interfaceDatabase
-
getConnectionCatalogName
protected String getConnectionCatalogName() throws DatabaseException
- Throws:
DatabaseException
-
correctSchema
@Deprecated public CatalogAndSchema correctSchema(String catalog, String schema)
Deprecated.
-
correctSchema
@Deprecated public CatalogAndSchema correctSchema(CatalogAndSchema schema)
Deprecated.Description copied from interface:DatabaseReturns a new CatalogAndSchema adjusted for this database. Examples of adjustments include: fixes for case issues, replacing null schema or catalog names with the default values removing set schema or catalog names if they are not supported- Specified by:
correctSchemain interfaceDatabase
-
correctObjectName
public String correctObjectName(String objectName, Class<? extends DatabaseObject> objectType)
Description copied from interface:DatabaseFix the object name to the format the database expects, handling changes in case, etc.- Specified by:
correctObjectNamein interfaceDatabase
-
isCatalogOrSchemaType
protected boolean isCatalogOrSchemaType(Class<? extends DatabaseObject> objectType)
-
getDefaultSchema
public CatalogAndSchema getDefaultSchema()
- Specified by:
getDefaultSchemain interfaceDatabase
-
getDefaultSchemaName
public String getDefaultSchemaName()
- Specified by:
getDefaultSchemaNamein interfaceDatabase
-
getDefaultScaleForNativeDataType
public Integer getDefaultScaleForNativeDataType(String nativeDataType)
Description copied from interface:DatabaseReturns the default precision for a given native data type, e.g. "datetime2" for Microsoft SQL Server.- Specified by:
getDefaultScaleForNativeDataTypein interfaceDatabase- Parameters:
nativeDataType- the name of the native data type (case-insensitive).- Returns:
- The default precision of the native data type, or null if the type is unknown to this database.
-
setDefaultSchemaName
public void setDefaultSchemaName(String schemaName)
- Specified by:
setDefaultSchemaNamein interfaceDatabase
-
getConnectionSchemaName
protected String getConnectionSchemaName()
Overwrite this method to get the default schema name for the connection. If you only need to change the statement that obtains the current schema then override- See Also:
getConnectionSchemaNameCallStatement()
-
getConnectionSchemaNameCallStatement
protected SqlStatement getConnectionSchemaNameCallStatement()
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.- See Also:
getConnectionSchemaName()
-
getFetchSize
public Integer getFetchSize()
- Specified by:
getFetchSizein interfaceDatabase
-
supportsSequences
public boolean supportsSequences()
Does the database type support sequence.- Specified by:
supportsSequencesin interfaceDatabase
-
supportsAutoIncrement
public boolean supportsAutoIncrement()
- Specified by:
supportsAutoIncrementin interfaceDatabase
-
getDateLiteral
public String getDateLiteral(String isoDate)
Return a date literal with the same value as a string formatted using ISO 8601. Note: many databases accept date literals in ISO8601 format with the 'T' replaced with a space. Only databases which do not accept these strings should need to override this method. Implementation restriction: Currently, only the following subsets of ISO8601 are supported: yyyy-MM-dd hh:mm:ss yyyy-MM-ddThh:mm:ss- Specified by:
getDateLiteralin interfaceDatabase
-
getDateTimeLiteral
public String getDateTimeLiteral(Timestamp date)
- Specified by:
getDateTimeLiteralin interfaceDatabase
-
getDateLiteral
public String getDateLiteral(Date date)
- Specified by:
getDateLiteralin interfaceDatabase
-
getTimeLiteral
public String getTimeLiteral(Time date)
- Specified by:
getTimeLiteralin interfaceDatabase
-
getDateLiteral
public String getDateLiteral(Date date)
- Specified by:
getDateLiteralin interfaceDatabase
-
parseDate
public Date parseDate(String dateAsString) throws DateParseException
- Specified by:
parseDatein interfaceDatabase- Throws:
DateParseException
-
isDateOnly
protected boolean isDateOnly(String isoDate)
Returns true if the String conforms to an ISO 8601 date, e.g. 2016-12-31. (Or, if it is a "NOW" or "TODAY" type value)- Parameters:
isoDate- value to check.
-
isDateTime
protected boolean isDateTime(String isoDate)
Returns true if the String conforms to an ISO 8601 date plus a time (hours, minutes, whole seconds and optionally fraction of a second) in UTC, e.g. 2016-12-31T18:43:59. (Or, if it is a "NOW" or "TODAY" type value.) The "T" may be replaced by a space. CAUTION: Does NOT recognize values with a timezone information (...[+-Z]...)- Parameters:
isoDate- value to check.
-
isTimestamp
protected boolean isTimestamp(String isoDate)
Returns true if the String conforms to an ISO 8601 date plus a timestamp (hours, minutes, seconds and at least one decimal fraction) in UTC, e.g. 2016-12-31T18:43:59.3 or 2016-12-31T18:43:59.345. (Or, if it is a "NOW" or "TODAY" type value). CAUTION: Does NOT recognize values with a timezone information (...[+-Z]...) The "T" may be replaced by a space.- Parameters:
isoDate- value to check
-
isTimeOnly
protected boolean isTimeOnly(String isoDate)
Returns true if the String conforms to an ISO 8601 time (hours, minutes and whole seconds) in UTC, e.g. 18:43:59. (Or, if it is a "NOW" or "TODAY" type value). CAUTION: Does NOT recognize values with a timezone information (...[+-Z]...)- Parameters:
isoDate- value to check
-
getLineComment
public String getLineComment()
Returns database-specific line comment string.- Specified by:
getLineCommentin interfaceDatabase
-
getAutoIncrementClause
public String getAutoIncrementClause(BigInteger startWith, BigInteger incrementBy, String generationType, Boolean defaultOnNull)
Description copied from interface:DatabaseReturns database-specific auto-increment DDL clause.- Specified by:
getAutoIncrementClausein interfaceDatabase
-
getAutoIncrementClause
protected String getAutoIncrementClause()
-
getAutoIncrementClause
protected String getAutoIncrementClause(String generationType, Boolean defaultOnNull)
Default implementation. Intended for override in database specific cases
-
generateAutoIncrementStartWith
protected boolean generateAutoIncrementStartWith(BigInteger startWith)
-
generateAutoIncrementBy
protected boolean generateAutoIncrementBy(BigInteger incrementBy)
-
getAutoIncrementOpening
protected String getAutoIncrementOpening()
-
getAutoIncrementClosing
protected String getAutoIncrementClosing()
-
getAutoIncrementStartWithClause
protected String getAutoIncrementStartWithClause()
-
getAutoIncrementByClause
protected String getAutoIncrementByClause()
-
getConcatSql
public String getConcatSql(String... values)
Description copied from interface:DatabaseReturns SQL to concat the passed values.- Specified by:
getConcatSqlin interfaceDatabase
-
getDatabaseChangeLogTableName
public String getDatabaseChangeLogTableName()
- Specified by:
getDatabaseChangeLogTableNamein interfaceDatabase
-
setDatabaseChangeLogTableName
public void setDatabaseChangeLogTableName(String tableName)
Description copied from interface:DatabaseSets the table name of the change log to the given table name.- Specified by:
setDatabaseChangeLogTableNamein interfaceDatabase- Parameters:
tableName- the name of the change log table to set
-
getRawDatabaseChangeLogTableName
protected String getRawDatabaseChangeLogTableName()
Method used by extensions to get raw dbcl table name
-
getDatabaseChangeLogLockTableName
public String getDatabaseChangeLogLockTableName()
- Specified by:
getDatabaseChangeLogLockTableNamein interfaceDatabase
-
setDatabaseChangeLogLockTableName
public void setDatabaseChangeLogLockTableName(String tableName)
Description copied from interface:DatabaseSet the table name of the change log lock to the given table name- Specified by:
setDatabaseChangeLogLockTableNamein interfaceDatabase
-
getRawDatabaseChangeLogLockTableName
protected String getRawDatabaseChangeLogLockTableName()
Method used by extensions to get raw dbcll table name
-
getLiquibaseTablespaceName
public String getLiquibaseTablespaceName()
- Specified by:
getLiquibaseTablespaceNamein interfaceDatabase
-
setLiquibaseTablespaceName
public void setLiquibaseTablespaceName(String tablespace)
- Specified by:
setLiquibaseTablespaceNamein interfaceDatabase
-
canCreateChangeLogTable
protected boolean canCreateChangeLogTable() throws DatabaseException- Throws:
DatabaseException
-
setCanCacheLiquibaseTableInfo
public void setCanCacheLiquibaseTableInfo(boolean canCacheLiquibaseTableInfo)
- Specified by:
setCanCacheLiquibaseTableInfoin interfaceDatabase
-
getLiquibaseCatalogName
public String getLiquibaseCatalogName()
- Specified by:
getLiquibaseCatalogNamein interfaceDatabase
-
setLiquibaseCatalogName
public void setLiquibaseCatalogName(String catalogName)
- Specified by:
setLiquibaseCatalogNamein interfaceDatabase
-
getLiquibaseSchemaName
public String getLiquibaseSchemaName()
- Specified by:
getLiquibaseSchemaNamein interfaceDatabase
-
setLiquibaseSchemaName
public void setLiquibaseSchemaName(String schemaName)
- Specified by:
setLiquibaseSchemaNamein interfaceDatabase
-
isCaseSensitive
public boolean isCaseSensitive()
- Specified by:
isCaseSensitivein interfaceDatabase
-
setCaseSensitive
public void setCaseSensitive(Boolean caseSensitive)
-
isReservedWord
public boolean isReservedWord(String string)
- Specified by:
isReservedWordin interfaceDatabase
-
startsWithNumeric
protected boolean startsWithNumeric(String objectName)
-
dropDatabaseObjects
public void dropDatabaseObjects(CatalogAndSchema schemaToDrop) throws LiquibaseException
Description copied from interface:DatabaseDrops all objects in a specified schema.- Specified by:
dropDatabaseObjectsin interfaceDatabase- Parameters:
schemaToDrop- schema (catalog+)schema to drop- Throws:
LiquibaseException- if any problem occurs
-
supportsDropTableCascadeConstraints
public boolean supportsDropTableCascadeConstraints()
- Specified by:
supportsDropTableCascadeConstraintsin interfaceDatabase
-
isSystemObject
public boolean isSystemObject(DatabaseObject example)
- Specified by:
isSystemObjectin interfaceDatabase
-
isSystemView
public boolean isSystemView(CatalogAndSchema schema, String viewName)
-
isLiquibaseObject
public boolean isLiquibaseObject(DatabaseObject object)
- Specified by:
isLiquibaseObjectin interfaceDatabase
-
tag
public void tag(String tagString) throws DatabaseException
Description copied from interface:DatabaseTags the database changelog with the given string.- Specified by:
tagin interfaceDatabase- Throws:
DatabaseException
-
doesTagExist
public boolean doesTagExist(String tag) throws DatabaseException
- Specified by:
doesTagExistin interfaceDatabase- Throws:
DatabaseException
-
getViewDefinition
public String getViewDefinition(CatalogAndSchema schema, String viewName) throws DatabaseException
- Specified by:
getViewDefinitionin interfaceDatabase- Throws:
DatabaseException
-
escapeTableName
public String escapeTableName(String catalogName, String schemaName, String tableName)
- Specified by:
escapeTableNamein interfaceDatabase
-
escapeObjectName
public String escapeObjectName(String catalogName, String schemaName, String objectName, Class<? extends DatabaseObject> objectType)
- Specified by:
escapeObjectNamein interfaceDatabase
-
escapeObjectName
public String escapeObjectName(String objectName, Class<? extends DatabaseObject> objectType)
- Specified by:
escapeObjectNamein interfaceDatabase
-
mustQuoteObjectName
protected boolean mustQuoteObjectName(String objectName, Class<? extends DatabaseObject> objectType)
-
getQuotingStartCharacter
protected String getQuotingStartCharacter()
-
getQuotingEndCharacter
protected String getQuotingEndCharacter()
-
getQuotingEndReplacement
protected String getQuotingEndReplacement()
-
quoteObject
public String quoteObject(String objectName, Class<? extends DatabaseObject> objectType)
-
escapeIndexName
public String escapeIndexName(String catalogName, String schemaName, String indexName)
- Specified by:
escapeIndexNamein interfaceDatabase
-
escapeSequenceName
public String escapeSequenceName(String catalogName, String schemaName, String sequenceName)
- Specified by:
escapeSequenceNamein interfaceDatabase
-
escapeConstraintName
public String escapeConstraintName(String constraintName)
- Specified by:
escapeConstraintNamein interfaceDatabase
-
escapeColumnName
public String escapeColumnName(String catalogName, String schemaName, String tableName, String columnName)
Description copied from interface:DatabaseEscapes a single column name in a database-dependent manner so reserved words can be used as a column name (i.e. "return").- Specified by:
escapeColumnNamein interfaceDatabasecolumnName- column name- Returns:
- escaped column name
-
escapeColumnName
public String escapeColumnName(String catalogName, String schemaName, String tableName, String columnName, boolean quoteNamesThatMayBeFunctions)
Description copied from interface:DatabaseSimilar toDatabase.escapeColumnName(String, String, String, String)but allows control over whether function-like names should be left unquoted.- Specified by:
escapeColumnNamein interfaceDatabase
-
escapeColumnNameList
public String escapeColumnNameList(String columnNames)
Description copied from interface:DatabaseEscapes a list of column names in a database-dependent manner so reserved words can be used as a column name (i.e. "return").- Specified by:
escapeColumnNameListin interfaceDatabase- Parameters:
columnNames- list of column names- Returns:
- escaped column name list
-
supportsSchemas
public boolean supportsSchemas()
- Specified by:
supportsSchemasin interfaceDatabase
-
supportsCatalogs
public boolean supportsCatalogs()
- Specified by:
supportsCatalogsin interfaceDatabase
-
jdbcCallsCatalogsSchemas
public boolean jdbcCallsCatalogsSchemas()
-
supportsCatalogInObjectName
public boolean supportsCatalogInObjectName(Class<? extends DatabaseObject> type)
- Specified by:
supportsCatalogInObjectNamein interfaceDatabase
-
generatePrimaryKeyName
public String generatePrimaryKeyName(String tableName)
- Specified by:
generatePrimaryKeyNamein interfaceDatabase
-
escapeViewName
public String escapeViewName(String catalogName, String schemaName, String viewName)
- Specified by:
escapeViewNamein interfaceDatabase
-
getRunStatus
public ChangeSet.RunStatus getRunStatus(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException
Description copied from interface:DatabaseReturns the run status for the given ChangeSet- Specified by:
getRunStatusin interfaceDatabase- Throws:
DatabaseExceptionDatabaseHistoryException
-
getRanChangeSet
public RanChangeSet getRanChangeSet(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException
- Specified by:
getRanChangeSetin interfaceDatabase- Throws:
DatabaseExceptionDatabaseHistoryException
-
getRanChangeSetList
public List<RanChangeSet> getRanChangeSetList() throws DatabaseException
Description copied from interface:DatabaseReturns the ChangeSets that have been run against the current database.- Specified by:
getRanChangeSetListin interfaceDatabase- Throws:
DatabaseException
-
getRanDate
public Date getRanDate(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException
- Specified by:
getRanDatein interfaceDatabase- Throws:
DatabaseExceptionDatabaseHistoryException
-
markChangeSetExecStatus
public void markChangeSetExecStatus(ChangeSet changeSet, ChangeSet.ExecType execType) throws DatabaseException
Description copied from interface:DatabaseAfter the changeset has been ran against the database this method will update the change log table with the information.- Specified by:
markChangeSetExecStatusin interfaceDatabase- Throws:
DatabaseException
-
removeRanStatus
public void removeRanStatus(ChangeSet changeSet) throws DatabaseException
- Specified by:
removeRanStatusin interfaceDatabase- Throws:
DatabaseException
-
escapeStringForDatabase
public String escapeStringForDatabase(String string)
- Specified by:
escapeStringForDatabasein interfaceDatabase
-
commit
public void commit() throws DatabaseException- Specified by:
commitin interfaceDatabase- Throws:
DatabaseException
-
rollback
public void rollback() throws DatabaseException- Specified by:
rollbackin interfaceDatabase- Throws:
DatabaseException
-
close
public void close() throws DatabaseException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDatabase- Throws:
DatabaseException
-
supportsRestrictForeignKeys
public boolean supportsRestrictForeignKeys()
- Specified by:
supportsRestrictForeignKeysin interfaceDatabase
-
isAutoCommit
public boolean isAutoCommit() throws DatabaseException- Specified by:
isAutoCommitin interfaceDatabase- Throws:
DatabaseException
-
setAutoCommit
public void setAutoCommit(boolean b) throws DatabaseException- Specified by:
setAutoCommitin interfaceDatabase- Throws:
DatabaseException
-
isSafeToRunUpdate
public boolean isSafeToRunUpdate() throws DatabaseExceptionDefault implementation of theisSafeToRunUpdate()method. It checks if the database connection URL contains "localhost" or "127.0.0.1". If the database returns anullURL, the method returnsfalsebecause it's not known whether it's safe to run the update.- Specified by:
isSafeToRunUpdatein interfaceDatabase- Returns:
trueif the database connection URL contains "localhost" or "127.0.0.1", otherwisefalse.- Throws:
DatabaseException- if there is an error accessing the database
-
executeStatements
public void executeStatements(Change change, DatabaseChangeLog changeLog, List<SqlVisitor> sqlVisitors) throws LiquibaseException
- Specified by:
executeStatementsin interfaceDatabase- Throws:
LiquibaseException
-
execute
public void execute(SqlStatement[] statements, List<SqlVisitor> sqlVisitors) throws LiquibaseException
- Specified by:
executein interfaceDatabase- Throws:
LiquibaseException
-
saveStatements
public void saveStatements(Change change, List<SqlVisitor> sqlVisitors, Writer writer) throws IOException
- Specified by:
saveStatementsin interfaceDatabase- Throws:
IOException
-
executeRollbackStatements
public void executeRollbackStatements(SqlStatement[] statements, List<SqlVisitor> sqlVisitors) throws LiquibaseException
- Specified by:
executeRollbackStatementsin interfaceDatabase- Throws:
LiquibaseException
-
executeRollbackStatements
public void executeRollbackStatements(Change change, List<SqlVisitor> sqlVisitors) throws LiquibaseException
- Specified by:
executeRollbackStatementsin interfaceDatabase- Throws:
LiquibaseException
-
saveRollbackStatement
public void saveRollbackStatement(Change change, List<SqlVisitor> sqlVisitors, Writer writer) throws IOException, LiquibaseException
- Specified by:
saveRollbackStatementin interfaceDatabase- Throws:
IOExceptionLiquibaseException
-
filterRollbackVisitors
protected List<SqlVisitor> filterRollbackVisitors(List<SqlVisitor> visitors)
Takes a list of SqlVisitors and returns a new list with only the SqlVisitors set to apply to rollbacks
-
getDateFunctions
public List<DatabaseFunction> getDateFunctions()
Description copied from interface:DatabaseReturns list of database native date functions- Specified by:
getDateFunctionsin interfaceDatabase
-
isFunction
public boolean isFunction(String string)
- Specified by:
isFunctionin interfaceDatabase
-
resetInternalState
public void resetInternalState()
- Specified by:
resetInternalStatein interfaceDatabase
-
supportsForeignKeyDisable
public boolean supportsForeignKeyDisable()
- Specified by:
supportsForeignKeyDisablein interfaceDatabase
-
disableForeignKeyChecks
public boolean disableForeignKeyChecks() throws DatabaseException- Specified by:
disableForeignKeyChecksin interfaceDatabase- Throws:
DatabaseException
-
enableForeignKeyChecks
public void enableForeignKeyChecks() throws DatabaseException- Specified by:
enableForeignKeyChecksin interfaceDatabase- Throws:
DatabaseException
-
createsIndexesForForeignKeys
public boolean createsIndexesForForeignKeys()
- Specified by:
createsIndexesForForeignKeysin interfaceDatabase
-
getDataTypeMaxParameters
public int getDataTypeMaxParameters(String dataTypeName)
- Specified by:
getDataTypeMaxParametersin interfaceDatabase
-
getSchemaFromJdbcInfo
public CatalogAndSchema getSchemaFromJdbcInfo(String rawCatalogName, String rawSchemaName)
-
getJdbcCatalogName
public String getJdbcCatalogName(CatalogAndSchema schema)
-
getJdbcSchemaName
public String getJdbcSchemaName(CatalogAndSchema schema)
-
dataTypeIsNotModifiable
public boolean dataTypeIsNotModifiable(String typeName)
Description copied from interface:DatabaseTypes like int4 in postgres cannot have a modifier. e.g. int4(10) Checks whether the type is allowed to have a modifier- Specified by:
dataTypeIsNotModifiablein interfaceDatabase- Parameters:
typeName- type name- Returns:
- Whether data type can have a modifier
-
getObjectQuotingStrategy
public ObjectQuotingStrategy getObjectQuotingStrategy()
- Specified by:
getObjectQuotingStrategyin interfaceDatabase
-
setObjectQuotingStrategy
public void setObjectQuotingStrategy(ObjectQuotingStrategy quotingStrategy)
- Specified by:
setObjectQuotingStrategyin interfaceDatabase
-
generateDatabaseFunctionValue
public String generateDatabaseFunctionValue(DatabaseFunction databaseFunction)
Description copied from interface:DatabaseSome function names are placeholders that need to be replaced with the specific database value. e.g. nextSequenceValue(sequenceName) should be replaced with NEXT_VAL('sequenceName') for Postgresql- Specified by:
generateDatabaseFunctionValuein interfaceDatabase- Parameters:
databaseFunction- database function to check.- Returns:
- the string value to use for an update or generate
-
isCurrentTimeFunction
protected boolean isCurrentTimeFunction(String functionValue)
-
getCurrentDateTimeFunction
public String getCurrentDateTimeFunction()
Description copied from interface:DatabaseReturns database-specific function for generating the current date/time.- Specified by:
getCurrentDateTimeFunctionin interfaceDatabase
-
setCurrentDateTimeFunction
public void setCurrentDateTimeFunction(String function)
- Specified by:
setCurrentDateTimeFunctionin interfaceDatabase
-
isDefaultSchema
public boolean isDefaultSchema(String catalog, String schema)
Description copied from interface:DatabaseIf the database supports schemas, test if a given combination of catalog and schema name equals to the default catalog and schema of the current logged in user.- Specified by:
isDefaultSchemain interfaceDatabase- Parameters:
catalog- catalog name to be testedschema- schema name to be tested- Returns:
- if the database supports catalogs: true if it is the default schema, false if not. If it does not support schemas, the behaviour of this method is undefined (please call supportsSchemas first!)
-
isDefaultCatalog
public boolean isDefaultCatalog(String catalog)
Description copied from interface:DatabaseIf the database supports catalogs, test if a given catalog name equals to the default catalog of the current logged in user.- Specified by:
isDefaultCatalogin interfaceDatabase- Parameters:
catalog- catalog name to be tested- Returns:
- if the database supports catalogs: true if it is the default catalog, false if not. If it does not support catalogs, the behaviour of this method is undefined (please call supportsCatalog first!)
-
getOutputDefaultSchema
public boolean getOutputDefaultSchema()
Description copied from interface:DatabaseShould the schema be included in identifiers even if it is the default schema?- Specified by:
getOutputDefaultSchemain interfaceDatabase- Returns:
- true (if the schema should be included in every case) or false (omit if default schema)
-
setOutputDefaultSchema
public void setOutputDefaultSchema(boolean outputDefaultSchema)
Description copied from interface:DatabaseWhether the default schema should be included in generated SQL- Specified by:
setOutputDefaultSchemain interfaceDatabase
-
getOutputDefaultCatalog
public boolean getOutputDefaultCatalog()
- Specified by:
getOutputDefaultCatalogin interfaceDatabase
-
setOutputDefaultCatalog
public void setOutputDefaultCatalog(boolean outputDefaultCatalog)
- Specified by:
setOutputDefaultCatalogin interfaceDatabase
-
supportsPrimaryKeyNames
public boolean supportsPrimaryKeyNames()
- Specified by:
supportsPrimaryKeyNamesin interfaceDatabase
-
getSystemSchema
public String getSystemSchema()
- Specified by:
getSystemSchemain interfaceDatabase
-
escapeDataTypeName
public String escapeDataTypeName(String dataTypeName)
- Specified by:
escapeDataTypeNamein interfaceDatabase
-
unescapeDataTypeName
public String unescapeDataTypeName(String dataTypeName)
- Specified by:
unescapeDataTypeNamein interfaceDatabase
-
unescapeDataTypeString
public String unescapeDataTypeString(String dataTypeString)
- Specified by:
unescapeDataTypeStringin interfaceDatabase
-
set
public AbstractJdbcDatabase set(String key, Object value)
-
validate
public ValidationErrors validate()
-
getMaxFractionalDigitsForTimestamp
public int getMaxFractionalDigitsForTimestamp()
Most relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.- Specified by:
getMaxFractionalDigitsForTimestampin interfaceDatabase- Returns:
- the maximum number of supported fractional digits in TIMESTAMP columns
-
getDefaultFractionalDigitsForTimestamp
public int getDefaultFractionalDigitsForTimestamp()
SQL Standard (Foundation) says: "...ifis not specified, then 6 is implicit." - Specified by:
getDefaultFractionalDigitsForTimestampin interfaceDatabase- Returns:
- the default precision / number of maximum digits in a timestamp if nothing else is specified.
-
supportsBatchUpdates
public boolean supportsBatchUpdates() throws DatabaseExceptionDescription copied from interface:DatabaseDoes the database support batched DML (INSERT/UPDATE/DELETE/MERGE/...) statements sent in a single call to the database?- Specified by:
supportsBatchUpdatesin interfaceDatabase- Returns:
- true if the database has this capability for all DML statements, false in all other cases
- Throws:
DatabaseException
-
supportsNotNullConstraintNames
public boolean supportsNotNullConstraintNames()
Description copied from interface:DatabaseDoes this database treat NOT NULL as an own kind of CONSTRAINT (in addition of simply being a column property)? This will affect the CONSTRAINT clause SQL generators.- Specified by:
supportsNotNullConstraintNamesin interfaceDatabase- Returns:
- true if the database supports naming NOT NULL constraints, false if not.
-
requiresExplicitNullForColumns
public boolean requiresExplicitNullForColumns()
Description copied from interface:DatabaseDoes the database require explicit NULL for nullable columns?- Specified by:
requiresExplicitNullForColumnsin interfaceDatabase- Returns:
- true if the database behaves incorrectly if NULL is not explicitly specified, false if it behaves like any good RDBMS should.
-
getSchemaAndCatalogCase
public CatalogAndSchema.CatalogAndSchemaCase getSchemaAndCatalogCase()
This logic is used when db support catalogs- Specified by:
getSchemaAndCatalogCasein interfaceDatabase- Returns:
- UPPER_CASE by default
-
-