Skip to content

Commit

Permalink
Merge branch '3.8' of https://github.com/JumpMind/symmetric-ds.git in…
Browse files Browse the repository at this point in the history
…to 3.8
  • Loading branch information
mmichalek committed Feb 15, 2017
2 parents 2058478 + 48e83e5 commit ac697b2
Show file tree
Hide file tree
Showing 31 changed files with 3,578 additions and 2,683 deletions.
Expand Up @@ -22,8 +22,12 @@

import java.math.BigDecimal;

import org.jumpmind.db.model.Database;
import org.jumpmind.db.platform.AbstractDatabasePlatform;
import org.jumpmind.db.platform.DatabaseNamesConstants;
import org.jumpmind.db.platform.PermissionResult;
import org.jumpmind.db.platform.PermissionType;
import org.jumpmind.db.platform.PermissionResult.Status;
import org.jumpmind.db.platform.sqlite.SqliteDdlBuilder;
import org.jumpmind.db.platform.sqlite.SqliteDdlReader;
import org.jumpmind.db.sql.ISqlTemplate;
Expand Down Expand Up @@ -110,4 +114,27 @@ protected Object parseInteger(String value) {
}
}

@Override
public PermissionResult getCreateSymTablePermission(Database database) {
PermissionResult result = new PermissionResult(PermissionType.CREATE_TABLE, Status.UNIMPLEMENTED);
return result;
}

@Override
public PermissionResult getDropSymTablePermission() {
PermissionResult result = new PermissionResult(PermissionType.DROP_TABLE, Status.UNIMPLEMENTED);
return result;
}

@Override
public PermissionResult getAlterSymTablePermission(Database database) {
PermissionResult result = new PermissionResult(PermissionType.ALTER_TABLE, Status.UNIMPLEMENTED);
return result;
}

@Override
public PermissionResult getDropSymTriggerPermission() {
PermissionResult result = new PermissionResult(PermissionType.DROP_TRIGGER, Status.UNIMPLEMENTED);
return result;
}
}
Expand Up @@ -32,6 +32,7 @@
import org.jumpmind.db.model.Table;
import org.jumpmind.db.model.TypeMap;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.platform.PermissionType;
import org.jumpmind.db.sql.IConnectionCallback;
import org.jumpmind.db.sql.ISqlTemplate;
import org.jumpmind.db.sql.ISqlTransaction;
Expand Down Expand Up @@ -417,4 +418,9 @@ protected String getDbSpecificDataHasChangedCondition(Trigger trigger) {
return "$(anyNonBlobColumnChanged)";
}

@Override
public PermissionType[] getSymTablePermissions() {
PermissionType[] permissions = { PermissionType.CREATE_TABLE, PermissionType.DROP_TABLE, PermissionType.CREATE_TRIGGER, PermissionType.DROP_TRIGGER, PermissionType.CREATE_FUNCTION};
return permissions;
}
}
@@ -1,120 +1,127 @@
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.db.mssql2000;

import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.util.BinaryEncoding;
import org.jumpmind.symmetric.db.mssql.MsSqlSymmetricDialect;
import org.jumpmind.symmetric.service.IParameterService;

