Top Description Fields Constructors Methods
liquibase.database.core

public Class MySQLDatabase

extends AbstractJdbcDatabase
Class Inheritance
Known Direct Subclasses
liquibase.database.core.MariaDBDatabase
Imports
liquibase.CatalogAndSchema, .Scope, liquibase.database.AbstractJdbcDatabase, .DatabaseConnection, liquibase.exception.DatabaseException, .Warnings, liquibase.executor.ExecutorService, liquibase.statement.DatabaseFunction, liquibase.statement.core.RawSqlStatement, liquibase.structure.DatabaseObject, liquibase.structure.core.Index, .PrimaryKey, .Table, liquibase.util.StringUtil, java.math.BigInteger, java.util.Arrays, .HashSet, .Locale, .Set, java.util.regex.Matcher, .Pattern

Encapsulates MySQL database support.

Field Summary

Modifier and TypeField and Description
public static final Pattern
private static final String
PRECISION_REGEX

Pattern used to extract function precision like 3 in CURRENT_TIMESTAMP(3)

private static final String
private static final Set<String>
Inherited from liquibase.database.AbstractJdbcDatabase:
caseSensitivecurrentDateTimeFunctiondateFunctionsdefaultAutoIncrementBydefaultAutoIncrementStartWithdefaultCatalogNamedefaultSchemaNamequotingStrategysequenceCurrentValueFunctionsequenceNextValueFunctionunmodifiableDataTypesunquotedObjectsAreUppercased

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
correctObjectName(String name, Class<? extends DatabaseObject> objectType)

Overrides liquibase.database.AbstractJdbcDatabase.correctObjectName.

Implements liquibase.database.Database.correctObjectName.

Fix the object name to the format the database expects, handling changes in case, etc.

private static Set<String>
public boolean
public boolean
public void
public String
public String
private int
protected boolean
protected boolean
public String
generateDatabaseFunctionValue(DatabaseFunction
database function to check.
databaseFunction
)

Overrides liquibase.database.AbstractJdbcDatabase.generateDatabaseFunctionValue.

Implements liquibase.database.Database.generateDatabaseFunctionValue.

Some function names are placeholders that need to be replaced with the specific database value.

protected String
protected String
protected String
protected String
public String
getConcatSql(String... values)

Overrides liquibase.database.AbstractJdbcDatabase.getConcatSql.

Implements liquibase.database.Database.getConcatSql.

Returns SQL to concat the passed values.

protected String
public int
protected String
public String
getDefaultDriver(String url)

Implements liquibase.database.Database.getDefaultDriver.

If this database understands the given url, return the default driver class name.

public int
public Integer
public String
getLineComment()

Overrides liquibase.database.AbstractJdbcDatabase.getLineComment.

Implements liquibase.database.Database.getLineComment.

Returns database-specific line comment string.

public int
getMaxFractionalDigitsForTimestamp()

Overrides liquibase.database.AbstractJdbcDatabase.getMaxFractionalDigitsForTimestamp.

Implements liquibase.database.Database.getMaxFractionalDigitsForTimestamp.

Most relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.

protected String
public int
protected String
protected String
public CatalogAndSchema
public String
getShortName()

Implements liquibase.database.Database.getShortName.

Returns an all-lower-case short name of the product.

public String
public boolean
isCorrectDatabaseImplementation(DatabaseConnection conn)

Implements liquibase.database.Database.isCorrectDatabaseImplementation.

Is this AbstractDatabase subclass the correct one to use for the given connection.

public boolean

Returns:

true if this instance of a MySQL database is equal to or greater than the specified version, false otherwise
isMinimumMySQLVersion
(String
the minimum version to check
minimumVersion
)

Checks whether this instance of a MySQL database is equal to or greater than the specified version.

public boolean
protected boolean
public boolean
public boolean
supportsCreateIfNotExists(Class<? extends DatabaseObject>
the DatabaseObject type to be checked.
type
)

Overrides default liquibase.database.Database.supportsCreateIfNotExists.

Does the database support the "if not exits" syntax?

public boolean
public boolean
supportsInitiallyDeferrableColumns()

Implements liquibase.database.Database.supportsInitiallyDeferrableColumns.

Returns whether this database support initially deferrable columns.

public boolean
public boolean
public boolean
public void
warnAboutAlterColumn(String changeName, Warnings warnings)

