Skip to content

Commit

Permalink
0000872: Add an uninstall feature to SymmetricDS. Add option to the c…
Browse files Browse the repository at this point in the history
…ommand line.
  • Loading branch information
chenson42 committed Nov 4, 2012
1 parent dd8aad7 commit 8448985
Showing 1 changed file with 30 additions and 31 deletions.
Expand Up @@ -69,52 +69,51 @@ protected void createRequiredFunctions() {
if (getMajorVersion() == 5
&& (getMinorVersion() == 0 || (getMinorVersion() == 1 && versions[2] < 23))) {
this.functionTemplateKeySuffix = "_pre_5_1_23";
String function = this.parameterService.getTablePrefix() + "_" + "transaction_id_post_5_1_23";
String function = this.parameterService.getTablePrefix() + "_" + TRANSACTION_ID + this.functionTemplateKeySuffix;
if (!installed(SQL_FUNCTION_INSTALLED, function)) {
String sql = "create function $(functionName)() " +
" returns varchar(50) NOT DETERMINISTIC READS SQL DATA " +
" begin " +
" declare comm_value varchar(50); " +
" declare comm_cur cursor for select VARIABLE_VALUE from INFORMATION_SCHEMA.SESSION_STATUS where VARIABLE_NAME='COM_COMMIT'; " +
" if @@autocommit = 0 then " +
" open comm_cur; " +
" fetch comm_cur into comm_value; " +
" close comm_cur; " +
" return concat(concat(connection_id(), '.'), comm_value); " +
" else " +
" return null; " +
" end if; " +
" end ";
" returns varchar(50) NOT DETERMINISTIC READS SQL DATA " +
" begin " +
" declare comm_value varchar(50); " +
" declare comm_cur cursor for select VARIABLE_VALUE from INFORMATION_SCHEMA.SESSION_STATUS where VARIABLE_NAME='COM_COMMIT'; " +
" if @@autocommit = 0 then " +
" open comm_cur; " +
" fetch comm_cur into comm_value; " +
" close comm_cur; " +
" return concat(concat(connection_id(), '.'), comm_value); " +
" else " +
" return null; " +
" end if; " +
" end ";
install(sql, function);
}

} else {
this.functionTemplateKeySuffix = "_post_5_1_23";
String function = this.parameterService.getTablePrefix() + "_" + "transaction_id_post_5_1_23";
String function = this.parameterService.getTablePrefix() + "_" + TRANSACTION_ID + this.functionTemplateKeySuffix;
if (!installed(SQL_FUNCTION_INSTALLED, function)) {
String sql = "create function $(functionName)() " +
" returns varchar(50) NOT DETERMINISTIC READS SQL DATA " +
" begin " +
" declare comm_name varchar(50); " +
" declare comm_value varchar(50); " +
" declare comm_cur cursor for show status like 'Com_commit'; " +
" if @@autocommit = 0 then " +
" open comm_cur; " +
" fetch comm_cur into comm_name, comm_value; " +
" close comm_cur; " +
" return concat(concat(connection_id(), '.'), comm_value); " +
" else " +
" return null; " +
" end if; " +
" end ";
" returns varchar(50) NOT DETERMINISTIC READS SQL DATA " +
" begin " +
" declare comm_value varchar(50); " +
" declare comm_cur cursor for select VARIABLE_VALUE from INFORMATION_SCHEMA.SESSION_STATUS where VARIABLE_NAME='COM_COMMIT'; " +
" if @@autocommit = 0 then " +
" open comm_cur; " +
" fetch comm_cur into comm_value; " +
" close comm_cur; " +
" return concat(concat(connection_id(), '.'), comm_value); " +
" else " +
" return null; " +
" end if; " +
" end ";
install(sql, function);
}
}
}

@Override
protected void dropRequiredFunctions() {
String function = this.parameterService.getTablePrefix() + "_" + "transaction_id" + functionTemplateKeySuffix;
String function = this.parameterService.getTablePrefix() + "_" + TRANSACTION_ID + this.functionTemplateKeySuffix;
if (installed(SQL_FUNCTION_INSTALLED, function)) {
uninstall(SQL_DROP_FUNCTION, function);
}
Expand Down Expand Up @@ -169,7 +168,7 @@ public String getSyncTriggersExpression() {

private final String getTransactionFunctionName() {
return SymmetricUtils.quote(this, platform.getDefaultCatalog()) + "." + parameterService.getTablePrefix() + "_"
+ TRANSACTION_ID;
+ TRANSACTION_ID + this.functionTemplateKeySuffix;
}

@Override
Expand Down

0 comments on commit 8448985

Please sign in to comment.