Skip to content

Commit

Permalink
Merge branch '3.8' of https://github.com/JumpMind/symmetric-ds into 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
klementinastojanovska committed Sep 26, 2017
2 parents 8dff7be + 1fb2508 commit 7a1456b
Show file tree
Hide file tree
Showing 5 changed files with 549 additions and 7 deletions.
9 changes: 9 additions & 0 deletions symmetric-assemble/src/asciidoc/appendix/databases.ad
Expand Up @@ -27,6 +27,15 @@ by database.
|Y
|Y
|Y
|Y

|DB2
|10,11
|Y
|Y
|Y
|Y
|Y
|Y

|DB2 for IBM i
Expand Down
Expand Up @@ -38,7 +38,9 @@ public class Db2SymmetricDialect extends AbstractSymmetricDialect implements ISy
public static final String VAR_SOURCE_NODE_ID = "_source_node_id";
public static final String VAR_TRIGGER_DISABLED = "_trigger_disabled";


public static final String FUNCTION_TRANSACTION_ID = "_transactionid";
static final String SQL_DROP_FUNCTION = "DROP FUNCTION $(functionName)";

public Db2SymmetricDialect(IParameterService parameterService, IDatabasePlatform platform) {
super(parameterService, platform);
this.triggerTemplate = new Db2TriggerTemplate(this);
Expand Down Expand Up @@ -99,10 +101,25 @@ public void createRequiredDatabaseObjects() {
log.debug("Failed checking for variable (usually means it doesn't exist yet) '" + sql + "'", e);
platform.getSqlTemplate().update("create variable " + parameterService.getTablePrefix() + VAR_TRIGGER_DISABLED + " varchar(50)");
}

String transactionIdFunction = this.parameterService.getTablePrefix() + FUNCTION_TRANSACTION_ID;

sql = "CREATE OR REPLACE FUNCTION $(functionName)() "
+ " RETURNS VARCHAR(100) "
+ " LANGUAGE SQL "
+ " READS SQL DATA "
+ " RETURN "
+ " select c.application_id || '_' || u.uow_id "
+ " from sysibmadm.mon_connection_summary c ,sysibmadm.mon_current_uow u "
+ " where u.application_handle = c.application_handle and c.application_id = application_id() ";

install(sql, transactionIdFunction);
}

@Override
public void dropRequiredDatabaseObjects() {
String transactionIdFunction = this.parameterService.getTablePrefix() + FUNCTION_TRANSACTION_ID;
uninstall(SQL_DROP_FUNCTION, transactionIdFunction);
}

@Override
Expand Down Expand Up @@ -139,14 +156,15 @@ public String getSyncTriggersExpression() {
@Override
public String getTransactionTriggerExpression(String defaultCatalog, String defaultSchema,
Trigger trigger) {
return "null";
return "sym_transactionid()";
}

@Override
public boolean supportsTransactionId() {
return false;
return true;
}


public void cleanDatabase() {
}

Expand Down
Expand Up @@ -1147,6 +1147,8 @@ protected void transferFromStaging(ExtractMode mode, BatchType batchType, Outgoi
writer.newLine();
}
}

writer.flush();
} else {
long totalCharsRead = 0, totalBytesRead = 0;
int numCharsRead = 0, numBytesRead = 0;
Expand Down

0 comments on commit 7a1456b

Please sign in to comment.