Inherited from liquibase.database.AbstractJdbcDatabase:
addReservedWordscanCreateChangeLogTableclosecommitcorrectSchemacorrectSchemadataTypeIsNotModifiabledoesTagExistdropDatabaseObjectsequalsescapeColumnNameescapeColumnNameescapeColumnNameListescapeConstraintNameescapeDataTypeNameescapeObjectNameescapeObjectNameescapeSequenceNameescapeTableNameescapeViewNameexecuteexecuteRollbackStatementsexecuteRollbackStatementsexecuteStatementsfilterRollbackVisitorsgeneratePrimaryKeyNamegetgetAutoCommitModegetAutoIncrementByClausegetAutoIncrementClausegetAutoIncrementClausegetConnectiongetConnectionCatalogNamegetConnectionSchemaNamegetConnectionSchemaNameCallStatementgetContainingObjectsgetCurrentDateTimeFunctiongetDatabaseChangeLogLockTableNamegetDatabaseChangeLogTableNamegetDatabaseMajorVersiongetDatabaseMinorVersiongetDatabaseProductNamegetDatabaseProductVersiongetDataTypeMaxParametersgetDateFunctionsgetDateLiteralgetDateLiteralgetDateLiteralgetDateTimeLiteralgetDefaultCatalogNamegetDefaultScaleForNativeDataTypegetDefaultSchemagetDefaultSchemaNamegetFetchSizegetJdbcCatalogNamegetJdbcCatalogNamegetJdbcSchemaNamegetJdbcSchemaNamegetLiquibaseCatalogNamegetLiquibaseSchemaNamegetLiquibaseTablespaceNamegetNamegetObjectQuotingStrategygetOutputDefaultCataloggetOutputDefaultSchemagetQuotingEndReplacementgetRanChangeSetgetRanChangeSetListgetRanDategetRawDatabaseChangeLogLockTableNamegetRawDatabaseChangeLogTableNamegetRunStatusgetSchemaAndCatalogCasegetSystemSchemagetSystemTablesgetSystemViewsgetTimeLiteralgetViewDefinitionhashCodeisAutoCommitisCaseSensitiveisCatalogOrSchemaTypeisCurrentTimeFunctionisDateOnlyisDateTimeisDefaultCatalogisDefaultSchemaisFunctionisLiquibaseObjectisSafeToRunUpdateisSystemObjectisSystemViewisTimeOnlyisTimestampjdbcCallsCatalogsSchemasmarkChangeSetExecStatusparseDatequoteObjectremoveRanStatusrequiresExplicitNullForColumnsrequiresPasswordrequiresUsernameresetInternalStaterollbacksaveRollbackStatementsaveStatementssetsetAutoCommitsetCanCacheLiquibaseTableInfosetCaseSensitivesetConnectionsetCurrentDateTimeFunctionsetDatabaseChangeLogLockTableNamesetDatabaseChangeLogTableNamesetDefaultCatalogNamesetDefaultSchemaNamesetLiquibaseCatalogNamesetLiquibaseSchemaNamesetLiquibaseTablespaceNamesetObjectQuotingStrategysetOutputDefaultCatalogsetOutputDefaultSchemastartsWithNumericsupportsAutoIncrementsupportsBatchUpdatessupportsCatalogInObjectNamesupportsDDLInTransactionsupportsDropTableCascadeConstraintssupportsNotNullConstraintNamessupportsPrimaryKeyNamessupportsRestrictForeignKeystagtoStringunescapeDataTypeNameunescapeDataTypeStringvalidate

Field Detail

PRECISION_PATTERNback to summary
public static final Pattern PRECISION_PATTERN
PRECISION_REGEXback to summary
private static final String PRECISION_REGEX

Pattern used to extract function precision like 3 in CURRENT_TIMESTAMP(3)

PRODUCT_NAMEback to summary
private static final String PRODUCT_NAME
RESERVED_WORDSback to summary
private static final Set<String> RESERVED_WORDS

Constructor Detail

MySQLDatabaseback to summary
public MySQLDatabase()

Method Detail

correctObjectNameback to summary
public String correctObjectName(String name, Class<? extends DatabaseObject> objectType)

Overrides liquibase.database.AbstractJdbcDatabase.correctObjectName.

Implements liquibase.database.Database.correctObjectName.

Doc from liquibase.database.Database.correctObjectName.

Fix the object name to the format the database expects, handling changes in case, etc.

Annotations
@Override
createReservedWordsback to summary
private static Set<String> createReservedWords()
createsIndexesForForeignKeysback to summary
public boolean createsIndexesForForeignKeys()

Overrides liquibase.database.AbstractJdbcDatabase.createsIndexesForForeignKeys.

Implements liquibase.database.Database.createsIndexesForForeignKeys.

Annotations
@Override
disableForeignKeyChecksback to summary
public boolean disableForeignKeyChecks() throws DatabaseException

Overrides liquibase.database.AbstractJdbcDatabase.disableForeignKeyChecks.

Implements liquibase.database.Database.disableForeignKeyChecks.

Annotations
@Override
enableForeignKeyChecksback to summary
public void enableForeignKeyChecks() throws DatabaseException

Overrides liquibase.database.AbstractJdbcDatabase.enableForeignKeyChecks.