public class MsSql2000SymmetricDialect extends MsSqlSymmetricDialect {


public MsSql2000SymmetricDialect(IParameterService parameterService, IDatabasePlatform platform) {
super(parameterService, platform);
this.triggerTemplate = new MsSql2000TriggerTemplate(this);
}

@Override
protected boolean alterLockEscalation() {
return false;
}

@Override
public void createRequiredDatabaseObjects() {
String encode = this.parameterService.getTablePrefix() + "_" + "base64_encode";
if (!installed(SQL_FUNCTION_INSTALLED, encode)) {
String sql = " create function dbo.$(functionName) (\n" +
" @binvalue varbinary(8000)) returns varchar(8000)\n" +
" as \n" +
" begin\n" +
" declare @charvalue varchar(8000)\n" +
" declare @i int\n" +
" declare @length int\n" +
" declare @hexstring char(16)\n" +
"\n" +
" select @charvalue = ''\n" +
" select @i = 1\n" +
" select @length = datalength(@binvalue)\n" +
" select @hexstring = '0123456789abcdef'\n" +
"\n" +
" while (@i <= @length)\n" +
" begin\n" +
"\n" +
" declare @tempint int\n" +
" declare @firstint int\n" +
" declare @secondint int\n" +
"\n" +
" select @tempint = convert(int, substring(@binvalue,@i,1))\n" +
" select @firstint = floor(@tempint/16)\n" +
" select @secondint = @tempint - (@firstint*16)\n" +
"\n" +
" select @charvalue = @charvalue +\n" +
" substring(@hexstring, @firstint+1, 1) +\n" +
" substring(@hexstring, @secondint+1, 1)\n" +
"\n" +
" select @i = @i + 1\n" +
" end\n" +
" return @charvalue\n" +
" end";
install(sql, encode);
}

String triggersDisabled = this.parameterService.getTablePrefix() + "_" + "triggers_disabled";
if (!installed(SQL_FUNCTION_INSTALLED, triggersDisabled)) {
String sql =
"create function dbo.$(functionName)() returns smallint \n" +
" begin \n" +
" declare @disabled varchar(1);\n" +
" declare @context_info varbinary(128); \n" +
" SELECT @Context_Info = CONTEXT_INFO\n" +
" FROM master.dbo.SYSPROCESSES \n" +
" WHERE SPID = @@SPID \n" +
" set @disabled = coalesce(replace(substring(cast(@context_info as varchar), 1, 1), 0x0, ''), ''); \n" +
" if @disabled is null or @disabled != '1' \n" +
" return 0; \n" +
" return 1; \n" +
" end ";
install(sql, triggersDisabled);
}

String nodeDisabled = this.parameterService.getTablePrefix() + "_" + "node_disabled";
if (!installed(SQL_FUNCTION_INSTALLED, nodeDisabled)) {
String sql = "create function dbo.$(functionName)() returns varchar(50) \n" +
" begin \n" +
" declare @node varchar(50);\n" +
" declare @context_info varbinary(128);\n" +
" SELECT @context_info = CONTEXT_INFO\n" +
" FROM master.dbo.SYSPROCESSES \n" +
" WHERE SPID = @@SPID \n " +
" SELECT @node = coalesce(replace(substring(cast(@context_info as varchar) collate SQL_Latin1_General_CP1_CI_AS, 2, 50), 0x0, ''), ''); \n " +
" return @node; " +
" end ";
install(sql, nodeDisabled);
}

}

@Override
public BinaryEncoding getBinaryEncoding() {
return BinaryEncoding.HEX;
}
}
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.db.mssql2000;

import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.platform.PermissionType;
import org.jumpmind.db.util.BinaryEncoding;
import org.jumpmind.symmetric.db.mssql.MsSqlSymmetricDialect;
import org.jumpmind.symmetric.service.IParameterService;

public class MsSql2000SymmetricDialect extends MsSqlSymmetricDialect {


public MsSql2000SymmetricDialect(IParameterService parameterService, IDatabasePlatform platform) {
super(parameterService, platform);
this.triggerTemplate = new MsSql2000TriggerTemplate(this);
}

@Override
protected boolean alterLockEscalation() {
return false;
}

@Override
public void createRequiredDatabaseObjects() {
String encode = this.parameterService.getTablePrefix() + "_" + "base64_encode";
if (!installed(SQL_FUNCTION_INSTALLED, encode)) {
String sql = " create function dbo.$(functionName) (\n" +
" @binvalue varbinary(8000)) returns varchar(8000)\n" +
" as \n" +
" begin\n" +
" declare @charvalue varchar(8000)\n" +
" declare @i int\n" +
" declare @length int\n" +
" declare @hexstring char(16)\n" +
"\n" +
" select @charvalue = ''\n" +
" select @i = 1\n" +
" select @length = datalength(@binvalue)\n" +
" select @hexstring = '0123456789abcdef'\n" +
"\n" +
" while (@i <= @length)\n" +
" begin\n" +
"\n" +
" declare @tempint int\n" +
" declare @firstint int\n" +
" declare @secondint int\n" +
"\n" +
" select @tempint = convert(int, substring(@binvalue,@i,1))\n" +
" select @firstint = floor(@tempint/16)\n" +
" select @secondint = @tempint - (@firstint*16)\n" +
"\n" +
" select @charvalue = @charvalue +\n" +
" substring(@hexstring, @firstint+1, 1) +\n" +
" substring(@hexstring, @secondint+1, 1)\n" +
"\n" +
" select @i = @i + 1\n" +
" end\n" +
" return @charvalue\n" +
" end";
install(sql, encode);
}

String triggersDisabled = this.parameterService.getTablePrefix() + "_" + "triggers_disabled";
if (!installed(SQL_FUNCTION_INSTALLED, triggersDisabled)) {
String sql =
"create function dbo.$(functionName)() returns smallint \n" +
" begin \n" +
" declare @disabled varchar(1);\n" +
" declare @context_info varbinary(128); \n" +
" SELECT @Context_Info = CONTEXT_INFO\n" +
" FROM master.dbo.SYSPROCESSES \n" +
" WHERE SPID = @@SPID \n" +
" set @disabled = coalesce(replace(substring(cast(@context_info as varchar), 1, 1), 0x0, ''), ''); \n" +
" if @disabled is null or @disabled != '1' \n" +
" return 0; \n" +
" return 1; \n" +
" end ";
install(sql, triggersDisabled);
}

String nodeDisabled = this.parameterService.getTablePrefix() + "_" + "node_disabled";
if (!installed(SQL_FUNCTION_INSTALLED, nodeDisabled)) {
String sql = "create function dbo.$(functionName)() returns varchar(50) \n" +
" begin \n" +
" declare @node varchar(50);\n" +
" declare @context_info varbinary(128);\n" +
" SELECT @context_info = CONTEXT_INFO\n" +
" FROM master.dbo.SYSPROCESSES \n" +
" WHERE SPID = @@SPID \n " +
" SELECT @node = coalesce(replace(substring(cast(@context_info as varchar) collate SQL_Latin1_General_CP1_CI_AS, 2, 50), 0x0, ''), ''); \n " +
" return @node; " +
" end ";
install(sql, nodeDisabled);
}

}

@Override
public BinaryEncoding getBinaryEncoding() {
return BinaryEncoding.HEX;
}

@Override
public PermissionType[] getSymTablePermissions() {
PermissionType[] permissions = { PermissionType.CREATE_TABLE, PermissionType.DROP_TABLE, PermissionType.CREATE_TRIGGER, PermissionType.DROP_TRIGGER, PermissionType.CREATE_FUNCTION};
return permissions;
}
}
Expand Up @@ -24,6 +24,7 @@
import java.sql.SQLException;

