From 3b0a65bd26b8f799a4eecb5e75fa0b72a606eb7b Mon Sep 17 00:00:00 2001 From: Ralf Wisser Date: Tue, 5 Nov 2019 10:13:43 +0100 Subject: [PATCH] new DBMS property "experimentalTypeReplacement" --- .../net/sf/jailer/configuration/DBMS.java | 20 +++++++++++++++++++ .../engine/net/sf/jailer/ddl/DDLCreator.java | 19 +++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/main/engine/net/sf/jailer/configuration/DBMS.java b/src/main/engine/net/sf/jailer/configuration/DBMS.java index ad163cfb8..6279fe549 100644 --- a/src/main/engine/net/sf/jailer/configuration/DBMS.java +++ b/src/main/engine/net/sf/jailer/configuration/DBMS.java @@ -80,6 +80,7 @@ public class DBMS { this.testQuery = other.testQuery; this.statisticRenovator = other.statisticRenovator; this.typeReplacement = other.typeReplacement; + this.experimentalTypeReplacement = other.experimentalTypeReplacement; this.stringLiteralEscapeSequences = other.stringLiteralEscapeSequences; this.sqlLimitSuffix = other.sqlLimitSuffix; this.varcharLengthLimit = other.varcharLengthLimit; @@ -206,6 +207,11 @@ public class DBMS { */ private Map typeReplacement = new HashMap(); + /** + * Replacement map for column types used for DDL generation. Only used if DBMS accept it. + */ + private Map experimentalTypeReplacement = new HashMap(); + /** * Replacement map for special characters in string literals. */ @@ -505,6 +511,13 @@ public class DBMS { typeReplacement = tr; } + /** + * Sets replacement map for column types used for DDL generation. Only used if DBMS accept it. + */ + public void setExperimentalTypeReplacement(Map tr) { + experimentalTypeReplacement = tr; + } + /** * @return the toBlob */ @@ -550,6 +563,13 @@ public class DBMS { return typeReplacement; } + /** + * Sets replacement map for column types used for DDL generation. Only used if DBMS accept it. + */ + public Map getExperimentalTypeReplacement() { + return experimentalTypeReplacement; + } + /** * Sets manager for session local temporary tables. */ diff --git a/src/main/engine/net/sf/jailer/ddl/DDLCreator.java b/src/main/engine/net/sf/jailer/ddl/DDLCreator.java index 2c0bcb538..4960ff5d0 100644 --- a/src/main/engine/net/sf/jailer/ddl/DDLCreator.java +++ b/src/main/engine/net/sf/jailer/ddl/DDLCreator.java @@ -101,6 +101,23 @@ public class DDLCreator { */ public boolean createDDL(DataModel datamodel, Session session, WorkingTableScope temporaryTableScope, String workingTableSchema) throws FileNotFoundException, IOException, SQLException { RowIdSupport rowIdSupport = new RowIdSupport(datamodel, targetDBMS(session), executionContext); + if (session != null && session.dbms.getExperimentalTypeReplacement() != null) { + Map oldTypeReplacement = session.dbms.getTypeReplacement(); + if (oldTypeReplacement == null) { + session.dbms.setTypeReplacement(session.dbms.getExperimentalTypeReplacement()); + } else { + HashMap repl = new HashMap(session.dbms.getExperimentalTypeReplacement()); + repl.putAll(session.dbms.getExperimentalTypeReplacement()); + session.dbms.setTypeReplacement(repl); + } + try { + return createDDL(datamodel, session, temporaryTableScope, rowIdSupport, workingTableSchema); + } catch (Throwable t) { + // fall through + } finally { + session.dbms.setTypeReplacement(oldTypeReplacement); + } + } return createDDL(datamodel, session, temporaryTableScope, rowIdSupport, workingTableSchema); } @@ -119,7 +136,7 @@ public class DDLCreator { /** * Creates the DDL for the working-tables. */ - public boolean createDDL(DataModel datamodel, Session session, WorkingTableScope temporaryTableScope, RowIdSupport rowIdSupport, String workingTableSchema, boolean withTableProperties) throws FileNotFoundException, IOException, SQLException { + private boolean createDDL(DataModel datamodel, Session session, WorkingTableScope temporaryTableScope, RowIdSupport rowIdSupport, String workingTableSchema, boolean withTableProperties) throws FileNotFoundException, IOException, SQLException { uPKWasTooLong = false; try { return createDDL(datamodel, session, temporaryTableScope, 0, rowIdSupport, workingTableSchema, withTableProperties);