Implements liquibase.database.Database.enableForeignKeyChecks.

Annotations
@Override
escapeIndexNameback to summary
public String escapeIndexName(String catalogName, String schemaName, String indexName)

Overrides liquibase.database.AbstractJdbcDatabase.escapeIndexName.

Implements liquibase.database.Database.escapeIndexName.

Annotations
@Override
escapeStringForDatabaseback to summary
public String escapeStringForDatabase(String string)

Overrides liquibase.database.AbstractJdbcDatabase.escapeStringForDatabase.

Implements liquibase.database.Database.escapeStringForDatabase.

Annotations
@Override
extractPrecisionback to summary
private int extractPrecision(DatabaseFunction databaseFunction)
generateAutoIncrementByback to summary
protected boolean generateAutoIncrementBy(BigInteger incrementBy)

Overrides liquibase.database.AbstractJdbcDatabase.generateAutoIncrementBy.

Annotations
@Override
generateAutoIncrementStartWithback to summary
protected boolean generateAutoIncrementStartWith(final BigInteger startWith)

Overrides liquibase.database.AbstractJdbcDatabase.generateAutoIncrementStartWith.

Annotations
@Override
generateDatabaseFunctionValueback to summary
public String generateDatabaseFunctionValue(DatabaseFunction databaseFunction)

Overrides liquibase.database.AbstractJdbcDatabase.generateDatabaseFunctionValue.

Implements liquibase.database.Database.generateDatabaseFunctionValue.

Doc from liquibase.database.Database.generateDatabaseFunctionValue.

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

Parameters
databaseFunction:DatabaseFunction

database function to check.

Returns:String

the string value to use for an update or generate

Annotations
@Override
getAutoIncrementClauseback to summary
protected String getAutoIncrementClause()

Overrides liquibase.database.AbstractJdbcDatabase.getAutoIncrementClause.

Annotations
@Override
getAutoIncrementClosingback to summary
protected String getAutoIncrementClosing()

Overrides liquibase.database.AbstractJdbcDatabase.getAutoIncrementClosing.

Annotations
@Override
getAutoIncrementOpeningback to summary
protected String getAutoIncrementOpening()

Overrides liquibase.database.AbstractJdbcDatabase.getAutoIncrementOpening.

Annotations
@Override
getAutoIncrementStartWithClauseback to summary
protected String getAutoIncrementStartWithClause()

Overrides liquibase.database.AbstractJdbcDatabase.getAutoIncrementStartWithClause.

Annotations
@Override
getConcatSqlback to summary
public String getConcatSql(String... values)

Overrides liquibase.database.AbstractJdbcDatabase.getConcatSql.

Implements liquibase.database.Database.getConcatSql.

Doc from liquibase.database.Database.getConcatSql.

Returns SQL to concat the passed values.

Annotations
@Override
getCurrentDateTimeFunctionback to summary
protected String getCurrentDateTimeFunction(int precision)
getDatabasePatchVersionback to summary
public int getDatabasePatchVersion() throws DatabaseException
getDefaultDatabaseProductNameback to summary
protected String getDefaultDatabaseProductName()

Implements abstract liquibase.database.AbstractJdbcDatabase.getDefaultDatabaseProductName.

Annotations
@Override
getDefaultDriverback to summary
public String getDefaultDriver(String url)

Implements liquibase.database.Database.getDefaultDriver.

Doc from liquibase.database.Database.getDefaultDriver.

If this database understands the given url, return the default driver class name. Otherwise return null.

Annotations
@Override
getDefaultFractionalDigitsForTimestampback to summary
public int getDefaultFractionalDigitsForTimestamp()

Overrides liquibase.database.AbstractJdbcDatabase.getDefaultFractionalDigitsForTimestamp.

Implements liquibase.database.Database.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.)"
Returns:int

always 0

Annotations
@Override
getDefaultPortback to summary
public Integer getDefaultPort()

Implements liquibase.database.Database.getDefaultPort.

Annotations
@Override
getLineCommentback to summary
public String getLineComment()

Overrides liquibase.database.AbstractJdbcDatabase.getLineComment.

Implements liquibase.database.Database.getLineComment.

Doc from liquibase.database.AbstractJdbcDatabase.getLineComment.

Returns database-specific line comment string.

Annotations
@Override
getMaxFractionalDigitsForTimestampback to summary
public int getMaxFractionalDigitsForTimestamp()

Overrides liquibase.database.AbstractJdbcDatabase.getMaxFractionalDigitsForTimestamp.

Implements liquibase.database.Database.getMaxFractionalDigitsForTimestamp.

Doc from liquibase.database.AbstractJdbcDatabase.getMaxFractionalDigitsForTimestamp.

Most relational databases support 9 fractional digits, and subclasses must overwrite this method if they support less than that.