import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.platform.PermissionType;
import org.jumpmind.db.sql.ISqlTransaction;
import org.jumpmind.db.sql.JdbcSqlTransaction;
import org.jumpmind.db.sql.SqlException;
Expand Down Expand Up @@ -228,4 +229,10 @@ public BinaryEncoding getBinaryEncoding() {
protected String getDbSpecificDataHasChangedCondition(Trigger trigger) {
return "var_old_data is null or var_row_data != var_old_data";
}

@Override
public PermissionType[] getSymTablePermissions() {
PermissionType[] permissions = { PermissionType.CREATE_TABLE, PermissionType.DROP_TABLE, PermissionType.CREATE_TRIGGER, PermissionType.DROP_TRIGGER, PermissionType.CREATE_ROUTINE};
return permissions;
}
}
Expand Up @@ -27,6 +27,7 @@
import org.apache.commons.lang.time.DateUtils;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.platform.PermissionType;
import org.jumpmind.db.sql.ISqlTransaction;
import org.jumpmind.db.sql.SqlException;
import org.jumpmind.db.util.BinaryEncoding;
Expand Down Expand Up @@ -358,4 +359,10 @@ protected String getDbSpecificDataHasChangedCondition(Trigger trigger) {
public String getTemplateNumberPrecisionSpec() {
return parameterService.getString(ParameterConstants.DBDIALECT_ORACLE_TEMPLATE_NUMBER_SPEC,"30,10");
}

@Override
public PermissionType[] getSymTablePermissions() {
PermissionType[] permissions = { PermissionType.CREATE_TABLE, PermissionType.DROP_TABLE, PermissionType.CREATE_TRIGGER, PermissionType.DROP_TRIGGER, PermissionType.EXECUTE};
return permissions;
}
}
Expand Up @@ -38,6 +38,7 @@
import org.jumpmind.db.platform.IAlterDatabaseInterceptor;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.platform.IDdlBuilder;
import org.jumpmind.db.platform.PermissionType;
import org.jumpmind.db.sql.ISqlResultsListener;
import org.jumpmind.db.sql.ISqlTemplate;
import org.jumpmind.db.sql.ISqlTransaction;
Expand Down Expand Up @@ -815,4 +816,9 @@ public IParameterService getParameterService() {
public void setExtensionService(IExtensionService extensionService) {
this.extensionService = extensionService;
}

public PermissionType[] getSymTablePermissions() {
PermissionType[] permissions = { PermissionType.CREATE_TABLE, PermissionType.DROP_TABLE, PermissionType.CREATE_TRIGGER, PermissionType.DROP_TRIGGER };
return permissions;
}
}

0 comments on commit ac697b2

Please sign in to comment.