Package liquibase.database.core
Class MySQLDatabase
- java.lang.Object
-
- liquibase.database.AbstractJdbcDatabase
-
- liquibase.database.core.MySQLDatabase
-
- All Implemented Interfaces:
AutoCloseable,Database,PrioritizedService
- Direct Known Subclasses:
MariaDBDatabase
public class MySQLDatabase extends AbstractJdbcDatabase
Encapsulates MySQL database support.
-
-
Field Summary
Fields Modifier and Type Field Description static PatternPRECISION_PATTERN-
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
Constructors Constructor Description MySQLDatabase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcorrectObjectName(String name, Class<? extends DatabaseObject> objectType)Fix the object name to the format the database expects, handling changes in case, etc.booleancreatesIndexesForForeignKeys()booleandisableForeignKeyChecks()voidenableForeignKeyChecks()StringescapeIndexName(String catalogName, String schemaName, String indexName)StringescapeStringForDatabase(String string)protected 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.protected StringgetAutoIncrementClause()protected StringgetAutoIncrementClosing()protected StringgetAutoIncrementOpening()protected StringgetAutoIncrementStartWithClause()StringgetConcatSql(String... values)Returns SQL to concat the passed values.protected StringgetCurrentDateTimeFunction(int precision)intgetDatabasePatchVersion()protected StringgetDefaultDatabaseProductName()StringgetDefaultDriver(String url)If this database understands the given url, return the default driver class name.intgetDefaultFractionalDigitsForTimestamp()Returns the default timestamp fractional digits if nothing is specified.IntegergetDefaultPort()StringgetLineComment()Returns database-specific line comment string.intgetMaxFractionalDigitsForTimestamp()Most relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.protected StringgetMinimumVersionForFractionalDigitsForTimestamp()intgetPriority()protected StringgetQuotingEndCharacter()protected StringgetQuotingStartCharacter()CatalogAndSchemagetSchemaFromJdbcInfo(String rawCatalogName, String rawSchemaName)StringgetShortName()Returns an all-lower-case short name of the product.StringgetTableOptionAutoIncrementStartWithClause(BigInteger startWith)booleanisCorrectDatabaseImplementation(DatabaseConnection conn)Is this AbstractDatabase subclass the correct one to use for the given connection.booleanisMinimumMySQLVersion(String minimumVersion)Checks whether this instance of a MySQL database is equal to or greater than the specified version.booleanisReservedWord(String string)protected booleanmustQuoteObjectName(String objectName, Class<? extends DatabaseObject> objectType)booleansupportsCatalogs()booleansupportsCreateIfNotExists(Class<? extends DatabaseObject> type)Does the database support the "if not exits" syntax?booleansupportsDatabaseChangeLogHistory()Does the particular database implementation support the database changelog history feature and associated table?booleansupportsForeignKeyDisable()booleansupportsInitiallyDeferrableColumns()Returns whether this database support initially deferrable columns.booleansupportsSchemas()booleansupportsSequences()Does the database type support sequence.booleansupportsTablespaces()voidwarnAboutAlterColumn(String changeName, Warnings warnings)-
Methods inherited from class liquibase.database.AbstractJdbcDatabase
addReservedWords, canCreateChangeLogTable, close, commit, correctSchema, correctSchema, dataTypeIsNotModifiable, doesTagExist, dropDatabaseObjects, equals, escapeColumnName, escapeColumnName, escapeColumnNameList, escapeConstraintName, escapeDataTypeName, escapeObjectName, escapeObjectName, escapeSequenceName, escapeTableName, escapeViewName, execute, executeRollbackStatements, executeRollbackStatements, executeStatements, filterRollbackVisitors, generatePrimaryKeyName, get, getAutoCommitMode, getAutoIncrementByClause, getAutoIncrementClause, getAutoIncrementClause, getConnection, getConnectionCatalogName, getConnectionSchemaName, getConnectionSchemaNameCallStatement, getContainingObjects, getCurrentDateTimeFunction, getDatabaseChangeLogLockTableName, getDatabaseChangeLogTableName, getDatabaseMajorVersion, getDatabaseMinorVersion, getDatabaseProductName, getDatabaseProductVersion, getDataTypeMaxParameters, getDateFunctions, getDateLiteral, getDateLiteral, getDateLiteral, getDateTimeLiteral, getDefaultCatalogName, getDefaultScaleForNativeDataType, getDefaultSchema, getDefaultSchemaName, getFetchSize, getJdbcCatalogName, getJdbcCatalogName, getJdbcSchemaName, getJdbcSchemaName, getLiquibaseCatalogName, getLiquibaseSchemaName, getLiquibaseTablespaceName, getName, getObjectQuotingStrategy, getOutputDefaultCatalog, getOutputDefaultSchema, getQuotingEndReplacement, getRanChangeSet, getRanChangeSetList, getRanDate, getRawDatabaseChangeLogLockTableName, getRawDatabaseChangeLogTableName, getRunStatus, getSchemaAndCatalogCase, getSystemSchema, getSystemTables, getSystemViews, getTimeLiteral, getViewDefinition, hashCode, isAutoCommit, isCaseSensitive, isCatalogOrSchemaType, isCurrentTimeFunction, isDateOnly, isDateTime, isDefaultCatalog, isDefaultSchema, isFunction, isLiquibaseObject, isSafeToRunUpdate, isSystemObject, isSystemView, isTimeOnly, isTimestamp, jdbcCallsCatalogsSchemas, markChangeSetExecStatus, parseDate, quoteObject, removeRanStatus, requiresExplicitNullForColumns, requiresPassword, requiresUsername, resetInternalState, rollback, saveRollbackStatement, saveStatements, set, setAutoCommit, setCanCacheLiquibaseTableInfo, setCaseSensitive, setConnection, setCurrentDateTimeFunction, setDatabaseChangeLogLockTableName, setDatabaseChangeLogTableName, setDefaultCatalogName, setDefaultSchemaName, setLiquibaseCatalogName, setLiquibaseSchemaName, setLiquibaseTablespaceName, setObjectQuotingStrategy, setOutputDefaultCatalog, setOutputDefaultSchema, startsWithNumeric, supportsAutoIncrement, supportsBatchUpdates, supportsCatalogInObjectName, supportsDDLInTransaction, supportsDropTableCascadeConstraints, supportsNotNullConstraintNames, supportsPrimaryKeyNames, supportsRestrictForeignKeys, tag, toString, unescapeDataTypeName, 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, dropDatabaseObjects, failOnDefferable, getDisplayName, temporarilySetObjectQuotingStrategy
-
-
-
-
Field Detail
-
PRECISION_PATTERN
public static final Pattern PRECISION_PATTERN
-
-
Method Detail
-
getShortName
public String 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.
-
correctObjectName
public String correctObjectName(String name, 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- Overrides:
correctObjectNamein classAbstractJdbcDatabase
-
getDefaultDatabaseProductName
protected String getDefaultDatabaseProductName()
- Specified by:
getDefaultDatabaseProductNamein classAbstractJdbcDatabase
-
getDefaultPort
public Integer getDefaultPort()
-
getPriority
public int getPriority()
-
isCorrectDatabaseImplementation
public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException
Description copied from interface:DatabaseIs this AbstractDatabase subclass the correct one to use for the given connection.- Throws:
DatabaseException
-
getDefaultDriver
public String getDefaultDriver(String url)
Description copied from interface:DatabaseIf this database understands the given url, return the default driver class name. Otherwise return null.
-
supportsSequences
public boolean supportsSequences()
Description copied from class:AbstractJdbcDatabaseDoes the database type support sequence.- Specified by:
supportsSequencesin interfaceDatabase- Overrides:
supportsSequencesin classAbstractJdbcDatabase
-
supportsInitiallyDeferrableColumns
public boolean supportsInitiallyDeferrableColumns()
Description copied from interface:DatabaseReturns whether this database support initially deferrable columns.
-
mustQuoteObjectName
protected boolean mustQuoteObjectName(String objectName, Class<? extends DatabaseObject> objectType)
- Overrides:
mustQuoteObjectNamein classAbstractJdbcDatabase
-
getLineComment
public String getLineComment()
Description copied from class:AbstractJdbcDatabaseReturns database-specific line comment string.- Specified by:
getLineCommentin interfaceDatabase- Overrides:
getLineCommentin classAbstractJdbcDatabase
-
getAutoIncrementClause
protected String getAutoIncrementClause()
- Overrides:
getAutoIncrementClausein classAbstractJdbcDatabase
-
generateAutoIncrementStartWith
protected boolean generateAutoIncrementStartWith(BigInteger startWith)
- Overrides:
generateAutoIncrementStartWithin classAbstractJdbcDatabase
-
getTableOptionAutoIncrementStartWithClause
public String getTableOptionAutoIncrementStartWithClause(BigInteger startWith)
-
generateAutoIncrementBy
protected boolean generateAutoIncrementBy(BigInteger incrementBy)
- Overrides:
generateAutoIncrementByin classAbstractJdbcDatabase
-
getAutoIncrementOpening
protected String getAutoIncrementOpening()
- Overrides:
getAutoIncrementOpeningin classAbstractJdbcDatabase
-
getAutoIncrementClosing
protected String getAutoIncrementClosing()
- Overrides:
getAutoIncrementClosingin classAbstractJdbcDatabase
-
getAutoIncrementStartWithClause
protected String getAutoIncrementStartWithClause()
- Overrides:
getAutoIncrementStartWithClausein classAbstractJdbcDatabase
-
getConcatSql
public String getConcatSql(String... values)
Description copied from interface:DatabaseReturns SQL to concat the passed values.- Specified by:
getConcatSqlin interfaceDatabase- Overrides:
getConcatSqlin classAbstractJdbcDatabase
-
supportsTablespaces
public boolean supportsTablespaces()
-
supportsSchemas
public boolean supportsSchemas()
- Specified by:
supportsSchemasin interfaceDatabase- Overrides:
supportsSchemasin classAbstractJdbcDatabase
-
supportsCatalogs
public boolean supportsCatalogs()
- Specified by:
supportsCatalogsin interfaceDatabase- Overrides:
supportsCatalogsin classAbstractJdbcDatabase
-
escapeIndexName
public String escapeIndexName(String catalogName, String schemaName, String indexName)
- Specified by:
escapeIndexNamein interfaceDatabase- Overrides:
escapeIndexNamein classAbstractJdbcDatabase
-
supportsForeignKeyDisable
public boolean supportsForeignKeyDisable()
- Specified by:
supportsForeignKeyDisablein interfaceDatabase- Overrides:
supportsForeignKeyDisablein classAbstractJdbcDatabase
-
disableForeignKeyChecks
public boolean disableForeignKeyChecks() throws DatabaseException- Specified by:
disableForeignKeyChecksin interfaceDatabase- Overrides:
disableForeignKeyChecksin classAbstractJdbcDatabase- Throws:
DatabaseException
-
enableForeignKeyChecks
public void enableForeignKeyChecks() throws DatabaseException- Specified by:
enableForeignKeyChecksin interfaceDatabase- Overrides:
enableForeignKeyChecksin classAbstractJdbcDatabase- Throws:
DatabaseException
-
getSchemaFromJdbcInfo
public CatalogAndSchema getSchemaFromJdbcInfo(String rawCatalogName, String rawSchemaName)
- Overrides:
getSchemaFromJdbcInfoin classAbstractJdbcDatabase
-
escapeStringForDatabase
public String escapeStringForDatabase(String string)
- Specified by:
escapeStringForDatabasein interfaceDatabase- Overrides:
escapeStringForDatabasein classAbstractJdbcDatabase
-
createsIndexesForForeignKeys
public boolean createsIndexesForForeignKeys()
- Specified by:
createsIndexesForForeignKeysin interfaceDatabase- Overrides:
createsIndexesForForeignKeysin classAbstractJdbcDatabase
-
isReservedWord
public boolean isReservedWord(String string)
- Specified by:
isReservedWordin interfaceDatabase- Overrides:
isReservedWordin classAbstractJdbcDatabase
-
getDatabasePatchVersion
public int getDatabasePatchVersion() throws DatabaseException- Throws:
DatabaseException
-
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
-
isMinimumMySQLVersion
public boolean isMinimumMySQLVersion(String minimumVersion)
Checks whether this instance of a MySQL database is equal to or greater than the specified version.- Parameters:
minimumVersion- the minimum version to check- Returns:
trueif this instance of a MySQL database is equal to or greater than the specified version,falseotherwise
-
getMinimumVersionForFractionalDigitsForTimestamp
protected String getMinimumVersionForFractionalDigitsForTimestamp()
-
getQuotingStartCharacter
protected String getQuotingStartCharacter()
- Overrides:
getQuotingStartCharacterin classAbstractJdbcDatabase
-
getQuotingEndCharacter
protected String getQuotingEndCharacter()
- Overrides:
getQuotingEndCharacterin classAbstractJdbcDatabase
-
getDefaultFractionalDigitsForTimestamp
public int getDefaultFractionalDigitsForTimestamp()
Returns the default timestamp fractional digits if nothing is specified.
fractional seconds: "The fsp value, if given, must be in the range 0 to 6. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0. (This differs from the STANDARD SQL default of 6, for compatibility with previous MySQL versions.)"- Specified by:
getDefaultFractionalDigitsForTimestampin interfaceDatabase- Overrides:
getDefaultFractionalDigitsForTimestampin classAbstractJdbcDatabase- Returns:
- always 0
-
getCurrentDateTimeFunction
protected String getCurrentDateTimeFunction(int precision)
-
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- Overrides:
generateDatabaseFunctionValuein classAbstractJdbcDatabase- Parameters:
databaseFunction- database function to check.- Returns:
- the string value to use for an update or generate
-
supportsCreateIfNotExists
public boolean supportsCreateIfNotExists(Class<? extends DatabaseObject> type)
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
-
-