Returns:int

the maximum number of supported fractional digits in TIMESTAMP columns

Annotations
@Override
getMinimumVersionForFractionalDigitsForTimestampback to summary
protected String getMinimumVersionForFractionalDigitsForTimestamp()
getPriorityback to summary
public int getPriority()

Implements liquibase.servicelocator.PrioritizedService.getPriority.

Annotations
@Override
getQuotingEndCharacterback to summary
protected String getQuotingEndCharacter()

Overrides liquibase.database.AbstractJdbcDatabase.getQuotingEndCharacter.

Annotations
@Override
getQuotingStartCharacterback to summary
protected String getQuotingStartCharacter()

Overrides liquibase.database.AbstractJdbcDatabase.getQuotingStartCharacter.

Annotations
@Override
getSchemaFromJdbcInfoback to summary
public CatalogAndSchema getSchemaFromJdbcInfo(String rawCatalogName, String rawSchemaName)

Overrides liquibase.database.AbstractJdbcDatabase.getSchemaFromJdbcInfo.

Annotations
@Override
getShortNameback to summary
public String getShortName()

Implements liquibase.database.Database.getShortName.

Doc from liquibase.database.Database.getShortName.

Returns an all-lower-case short name of the product. Used for end-user selecting of database type such as the DBMS precondition.

Annotations
@Override
getTableOptionAutoIncrementStartWithClauseback to summary
public String getTableOptionAutoIncrementStartWithClause(BigInteger startWith)
isCorrectDatabaseImplementationback to summary
public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException

Implements liquibase.database.Database.isCorrectDatabaseImplementation.

Doc from liquibase.database.Database.isCorrectDatabaseImplementation.

Is this AbstractDatabase subclass the correct one to use for the given connection.

Annotations
@Override
isMinimumMySQLVersionback to summary
public boolean isMinimumMySQLVersion(String minimumVersion)

Checks whether this instance of a MySQL database is equal to or greater than the specified version.

Parameters
minimumVersion:String

the minimum version to check

Returns:boolean

true if this instance of a MySQL database is equal to or greater than the specified version, false otherwise

isReservedWordback to summary
public boolean isReservedWord(String string)

Overrides liquibase.database.AbstractJdbcDatabase.isReservedWord.

Implements liquibase.database.Database.isReservedWord.

Annotations
@Override
mustQuoteObjectNameback to summary
protected boolean mustQuoteObjectName(String objectName, Class<? extends DatabaseObject> objectType)

Overrides liquibase.database.AbstractJdbcDatabase.mustQuoteObjectName.

Annotations
@Override
supportsCatalogsback to summary
public boolean supportsCatalogs()

Overrides liquibase.database.AbstractJdbcDatabase.supportsCatalogs.

Implements liquibase.database.Database.supportsCatalogs.

Annotations
@Override
supportsCreateIfNotExistsback to summary
public boolean supportsCreateIfNotExists(Class<? extends DatabaseObject> type)

Overrides default liquibase.database.Database.supportsCreateIfNotExists.

Doc from liquibase.database.Database.supportsCreateIfNotExists.

Does the database support the "if not exits" syntax?

Parameters
type:Class<? extends DatabaseObject>

the DatabaseObject type to be checked.

Returns:boolean

true if the "if not exists" syntax is supported, false otherwise.

Annotations
@Override
supportsForeignKeyDisableback to summary
public boolean supportsForeignKeyDisable()

Overrides liquibase.database.AbstractJdbcDatabase.supportsForeignKeyDisable.

Implements liquibase.database.Database.supportsForeignKeyDisable.

Annotations
@Override
supportsInitiallyDeferrableColumnsback to summary
public boolean supportsInitiallyDeferrableColumns()

Implements liquibase.database.Database.supportsInitiallyDeferrableColumns.

Doc from liquibase.database.Database.supportsInitiallyDeferrableColumns.

Returns whether this database support initially deferrable columns.

Annotations
@Override
supportsSchemasback to summary
public boolean supportsSchemas()

Overrides liquibase.database.AbstractJdbcDatabase.supportsSchemas.

Implements liquibase.database.Database.supportsSchemas.

Annotations
@Override
supportsSequencesback to summary
public boolean supportsSequences()

Overrides liquibase.database.AbstractJdbcDatabase.supportsSequences.

Implements liquibase.database.Database.supportsSequences.

Doc from liquibase.database.AbstractJdbcDatabase.supportsSequences.

Does the database type support sequence.

Annotations
@Override
supportsTablespacesback to summary
public boolean supportsTablespaces()

Implements liquibase.database.Database.supportsTablespaces.

Annotations
@Override
warnAboutAlterColumnback to summary
public void warnAboutAlterColumn(String changeName, Warnings warnings)