Skip to content

Commit

Permalink
0003212: Add NuoDB Dialect
Browse files Browse the repository at this point in the history
  • Loading branch information
klementinastojanovska committed Aug 25, 2017
1 parent 2920b5a commit 8fef64b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Expand Up @@ -59,7 +59,7 @@ public String getTransactionTriggerExpression(String defaultCatalog, String defa

@Override
public void createRequiredDatabaseObjects() {
String function = "sym_get_session_variable";
String function = this.parameterService.getTablePrefix() + "_get_session_variable";
if(!installed(SQL_FUNCTION_INSTALLED, function)){
String sql = "create function $(functionName)(akey string) returns string " +
" as " +
Expand All @@ -73,7 +73,7 @@ public void createRequiredDatabaseObjects() {
" END_FUNCTION;";
install(sql, function);
}
function = "sym_set_session_variable";
function = this.parameterService.getTablePrefix() + "_set_session_variable";
if(!installed(SQL_FUNCTION_INSTALLED, function)){
String sql = "create function $(functionName)(akey string, avalue string) returns string " +
" as " +
Expand All @@ -93,12 +93,12 @@ public void createRequiredDatabaseObjects() {

@Override
public void dropRequiredDatabaseObjects() {
String function = "sym_get_session_variable";
String function = this.parameterService.getTablePrefix() + "_get_session_variable";
if (installed(SQL_FUNCTION_INSTALLED, function)) {
uninstall(SQL_DROP_FUNCTION, function);
}

function = "sym_set_session_variable";
function = this.parameterService.getTablePrefix() + "_set_session_variable";
if (installed(SQL_FUNCTION_INSTALLED, function)){
uninstall(SQL_DROP_FUNCTION, function);
}
Expand Down Expand Up @@ -134,20 +134,20 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
}

public void disableSyncTriggers(ISqlTransaction transaction, String nodeId) {
transaction.prepareAndExecute("select sym_set_session_variable('" + SYNC_TRIGGERS_DISABLED_USER_VARIABLE + "', '1') from dual");
transaction.prepareAndExecute("select " + this.parameterService.getTablePrefix() + "_set_session_variable('" + SYNC_TRIGGERS_DISABLED_USER_VARIABLE + "', '1') from dual");
if (nodeId != null) {
transaction
.prepareAndExecute("select sym_set_session_variable('" + SYNC_TRIGGERS_DISABLED_NODE_VARIABLE + "','" + nodeId + "') from dual");
.prepareAndExecute("select " + this.parameterService.getTablePrefix()+ "_set_session_variable('" + SYNC_TRIGGERS_DISABLED_NODE_VARIABLE + "','" + nodeId + "') from dual");
}
}

public void enableSyncTriggers(ISqlTransaction transaction) {
transaction.prepareAndExecute("select sym_set_session_variable('" + SYNC_TRIGGERS_DISABLED_USER_VARIABLE + "', null) from dual");
transaction.prepareAndExecute("select sym_set_session_variable('" + SYNC_TRIGGERS_DISABLED_NODE_VARIABLE + "', null) from dual");
transaction.prepareAndExecute("select " + this.parameterService.getTablePrefix() + "_set_session_variable('" + SYNC_TRIGGERS_DISABLED_USER_VARIABLE + "', null) from dual");
transaction.prepareAndExecute("select " + this.parameterService.getTablePrefix() + "_set_session_variable('" + SYNC_TRIGGERS_DISABLED_NODE_VARIABLE + "', null) from dual");
}

public String getSyncTriggersExpression() {
return "sym_get_session_variable('" + SYNC_TRIGGERS_DISABLED_USER_VARIABLE + "') is null";
return this.parameterService.getTablePrefix()+ "_get_session_variable('" + SYNC_TRIGGERS_DISABLED_USER_VARIABLE + "') is null";
}

public void cleanDatabase() {
Expand Down
Expand Up @@ -56,7 +56,7 @@ public NuoDbTriggerTemplate(ISymmetricDialect symmetricDialect) {
" $(triggerHistoryId), \n" +
" concat($(columns) \n" +
" ), \n" +
" $(channelExpression), $(txIdExpression), sym_get_session_variable('sync_node_disabled'), \n" +
" $(channelExpression), $(txIdExpression), $(prefixName)_get_session_variable('sync_node_disabled'), \n" +
" $(externalSelect), \n" +
" CURRENT_TIMESTAMP \n" +
" ); \n" +
Expand All @@ -75,7 +75,7 @@ public NuoDbTriggerTemplate(ISymmetricDialect symmetricDialect) {
" 'R', \n" +
" $(triggerHistoryId), \n" +
" $(newKeys), \n" +
" $(channelExpression), $(txIdExpression), sym_get_session_variable('sync_node_disabled'), \n" +
" $(channelExpression), $(txIdExpression), $(prefixName)_get_session_variable('sync_node_disabled'), \n" +
" $(externalSelect), \n" +
" CURRENT_TIMESTAMP \n" +
" ); \n" +
Expand All @@ -98,7 +98,7 @@ public NuoDbTriggerTemplate(ISymmetricDialect symmetricDialect) {
" ), \n" +
" concat($(columns)), \n" +
" concat($(oldColumns)), \n" +
" $(channelExpression), $(txIdExpression), sym_get_session_variable('sync_node_disabled'), \n" +
" $(channelExpression), $(txIdExpression), $(prefixName)_get_session_variable('sync_node_disabled'), \n" +
" $(externalSelect), \n" +
" CURRENT_TIMESTAMP \n" +
" ); \n" +
Expand All @@ -121,7 +121,7 @@ public NuoDbTriggerTemplate(ISymmetricDialect symmetricDialect) {
" ), \n" +
" concat($(oldColumns) \n" +
" ), \n" +
" $(channelExpression), $(txIdExpression), sym_get_session_variable('sync_node_disabled'), \n" +
" $(channelExpression), $(txIdExpression), $(prefixName)_get_session_variable('sync_node_disabled'), \n" +
" $(externalSelect), \n" +
" CURRENT_TIMESTAMP \n" +
" ); \n" +
Expand Down

0 comments on commit 8fef64b

Please sign in to comment.