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
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 TypeMethodDescriptionvoid
addReservedWords
(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.boolean
boolean
void
escapeIndexName
(String catalogName, String schemaName, String indexName) escapeStringForDatabase
(String string) protected boolean
generateAutoIncrementBy
(BigInteger incrementBy) protected boolean
generateAutoIncrementStartWith
(BigInteger startWith) generateDatabaseFunctionValue
(DatabaseFunction databaseFunction) Some function names are placeholders that need to be replaced with the specific database value.protected String
protected String
protected String
protected String
getConcatSql
(String... values) Returns SQL to concat the passed values.protected String
getCurrentDateTimeFunction
(int precision) int
protected String
getDefaultDriver
(String url) If this database understands the given url, return the default driver class name.int
Returns the default timestamp fractional digits if nothing is specified.getFSPFromTimeType
(int columnSize, int jdbcType) Returns database-specific line comment string.int
Most relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.protected String
int
protected String
protected String
getSchemaFromJdbcInfo
(String rawCatalogName, String rawSchemaName) Returns an all-lower-case short name of the product.boolean
boolean
Is this AbstractDatabase subclass the correct one to use for the given connection.boolean
isMinimumMySQLVersion
(String minimumVersion) Checks whether this instance of a MySQL database is equal to or greater than the specified version.boolean
isReservedWord
(String string) protected boolean
mustQuoteObjectName
(String objectName, Class<? extends DatabaseObject> objectType) boolean
supports
(Class<? extends DatabaseObject> object) Whether this database supports the specified object type.boolean
Whether this database supports catalogsboolean
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
boolean
Returns whether this database support initially deferrable columns.boolean
Whether this database supports schemasboolean
Does the database type support sequence.boolean
void
warnAboutAlterColumn
(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, 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, temporarilySetObjectQuotingStrategy
-
Field Details
-
PRECISION_PATTERN
-
-
Constructor Details
-
MySQLDatabase
public MySQLDatabase()
-
-
Method Details
-
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. -
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
-
getDefaultDatabaseProductName
- Specified by:
getDefaultDatabaseProductName
in classAbstractJdbcDatabase
-
getDefaultPort
-
getPriority
public int getPriority() -
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. -
supportsSequences
public boolean supportsSequences()Description copied from class:AbstractJdbcDatabase
Does the database type support sequence.- Specified by:
supportsSequences
in interfaceDatabase
- Overrides:
supportsSequences
in classAbstractJdbcDatabase
-
supportsInitiallyDeferrableColumns
public boolean supportsInitiallyDeferrableColumns()Description copied from interface:Database
Returns whether this database support initially deferrable columns. -
mustQuoteObjectName
protected boolean mustQuoteObjectName(String objectName, Class<? extends DatabaseObject> objectType) - Overrides:
mustQuoteObjectName
in classAbstractJdbcDatabase
-
getLineComment
Description copied from class:AbstractJdbcDatabase
Returns database-specific line comment string.- Specified by:
getLineComment
in interfaceDatabase
- Overrides:
getLineComment
in classAbstractJdbcDatabase
-
getAutoIncrementClause
- Overrides:
getAutoIncrementClause
in classAbstractJdbcDatabase
-
generateAutoIncrementStartWith
- Overrides:
generateAutoIncrementStartWith
in classAbstractJdbcDatabase
-
getTableOptionAutoIncrementStartWithClause
-
generateAutoIncrementBy
- Overrides:
generateAutoIncrementBy
in classAbstractJdbcDatabase
-
getAutoIncrementOpening
- Overrides:
getAutoIncrementOpening
in classAbstractJdbcDatabase
-
getAutoIncrementClosing
- Overrides:
getAutoIncrementClosing
in classAbstractJdbcDatabase
-
getAutoIncrementStartWithClause
- Overrides:
getAutoIncrementStartWithClause
in classAbstractJdbcDatabase
-
getConcatSql
Description copied from interface:Database
Returns SQL to concat the passed values.- Specified by:
getConcatSql
in interfaceDatabase
- Overrides:
getConcatSql
in classAbstractJdbcDatabase
-
supportsTablespaces
public boolean supportsTablespaces() -
supports
Description copied from interface:Database
Whether 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:Database
Whether this database supports schemas- Specified by:
supportsSchemas
in interfaceDatabase
- Overrides:
supportsSchemas
in classAbstractJdbcDatabase
-
supportsCatalogs
public boolean supportsCatalogs()Description copied from interface:Database
Whether this database supports catalogs- Specified by:
supportsCatalogs
in interfaceDatabase
- Overrides:
supportsCatalogs
in classAbstractJdbcDatabase
-
escapeIndexName
- Specified by:
escapeIndexName
in interfaceDatabase
- Overrides:
escapeIndexName
in classAbstractJdbcDatabase
-
supportsForeignKeyDisable
public boolean supportsForeignKeyDisable()- Specified by:
supportsForeignKeyDisable
in interfaceDatabase
- Overrides:
supportsForeignKeyDisable
in classAbstractJdbcDatabase
-
disableForeignKeyChecks
- Specified by:
disableForeignKeyChecks
in interfaceDatabase
- Overrides:
disableForeignKeyChecks
in classAbstractJdbcDatabase
- Throws:
DatabaseException
-
enableForeignKeyChecks
- Specified by:
enableForeignKeyChecks
in interfaceDatabase
- Overrides:
enableForeignKeyChecks
in classAbstractJdbcDatabase
- Throws:
DatabaseException
-
getSchemaFromJdbcInfo
- Overrides:
getSchemaFromJdbcInfo
in classAbstractJdbcDatabase
-
escapeStringForDatabase
- Specified by:
escapeStringForDatabase
in interfaceDatabase
- Overrides:
escapeStringForDatabase
in classAbstractJdbcDatabase
-
createsIndexesForForeignKeys
public boolean createsIndexesForForeignKeys()- Specified by:
createsIndexesForForeignKeys
in interfaceDatabase
- Overrides:
createsIndexesForForeignKeys
in classAbstractJdbcDatabase
-
isReservedWord
- Specified by:
isReservedWord
in interfaceDatabase
- Overrides:
isReservedWord
in classAbstractJdbcDatabase
-
getDatabasePatchVersion
- Throws:
DatabaseException
-
getFSPFromTimeType
-
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
-
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:
true
if this instance of a MySQL database is equal to or greater than the specified version,false
otherwise
-
getMinimumVersionForFractionalDigitsForTimestamp
-
getQuotingStartCharacter
- Overrides:
getQuotingStartCharacter
in classAbstractJdbcDatabase
-
getQuotingEndCharacter
- Overrides:
getQuotingEndCharacter
in 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:
getDefaultFractionalDigitsForTimestamp
in interfaceDatabase
- Overrides:
getDefaultFractionalDigitsForTimestamp
in classAbstractJdbcDatabase
- Returns:
- always 0
-
getCurrentDateTimeFunction
-
generateDatabaseFunctionValue
Description copied from interface:Database
Some 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:
generateDatabaseFunctionValue
in interfaceDatabase
- Overrides:
generateDatabaseFunctionValue
in classAbstractJdbcDatabase
- Parameters:
databaseFunction
- database function to check.- Returns:
- the string value to use for an update or generate
-
warnAboutAlterColumn
-
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
-
getUseAffectedRows
- Throws:
DatabaseException
-
addReservedWords
- Specified by:
addReservedWords
in interfaceDatabase
- Overrides:
addReservedWords
in classAbstractJdbcDatabase
-