Skip to content

Commit

Permalink
0000844: Windows Azure does not allow the use of context_info which S…
Browse files Browse the repository at this point in the history
…ymmetricDS uses
  • Loading branch information
chenson42 committed Oct 3, 2012
1 parent 580dd3d commit b33d18c
Showing 1 changed file with 27 additions and 5 deletions.
Expand Up @@ -50,11 +50,29 @@
*/
public class MsSqlSymmetricDialect extends AbstractSymmetricDialect implements ISymmetricDialect {

Boolean supportsDisableTriggers = null;

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

protected boolean supportsDisableTriggers() {
if (supportsDisableTriggers == null) {
try {
getPlatform().getSqlTemplate().update("set context_info 0x0");
log.warn("This database DOES support disabling triggers during a symmetricds data load");
supportsDisableTriggers = true;
} catch (Exception ex) {
log.warn("This database does NOT support disabling triggers during a symmetricds data load");
supportsDisableTriggers = false;
}
}

return supportsDisableTriggers == null ? false : supportsDisableTriggers;

}

@Override
public void removeTrigger(StringBuilder sqlBuffer, final String catalogName, String schemaName,
final String triggerName, String tableName, TriggerHistory oldHistory) {
Expand Down Expand Up @@ -143,15 +161,19 @@ public Boolean execute(Connection con) throws SQLException {
}

public void disableSyncTriggers(ISqlTransaction transaction, String nodeId) {
if (nodeId == null) {
nodeId = "";
if (supportsDisableTriggers()) {
if (nodeId == null) {
nodeId = "";
}
transaction.prepareAndExecute("DECLARE @CI VarBinary(128);" + "SET @CI=cast ('1"
+ nodeId + "' as varbinary(128));" + "SET context_info @CI;");
}
transaction.prepareAndExecute("DECLARE @CI VarBinary(128);" + "SET @CI=cast ('1" + nodeId
+ "' as varbinary(128));" + "SET context_info @CI;");
}

public void enableSyncTriggers(ISqlTransaction transaction) {
transaction.prepareAndExecute("set context_info 0x0");
if (supportsDisableTriggers()) {
transaction.prepareAndExecute("set context_info 0x0");
}
}

public String getSyncTriggersExpression() {
Expand Down

0 comments on commit b33d18c

Please sign in to comment.