From 8448985285831b32080cabb1d89bc0908897071b Mon Sep 17 00:00:00 2001 From: chenson42 Date: Sun, 4 Nov 2012 20:59:16 +0000 Subject: [PATCH] 0000872: Add an uninstall feature to SymmetricDS. Add option to the command line. --- .../db/mysql/MySqlSymmetricDialect.java | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/symmetric-client/src/main/java/org/jumpmind/symmetric/db/mysql/MySqlSymmetricDialect.java b/symmetric-client/src/main/java/org/jumpmind/symmetric/db/mysql/MySqlSymmetricDialect.java index 30c8f82635..0ce54e3e4b 100644 --- a/symmetric-client/src/main/java/org/jumpmind/symmetric/db/mysql/MySqlSymmetricDialect.java +++ b/symmetric-client/src/main/java/org/jumpmind/symmetric/db/mysql/MySqlSymmetricDialect.java @@ -69,44 +69,43 @@ 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); } } @@ -114,7 +113,7 @@ protected void createRequiredFunctions() { @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); } @@ -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