new DBMS property "experimentalTypeReplacement"

This commit is contained in:
Ralf Wisser
2019-11-05 10:13:43 +01:00
parent 02ff08b3dc
commit 3b0a65bd26
2 changed files with 38 additions and 1 deletions
@@ -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<String, String> typeReplacement = new HashMap<String, String>();
/**
* Replacement map for column types used for DDL generation. Only used if DBMS accept it.
*/
private Map<String, String> experimentalTypeReplacement = new HashMap<String, String>();
/**
* 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<String, String> 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<String, String> getExperimentalTypeReplacement() {
return experimentalTypeReplacement;
}
/**
* Sets manager for session local temporary tables.
*/
@@ -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<String, String> oldTypeReplacement = session.dbms.getTypeReplacement();
if (oldTypeReplacement == null) {
session.dbms.setTypeReplacement(session.dbms.getExperimentalTypeReplacement());
} else {
HashMap<String, String> repl = new HashMap<String, String>(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);