Skip to content
Permalink
Browse files

0001833: ASE 12.5 create triggers in a multi-statement fails

  • Loading branch information...
chenson42 committed Jul 28, 2014
1 parent 462f296 commit f384d18973ca2859b8a8d11ac643a521de6cc093
@@ -227,8 +227,13 @@ public boolean isForeignKeyViolation(Throwable ex) {
return false;
}

@Override
public ISqlTransaction startSqlTransaction(boolean autoCommit) {
return new AndroidSqlTransaction(this, autoCommit);
}

public ISqlTransaction startSqlTransaction() {
return new AndroidSqlTransaction(this);
return startSqlTransaction(false);
}

public int getDatabaseMajorVersion() {
@@ -35,14 +35,15 @@
protected AndroidSqlTemplate sqlTemplate;

protected SQLiteDatabase database;

protected boolean oldAutoCommitValue;
protected boolean autoCommit = false;

protected String sql;

protected boolean needsRolledback = false;

public AndroidSqlTransaction(AndroidSqlTemplate sqlTemplate) {
public AndroidSqlTransaction(AndroidSqlTemplate sqlTemplate, boolean autoCommit) {
this.autoCommit = autoCommit;
this.sqlTemplate = sqlTemplate;
this.database = sqlTemplate.getDatabaseHelper().getWritableDatabase();
this.database.beginTransaction();
@@ -305,7 +305,8 @@ public void createTrigger(final StringBuilder sqlBuffer, final DataEventType dml
if (parameterService.is(ParameterConstants.AUTO_SYNC_TRIGGERS)) {
ISqlTransaction transaction = null;
try {
transaction = this.platform.getSqlTemplate().startSqlTransaction();
transaction = this.platform.getSqlTemplate().startSqlTransaction(
platform.getDatabaseInfo().isRequiresAutoCommitForDdl());
previousCatalog = switchCatalogForTriggerInstall(sourceCatalogName, transaction);

try {
@@ -103,6 +103,8 @@
public boolean isForeignKeyViolation(Throwable ex);

public ISqlTransaction startSqlTransaction();

public ISqlTransaction startSqlTransaction(boolean autoCommit);

public int getDatabaseMajorVersion();

@@ -280,6 +280,10 @@ public String execute(Connection con) throws SQLException {
});
}

public ISqlTransaction startSqlTransaction(boolean autoCommit) {
return new JdbcSqlTransaction(this, autoCommit);
}

public ISqlTransaction startSqlTransaction() {
return new JdbcSqlTransaction(this);
}
@@ -54,11 +54,19 @@

protected JdbcSqlTemplate jdbcSqlTemplate;

protected boolean autoCommit = false;

protected boolean oldAutoCommitValue;

protected List<Object> markers = new ArrayList<Object>();


public JdbcSqlTransaction(JdbcSqlTemplate jdbcSqlTemplate) {
this(jdbcSqlTemplate, false);
}

public JdbcSqlTransaction(JdbcSqlTemplate jdbcSqlTemplate, boolean autoCommit) {
this.autoCommit = autoCommit;
this.jdbcSqlTemplate = jdbcSqlTemplate;
this.init();
}
@@ -79,7 +87,7 @@ protected void init() {
try {
this.connection = jdbcSqlTemplate.getDataSource().getConnection();
this.oldAutoCommitValue = this.connection.getAutoCommit();
this.connection.setAutoCommit(false);
this.connection.setAutoCommit(autoCommit);
SqlUtils.addSqlTransaction(this);
} catch (SQLException ex) {
close();
@@ -104,7 +112,9 @@ public void commit() {
if (pstmt != null && inBatchMode) {
flush();
}
connection.commit();
if (!autoCommit) {
connection.commit();
}
} catch (SQLException ex) {
throw jdbcSqlTemplate.translate(ex);
}
@@ -122,7 +132,9 @@ protected void rollback(boolean clearMarkers) {
if (clearMarkers) {
markers.clear();
}
connection.rollback();
if (!autoCommit) {
connection.rollback();
}
} catch (SQLException ex) {
// do nothing
}

0 comments on commit f384d18

Please sign in to comment.
You can’t perform that action at this time.