Skip to content

Commit

Permalink
Merge branch '3.7' of https://github.com/JumpMind/symmetric-ds into 3.8
Browse files Browse the repository at this point in the history
Conflicts:
	symmetric-client/src/main/java/org/jumpmind/symmetric/db/JdbcSymmetricDialectFactory.java
	symmetric-client/src/main/java/org/jumpmind/symmetric/util/SnapshotUtil.java
  • Loading branch information
erilong committed May 23, 2016
2 parents ad9660f + 38f0acb commit 6396eb9
Show file tree
Hide file tree
Showing 28 changed files with 938 additions and 102 deletions.
2 changes: 2 additions & 0 deletions symmetric-assemble/common.gradle
Expand Up @@ -167,6 +167,7 @@ subprojects { subproject ->
servletVersion = '3.1.0'
springVersion = '4.0.5.RELEASE'
jtdsVersion = '1.2.8'
voltDbVersion = '6.2'
bouncyCastleVersion = '140'
animalSnifferVersion = '1.10'
jnaVersion = '4.1.0'
Expand All @@ -189,6 +190,7 @@ subprojects { subproject ->
provided "jdbc.postgresql:postgresql:$postgresqlVersion"
provided "jdbc:ojdbc:11.2.0.3"
provided "net.sourceforge.jtds:jtds:$jtdsVersion"
provided "org.voltdb:voltdbclient:$voltDbVersion"
provided "org.hsqldb:hsqldb:$hsqldbVersion:jdk5"
provided "com.h2database:h2:$h2Version"
provided "org.xerial:sqlite-jdbc:$sqliteVersion"
Expand Down
18 changes: 18 additions & 0 deletions symmetric-assemble/src/asciidoc/appendix/mysql.ad
Expand Up @@ -39,3 +39,21 @@ If you are using UTF-8 encoding in the database, you might consider using the ch
----
jdbc:mysql://hostname/databasename?tinyInt1isBit=false&characterEncoding=utf8
----

.Supported Data Types
|===
|Data Type|Supported?

|TinyInt, SmallInt, Int, MediumInt, BigInt|Yes
|Decimal, Numeric|Yes
|Float, Double|Yes
|Bit|Yes
|Date, DateTime, TimeStamp, Time, Year|Yes
|Char, Varchar|Yes
|Binary, VarBinary|Yes
|TinyBlob, Blob, MediumBlob, BigBlob|Yes
|TinyText, Text, MediumText, BigText|Yes
|Enum|No
|Set|No
|Geometry, Point, LineString, Polygon, GeometryCollection, MultiPoint, MultiLinestring, MultiPolygon|No
|===
Expand Up @@ -99,12 +99,16 @@ protected boolean executeWithOptions(CommandLine line) throws Exception {
dbCompare.setIncludedTableNames(Arrays.asList(line.getArgList().get(0).toString().split(",")));
}

String numericScaleArg = line.getOptionValue(OPTION_NUMERIC_SCALE);
if (!StringUtils.isEmpty(numericScaleArg)) {
try {
dbCompare.setNumericScale(Integer.parseInt(numericScaleArg.trim()));
} catch (Exception ex) {
throw new ParseException("Failed to parse arg [" + numericScaleArg + "] " + ex);
}
}

DbCompareReport report = dbCompare.compare();
// if (report.getTableReports() != null) {
// for (TableReport tableReport : report.getTableReports()) {
// System.out.println(tableReport);
// }
// }

return false;
}
Expand All @@ -125,6 +129,8 @@ protected static void initFromServerProperties() {
private static final String OPTION_USE_SYM_CONFIG = "use-sym-config";

private static final String OPTION_OUTPUT_SQL = "output-sql";

private static final String OPTION_NUMERIC_SCALE = "numeric-scale";

@Override
protected void printHelp(CommandLine cmd, Options options) {
Expand All @@ -141,6 +147,7 @@ protected void buildOptions(Options options) {
addOption(options, null, OPTION_EXCLUDE, true);
addOption(options, null, OPTION_USE_SYM_CONFIG, false);
addOption(options, null, OPTION_OUTPUT_SQL, true);
addOption(options, null, OPTION_NUMERIC_SCALE, true);
}

}
Expand Up @@ -43,6 +43,7 @@
import org.jumpmind.db.platform.redshift.RedshiftDatabasePlatform;
import org.jumpmind.db.platform.sqlanywhere.SqlAnywhereDatabasePlatform;
import org.jumpmind.db.platform.sqlite.SqliteDatabasePlatform;
import org.jumpmind.db.platform.voltdb.VoltDbDatabasePlatform;
import org.jumpmind.symmetric.db.ase.AseSymmetricDialect;
import org.jumpmind.symmetric.db.db2.Db2As400SymmetricDialect;
import org.jumpmind.symmetric.db.db2.Db2SymmetricDialect;
Expand All @@ -68,6 +69,7 @@
import org.jumpmind.symmetric.db.sqlanywhere.SqlAnywhereSymmetricDialect;
import org.jumpmind.symmetric.db.sqlite.SqliteJdbcSymmetricDialect;
import org.jumpmind.symmetric.service.IContextService;
import org.jumpmind.symmetric.db.voltdb.VoltDbSymmetricDialect;
import org.jumpmind.symmetric.service.IParameterService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -153,6 +155,8 @@ public ISymmetricDialect create() {
dialect = new InterbaseSymmetricDialect(parameterService, platform);
} else if (platform instanceof SqliteDatabasePlatform) {
dialect = new SqliteJdbcSymmetricDialect(parameterService, contextService, platform);
} else if (platform instanceof VoltDbDatabasePlatform) {
dialect = new VoltDbSymmetricDialect(parameterService, platform);
} else {
throw new DbNotSupportedException();
}
Expand Down
Expand Up @@ -342,9 +342,8 @@ public void enableSyncTriggers(ISqlTransaction transaction) {
}

public String getSyncTriggersExpression() {
//return "$(defaultCatalog)dbo." + parameterService.getTablePrefix()
// + "_triggers_disabled() = 0";
return "dbo." + parameterService.getTablePrefix()
String catalog = parameterService.is(ParameterConstants.MSSQL_INCLUDE_CATALOG_IN_TRIGGERS, true) ? "$(defaultCatalog)" : "";
return catalog + "dbo." + parameterService.getTablePrefix()
+ "_triggers_disabled() = 0";
}

Expand Down
Expand Up @@ -58,8 +58,8 @@ public MsSqlTriggerTemplate(ISymmetricDialect symmetricDialect) {
numberColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else ('\"' + convert(varchar(40), $(tableAlias).\"$(columnName)\",2) + '\"') end" ;
datetimeColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else ('\"' + convert(varchar,$(tableAlias).\"$(columnName)\",121) + '\"') end" ;
clobColumnTemplate = "case when $(origTableAlias).\"$(columnName)\" is null then '' else '\"' + replace(replace(cast($(origTableAlias).\"$(columnName)\" as "+(castToNVARCHAR ? "n" : "")+"varchar(max)),'\\','\\\\'),'\"','\\\"') + '\"' end" ;
blobColumnTemplate = "case when $(origTableAlias).\"$(columnName)\" is null then '' else '\"' + replace(replace($(defaultCatalog)dbo.$(prefixName)_base64_encode(CONVERT(VARBINARY(max), $(origTableAlias).\"$(columnName)\")),'\\','\\\\'),'\"','\\\"') + '\"' end" ;
binaryColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' + replace(replace($(defaultCatalog)dbo.$(prefixName)_base64_encode(CONVERT(VARBINARY(max), $(tableAlias).\"$(columnName)\")),'\\','\\\\'),'\"','\\\"') + '\"' end" ;
blobColumnTemplate = "case when $(origTableAlias).\"$(columnName)\" is null then '' else '\"' + replace(replace(" + defaultCatalog + "dbo.$(prefixName)_base64_encode(CONVERT(VARBINARY(max), $(origTableAlias).\"$(columnName)\")),'\\','\\\\'),'\"','\\\"') + '\"' end" ;
binaryColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' + replace(replace(" + defaultCatalog + "dbo.$(prefixName)_base64_encode(CONVERT(VARBINARY(max), $(tableAlias).\"$(columnName)\")),'\\','\\\\'),'\"','\\\"') + '\"' end" ;
booleanColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' when $(tableAlias).\"$(columnName)\" = 1 then '\"1\"' else '\"0\"' end" ;
triggerConcatCharacter = "+" ;
newTriggerValue = "inserted" ;
Expand Down
@@ -0,0 +1,79 @@
/**
* 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.voltdb;

import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.sql.ISqlTransaction;
import org.jumpmind.db.util.BinaryEncoding;
import org.jumpmind.symmetric.db.AbstractSymmetricDialect;
import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.db.JdbcSymmetricDialectFactory;
import org.jumpmind.symmetric.db.postgresql.GreenplumTriggerTemplate;
import org.jumpmind.symmetric.service.IParameterService;

public class VoltDbSymmetricDialect extends AbstractSymmetricDialect {

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

@Override
public void cleanDatabase() {
}

@Override
public void dropRequiredDatabaseObjects() {
}

@Override
public void createRequiredDatabaseObjects() {
}

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

@Override
public void disableSyncTriggers(ISqlTransaction transaction, String nodeId) {
// VoltDB doesn't support triggers currently.
}

@Override
public void enableSyncTriggers(ISqlTransaction transaction) {
// VoltDB doesn't support triggers currently.
}

/* (non-Javadoc)
* @see org.jumpmind.symmetric.db.ISymmetricDialect#getSyncTriggersExpression()
*/
@Override
public String getSyncTriggersExpression() {
return null;
}

@Override
protected boolean doesTriggerExistOnPlatform(String catalogName, String schema, String tableName, String triggerName) {
return false;
}

}
@@ -0,0 +1,72 @@
/**
* 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.voltdb;

import java.util.HashMap;

import org.jumpmind.symmetric.db.AbstractTriggerTemplate;
import org.jumpmind.symmetric.db.ISymmetricDialect;

public class VoltDbTriggerTemplate extends AbstractTriggerTemplate {

public VoltDbTriggerTemplate(ISymmetricDialect symmetricDialect) {
super(symmetricDialect);
emptyColumnTemplate = "''" ;
stringColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' || replace(replace($(tableAlias).\"$(columnName)\",'\\','\\\\'),'\"','\\\"')|| '\"' end " ;
numberColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"'||cast($(tableAlias).\"$(columnName)\" as varchar(50))||'\"' end " ;
datetimeColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"'|| cast($(tableAlias).\"$(columnName)\" as varchar) || '\"' end " ;
clobColumnTemplate = stringColumnTemplate;
blobColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"'||replace(replace(sym_BASE64_ENCODE($(tableAlias).\"$(columnName)\"),'\\','\\\\'),'\"','\\\"')||'\"' end " ;
booleanColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' when $(tableAlias).\"$(columnName)\" then '\"1\"' else '\"0\"' end " ;
triggerConcatCharacter = "||" ;
newTriggerValue = "" ;
oldTriggerValue = "" ;
// timeColumnTemplate = null;
// dateColumnTemplate = null;
// clobColumnTemplate = "case when $(tableAlias)..\"$(columnName)\" is null then '' else '\"' || replace(replace($(tableAlias)..\"$(columnName)\",$$\\$$,$$\\\\$$),'\"',$$\\\"$$) || '\"' end" ;
// blobColumnTemplate = "case when $(tableAlias)..\"$(columnName)\" is null then '' else '\"' || pg_catalog.encode($(tableAlias)..\"$(columnName)\", 'base64') || '\"' end" ;
// wrappedBlobColumnTemplate = "case when $(tableAlias)..\"$(columnName)\" is null then '' else '\"' || $(defaultSchema)$(prefixName)_largeobject($(tableAlias)..\"$(columnName)\") || '\"' end" ;
// booleanColumnTemplate = "case when $(tableAlias)..\"$(columnName)\" is null then '' when $(tableAlias)..\"$(columnName)\" then '\"1\"' else '\"0\"' end" ;
// triggerConcatCharacter = "||" ;
// newTriggerValue = "new" ;
// oldTriggerValue = "old" ;
// oldColumnPrefix = "" ;
// newColumnPrefix = "" ;
// otherColumnTemplate = null;

sqlTemplates = new HashMap<String,String>();

sqlTemplates.put("insertTriggerTemplate" , "");
sqlTemplates.put("updateTriggerTemplate" , "");
sqlTemplates.put("deleteTriggerTemplate" , "");
sqlTemplates.put("initialLoadSqlTemplate" ,
"select $(columns) from $(schemaName)$(tableName) t where $(whereClause) " );
}

//
// sqlTemplates.put("deletePostTriggerTemplate" ,
//"create trigger $(triggerName) after delete on $(schemaName)$(tableName) " +
//" for each row execute procedure $(schemaName)f$(triggerName)(); " );
//
// sqlTemplates.put("initialLoadSqlTemplate" ,
//"select $(columns) from $(schemaName)$(tableName) t where $(whereClause) " );
// }
}

0 comments on commit 6396eb9

Please sign in to comment.