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
Encapsulates MySQL database support.
-
Field Summary
FieldsFields 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 TypeMethodDescriptionvoidaddReservedWords(Collection<String> words) correctObjectName(String name, Class<? extends DatabaseObject> objectType) Fix the object name to the format the database expects, handling changes in case, etc.booleanbooleanvoidescapeIndexName(String catalogName, String schemaName, String indexName) escapeStringForDatabase(String string) protected booleangenerateAutoIncrementBy(BigInteger incrementBy) protected booleangenerateAutoIncrementStartWith(BigInteger startWith) generateDatabaseFunctionValue(DatabaseFunction databaseFunction) Some function names are placeholders that need to be replaced with the specific database value.protected Stringprotected Stringprotected Stringprotected StringgetConcatSql(String... values) Returns SQL to concat the passed values.protected StringgetCurrentDateTimeFunction(int precision) intprotected StringgetDefaultDriver(String url) If this database understands the given url, return the default driver class name.intReturns the default timestamp fractional digits if nothing is specified.getFSPFromTimeType(int columnSize, int jdbcType) Returns database-specific line comment string.intMost relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.protected Stringintprotected Stringprotected StringgetSchemaFromJdbcInfo(String rawCatalogName, String rawSchemaName) Returns an all-lower-case short name of the product.booleanbooleanIs 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) booleansupports(Class<? extends DatabaseObject> object) Whether this database supports the specified object type.booleanWhether this database supports catalogsbooleansupportsCreateIfNotExists(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?booleanbooleanReturns whether this database support initially deferrable columns.booleanWhether this database supports schemasbooleanDoes the database type support sequence.booleanvoidwarnAboutAlterColumn(String changeName, Warnings warnings) Methods inherited from class liquibase.database.AbstractJdbcDatabase
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, setPreviousAutoCommit, startsWithNumeric, supportsAutoIncrement, supportsBatchUpdates, supportsCatalogInObjectName, supportsDDLInTransaction, supportsDropTableCascadeConstraints, supportsNotNullConstraintNames, supportsPrimaryKeyNames, supportsRestrictForeignKeys, tag, toString, unescapeDataTypeName, 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, temporarilySetObjectQuotingStrategy
-
Field Details
-
PRECISION_PATTERN
-
-
Constructor Details
-
MySQLDatabase
public MySQLDatabase()
-
-
Method Details
-
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
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
- Specified by:
getDefaultDatabaseProductNamein classAbstractJdbcDatabase
-
getDefaultPort
-
getPriority
public int getPriority() -
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. -
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
Description copied from class:AbstractJdbcDatabaseReturns database-specific line comment string.- Specified by:
getLineCommentin interfaceDatabase- Overrides:
getLineCommentin classAbstractJdbcDatabase
-
getAutoIncrementClause
- Overrides:
getAutoIncrementClausein classAbstractJdbcDatabase
-
generateAutoIncrementStartWith
- Overrides:
generateAutoIncrementStartWithin classAbstractJdbcDatabase
-
getTableOptionAutoIncrementStartWithClause
-
generateAutoIncrementBy
- Overrides:
generateAutoIncrementByin classAbstractJdbcDatabase
-
getAutoIncrementOpening
- Overrides:
getAutoIncrementOpeningin classAbstractJdbcDatabase
-
getAutoIncrementClosing
- Overrides:
getAutoIncrementClosingin classAbstractJdbcDatabase
-
getAutoIncrementStartWithClause
- Overrides:
getAutoIncrementStartWithClausein classAbstractJdbcDatabase
-
getConcatSql
Description copied from interface:DatabaseReturns SQL to concat the passed values.- Specified by:
getConcatSqlin interfaceDatabase- Overrides:
getConcatSqlin classAbstractJdbcDatabase
-
supportsTablespaces
public boolean supportsTablespaces() -
supports
Description copied from interface:DatabaseWhether this database supports the specified object type. It is invoking the deprecated methods to ensure that extensions are not broken, but once those are removed it will return only true- Parameters:
object- the object type to check- Returns:
- true if the database supports the object type, false otherwise
-
supportsSchemas
public boolean supportsSchemas()Description copied from interface:DatabaseWhether this database supports schemas- Specified by:
supportsSchemasin interfaceDatabase- Overrides:
supportsSchemasin classAbstractJdbcDatabase
-
supportsCatalogs
public boolean supportsCatalogs()Description copied from interface:DatabaseWhether this database supports catalogs- Specified by:
supportsCatalogsin interfaceDatabase- Overrides:
supportsCatalogsin classAbstractJdbcDatabase
-
escapeIndexName
- Specified by:
escapeIndexNamein interfaceDatabase- Overrides:
escapeIndexNamein classAbstractJdbcDatabase
-
supportsForeignKeyDisable
public boolean supportsForeignKeyDisable()- Specified by:
supportsForeignKeyDisablein interfaceDatabase- Overrides:
supportsForeignKeyDisablein classAbstractJdbcDatabase
-
disableForeignKeyChecks
- Specified by:
disableForeignKeyChecksin interfaceDatabase- Overrides:
disableForeignKeyChecksin classAbstractJdbcDatabase- Throws:
DatabaseException
-
enableForeignKeyChecks
- Specified by:
enableForeignKeyChecksin interfaceDatabase- Overrides:
enableForeignKeyChecksin classAbstractJdbcDatabase- Throws:
DatabaseException
-
getSchemaFromJdbcInfo
- Overrides:
getSchemaFromJdbcInfoin classAbstractJdbcDatabase
-
escapeStringForDatabase
- Specified by:
escapeStringForDatabasein interfaceDatabase- Overrides:
escapeStringForDatabasein classAbstractJdbcDatabase
-
createsIndexesForForeignKeys
public boolean createsIndexesForForeignKeys()- Specified by:
createsIndexesForForeignKeysin interfaceDatabase- Overrides:
createsIndexesForForeignKeysin classAbstractJdbcDatabase
-
isReservedWord
- Specified by:
isReservedWordin interfaceDatabase- Overrides:
isReservedWordin classAbstractJdbcDatabase
-
getDatabasePatchVersion
- Throws:
DatabaseException
-
getFSPFromTimeType
-
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
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
-
getQuotingStartCharacter
- Overrides:
getQuotingStartCharacterin classAbstractJdbcDatabase
-
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
-
generateDatabaseFunctionValue
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
-
warnAboutAlterColumn
-
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
-
getUseAffectedRows
- Throws:
DatabaseException
-
addReservedWords
- Specified by:
addReservedWordsin interfaceDatabase- Overrides:
addReservedWordsin classAbstractJdbcDatabase
-