暂时不兼容bpm模块的达梦

This commit is contained in:
陈博文
2025-06-11 09:23:07 +08:00
parent 6a72f08cfa
commit cd62a9315b
9 changed files with 347 additions and 3179 deletions

View File

@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.flowable.common.engine.impl; package org.flowable.common.engine.impldm;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;

View File

@@ -1,7 +1,14 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package liquibase.database.core; package liquibase.database.core;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.sql.CallableStatement;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
@@ -12,10 +19,12 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import liquibase.CatalogAndSchema; import liquibase.CatalogAndSchema;
import liquibase.GlobalConfiguration;
import liquibase.Scope; import liquibase.Scope;
import liquibase.database.AbstractJdbcDatabase; import liquibase.database.AbstractJdbcDatabase;
import liquibase.database.DatabaseConnection; import liquibase.database.DatabaseConnection;
@@ -28,571 +37,510 @@ import liquibase.executor.ExecutorService;
import liquibase.statement.DatabaseFunction; import liquibase.statement.DatabaseFunction;
import liquibase.statement.SequenceCurrentValueFunction; import liquibase.statement.SequenceCurrentValueFunction;
import liquibase.statement.SequenceNextValueFunction; import liquibase.statement.SequenceNextValueFunction;
import liquibase.statement.UniqueConstraint;
import liquibase.statement.core.RawCallStatement; import liquibase.statement.core.RawCallStatement;
import liquibase.statement.core.RawSqlStatement; import liquibase.statement.core.RawParameterizedSqlStatement;
import liquibase.structure.DatabaseObject; import liquibase.structure.DatabaseObject;
import liquibase.structure.core.Catalog; import liquibase.structure.core.Catalog;
import liquibase.structure.core.Column;
import liquibase.structure.core.Index; import liquibase.structure.core.Index;
import liquibase.structure.core.PrimaryKey; import liquibase.structure.core.PrimaryKey;
import liquibase.structure.core.Schema; import liquibase.structure.core.Schema;
import liquibase.util.JdbcUtils; import liquibase.util.JdbcUtil;
import liquibase.util.StringUtil; import liquibase.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
public class DmDatabase extends AbstractJdbcDatabase { public class DmDatabase extends AbstractJdbcDatabase {
private static final String PRODUCT_NAME = "DM DBMS"; private static final String PROXY_USER_REGEX = ".*(?:thin|oci)\\:(.+)/@.*";
public static final Pattern PROXY_USER_PATTERN = Pattern.compile(".*(?:thin|oci)\\:(.+)/@.*");
@Override private static final String VERSION_REGEX = "(\\d+)\\.(\\d+)\\..*";
protected String getDefaultDatabaseProductName() { private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\..*");
return PRODUCT_NAME; public static final String PRODUCT_NAME = "DM DBMS";
} private static final ResourceBundle coreBundle = ResourceBundle.getBundle("liquibase/i18n/liquibase-core");
/**
* Is this AbstractDatabase subclass the correct one to use for the given connection.
*
* @param conn
*/
@Override
public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {
return PRODUCT_NAME.equalsIgnoreCase(conn.getDatabaseProductName());
}
/**
* If this database understands the given url, return the default driver class name. Otherwise return null.
*
* @param url
*/
@Override
public String getDefaultDriver(String url) {
if(url.startsWith("jdbc:dm")) {
return "dm.jdbc.driver.DmDriver";
}
return null;
}
/**
* Returns an all-lower-case short name of the product. Used for end-user selecting of database type
* such as the DBMS precondition.
*/
@Override
public String getShortName() {
return "dm";
}
@Override
public Integer getDefaultPort() {
return 5236;
}
/**
* Returns whether this database support initially deferrable columns.
*/
@Override
public boolean supportsInitiallyDeferrableColumns() {
return true;
}
@Override
public boolean supportsTablespaces() {
return true;
}
@Override
public int getPriority() {
return PRIORITY_DEFAULT;
}
private static final Pattern PROXY_USER = Pattern.compile(".*(?:thin|oci)\\:(.+)/@.*");
protected final int SHORT_IDENTIFIERS_LENGTH = 30; protected final int SHORT_IDENTIFIERS_LENGTH = 30;
protected final int LONG_IDENTIFIERS_LEGNTH = 128; protected final int LONG_IDENTIFIERS_LEGNTH = 128;
public static final int ORACLE_12C_MAJOR_VERSION = 12; public static final int ORACLE_12C_MAJOR_VERSION = 12;
public static final int ORACLE_23C_MAJOR_VERSION = 23;
private Set<String> reservedWords = new HashSet<>(); private final Set<String> reservedWords = new HashSet();
private Set<String> userDefinedTypes; private Set<String> userDefinedTypes;
private Map<String, String> savedSessionNlsSettings; private Map<String, String> savedSessionNlsSettings;
private Boolean canAccessDbaRecycleBin; private Boolean canAccessDbaRecycleBin;
private Integer databaseMajorVersion; private Integer databaseMajorVersion;
private Integer databaseMinorVersion; private Integer databaseMinorVersion;
/**
* Default constructor for an object that represents the Oracle Database DBMS.
*/
public DmDatabase() { public DmDatabase() {
super.unquotedObjectsAreUppercased = true; super.unquotedObjectsAreUppercased = true;
//noinspection HardCodedStringLiteral
super.setCurrentDateTimeFunction("SYSTIMESTAMP"); super.setCurrentDateTimeFunction("SYSTIMESTAMP");
// Setting list of Oracle's native functions this.dateFunctions.add(new DatabaseFunction("SYSDATE"));
//noinspection HardCodedStringLiteral this.dateFunctions.add(new DatabaseFunction("SYSTIMESTAMP"));
dateFunctions.add(new DatabaseFunction("SYSDATE")); this.dateFunctions.add(new DatabaseFunction("CURRENT_TIMESTAMP"));
//noinspection HardCodedStringLiteral
dateFunctions.add(new DatabaseFunction("SYSTIMESTAMP"));
//noinspection HardCodedStringLiteral
dateFunctions.add(new DatabaseFunction("CURRENT_TIMESTAMP"));
//noinspection HardCodedStringLiteral
super.sequenceNextValueFunction = "%s.nextval"; super.sequenceNextValueFunction = "%s.nextval";
//noinspection HardCodedStringLiteral
super.sequenceCurrentValueFunction = "%s.currval"; super.sequenceCurrentValueFunction = "%s.currval";
} }
private void tryProxySession(final String url, final Connection con) { public int getPriority() {
Matcher m = PROXY_USER.matcher(url); return 1;
}
private void tryProxySession(String url, Connection con) {
Matcher m = PROXY_USER_PATTERN.matcher(url);
if (m.matches()) { if (m.matches()) {
Properties props = new Properties(); Properties props = new Properties();
props.put("PROXY_USER_NAME", m.group(1)); props.put("PROXY_USER_NAME", m.group(1));
try { try {
Method method = con.getClass().getMethod("openProxySession", int.class, Properties.class); Method method = con.getClass().getMethod("openProxySession", Integer.TYPE, Properties.class);
method.setAccessible(true); method.setAccessible(true);
method.invoke(con, 1, props); method.invoke(con, 1, props);
} catch (Exception e) { } catch (Exception e) {
Scope.getCurrentScope().getLog(getClass()).info("Could not open proxy session on OracleDatabase: " + e.getCause().getMessage()); Scope.getCurrentScope().getLog(this.getClass()).info("Could not open proxy session on OracleDatabase: " + e.getCause().getMessage());
return;
}
try {
Method method = con.getClass().getMethod("isProxySession");
method.setAccessible(true);
boolean b = (Boolean)method.invoke(con);
if (!b) {
Scope.getCurrentScope().getLog(this.getClass()).info("Proxy session not established on OracleDatabase: ");
}
} catch (Exception e) {
Scope.getCurrentScope().getLog(this.getClass()).info("Could not open proxy session on OracleDatabase: " + e.getCause().getMessage());
}
}
}
public void setConnection(DatabaseConnection conn) {
this.reservedWords.addAll(Arrays.asList("GROUP", "USER", "SESSION", "PASSWORD", "RESOURCE", "START", "SIZE", "UID", "DESC", "ORDER"));
Connection sqlConn = null;
if (!(conn instanceof OfflineConnection)) {
try {
if (conn instanceof JdbcConnection) {
sqlConn = ((JdbcConnection)conn).getWrappedConnection();
}
} catch (Exception e) {
throw new UnexpectedLiquibaseException(e);
}
if (sqlConn != null) {
this.tryProxySession(conn.getURL(), sqlConn);
try {
this.reservedWords.addAll(Arrays.asList(sqlConn.getMetaData().getSQLKeywords().toUpperCase().split(",\\s*")));
} catch (SQLException e) {
Scope.getCurrentScope().getLog(this.getClass()).info("Could get sql keywords on OracleDatabase: " + e.getMessage());
}
try {
Method method = sqlConn.getClass().getMethod("setRemarksReporting", Boolean.TYPE);
method.setAccessible(true);
method.invoke(sqlConn, true);
} catch (Exception e) {
Scope.getCurrentScope().getLog(this.getClass()).info("Could not set remarks reporting on OracleDatabase: " + e.getMessage());
}
CallableStatement statement = null;
try {
statement = sqlConn.prepareCall("{call DBMS_UTILITY.DB_VERSION(?,?)}");
statement.registerOutParameter(1, 12);
statement.registerOutParameter(2, 12);
statement.execute();
String compatibleVersion = statement.getString(2);
if (compatibleVersion != null) {
Matcher majorVersionMatcher = VERSION_PATTERN.matcher(compatibleVersion);
if (majorVersionMatcher.matches()) {
this.databaseMajorVersion = Integer.valueOf(majorVersionMatcher.group(1));
this.databaseMinorVersion = Integer.valueOf(majorVersionMatcher.group(2));
}
}
} catch (SQLException e) {
String message = "Cannot read from DBMS_UTILITY.DB_VERSION: " + e.getMessage();
Scope.getCurrentScope().getLog(this.getClass()).info("Could not set check compatibility mode on OracleDatabase, assuming not running in any sort of compatibility mode: " + message);
} finally {
JdbcUtil.closeStatement(statement);
}
if (GlobalConfiguration.DDL_LOCK_TIMEOUT.getCurrentValue() != null) {
int timeoutValue = (Integer)GlobalConfiguration.DDL_LOCK_TIMEOUT.getCurrentValue();
Scope.getCurrentScope().getLog(this.getClass()).fine("Setting DDL_LOCK_TIMEOUT value to " + timeoutValue);
String sql = "ALTER SESSION SET DDL_LOCK_TIMEOUT=" + timeoutValue;
PreparedStatement ddlLockTimeoutStatement = null;
try {
ddlLockTimeoutStatement = sqlConn.prepareStatement(sql);
ddlLockTimeoutStatement.execute();
} catch (SQLException sqle) {
Scope.getCurrentScope().getUI().sendErrorMessage("Unable to set the DDL_LOCK_TIMEOUT_VALUE: " + sqle.getMessage(), sqle);
Scope.getCurrentScope().getLog(this.getClass()).warning("Unable to set the DDL_LOCK_TIMEOUT_VALUE: " + sqle.getMessage(), sqle);
} finally {
JdbcUtil.closeStatement(ddlLockTimeoutStatement);
}
} }
} }
} }
@Override super.setConnection(conn);
}
public String getShortName() {
return "dm";
}
protected String getDefaultDatabaseProductName() {
return PRODUCT_NAME;
}
public int getDatabaseMajorVersion() throws DatabaseException { public int getDatabaseMajorVersion() throws DatabaseException {
if (databaseMajorVersion == null) { return this.databaseMajorVersion == null ? super.getDatabaseMajorVersion() : this.databaseMajorVersion;
return super.getDatabaseMajorVersion();
} else {
return databaseMajorVersion;
}
} }
@Override
public int getDatabaseMinorVersion() throws DatabaseException { public int getDatabaseMinorVersion() throws DatabaseException {
if (databaseMinorVersion == null) { return this.databaseMinorVersion == null ? super.getDatabaseMinorVersion() : this.databaseMinorVersion;
return super.getDatabaseMinorVersion(); }
} else {
return databaseMinorVersion; public Integer getDefaultPort() {
} return 5236;
} }
@Override
public String getJdbcCatalogName(CatalogAndSchema schema) { public String getJdbcCatalogName(CatalogAndSchema schema) {
return null; return null;
} }
@Override
public String getJdbcSchemaName(CatalogAndSchema schema) { public String getJdbcSchemaName(CatalogAndSchema schema) {
return correctObjectName((schema.getCatalogName() == null) ? schema.getSchemaName() : schema.getCatalogName(), Schema.class); return this.correctObjectName(schema.getCatalogName() == null ? schema.getSchemaName() : schema.getCatalogName(), Schema.class);
} }
@Override protected String getAutoIncrementClause(String generationType, Boolean defaultOnNull) {
protected String getAutoIncrementClause(final String generationType, final Boolean defaultOnNull) {
if (StringUtil.isEmpty(generationType)) { if (StringUtil.isEmpty(generationType)) {
return super.getAutoIncrementClause(); return super.getAutoIncrementClause();
} } else {
String autoIncrementClause = "GENERATED %s AS IDENTITY";
String autoIncrementClause = "GENERATED %s AS IDENTITY"; // %s -- [ ALWAYS | BY DEFAULT [ ON NULL ] ]
String generationStrategy = generationType; String generationStrategy = generationType;
if (Boolean.TRUE.equals(defaultOnNull) && generationType.toUpperCase().equals("BY DEFAULT")) { if (Boolean.TRUE.equals(defaultOnNull) && generationType.toUpperCase().equals("BY DEFAULT")) {
generationStrategy += " ON NULL"; generationStrategy = generationType + " ON NULL";
} }
return String.format(autoIncrementClause, generationStrategy); return String.format(autoIncrementClause, generationStrategy);
} }
}
@Override
public String generatePrimaryKeyName(String tableName) { public String generatePrimaryKeyName(String tableName) {
if (tableName.length() > 27) { return tableName.length() > 27 ? "PK_" + tableName.toUpperCase(Locale.US).substring(0, 27) : "PK_" + tableName.toUpperCase(Locale.US);
//noinspection HardCodedStringLiteral }
return "PK_" + tableName.toUpperCase(Locale.US).substring(0, 27);
} else { public boolean supportsInitiallyDeferrableColumns() {
//noinspection HardCodedStringLiteral return true;
return "PK_" + tableName.toUpperCase(Locale.US);
}
} }
@Override
public boolean isReservedWord(String objectName) { public boolean isReservedWord(String objectName) {
return reservedWords.contains(objectName.toUpperCase()); return this.reservedWords.contains(objectName.toUpperCase());
} }
@Override
public boolean supportsSequences() { public boolean supportsSequences() {
return true; return true;
} }
/** public boolean supports(Class<? extends DatabaseObject> object) {
* Oracle supports catalogs in liquibase terms return Schema.class.isAssignableFrom(object) ? false : super.supports(object);
* }
* @return false
*/
@Override
public boolean supportsSchemas() { public boolean supportsSchemas() {
return false; return false;
} }
@Override
protected String getConnectionCatalogName() throws DatabaseException { protected String getConnectionCatalogName() throws DatabaseException {
if (getConnection() instanceof OfflineConnection) { if (this.getConnection() instanceof OfflineConnection) {
return getConnection().getCatalog(); return this.getConnection().getCatalog();
} } else if (!(this.getConnection() instanceof JdbcConnection)) {
return this.defaultCatalogName;
} else {
try { try {
//noinspection HardCodedStringLiteral return (String)((ExecutorService)Scope.getCurrentScope().getSingleton(ExecutorService.class)).getExecutor("jdbc", this).queryForObject(new RawCallStatement("select sys_context( 'userenv', 'current_schema' ) from dual"), String.class);
return Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", this).queryForObject(new RawCallStatement("select sys_context( 'userenv', 'current_schema' ) from dual"), String.class);
} catch (Exception e) { } catch (Exception e) {
//noinspection HardCodedStringLiteral Scope.getCurrentScope().getLog(this.getClass()).info("Error getting default schema", e);
Scope.getCurrentScope().getLog(getClass()).info("Error getting default schema", e);
}
return null; return null;
} }
}
@Override }
public String getDefaultCatalogName() {//NOPMD
return (super.getDefaultCatalogName() == null) ? null : super.getDefaultCatalogName().toUpperCase(Locale.US); public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {
return "oracle".equalsIgnoreCase(conn.getDatabaseProductName());
}
public String getDefaultDriver(String url) {
return url.startsWith("jdbc:dm") ? "dm.jdbc.driver.DmDriver" : null;
}
public String getDefaultCatalogName() {
String defaultCatalogName = super.getDefaultCatalogName();
if (Boolean.TRUE.equals(GlobalConfiguration.PRESERVE_SCHEMA_CASE.getCurrentValue())) {
return defaultCatalogName;
} else {
return defaultCatalogName == null ? null : defaultCatalogName.toUpperCase(Locale.US);
}
} }
/**
* <p>Returns an Oracle date literal with the same value as a string formatted using ISO 8601.</p>
*
* <p>Convert an ISO8601 date string to one of the following results:
* to_date('1995-05-23', 'YYYY-MM-DD')
* to_date('1995-05-23 09:23:59', 'YYYY-MM-DD HH24:MI:SS')</p>
* <p>
* Implementation restriction:<br>
* Currently, only the following subsets of ISO8601 are supported:<br>
* <ul>
* <li>YYYY-MM-DD</li>
* <li>YYYY-MM-DDThh:mm:ss</li>
* </ul>
*/
@Override
public String getDateLiteral(String isoDate) { public String getDateLiteral(String isoDate) {
String normalLiteral = super.getDateLiteral(isoDate); String normalLiteral = super.getDateLiteral(isoDate);
if (this.isDateOnly(isoDate)) {
if (isDateOnly(isoDate)) {
return "TO_DATE(" + normalLiteral + ", 'YYYY-MM-DD')"; return "TO_DATE(" + normalLiteral + ", 'YYYY-MM-DD')";
} else if (isTimeOnly(isoDate)) { } else if (this.isTimeOnly(isoDate)) {
return "TO_DATE(" + normalLiteral + ", 'HH24:MI:SS')"; return "TO_DATE(" + normalLiteral + ", 'HH24:MI:SS')";
} else if (isTimestamp(isoDate)) { } else if (this.isTimestamp(isoDate)) {
return "TO_TIMESTAMP(" + normalLiteral + ", 'YYYY-MM-DD HH24:MI:SS.FF')"; return "TO_TIMESTAMP(" + normalLiteral + ", 'YYYY-MM-DD HH24:MI:SS.FF')";
} else if (isDateTime(isoDate)) { } else if (this.isDateTime(isoDate)) {
int seppos = normalLiteral.lastIndexOf('.'); int seppos = normalLiteral.lastIndexOf(46);
if (seppos != -1) { if (seppos != -1) {
normalLiteral = normalLiteral.substring(0, seppos) + "'"; normalLiteral = normalLiteral.substring(0, seppos) + "'";
} }
return "TO_DATE(" + normalLiteral + ", 'YYYY-MM-DD HH24:MI:SS')"; return "TO_DATE(" + normalLiteral + ", 'YYYY-MM-DD HH24:MI:SS')";
} } else {
return "UNSUPPORTED:" + isoDate; return "UNSUPPORTED:" + isoDate;
} }
}
@Override
public boolean isSystemObject(DatabaseObject example) { public boolean isSystemObject(DatabaseObject example) {
if (example == null) { if (example == null) {
return false; return false;
} } else if (this.isLiquibaseObject(example)) {
if (this.isLiquibaseObject(example)) {
return false; return false;
} } else {
if (example instanceof Schema) { if (example instanceof Schema) {
//noinspection HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral
if ("SYSTEM".equals(example.getName()) || "SYS".equals(example.getName()) || "CTXSYS".equals(example.getName()) || "XDB".equals(example.getName())) { if ("SYSTEM".equals(example.getName()) || "SYS".equals(example.getName()) || "CTXSYS".equals(example.getName()) || "XDB".equals(example.getName())) {
return true; return true;
} }
//noinspection HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral
if ("SYSTEM".equals(example.getSchema().getCatalogName()) || "SYS".equals(example.getSchema().getCatalogName()) || "CTXSYS".equals(example.getSchema().getCatalogName()) || "XDB".equals(example.getSchema().getCatalogName())) { if ("SYSTEM".equals(example.getSchema().getCatalogName()) || "SYS".equals(example.getSchema().getCatalogName()) || "CTXSYS".equals(example.getSchema().getCatalogName()) || "XDB".equals(example.getSchema().getCatalogName())) {
return true; return true;
} }
} else if (isSystemObject(example.getSchema())) { } else if (this.isSystemObject(example.getSchema())) {
return true; return true;
} }
if (example instanceof Catalog) { if (example instanceof Catalog) {
//noinspection HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral if ("SYSTEM".equals(example.getName()) || "SYS".equals(example.getName()) || "CTXSYS".equals(example.getName()) || "XDB".equals(example.getName())) {
if (("SYSTEM".equals(example.getName()) || "SYS".equals(example.getName()) || "CTXSYS".equals(example.getName()) || "XDB".equals(example.getName()))) {
return true; return true;
} }
} else if (example.getName() != null) { } else if (example.getName() != null) {
//noinspection HardCodedStringLiteral if (example.getName().startsWith("BIN$")) {
if (example.getName().startsWith("BIN$")) { //oracle deleted table
boolean filteredInOriginalQuery = this.canAccessDbaRecycleBin(); boolean filteredInOriginalQuery = this.canAccessDbaRecycleBin();
if (!filteredInOriginalQuery) { if (!filteredInOriginalQuery) {
filteredInOriginalQuery = StringUtil.trimToEmpty(example.getSchema().getName()).equalsIgnoreCase(this.getConnection().getConnectionUserName()); filteredInOriginalQuery = StringUtil.trimToEmpty(example.getSchema().getName()).equalsIgnoreCase(this.getConnection().getConnectionUserName());
} }
if (filteredInOriginalQuery) { if (!filteredInOriginalQuery) {
return !((example instanceof PrimaryKey) || (example instanceof Index) || (example instanceof
liquibase.statement.UniqueConstraint));
} else {
return true; return true;
} }
} else //noinspection HardCodedStringLiteral
if (example.getName().startsWith("AQ$")) { //oracle AQ tables return !(example instanceof PrimaryKey) && !(example instanceof Index) && !(example instanceof UniqueConstraint);
}
if (example.getName().startsWith("AQ$")) {
return true; return true;
} else //noinspection HardCodedStringLiteral }
if (example.getName().startsWith("DR$")) { //oracle index tables
if (example.getName().startsWith("DR$")) {
return true; return true;
} else //noinspection HardCodedStringLiteral }
if (example.getName().startsWith("SYS_IOT_OVER")) { //oracle system table
if (example.getName().startsWith("SYS_IOT_OVER")) {
return true; return true;
} else //noinspection HardCodedStringLiteral,HardCodedStringLiteral }
if ((example.getName().startsWith("MDRT_") || example.getName().startsWith("MDRS_")) && example.getName().endsWith("$")) { if ((example.getName().startsWith("MDRT_") || example.getName().startsWith("MDRS_")) && example.getName().endsWith("$")) {
// CORE-1768 - Oracle creates these for spatial indices and will remove them when the index is removed.
return true; return true;
} else //noinspection HardCodedStringLiteral }
if (example.getName().startsWith("MLOG$_")) { //Created by materliaized view logs for every table that is part of a materialized view. Not available for DDL operations.
if (example.getName().startsWith("MLOG$_")) {
return true; return true;
} else //noinspection HardCodedStringLiteral }
if (example.getName().startsWith("RUPD$_")) { //Created by materialized view log tables using primary keys. Not available for DDL operations.
if (example.getName().startsWith("RUPD$_")) {
return true; return true;
} else //noinspection HardCodedStringLiteral }
if (example.getName().startsWith("WM$_")) { //Workspace Manager backup tables.
if (example.getName().startsWith("WM$_")) {
return true; return true;
} else //noinspection HardCodedStringLiteral }
if ("CREATE$JAVA$LOB$TABLE".equals(example.getName())) { //This table contains the name of the Java object, the date it was loaded, and has a BLOB column to store the Java object.
if ("CREATE$JAVA$LOB$TABLE".equals(example.getName())) {
return true; return true;
} else //noinspection HardCodedStringLiteral }
if ("JAVA$CLASS$MD5$TABLE".equals(example.getName())) { //This is a hash table that tracks the loading of Java objects into a schema.
if ("JAVA$CLASS$MD5$TABLE".equals(example.getName())) {
return true; return true;
} else //noinspection HardCodedStringLiteral }
if (example.getName().startsWith("ISEQ$$_")) { //System-generated sequence
if (example.getName().startsWith("ISEQ$$_")) {
return true; return true;
} else //noinspection HardCodedStringLiteral }
if (example.getName().startsWith("USLOG$")) { //for update materialized view
if (example.getName().startsWith("USLOG$")) {
return true; return true;
} else if (example.getName().startsWith("SYS_FBA")) { //for Flashback tables }
if (example.getName().startsWith("SYS_FBA")) {
return true; return true;
} }
} }
return super.isSystemObject(example); return super.isSystemObject(example);
} }
}
public boolean supportsTablespaces() {
return true;
}
@Override
public boolean supportsAutoIncrement() { public boolean supportsAutoIncrement() {
// Oracle supports Identity beginning with version 12c
boolean isAutoIncrementSupported = false; boolean isAutoIncrementSupported = false;
try { try {
if (getDatabaseMajorVersion() >= 12) { if (this.getDatabaseMajorVersion() >= 12) {
isAutoIncrementSupported = true; isAutoIncrementSupported = true;
} }
} catch (DatabaseException var3) {
// Returning true will generate create table command with 'IDENTITY' clause, example:
// CREATE TABLE AutoIncTest (IDPrimaryKey NUMBER(19) GENERATED BY DEFAULT AS IDENTITY NOT NULL, TypeID NUMBER(3) NOT NULL, Description NVARCHAR2(50), CONSTRAINT PK_AutoIncTest PRIMARY KEY (IDPrimaryKey));
// While returning false will continue to generate create table command without 'IDENTITY' clause, example:
// CREATE TABLE AutoIncTest (IDPrimaryKey NUMBER(19) NOT NULL, TypeID NUMBER(3) NOT NULL, Description NVARCHAR2(50), CONSTRAINT PK_AutoIncTest PRIMARY KEY (IDPrimaryKey));
} catch (DatabaseException ex) {
isAutoIncrementSupported = false; isAutoIncrementSupported = false;
} }
return isAutoIncrementSupported; return isAutoIncrementSupported;
} }
// public Set<UniqueConstraint> findUniqueConstraints(String schema) throws DatabaseException {
// Set<UniqueConstraint> returnSet = new HashSet<UniqueConstraint>();
//
// List<Map> maps = new Executor(this).queryForList(new RawSqlStatement("SELECT UC.CONSTRAINT_NAME, UCC.TABLE_NAME, UCC.COLUMN_NAME FROM USER_CONSTRAINTS UC, USER_CONS_COLUMNS UCC WHERE UC.CONSTRAINT_NAME=UCC.CONSTRAINT_NAME AND CONSTRAINT_TYPE='U' ORDER BY UC.CONSTRAINT_NAME"));
//
// UniqueConstraint constraint = null;
// for (Map map : maps) {
// if (constraint == null || !constraint.getName().equals(constraint.getName())) {
// returnSet.add(constraint);
// Table table = new Table((String) map.get("TABLE_NAME"));
// constraint = new UniqueConstraint(map.get("CONSTRAINT_NAME").toString(), table);
// }
// }
// if (constraint != null) {
// returnSet.add(constraint);
// }
//
// return returnSet;
// }
@Override
public boolean supportsRestrictForeignKeys() { public boolean supportsRestrictForeignKeys() {
return false; return false;
} }
@Override
public int getDataTypeMaxParameters(String dataTypeName) { public int getDataTypeMaxParameters(String dataTypeName) {
//noinspection HardCodedStringLiteral
if ("BINARY_FLOAT".equals(dataTypeName.toUpperCase())) { if ("BINARY_FLOAT".equals(dataTypeName.toUpperCase())) {
return 0; return 0;
} else {
return "BINARY_DOUBLE".equals(dataTypeName.toUpperCase()) ? 0 : super.getDataTypeMaxParameters(dataTypeName);
} }
//noinspection HardCodedStringLiteral
if ("BINARY_DOUBLE".equals(dataTypeName.toUpperCase())) {
return 0;
}
return super.getDataTypeMaxParameters(dataTypeName);
} }
public String getSystemTableWhereClause(String tableNameColumn) { public String getSystemTableWhereClause(String tableNameColumn) {
List<String> clauses = new ArrayList<String>(Arrays.asList("BIN$", List<String> clauses = new ArrayList(Arrays.asList("BIN$", "AQ$", "DR$", "SYS_IOT_OVER", "MLOG$_", "RUPD$_", "WM$_", "ISEQ$$_", "USLOG$", "SYS_FBA"));
"AQ$", clauses.replaceAll((s) -> tableNameColumn + " NOT LIKE '" + s + "%'");
"DR$",
"SYS_IOT_OVER",
"MLOG$_",
"RUPD$_",
"WM$_",
"ISEQ$$_",
"USLOG$",
"SYS_FBA"));
for (int i = 0;i<clauses.size(); i++) {
clauses.set(i, tableNameColumn+" NOT LIKE '"+clauses.get(i)+"%'");
}
return "(" + StringUtil.join(clauses, " AND ") + ")"; return "(" + StringUtil.join(clauses, " AND ") + ")";
} }
@Override
public boolean jdbcCallsCatalogsSchemas() { public boolean jdbcCallsCatalogsSchemas() {
return true; return true;
} }
public Set<String> getUserDefinedTypes() { public Set<String> getUserDefinedTypes() {
if (userDefinedTypes == null) { if (this.userDefinedTypes == null) {
userDefinedTypes = new HashSet<>(); this.userDefinedTypes = new HashSet();
if ((getConnection() != null) && !(getConnection() instanceof OfflineConnection)) { if (this.getConnection() != null && !(this.getConnection() instanceof OfflineConnection)) {
try { try {
try { try {
//noinspection HardCodedStringLiteral this.userDefinedTypes.addAll(((ExecutorService)Scope.getCurrentScope().getSingleton(ExecutorService.class)).getExecutor("jdbc", this).queryForList(new RawParameterizedSqlStatement("SELECT DISTINCT TYPE_NAME FROM ALL_TYPES"), String.class));
userDefinedTypes.addAll(Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", this).queryForList(new RawSqlStatement("SELECT DISTINCT TYPE_NAME FROM ALL_TYPES"), String.class)); } catch (DatabaseException var2) {
} catch (DatabaseException e) { //fall back to USER_TYPES if the user cannot see ALL_TYPES this.userDefinedTypes.addAll(((ExecutorService)Scope.getCurrentScope().getSingleton(ExecutorService.class)).getExecutor("jdbc", this).queryForList(new RawParameterizedSqlStatement("SELECT TYPE_NAME FROM USER_TYPES"), String.class));
//noinspection HardCodedStringLiteral
userDefinedTypes.addAll(Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", this).queryForList(new RawSqlStatement("SELECT TYPE_NAME FROM USER_TYPES"), String.class));
} }
} catch (DatabaseException e) { } catch (DatabaseException var3) {
//ignore error
} }
} }
} }
return userDefinedTypes; return this.userDefinedTypes;
} }
@Override
public String generateDatabaseFunctionValue(DatabaseFunction databaseFunction) { public String generateDatabaseFunctionValue(DatabaseFunction databaseFunction) {
//noinspection HardCodedStringLiteral if (databaseFunction != null && "current_timestamp".equalsIgnoreCase(databaseFunction.toString())) {
if ((databaseFunction != null) && "current_timestamp".equalsIgnoreCase(databaseFunction.toString())) {
return databaseFunction.toString(); return databaseFunction.toString();
} } else if (!(databaseFunction instanceof SequenceNextValueFunction) && !(databaseFunction instanceof SequenceCurrentValueFunction)) {
if ((databaseFunction instanceof SequenceNextValueFunction) || (databaseFunction instanceof
SequenceCurrentValueFunction)) {
String quotedSeq = super.generateDatabaseFunctionValue(databaseFunction);
// replace "myschema.my_seq".nextval with "myschema"."my_seq".nextval
return quotedSeq.replaceFirst("\"([^\\.\"]+)\\.([^\\.\"]+)\"", "\"$1\".\"$2\"");
}
return super.generateDatabaseFunctionValue(databaseFunction); return super.generateDatabaseFunctionValue(databaseFunction);
} else {
String quotedSeq = super.generateDatabaseFunctionValue(databaseFunction);
return quotedSeq.replaceFirst("\"([^.\"]+)\\.([^.\"]+)\"", "\"$1\".\"$2\"");
}
} }
@Override
public ValidationErrors validate() { public ValidationErrors validate() {
ValidationErrors errors = super.validate(); ValidationErrors errors = super.validate();
DatabaseConnection connection = getConnection(); DatabaseConnection connection = this.getConnection();
if ((connection == null) || (connection instanceof OfflineConnection)) { if (connection != null && !(connection instanceof OfflineConnection)) {
//noinspection HardCodedStringLiteral if (!this.canAccessDbaRecycleBin()) {
Scope.getCurrentScope().getLog(getClass()).info("Cannot validate offline database"); errors.addWarning(this.getDbaRecycleBinWarning());
return errors;
}
if (!canAccessDbaRecycleBin()) {
errors.addWarning(getDbaRecycleBinWarning());
} }
return errors; return errors;
} else {
Scope.getCurrentScope().getLog(this.getClass()).info("Cannot validate offline database");
return errors;
}
} }
public String getDbaRecycleBinWarning() { public String getDbaRecycleBinWarning() {
//noinspection HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral, return "Liquibase needs to access the DBA_RECYCLEBIN table so we can automatically handle the case where constraints are deleted and restored. Since Oracle doesn't properly restore the original table names referenced in the constraint, we use the information from the DBA_RECYCLEBIN to automatically correct this issue.\n\nThe user you used to connect to the database (" + this.getConnection().getConnectionUserName() + ") needs to have \"SELECT ON SYS.DBA_RECYCLEBIN\" permissions set before we can perform this operation. Please run the following SQL to set the appropriate permissions, and try running the command again.\n\n GRANT SELECT ON SYS.DBA_RECYCLEBIN TO " + this.getConnection().getConnectionUserName() + ";";
// HardCodedStringLiteral
//noinspection HardCodedStringLiteral,HardCodedStringLiteral,HardCodedStringLiteral
return "Liquibase needs to access the DBA_RECYCLEBIN table so we can automatically handle the case where " +
"constraints are deleted and restored. Since Oracle doesn't properly restore the original table names " +
"referenced in the constraint, we use the information from the DBA_RECYCLEBIN to automatically correct this" +
" issue.\n" +
"\n" +
"The user you used to connect to the database (" + getConnection().getConnectionUserName() +
") needs to have \"SELECT ON SYS.DBA_RECYCLEBIN\" permissions set before we can perform this operation. " +
"Please run the following SQL to set the appropriate permissions, and try running the command again.\n" +
"\n" +
" GRANT SELECT ON SYS.DBA_RECYCLEBIN TO " + getConnection().getConnectionUserName() + ";";
} }
public boolean canAccessDbaRecycleBin() { public boolean canAccessDbaRecycleBin() {
if (canAccessDbaRecycleBin == null) { if (this.canAccessDbaRecycleBin == null) {
DatabaseConnection connection = getConnection(); DatabaseConnection connection = this.getConnection();
if ((connection == null) || (connection instanceof OfflineConnection)) { if (connection == null || connection instanceof OfflineConnection) {
return false; return false;
} }
Statement statement = null; Statement statement = null;
try { try {
statement = ((JdbcConnection)connection).createStatement(); statement = ((JdbcConnection)connection).createStatement();
@SuppressWarnings("HardCodedStringLiteral") ResultSet resultSet = statement.executeQuery("select 1 from dba_recyclebin where 0=1"); ResultSet resultSet = statement.executeQuery("select 1 from dba_recyclebin where 0=1");
resultSet.close(); //don't need to do anything with the result set, just make sure statement ran. resultSet.close();
this.canAccessDbaRecycleBin = true; this.canAccessDbaRecycleBin = true;
} catch (Exception e) { } catch (Exception var7) {
//noinspection HardCodedStringLiteral if (var7 instanceof SQLException && var7.getMessage().startsWith("ORA-00942")) {
if ((e instanceof SQLException) && e.getMessage().startsWith("ORA-00942")) { //ORA-00942: table or view does not exist
this.canAccessDbaRecycleBin = false; this.canAccessDbaRecycleBin = false;
} else { } else {
//noinspection HardCodedStringLiteral Scope.getCurrentScope().getLog(this.getClass()).warning("Cannot check dba_recyclebin access", var7);
Scope.getCurrentScope().getLog(getClass()).warning("Cannot check dba_recyclebin access", e);
this.canAccessDbaRecycleBin = false; this.canAccessDbaRecycleBin = false;
} }
} finally { } finally {
JdbcUtils.close(null, statement); JdbcUtil.close((ResultSet)null, statement);
} }
} }
return canAccessDbaRecycleBin; return this.canAccessDbaRecycleBin;
} }
@Override
public boolean supportsNotNullConstraintNames() { public boolean supportsNotNullConstraintNames() {
return true; return true;
} }
/**
* Tests if the given String would be a valid identifier in Oracle DBMS. In Oracle, a valid identifier has
* the following form (case-insensitive comparison):
* 1st character: A-Z
* 2..n characters: A-Z0-9$_#
* The maximum length of an identifier differs by Oracle version and object type.
*/
public boolean isValidOracleIdentifier(String identifier, Class<? extends DatabaseObject> type) { public boolean isValidOracleIdentifier(String identifier, Class<? extends DatabaseObject> type) {
if ((identifier == null) || (identifier.length() < 1)) if (identifier != null && identifier.length() >= 1) {
if (!identifier.matches("^(i?)[A-Z][A-Z0-9\\$\\_\\#]*$")) {
return false; return false;
} else {
if (!identifier.matches("^(i?)[A-Z][A-Z0-9\\$\\_\\#]*$")) return identifier.length() <= 128;
}
} else {
return false; return false;
}
/*
* @todo It seems we currently do not have a class for tablespace identifiers, and all other classes
* we do know seem to be supported as 12cR2 long identifiers, so:
*/
return (identifier.length() <= LONG_IDENTIFIERS_LEGNTH);
} }
/**
* Returns the maximum number of bytes (NOT: characters) for an identifier. For Oracle <=12c Release 20, this
* is 30 bytes, and starting from 12cR2, up to 128 (except for tablespaces, PDB names and some other rather rare
* object types).
*
* @return the maximum length of an object identifier, in bytes
*/
public int getIdentifierMaximumLength() { public int getIdentifierMaximumLength() {
try { try {
if (getDatabaseMajorVersion() < ORACLE_12C_MAJOR_VERSION) { if (this.getDatabaseMajorVersion() < 12) {
return SHORT_IDENTIFIERS_LENGTH; return 30;
} else if ((getDatabaseMajorVersion() == ORACLE_12C_MAJOR_VERSION) && (getDatabaseMinorVersion() <= 1)) {
return SHORT_IDENTIFIERS_LENGTH;
} else { } else {
return LONG_IDENTIFIERS_LEGNTH; return this.getDatabaseMajorVersion() == 12 && this.getDatabaseMinorVersion() <= 1 ? 30 : 128;
} }
} catch (DatabaseException ex) { } catch (DatabaseException ex) {
throw new UnexpectedLiquibaseException("Cannot determine the Oracle database version number", ex); throw new UnexpectedLiquibaseException("Cannot determine the Oracle database version number", ex);
} }
}
public boolean supportsDatabaseChangeLogHistory() {
return true;
}
public String correctObjectName(String objectName, Class<? extends DatabaseObject> objectType) {
return objectType.equals(Column.class) && StringUtils.startsWithIgnoreCase(objectName, "int") ? "NUMBER(*, 0)" : super.correctObjectName(objectName, objectType);
} }
} }

View File

@@ -9,9 +9,9 @@ import liquibase.datatype.LiquibaseDataType;
import liquibase.exception.UnexpectedLiquibaseException; import liquibase.exception.UnexpectedLiquibaseException;
import liquibase.statement.DatabaseFunction; import liquibase.statement.DatabaseFunction;
import liquibase.util.StringUtil; import liquibase.util.StringUtil;
import liquibase.database.core.DmDatabase;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Pattern;
@DataTypeInfo(name = "boolean", aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"}, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DEFAULT) @DataTypeInfo(name = "boolean", aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"}, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DEFAULT)
public class BooleanType extends LiquibaseDataType { public class BooleanType extends LiquibaseDataType {
@@ -19,11 +19,11 @@ public class BooleanType extends LiquibaseDataType {
@Override @Override
public DatabaseDataType toDatabaseDataType(Database database) { public DatabaseDataType toDatabaseDataType(Database database) {
String originalDefinition = StringUtil.trimToEmpty(getRawDefinition()); String originalDefinition = StringUtil.trimToEmpty(getRawDefinition());
if ((database instanceof Firebird3Database)) { // if ((database instanceof Firebird3Database)) {
return new DatabaseDataType("BOOLEAN"); // return new DatabaseDataType("BOOLEAN");
} // }
if ((database instanceof Db2zDatabase) || (database instanceof FirebirdDatabase)) { if ((database instanceof AbstractDb2Database) || (database instanceof FirebirdDatabase)) {
return new DatabaseDataType("SMALLINT"); return new DatabaseDataType("SMALLINT");
} else if (database instanceof MSSQLDatabase) { } else if (database instanceof MSSQLDatabase) {
return new DatabaseDataType(database.escapeDataTypeName("bit")); return new DatabaseDataType(database.escapeDataTypeName("bit"));
@@ -42,7 +42,7 @@ public class BooleanType extends LiquibaseDataType {
} else { } else {
return new DatabaseDataType("SMALLINT"); return new DatabaseDataType("SMALLINT");
} }
} else if (database instanceof DB2Database) { } else if (database.getClass().isAssignableFrom(DB2Database.class)) {
if (((DB2Database) database).supportsBooleanDataType()) if (((DB2Database) database).supportsBooleanDataType())
return new DatabaseDataType("BOOLEAN"); return new DatabaseDataType("BOOLEAN");
else else
@@ -53,7 +53,7 @@ public class BooleanType extends LiquibaseDataType {
if (originalDefinition.toLowerCase(Locale.US).startsWith("bit")) { if (originalDefinition.toLowerCase(Locale.US).startsWith("bit")) {
return new DatabaseDataType("BIT", getParameters()); return new DatabaseDataType("BIT", getParameters());
} }
} else if (database instanceof DmDatabase) { // dhb52: DM Support } else if(database instanceof DmDatabase) {
return new DatabaseDataType("bit"); return new DatabaseDataType("bit");
} }
@@ -74,13 +74,6 @@ public class BooleanType extends LiquibaseDataType {
} else if ("false".equals(((String) value).toLowerCase(Locale.US)) || "0".equals(value) || "b'0'".equals( } else if ("false".equals(((String) value).toLowerCase(Locale.US)) || "0".equals(value) || "b'0'".equals(
((String) value).toLowerCase(Locale.US)) || "f".equals(((String) value).toLowerCase(Locale.US)) || ((String) value).toLowerCase(Locale.US).equals(this.getFalseBooleanValue(database).toLowerCase(Locale.US))) { ((String) value).toLowerCase(Locale.US)) || "f".equals(((String) value).toLowerCase(Locale.US)) || ((String) value).toLowerCase(Locale.US).equals(this.getFalseBooleanValue(database).toLowerCase(Locale.US))) {
returnValue = this.getFalseBooleanValue(database); returnValue = this.getFalseBooleanValue(database);
} else if (database instanceof PostgresDatabase && Pattern.matches("b?([01])\\1*(::bit|::\"bit\")?", (String) value)) {
returnValue = "b'"
+ value.toString()
.replace("b", "")
.replace("\"", "")
.replace("::it", "")
+ "'::\"bit\"";
} else { } else {
throw new UnexpectedLiquibaseException("Unknown boolean value: " + value); throw new UnexpectedLiquibaseException("Unknown boolean value: " + value);
} }
@@ -112,23 +105,15 @@ public class BooleanType extends LiquibaseDataType {
} }
protected boolean isNumericBoolean(Database database) { protected boolean isNumericBoolean(Database database) {
if (database instanceof Firebird3Database) {
return false;
}
if (database instanceof DerbyDatabase) { if (database instanceof DerbyDatabase) {
return !((DerbyDatabase) database).supportsBooleanDataType(); return !((DerbyDatabase) database).supportsBooleanDataType();
} else if (database instanceof DB2Database) { } else if (database.getClass().isAssignableFrom(DB2Database.class)) {
return !((DB2Database) database).supportsBooleanDataType(); return !((DB2Database) database).supportsBooleanDataType();
} }
return (database instanceof Db2zDatabase) return (database instanceof Db2zDatabase) || (database instanceof DB2Database) || (database instanceof FirebirdDatabase) || (database instanceof
|| (database instanceof FirebirdDatabase) MSSQLDatabase) || (database instanceof MySQLDatabase) || (database instanceof OracleDatabase) ||
|| (database instanceof MSSQLDatabase) (database instanceof SQLiteDatabase) || (database instanceof SybaseASADatabase) || (database instanceof
|| (database instanceof MySQLDatabase) SybaseDatabase) || (database instanceof DmDatabase);
|| (database instanceof OracleDatabase)
|| (database instanceof SQLiteDatabase)
|| (database instanceof SybaseASADatabase)
|| (database instanceof SybaseDatabase)
|| (database instanceof DmDatabase); // dhb52: DM Support
} }
/** /**
@@ -161,5 +146,4 @@ public class BooleanType extends LiquibaseDataType {
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
return LoadDataChange.LOAD_DATA_TYPE.BOOLEAN; return LoadDataChange.LOAD_DATA_TYPE.BOOLEAN;
} }
} }

View File

@@ -1,546 +0,0 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package liquibase.database.core;
import java.lang.reflect.Method;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import liquibase.CatalogAndSchema;
import liquibase.GlobalConfiguration;
import liquibase.Scope;
import liquibase.database.AbstractJdbcDatabase;
import liquibase.database.DatabaseConnection;
import liquibase.database.OfflineConnection;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.DatabaseException;
import liquibase.exception.UnexpectedLiquibaseException;
import liquibase.exception.ValidationErrors;
import liquibase.executor.ExecutorService;
import liquibase.statement.DatabaseFunction;
import liquibase.statement.SequenceCurrentValueFunction;
import liquibase.statement.SequenceNextValueFunction;
import liquibase.statement.UniqueConstraint;
import liquibase.statement.core.RawCallStatement;
import liquibase.statement.core.RawParameterizedSqlStatement;
import liquibase.structure.DatabaseObject;
import liquibase.structure.core.Catalog;
import liquibase.structure.core.Column;
import liquibase.structure.core.Index;
import liquibase.structure.core.PrimaryKey;
import liquibase.structure.core.Schema;
import liquibase.util.JdbcUtil;
import liquibase.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
public class DmDatabase extends AbstractJdbcDatabase {
private static final String PROXY_USER_REGEX = ".*(?:thin|oci)\\:(.+)/@.*";
public static final Pattern PROXY_USER_PATTERN = Pattern.compile(".*(?:thin|oci)\\:(.+)/@.*");
private static final String VERSION_REGEX = "(\\d+)\\.(\\d+)\\..*";
private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\..*");
public static final String PRODUCT_NAME = "DM DBMS";
private static final ResourceBundle coreBundle = ResourceBundle.getBundle("liquibase/i18n/liquibase-core");
protected final int SHORT_IDENTIFIERS_LENGTH = 30;
protected final int LONG_IDENTIFIERS_LEGNTH = 128;
public static final int ORACLE_12C_MAJOR_VERSION = 12;
public static final int ORACLE_23C_MAJOR_VERSION = 23;
private final Set<String> reservedWords = new HashSet();
private Set<String> userDefinedTypes;
private Map<String, String> savedSessionNlsSettings;
private Boolean canAccessDbaRecycleBin;
private Integer databaseMajorVersion;
private Integer databaseMinorVersion;
public DmDatabase() {
super.unquotedObjectsAreUppercased = true;
super.setCurrentDateTimeFunction("SYSTIMESTAMP");
this.dateFunctions.add(new DatabaseFunction("SYSDATE"));
this.dateFunctions.add(new DatabaseFunction("SYSTIMESTAMP"));
this.dateFunctions.add(new DatabaseFunction("CURRENT_TIMESTAMP"));
super.sequenceNextValueFunction = "%s.nextval";
super.sequenceCurrentValueFunction = "%s.currval";
}
public int getPriority() {
return 1;
}
private void tryProxySession(String url, Connection con) {
Matcher m = PROXY_USER_PATTERN.matcher(url);
if (m.matches()) {
Properties props = new Properties();
props.put("PROXY_USER_NAME", m.group(1));
try {
Method method = con.getClass().getMethod("openProxySession", Integer.TYPE, Properties.class);
method.setAccessible(true);
method.invoke(con, 1, props);
} catch (Exception e) {
Scope.getCurrentScope().getLog(this.getClass()).info("Could not open proxy session on OracleDatabase: " + e.getCause().getMessage());
return;
}
try {
Method method = con.getClass().getMethod("isProxySession");
method.setAccessible(true);
boolean b = (Boolean)method.invoke(con);
if (!b) {
Scope.getCurrentScope().getLog(this.getClass()).info("Proxy session not established on OracleDatabase: ");
}
} catch (Exception e) {
Scope.getCurrentScope().getLog(this.getClass()).info("Could not open proxy session on OracleDatabase: " + e.getCause().getMessage());
}
}
}
public void setConnection(DatabaseConnection conn) {
this.reservedWords.addAll(Arrays.asList("GROUP", "USER", "SESSION", "PASSWORD", "RESOURCE", "START", "SIZE", "UID", "DESC", "ORDER"));
Connection sqlConn = null;
if (!(conn instanceof OfflineConnection)) {
try {
if (conn instanceof JdbcConnection) {
sqlConn = ((JdbcConnection)conn).getWrappedConnection();
}
} catch (Exception e) {
throw new UnexpectedLiquibaseException(e);
}
if (sqlConn != null) {
this.tryProxySession(conn.getURL(), sqlConn);
try {
this.reservedWords.addAll(Arrays.asList(sqlConn.getMetaData().getSQLKeywords().toUpperCase().split(",\\s*")));
} catch (SQLException e) {
Scope.getCurrentScope().getLog(this.getClass()).info("Could get sql keywords on OracleDatabase: " + e.getMessage());
}
try {
Method method = sqlConn.getClass().getMethod("setRemarksReporting", Boolean.TYPE);
method.setAccessible(true);
method.invoke(sqlConn, true);
} catch (Exception e) {
Scope.getCurrentScope().getLog(this.getClass()).info("Could not set remarks reporting on OracleDatabase: " + e.getMessage());
}
CallableStatement statement = null;
try {
statement = sqlConn.prepareCall("{call DBMS_UTILITY.DB_VERSION(?,?)}");
statement.registerOutParameter(1, 12);
statement.registerOutParameter(2, 12);
statement.execute();
String compatibleVersion = statement.getString(2);
if (compatibleVersion != null) {
Matcher majorVersionMatcher = VERSION_PATTERN.matcher(compatibleVersion);
if (majorVersionMatcher.matches()) {
this.databaseMajorVersion = Integer.valueOf(majorVersionMatcher.group(1));
this.databaseMinorVersion = Integer.valueOf(majorVersionMatcher.group(2));
}
}
} catch (SQLException e) {
String message = "Cannot read from DBMS_UTILITY.DB_VERSION: " + e.getMessage();
Scope.getCurrentScope().getLog(this.getClass()).info("Could not set check compatibility mode on OracleDatabase, assuming not running in any sort of compatibility mode: " + message);
} finally {
JdbcUtil.closeStatement(statement);
}
if (GlobalConfiguration.DDL_LOCK_TIMEOUT.getCurrentValue() != null) {
int timeoutValue = (Integer)GlobalConfiguration.DDL_LOCK_TIMEOUT.getCurrentValue();
Scope.getCurrentScope().getLog(this.getClass()).fine("Setting DDL_LOCK_TIMEOUT value to " + timeoutValue);
String sql = "ALTER SESSION SET DDL_LOCK_TIMEOUT=" + timeoutValue;
PreparedStatement ddlLockTimeoutStatement = null;
try {
ddlLockTimeoutStatement = sqlConn.prepareStatement(sql);
ddlLockTimeoutStatement.execute();
} catch (SQLException sqle) {
Scope.getCurrentScope().getUI().sendErrorMessage("Unable to set the DDL_LOCK_TIMEOUT_VALUE: " + sqle.getMessage(), sqle);
Scope.getCurrentScope().getLog(this.getClass()).warning("Unable to set the DDL_LOCK_TIMEOUT_VALUE: " + sqle.getMessage(), sqle);
} finally {
JdbcUtil.closeStatement(ddlLockTimeoutStatement);
}
}
}
}
super.setConnection(conn);
}
public String getShortName() {
return "dm";
}
protected String getDefaultDatabaseProductName() {
return PRODUCT_NAME;
}
public int getDatabaseMajorVersion() throws DatabaseException {
return this.databaseMajorVersion == null ? super.getDatabaseMajorVersion() : this.databaseMajorVersion;
}
public int getDatabaseMinorVersion() throws DatabaseException {
return this.databaseMinorVersion == null ? super.getDatabaseMinorVersion() : this.databaseMinorVersion;
}
public Integer getDefaultPort() {
return 5236;
}
public String getJdbcCatalogName(CatalogAndSchema schema) {
return null;
}
public String getJdbcSchemaName(CatalogAndSchema schema) {
return this.correctObjectName(schema.getCatalogName() == null ? schema.getSchemaName() : schema.getCatalogName(), Schema.class);
}
protected String getAutoIncrementClause(String generationType, Boolean defaultOnNull) {
if (StringUtil.isEmpty(generationType)) {
return super.getAutoIncrementClause();
} else {
String autoIncrementClause = "GENERATED %s AS IDENTITY";
String generationStrategy = generationType;
if (Boolean.TRUE.equals(defaultOnNull) && generationType.toUpperCase().equals("BY DEFAULT")) {
generationStrategy = generationType + " ON NULL";
}
return String.format(autoIncrementClause, generationStrategy);
}
}
public String generatePrimaryKeyName(String tableName) {
return tableName.length() > 27 ? "PK_" + tableName.toUpperCase(Locale.US).substring(0, 27) : "PK_" + tableName.toUpperCase(Locale.US);
}
public boolean supportsInitiallyDeferrableColumns() {
return true;
}
public boolean isReservedWord(String objectName) {
return this.reservedWords.contains(objectName.toUpperCase());
}
public boolean supportsSequences() {
return true;
}
public boolean supports(Class<? extends DatabaseObject> object) {
return Schema.class.isAssignableFrom(object) ? false : super.supports(object);
}
public boolean supportsSchemas() {
return false;
}
protected String getConnectionCatalogName() throws DatabaseException {
if (this.getConnection() instanceof OfflineConnection) {
return this.getConnection().getCatalog();
} else if (!(this.getConnection() instanceof JdbcConnection)) {
return this.defaultCatalogName;
} else {
try {
return (String)((ExecutorService)Scope.getCurrentScope().getSingleton(ExecutorService.class)).getExecutor("jdbc", this).queryForObject(new RawCallStatement("select sys_context( 'userenv', 'current_schema' ) from dual"), String.class);
} catch (Exception e) {
Scope.getCurrentScope().getLog(this.getClass()).info("Error getting default schema", e);
return null;
}
}
}
public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {
return "oracle".equalsIgnoreCase(conn.getDatabaseProductName());
}
public String getDefaultDriver(String url) {
return url.startsWith("jdbc:dm") ? "dm.jdbc.driver.DmDriver" : null;
}
public String getDefaultCatalogName() {
String defaultCatalogName = super.getDefaultCatalogName();
if (Boolean.TRUE.equals(GlobalConfiguration.PRESERVE_SCHEMA_CASE.getCurrentValue())) {
return defaultCatalogName;
} else {
return defaultCatalogName == null ? null : defaultCatalogName.toUpperCase(Locale.US);
}
}
public String getDateLiteral(String isoDate) {
String normalLiteral = super.getDateLiteral(isoDate);
if (this.isDateOnly(isoDate)) {
return "TO_DATE(" + normalLiteral + ", 'YYYY-MM-DD')";
} else if (this.isTimeOnly(isoDate)) {
return "TO_DATE(" + normalLiteral + ", 'HH24:MI:SS')";
} else if (this.isTimestamp(isoDate)) {
return "TO_TIMESTAMP(" + normalLiteral + ", 'YYYY-MM-DD HH24:MI:SS.FF')";
} else if (this.isDateTime(isoDate)) {
int seppos = normalLiteral.lastIndexOf(46);
if (seppos != -1) {
normalLiteral = normalLiteral.substring(0, seppos) + "'";
}
return "TO_DATE(" + normalLiteral + ", 'YYYY-MM-DD HH24:MI:SS')";
} else {
return "UNSUPPORTED:" + isoDate;
}
}
public boolean isSystemObject(DatabaseObject example) {
if (example == null) {
return false;
} else if (this.isLiquibaseObject(example)) {
return false;
} else {
if (example instanceof Schema) {
if ("SYSTEM".equals(example.getName()) || "SYS".equals(example.getName()) || "CTXSYS".equals(example.getName()) || "XDB".equals(example.getName())) {
return true;
}
if ("SYSTEM".equals(example.getSchema().getCatalogName()) || "SYS".equals(example.getSchema().getCatalogName()) || "CTXSYS".equals(example.getSchema().getCatalogName()) || "XDB".equals(example.getSchema().getCatalogName())) {
return true;
}
} else if (this.isSystemObject(example.getSchema())) {
return true;
}
if (example instanceof Catalog) {
if ("SYSTEM".equals(example.getName()) || "SYS".equals(example.getName()) || "CTXSYS".equals(example.getName()) || "XDB".equals(example.getName())) {
return true;
}
} else if (example.getName() != null) {
if (example.getName().startsWith("BIN$")) {
boolean filteredInOriginalQuery = this.canAccessDbaRecycleBin();
if (!filteredInOriginalQuery) {
filteredInOriginalQuery = StringUtil.trimToEmpty(example.getSchema().getName()).equalsIgnoreCase(this.getConnection().getConnectionUserName());
}
if (!filteredInOriginalQuery) {
return true;
}
return !(example instanceof PrimaryKey) && !(example instanceof Index) && !(example instanceof UniqueConstraint);
}
if (example.getName().startsWith("AQ$")) {
return true;
}
if (example.getName().startsWith("DR$")) {
return true;
}
if (example.getName().startsWith("SYS_IOT_OVER")) {
return true;
}
if ((example.getName().startsWith("MDRT_") || example.getName().startsWith("MDRS_")) && example.getName().endsWith("$")) {
return true;
}
if (example.getName().startsWith("MLOG$_")) {
return true;
}
if (example.getName().startsWith("RUPD$_")) {
return true;
}
if (example.getName().startsWith("WM$_")) {
return true;
}
if ("CREATE$JAVA$LOB$TABLE".equals(example.getName())) {
return true;
}
if ("JAVA$CLASS$MD5$TABLE".equals(example.getName())) {
return true;
}
if (example.getName().startsWith("ISEQ$$_")) {
return true;
}
if (example.getName().startsWith("USLOG$")) {
return true;
}
if (example.getName().startsWith("SYS_FBA")) {
return true;
}
}
return super.isSystemObject(example);
}
}
public boolean supportsTablespaces() {
return true;
}
public boolean supportsAutoIncrement() {
boolean isAutoIncrementSupported = false;
try {
if (this.getDatabaseMajorVersion() >= 12) {
isAutoIncrementSupported = true;
}
} catch (DatabaseException var3) {
isAutoIncrementSupported = false;
}
return isAutoIncrementSupported;
}
public boolean supportsRestrictForeignKeys() {
return false;
}
public int getDataTypeMaxParameters(String dataTypeName) {
if ("BINARY_FLOAT".equals(dataTypeName.toUpperCase())) {
return 0;
} else {
return "BINARY_DOUBLE".equals(dataTypeName.toUpperCase()) ? 0 : super.getDataTypeMaxParameters(dataTypeName);
}
}
public String getSystemTableWhereClause(String tableNameColumn) {
List<String> clauses = new ArrayList(Arrays.asList("BIN$", "AQ$", "DR$", "SYS_IOT_OVER", "MLOG$_", "RUPD$_", "WM$_", "ISEQ$$_", "USLOG$", "SYS_FBA"));
clauses.replaceAll((s) -> tableNameColumn + " NOT LIKE '" + s + "%'");
return "(" + StringUtil.join(clauses, " AND ") + ")";
}
public boolean jdbcCallsCatalogsSchemas() {
return true;
}
public Set<String> getUserDefinedTypes() {
if (this.userDefinedTypes == null) {
this.userDefinedTypes = new HashSet();
if (this.getConnection() != null && !(this.getConnection() instanceof OfflineConnection)) {
try {
try {
this.userDefinedTypes.addAll(((ExecutorService)Scope.getCurrentScope().getSingleton(ExecutorService.class)).getExecutor("jdbc", this).queryForList(new RawParameterizedSqlStatement("SELECT DISTINCT TYPE_NAME FROM ALL_TYPES"), String.class));
} catch (DatabaseException var2) {
this.userDefinedTypes.addAll(((ExecutorService)Scope.getCurrentScope().getSingleton(ExecutorService.class)).getExecutor("jdbc", this).queryForList(new RawParameterizedSqlStatement("SELECT TYPE_NAME FROM USER_TYPES"), String.class));
}
} catch (DatabaseException var3) {
}
}
}
return this.userDefinedTypes;
}
public String generateDatabaseFunctionValue(DatabaseFunction databaseFunction) {
if (databaseFunction != null && "current_timestamp".equalsIgnoreCase(databaseFunction.toString())) {
return databaseFunction.toString();
} else if (!(databaseFunction instanceof SequenceNextValueFunction) && !(databaseFunction instanceof SequenceCurrentValueFunction)) {
return super.generateDatabaseFunctionValue(databaseFunction);
} else {
String quotedSeq = super.generateDatabaseFunctionValue(databaseFunction);
return quotedSeq.replaceFirst("\"([^.\"]+)\\.([^.\"]+)\"", "\"$1\".\"$2\"");
}
}
public ValidationErrors validate() {
ValidationErrors errors = super.validate();
DatabaseConnection connection = this.getConnection();
if (connection != null && !(connection instanceof OfflineConnection)) {
if (!this.canAccessDbaRecycleBin()) {
errors.addWarning(this.getDbaRecycleBinWarning());
}
return errors;
} else {
Scope.getCurrentScope().getLog(this.getClass()).info("Cannot validate offline database");
return errors;
}
}
public String getDbaRecycleBinWarning() {
return "Liquibase needs to access the DBA_RECYCLEBIN table so we can automatically handle the case where constraints are deleted and restored. Since Oracle doesn't properly restore the original table names referenced in the constraint, we use the information from the DBA_RECYCLEBIN to automatically correct this issue.\n\nThe user you used to connect to the database (" + this.getConnection().getConnectionUserName() + ") needs to have \"SELECT ON SYS.DBA_RECYCLEBIN\" permissions set before we can perform this operation. Please run the following SQL to set the appropriate permissions, and try running the command again.\n\n GRANT SELECT ON SYS.DBA_RECYCLEBIN TO " + this.getConnection().getConnectionUserName() + ";";
}
public boolean canAccessDbaRecycleBin() {
if (this.canAccessDbaRecycleBin == null) {
DatabaseConnection connection = this.getConnection();
if (connection == null || connection instanceof OfflineConnection) {
return false;
}
Statement statement = null;
try {
statement = ((JdbcConnection)connection).createStatement();
ResultSet resultSet = statement.executeQuery("select 1 from dba_recyclebin where 0=1");
resultSet.close();
this.canAccessDbaRecycleBin = true;
} catch (Exception var7) {
if (var7 instanceof SQLException && var7.getMessage().startsWith("ORA-00942")) {
this.canAccessDbaRecycleBin = false;
} else {
Scope.getCurrentScope().getLog(this.getClass()).warning("Cannot check dba_recyclebin access", var7);
this.canAccessDbaRecycleBin = false;
}
} finally {
JdbcUtil.close((ResultSet)null, statement);
}
}
return this.canAccessDbaRecycleBin;
}
public boolean supportsNotNullConstraintNames() {
return true;
}
public boolean isValidOracleIdentifier(String identifier, Class<? extends DatabaseObject> type) {
if (identifier != null && identifier.length() >= 1) {
if (!identifier.matches("^(i?)[A-Z][A-Z0-9\\$\\_\\#]*$")) {
return false;
} else {
return identifier.length() <= 128;
}
} else {
return false;
}
}
public int getIdentifierMaximumLength() {
try {
if (this.getDatabaseMajorVersion() < 12) {
return 30;
} else {
return this.getDatabaseMajorVersion() == 12 && this.getDatabaseMinorVersion() <= 1 ? 30 : 128;
}
} catch (DatabaseException ex) {
throw new UnexpectedLiquibaseException("Cannot determine the Oracle database version number", ex);
}
}
public boolean supportsDatabaseChangeLogHistory() {
return true;
}
public String correctObjectName(String objectName, Class<? extends DatabaseObject> objectType) {
return objectType.equals(Column.class) && StringUtils.startsWithIgnoreCase(objectName, "int") ? "NUMBER(*, 0)" : super.correctObjectName(objectName, objectType);
}
}

View File

@@ -1,149 +0,0 @@
package liquibase.datatype.core;
import liquibase.change.core.LoadDataChange;
import liquibase.database.Database;
import liquibase.database.core.*;
import liquibase.datatype.DataTypeInfo;
import liquibase.datatype.DatabaseDataType;
import liquibase.datatype.LiquibaseDataType;
import liquibase.exception.UnexpectedLiquibaseException;
import liquibase.statement.DatabaseFunction;
import liquibase.util.StringUtil;
import java.util.Locale;
import java.util.regex.Pattern;
@DataTypeInfo(name = "boolean", aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"}, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DEFAULT)
public class BooleanType extends LiquibaseDataType {
@Override
public DatabaseDataType toDatabaseDataType(Database database) {
String originalDefinition = StringUtil.trimToEmpty(getRawDefinition());
// if ((database instanceof Firebird3Database)) {
// return new DatabaseDataType("BOOLEAN");
// }
if ((database instanceof AbstractDb2Database) || (database instanceof FirebirdDatabase)) {
return new DatabaseDataType("SMALLINT");
} else if (database instanceof MSSQLDatabase) {
return new DatabaseDataType(database.escapeDataTypeName("bit"));
} else if (database instanceof MySQLDatabase) {
if (originalDefinition.toLowerCase(Locale.US).startsWith("bit")) {
return new DatabaseDataType("BIT", getParameters());
}
return new DatabaseDataType("BIT", 1);
} else if (database instanceof OracleDatabase) {
return new DatabaseDataType("NUMBER", 1);
} else if ((database instanceof SybaseASADatabase) || (database instanceof SybaseDatabase)) {
return new DatabaseDataType("BIT");
} else if (database instanceof DerbyDatabase) {
if (((DerbyDatabase) database).supportsBooleanDataType()) {
return new DatabaseDataType("BOOLEAN");
} else {
return new DatabaseDataType("SMALLINT");
}
} else if (database.getClass().isAssignableFrom(DB2Database.class)) {
if (((DB2Database) database).supportsBooleanDataType())
return new DatabaseDataType("BOOLEAN");
else
return new DatabaseDataType("SMALLINT");
} else if (database instanceof HsqlDatabase) {
return new DatabaseDataType("BOOLEAN");
} else if (database instanceof PostgresDatabase) {
if (originalDefinition.toLowerCase(Locale.US).startsWith("bit")) {
return new DatabaseDataType("BIT", getParameters());
}
} else if(database instanceof DmDatabase) {
return new DatabaseDataType("bit");
}
return super.toDatabaseDataType(database);
}
@Override
public String objectToSql(Object value, Database database) {
if ((value == null) || "null".equals(value.toString().toLowerCase(Locale.US))) {
return null;
}
String returnValue;
if (value instanceof String) {
value = ((String) value).replaceAll("'", "");
if ("true".equals(((String) value).toLowerCase(Locale.US)) || "1".equals(value) || "b'1'".equals(((String) value).toLowerCase(Locale.US)) || "t".equals(((String) value).toLowerCase(Locale.US)) || ((String) value).toLowerCase(Locale.US).equals(this.getTrueBooleanValue(database).toLowerCase(Locale.US))) {
returnValue = this.getTrueBooleanValue(database);
} else if ("false".equals(((String) value).toLowerCase(Locale.US)) || "0".equals(value) || "b'0'".equals(
((String) value).toLowerCase(Locale.US)) || "f".equals(((String) value).toLowerCase(Locale.US)) || ((String) value).toLowerCase(Locale.US).equals(this.getFalseBooleanValue(database).toLowerCase(Locale.US))) {
returnValue = this.getFalseBooleanValue(database);
} else {
throw new UnexpectedLiquibaseException("Unknown boolean value: " + value);
}
} else if (value instanceof Long) {
if (Long.valueOf(1).equals(value)) {
returnValue = this.getTrueBooleanValue(database);
} else {
returnValue = this.getFalseBooleanValue(database);
}
} else if (value instanceof Number) {
if (value.equals(1) || "1".equals(value.toString()) || "1.0".equals(value.toString())) {
returnValue = this.getTrueBooleanValue(database);
} else {
returnValue = this.getFalseBooleanValue(database);
}
} else if (value instanceof DatabaseFunction) {
return value.toString();
} else if (value instanceof Boolean) {
if (((Boolean) value)) {
returnValue = this.getTrueBooleanValue(database);
} else {
returnValue = this.getFalseBooleanValue(database);
}
} else {
throw new UnexpectedLiquibaseException("Cannot convert type " + value.getClass() + " to a boolean value");
}
return returnValue;
}
protected boolean isNumericBoolean(Database database) {
if (database instanceof DerbyDatabase) {
return !((DerbyDatabase) database).supportsBooleanDataType();
} else if (database.getClass().isAssignableFrom(DB2Database.class)) {
return !((DB2Database) database).supportsBooleanDataType();
}
return (database instanceof Db2zDatabase) || (database instanceof DB2Database) || (database instanceof FirebirdDatabase) || (database instanceof
MSSQLDatabase) || (database instanceof MySQLDatabase) || (database instanceof OracleDatabase) ||
(database instanceof SQLiteDatabase) || (database instanceof SybaseASADatabase) || (database instanceof
SybaseDatabase) || (database instanceof DmDatabase);
}
/**
* The database-specific value to use for "false" "boolean" columns.
*/
public String getFalseBooleanValue(Database database) {
if (isNumericBoolean(database)) {
return "0";
}
if (database instanceof InformixDatabase) {
return "'f'";
}
return "FALSE";
}
/**
* The database-specific value to use for "true" "boolean" columns.
*/
public String getTrueBooleanValue(Database database) {
if (isNumericBoolean(database)) {
return "1";
}
if (database instanceof InformixDatabase) {
return "'t'";
}
return "TRUE";
}
@Override
public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
return LoadDataChange.LOAD_DATA_TYPE.BOOLEAN;
}
}

View File

@@ -17,5 +17,4 @@ liquibase.database.core.PostgresDatabase
liquibase.database.core.SQLiteDatabase liquibase.database.core.SQLiteDatabase
liquibase.database.core.SybaseASADatabase liquibase.database.core.SybaseASADatabase
liquibase.database.core.SybaseDatabase liquibase.database.core.SybaseDatabase
liquibase.database.core.DmDatabase
liquibase.database.core.UnsupportedDatabase liquibase.database.core.UnsupportedDatabase