Skip to content

Commit

Permalink
0000872: Run uninstall with unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Nov 5, 2012
1 parent 5ad24b8 commit cefa36b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
Expand Up @@ -50,7 +50,7 @@ public class InterbaseSymmetricDialect extends AbstractSymmetricDialect implemen

static final String SQL_FUNCTION_INSTALLED = "select count(*) from rdb$functions where rdb$function_name = upper('$(functionName)')" ;

static final String SQL_DROP_FUNCTION = "drop function $(functionName)";
static final String SQL_DROP_FUNCTION = "DROP EXTERNAL FUNCTION $(functionName)";

public InterbaseSymmetricDialect(IParameterService parameterService, IDatabasePlatform platform) {
super(parameterService, platform);
Expand Down
Expand Up @@ -42,7 +42,7 @@ public class PostgreSqlSymmetricDialect extends AbstractSymmetricDialect impleme

static final String SYNC_NODE_DISABLED_VARIABLE = "symmetric.node_disabled";

static final String SQL_DROP_FUNCTION = "drop function $(defaultSchema)$(functionName)";
static final String SQL_DROP_FUNCTION = "drop function $(functionName)";

static final String SQL_FUNCTION_INSTALLED =
" select count(*) from information_schema.routines " +
Expand Down Expand Up @@ -83,7 +83,7 @@ protected void createRequiredDatabaseObjects() {

String triggersDisabled = this.parameterService.getTablePrefix() + "_" + "triggers_disabled";
if (!installed(SQL_FUNCTION_INSTALLED, triggersDisabled)) {
String sql = "CREATE or REPLACE FUNCTION $(defaultSchema)$(functionName)() RETURNS INTEGER AS $$ " +
String sql = "CREATE or REPLACE FUNCTION $(functionName)() RETURNS INTEGER AS $$ " +
" DECLARE " +
" triggerDisabled INTEGER; " +
" BEGIN " +
Expand All @@ -96,9 +96,9 @@ protected void createRequiredDatabaseObjects() {
install(sql, triggersDisabled);
}

String nodeDisabled = this.parameterService.getTablePrefix() + "_" + "escape";
String nodeDisabled = this.parameterService.getTablePrefix() + "_" + "node_disabled";
if (!installed(SQL_FUNCTION_INSTALLED, nodeDisabled)) {
String sql = "CREATE or REPLACE FUNCTION $(defaultSchema)$(functionName)() RETURNS VARCHAR AS $$ " +
String sql = "CREATE or REPLACE FUNCTION $(functionName)() RETURNS VARCHAR AS $$ " +
" DECLARE " +
" nodeId VARCHAR(50); " +
" BEGIN " +
Expand All @@ -111,9 +111,9 @@ protected void createRequiredDatabaseObjects() {
install(sql, nodeDisabled);
}

String largeObjects = this.parameterService.getTablePrefix() + "_" + "escape";
String largeObjects = this.parameterService.getTablePrefix() + "_" + "largeobject";
if (!installed(SQL_FUNCTION_INSTALLED, largeObjects)) {
String sql = "CREATE OR REPLACE FUNCTION $(defaultSchema)$(functionName)(objectId oid) RETURNS text AS $$ " +
String sql = "CREATE OR REPLACE FUNCTION $(functionName)(objectId oid) RETURNS text AS $$ " +
" DECLARE " +
" encodedBlob text; " +
" encodedBlobPage text; " +
Expand All @@ -137,17 +137,17 @@ protected void createRequiredDatabaseObjects() {
protected void dropRequiredDatabaseObjects() {
String triggersDisabled = this.parameterService.getTablePrefix() + "_" + "triggers_disabled";
if (installed(SQL_FUNCTION_INSTALLED, triggersDisabled)) {
uninstall(SQL_DROP_FUNCTION, triggersDisabled);
uninstall(SQL_DROP_FUNCTION+ "()", triggersDisabled);
}

String nodeDisabled = this.parameterService.getTablePrefix() + "_" + "escape";
String nodeDisabled = this.parameterService.getTablePrefix() + "_" + "node_disabled";
if (installed(SQL_FUNCTION_INSTALLED, nodeDisabled)) {
uninstall(SQL_DROP_FUNCTION, nodeDisabled);
uninstall(SQL_DROP_FUNCTION + "()", nodeDisabled);
}

String largeObjects = this.parameterService.getTablePrefix() + "_" + "escape";
String largeObjects = this.parameterService.getTablePrefix() + "_" + "largeobject";
if (installed(SQL_FUNCTION_INSTALLED, largeObjects)) {
uninstall(SQL_DROP_FUNCTION, largeObjects);
uninstall(SQL_DROP_FUNCTION + "(objectId oid)", largeObjects);
}

}
Expand Down
Expand Up @@ -147,7 +147,8 @@ protected void install(String sql, String objectName) {
}

protected void uninstall(String sql, String objectName) {
platform.getSqlTemplate().update(replaceTokens(sql, objectName));
sql = replaceTokens(sql, objectName);
platform.getSqlTemplate().update(sql);
log.info("Just uninstalled {}", objectName);
}

Expand Down

0 comments on commit cefa36b

Please sign in to comment.