Skip to content

Commit

Permalink
0005610: SqlAnywhere support for v. 12 and higher
Browse files Browse the repository at this point in the history
  • Loading branch information
joshahicks committed Dec 13, 2022
1 parent bed7282 commit cc25368
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 3 deletions.
Expand Up @@ -44,6 +44,7 @@
import org.jumpmind.db.platform.postgresql.PostgreSqlDatabasePlatform;
import org.jumpmind.db.platform.raima.RaimaDatabasePlatform;
import org.jumpmind.db.platform.redshift.RedshiftDatabasePlatform;
import org.jumpmind.db.platform.sqlanywhere.SqlAnywhere12DatabasePlatform;
import org.jumpmind.db.platform.sqlanywhere.SqlAnywhereDatabasePlatform;
import org.jumpmind.db.platform.sqlite.SqliteDatabasePlatform;
import org.jumpmind.db.platform.tibero.TiberoDatabasePlatform;
Expand Down Expand Up @@ -75,6 +76,7 @@
import org.jumpmind.symmetric.db.postgresql.PostgreSqlSymmetricDialect;
import org.jumpmind.symmetric.db.raima.RaimaSymmetricDialect;
import org.jumpmind.symmetric.db.redshift.RedshiftSymmetricDialect;
import org.jumpmind.symmetric.db.sqlanywhere.SqlAnywhere12SymmetricDialect;
import org.jumpmind.symmetric.db.sqlanywhere.SqlAnywhereSymmetricDialect;
import org.jumpmind.symmetric.db.sqlite.SqliteJdbcSymmetricDialect;
import org.jumpmind.symmetric.db.tibero.TiberoSymmetricDialect;
Expand Down Expand Up @@ -150,6 +152,8 @@ public ISymmetricDialect create(IParameterService parameterService, IDatabasePla
}
} else if (platform instanceof AseDatabasePlatform) {
dialect = new AseSymmetricDialect(parameterService, platform);
} else if (platform instanceof SqlAnywhere12DatabasePlatform) {
dialect = new SqlAnywhere12SymmetricDialect(parameterService, platform);
} else if (platform instanceof SqlAnywhereDatabasePlatform) {
dialect = new SqlAnywhereSymmetricDialect(parameterService, platform);
} else if (platform instanceof InterbaseDatabasePlatform) {
Expand Down
@@ -0,0 +1,13 @@
package org.jumpmind.symmetric.db.sqlanywhere;

import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.symmetric.db.mssql.MsSql2008TriggerTemplate;
import org.jumpmind.symmetric.service.IParameterService;

public class SqlAnywhere12SymmetricDialect extends SqlAnywhereSymmetricDialect {

public SqlAnywhere12SymmetricDialect(IParameterService parameterService, IDatabasePlatform platform) {
super(parameterService, platform);
this.triggerTemplate = new SqlAnywhere12TriggerTemplate(this);
}
}

Large diffs are not rendered by default.

Expand Up @@ -136,10 +136,10 @@ public void dropRequiredDatabaseObjects() {
@Override
public void removeTrigger(StringBuilder sqlBuffer, final String catalogName, String schemaName,
final String triggerName, String tableName, ISqlTransaction transaction) {
final String sql = "drop trigger " + Table.getFullyQualifiedTableName(catalogName, schemaName, tableName) + "." + triggerName;
final String sql = "drop trigger " + schemaName + "." + tableName + "." + triggerName;
logSql(sql, sqlBuffer);
if (parameterService.is(ParameterConstants.AUTO_SYNC_TRIGGERS)) {
log.info("Dropping {} trigger for {}", triggerName, Table.getFullyQualifiedTableName(catalogName, schemaName, tableName));
log.info("Dropping {} trigger for {}", triggerName, schemaName + "." + tableName + "." + triggerName);
((JdbcSqlTransaction) transaction)
.executeCallback(new IConnectionCallback<Boolean>() {
public Boolean execute(Connection con) throws SQLException {
Expand Down
Expand Up @@ -280,6 +280,7 @@ protected String buildKeyVariablesDeclare(Column[] columns, String prefix) {
throw new NotImplementedException(columns[i] + " is of type "
+ columns[i].getMappedType());
}
text+=";";
}
return text;
}
Expand Down
Expand Up @@ -51,6 +51,7 @@ private DatabaseNamesConstants() {
public final static String POSTGRESQL95 = "postgres95";
public final static String ASE = "ase";
public final static String SQLANYWHERE = "sqlanywhere";
public final static String SQLANYWHERE12 = "sqlanywhere12";
public final static String MARIADB = "mariadb";
public final static String REDSHIFT = "redshift";
public final static String VOLTDB = "voltdb";
Expand Down
Expand Up @@ -84,6 +84,7 @@
import org.jumpmind.db.platform.postgresql.PostgreSqlDatabasePlatform;
import org.jumpmind.db.platform.raima.RaimaDatabasePlatform;
import org.jumpmind.db.platform.redshift.RedshiftDatabasePlatform;
import org.jumpmind.db.platform.sqlanywhere.SqlAnywhere12DatabasePlatform;
import org.jumpmind.db.platform.sqlanywhere.SqlAnywhereDatabasePlatform;
import org.jumpmind.db.platform.sqlite.SqliteDatabasePlatform;
import org.jumpmind.db.platform.tibero.TiberoDatabasePlatform;
Expand Down Expand Up @@ -144,7 +145,8 @@ protected JdbcDatabasePlatformFactory() {
addPlatform(platforms, DatabaseNamesConstants.POSTGRESQL, PostgreSqlDatabasePlatform.class);
addPlatform(platforms, DatabaseNamesConstants.POSTGRESQL95, PostgreSql95DatabasePlatform.class);
addPlatform(platforms, DatabaseNamesConstants.SQLITE, SqliteDatabasePlatform.class);
addPlatform(platforms, DatabaseNamesConstants.SQLANYWHERE, SqliteDatabasePlatform.class);
addPlatform(platforms, DatabaseNamesConstants.SQLANYWHERE, SqlAnywhere12DatabasePlatform.class);
addPlatform(platforms, DatabaseNamesConstants.SQLANYWHERE12, SqlAnywhere12DatabasePlatform.class);
addPlatform(platforms, DatabaseNamesConstants.RAIMA, RaimaDatabasePlatform.class);
addPlatform(platforms, DatabaseNamesConstants.REDSHIFT, RedshiftDatabasePlatform.class);
addPlatform(platforms, DatabaseNamesConstants.TIBERO, TiberoDatabasePlatform.class);
Expand Down Expand Up @@ -316,6 +318,9 @@ protected void determineDatabaseNameVersionSubprotocol(DataSource dataSource, Co
nameVersion.setName(DatabaseNamesConstants.MSSQLAZURE);
}
}
if (nameVersion.getProtocol().equalsIgnoreCase(SqlAnywhereDatabasePlatform.JDBC_SUBPROTOCOL_SHORT) && nameVersion.getVersion() >= 12) {
nameVersion.setName(DatabaseNamesConstants.SQLANYWHERE12);
}
}

private boolean isGreenplumDatabase(Connection connection) {
Expand Down
@@ -0,0 +1,15 @@
package org.jumpmind.db.platform.sqlanywhere;

import javax.sql.DataSource;

import org.jumpmind.db.platform.DatabaseNamesConstants;
import org.jumpmind.db.sql.SqlTemplateSettings;

public class SqlAnywhere12DatabasePlatform extends SqlAnywhereDatabasePlatform {

public SqlAnywhere12DatabasePlatform(DataSource dataSource, SqlTemplateSettings settings) {
super(dataSource, settings);
}


}
Expand Up @@ -63,6 +63,7 @@ public class SqlAnywhereDatabasePlatform extends AbstractJdbcDatabasePlatform {
public static final String JDBC_DRIVER_OLD = "com.sybase.jdbc4.jdbc.SybDriver";
/* The subprotocol used by the standard Sybase driver. */
public static final String JDBC_SUBPROTOCOL = "sybase:Tds";
public static final String JDBC_SUBPROTOCOL_SHORT = "sybase";
/* The maximum size that text and binary columns can have. */
public static final long MAX_TEXT_SIZE = 2147483647;
private Map<String, String> sqlScriptReplacementTokens;
Expand Down

0 comments on commit cc25368

Please sign in to comment.