Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-04-03 07:55:06 +0000
committerEike Stepper2020-04-03 07:55:06 +0000
commitcc6e929b042369cb56a2a30436f150b337ddd664 (patch)
tree722b6f86cd8d177507055acf6e24a75fd8f5d101
parent63f22c8a00539d2404a1b4ce48eb71b9c80df603 (diff)
downloadcdo-cc6e929b042369cb56a2a30436f150b337ddd664.tar.gz
cdo-cc6e929b042369cb56a2a30436f150b337ddd664.tar.xz
cdo-cc6e929b042369cb56a2a30436f150b337ddd664.zip
[546872] MySQL8 Error: "Table definition has changed" on initialising new CDO repository
https://bugs.eclipse.org/bugs/show_bug.cgi?id=546872
-rw-r--r--features/org.eclipse.emf.cdo.server.db-feature/feature.xml2
-rw-r--r--features/org.eclipse.emf.cdo.server.db-feature/pom.xml2
-rw-r--r--features/org.eclipse.net4j.db-feature/feature.xml2
-rw-r--r--features/org.eclipse.net4j.db-feature/pom.xml2
-rw-r--r--features/org.eclipse.net4j.db.mysql-feature/feature.xml2
-rw-r--r--features/org.eclipse.net4j.db.mysql-feature/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml4
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Mysql).launch2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/META-INF/MANIFEST.MF18
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/install-db/install-mysql.ant56
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AbstractSetupDBConfig.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java52
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java95
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MultiValuedOfAttributeTest.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SetFeatureTest.java14
-rw-r--r--plugins/org.eclipse.net4j.db.mysql/.settings/.api_filters7
-rw-r--r--plugins/org.eclipse.net4j.db.mysql/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.net4j.db.mysql/pom.xml2
-rw-r--r--plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/mysql/MYSQLAdapter.java171
-rw-r--r--plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF24
-rw-r--r--plugins/org.eclipse.net4j.db/pom.xml2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBField.java10
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java35
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBField.java13
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java45
43 files changed, 593 insertions, 162 deletions
diff --git a/features/org.eclipse.emf.cdo.server.db-feature/feature.xml b/features/org.eclipse.emf.cdo.server.db-feature/feature.xml
index d541456cb4..c40223b1e4 100644
--- a/features/org.eclipse.emf.cdo.server.db-feature/feature.xml
+++ b/features/org.eclipse.emf.cdo.server.db-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.emf.cdo.server.db"
label="%featureName"
- version="4.8.1.qualifier"
+ version="4.9.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.emf.cdo.license"
license-feature-version="0.0.0">
diff --git a/features/org.eclipse.emf.cdo.server.db-feature/pom.xml b/features/org.eclipse.emf.cdo.server.db-feature/pom.xml
index 8c8cefc779..c8682efcf3 100644
--- a/features/org.eclipse.emf.cdo.server.db-feature/pom.xml
+++ b/features/org.eclipse.emf.cdo.server.db-feature/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo.features</groupId>
<artifactId>org.eclipse.emf.cdo.server.db</artifactId>
- <version>4.8.1-SNAPSHOT</version>
+ <version>4.9.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/features/org.eclipse.net4j.db-feature/feature.xml b/features/org.eclipse.net4j.db-feature/feature.xml
index a7aea4cbe6..1dae8377b6 100644
--- a/features/org.eclipse.net4j.db-feature/feature.xml
+++ b/features/org.eclipse.net4j.db-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.net4j.db"
label="%featureName"
- version="4.9.1.qualifier"
+ version="4.10.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.emf.cdo.license"
license-feature-version="0.0.0">
diff --git a/features/org.eclipse.net4j.db-feature/pom.xml b/features/org.eclipse.net4j.db-feature/pom.xml
index ecdddb1588..93015026ae 100644
--- a/features/org.eclipse.net4j.db-feature/pom.xml
+++ b/features/org.eclipse.net4j.db-feature/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo.features</groupId>
<artifactId>org.eclipse.net4j.db</artifactId>
- <version>4.9.1-SNAPSHOT</version>
+ <version>4.10.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/features/org.eclipse.net4j.db.mysql-feature/feature.xml b/features/org.eclipse.net4j.db.mysql-feature/feature.xml
index 35493d0bf5..11bf358974 100644
--- a/features/org.eclipse.net4j.db.mysql-feature/feature.xml
+++ b/features/org.eclipse.net4j.db.mysql-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.net4j.db.mysql"
label="%featureName"
- version="4.3.0.qualifier"
+ version="4.3.1.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.emf.cdo.license"
license-feature-version="0.0.0">
diff --git a/features/org.eclipse.net4j.db.mysql-feature/pom.xml b/features/org.eclipse.net4j.db.mysql-feature/pom.xml
index 56741e2f45..b00b4eff04 100644
--- a/features/org.eclipse.net4j.db.mysql-feature/pom.xml
+++ b/features/org.eclipse.net4j.db.mysql-feature/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo.features</groupId>
<artifactId>org.eclipse.net4j.db.mysql</artifactId>
- <version>4.3.0-SNAPSHOT</version>
+ <version>4.3.1-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml b/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml
index 65b63a4128..591c238862 100644
--- a/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml
+++ b/plugins/org.eclipse.emf.cdo.examples.installer/examples/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml
@@ -71,6 +71,10 @@
<!-- Maximum number of store accessors (JDBC connections) to keep in the writer pool. The default value is 15. -->
<property name="writerPoolCapacity" value="20"/>
+ <!-- Example for Mysql with 4 bytes per char:
+ <property name="externalRefsURIColumnType" value="VARCHAR"/>
+ <property name="externalRefsURIColumnLength" value="768"/>
+ -->
<mappingStrategy type="horizontal"> <!-- callout -->
<property name="qualifiedNames" value="true"/>
diff --git a/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml b/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml
index 65b63a4128..591c238862 100644
--- a/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml
+++ b/plugins/org.eclipse.emf.cdo.examples.master/config/cdo-server.xml
@@ -71,6 +71,10 @@
<!-- Maximum number of store accessors (JDBC connections) to keep in the writer pool. The default value is 15. -->
<property name="writerPoolCapacity" value="20"/>
+ <!-- Example for Mysql with 4 bytes per char:
+ <property name="externalRefsURIColumnType" value="VARCHAR"/>
+ <property name="externalRefsURIColumnLength" value="768"/>
+ -->
<mappingStrategy type="horizontal"> <!-- callout -->
<property name="qualifiedNames" value="true"/>
diff --git a/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
index e4a10d1238..e137eee69a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.server.db;singleton:=true
-Bundle-Version: 4.8.1.qualifier
+Bundle-Version: 4.9.0.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -12,11 +12,11 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.net4j.db;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.server.db;version="4.8.1",
- org.eclipse.emf.cdo.server.db.mapping;version="4.8.1",
- org.eclipse.emf.cdo.server.internal.db;version="4.8.1";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db,org.eclipse.emf.cdo.explorer.ui",
- org.eclipse.emf.cdo.server.internal.db.bundle;version="4.8.1";x-internal:=true,
- org.eclipse.emf.cdo.server.internal.db.mapping;version="4.8.1";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
- org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;version="4.8.1";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
- org.eclipse.emf.cdo.server.internal.db.messages;version="4.8.1";x-internal:=true
+Export-Package: org.eclipse.emf.cdo.server.db;version="4.9.0",
+ org.eclipse.emf.cdo.server.db.mapping;version="4.9.0",
+ org.eclipse.emf.cdo.server.internal.db;version="4.9.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db,org.eclipse.emf.cdo.explorer.ui",
+ org.eclipse.emf.cdo.server.internal.db.bundle;version="4.9.0";x-internal:=true,
+ org.eclipse.emf.cdo.server.internal.db.mapping;version="4.9.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
+ org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;version="4.9.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
+ org.eclipse.emf.cdo.server.internal.db.messages;version="4.9.0";x-internal:=true
Automatic-Module-Name: org.eclipse.emf.cdo.server.db
diff --git a/plugins/org.eclipse.emf.cdo.server.db/pom.xml b/plugins/org.eclipse.emf.cdo.server.db/pom.xml
index c40946652d..878be59ee1 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/pom.xml
+++ b/plugins/org.eclipse.emf.cdo.server.db/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.emf.cdo.server.db</artifactId>
- <version>4.8.1-SNAPSHOT</version>
+ <version>4.9.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java
index 4b83aa1833..5dce3e2bd0 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.IStoreAccessor.UnitSupport;
import org.eclipse.net4j.db.IDBConnection;
+import org.eclipse.net4j.db.IDBSchemaTransaction;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.emf.ecore.EClass;
@@ -56,4 +57,9 @@ public interface IDBStoreAccessor extends IStoreAccessor.Raw2, UnitSupport
* @since 4.6
*/
public void tableCreated(IDBTable table);
+
+ /**
+ * @since 4.9
+ */
+ public IDBSchemaTransaction openSchemaTransaction();
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index 8fadd89afe..c6d5dfbfda 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -72,11 +72,13 @@ import org.eclipse.net4j.db.BatchedStatement;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBConnection;
+import org.eclipse.net4j.db.IDBDatabase;
import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.IDBSchemaTransaction;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.internal.db.ddl.DBField;
+import org.eclipse.net4j.spi.db.DBAdapter;
import org.eclipse.net4j.util.HexUtil;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.StringUtil;
@@ -193,6 +195,16 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
return new DBStoreChunkReader(this, revision, feature);
}
+ @Override
+ public IDBSchemaTransaction openSchemaTransaction()
+ {
+ DBStore store = getStore();
+ DBAdapter dbAdapter = (DBAdapter)store.getDBAdapter();
+ IDBDatabase database = store.getDatabase();
+
+ return dbAdapter.openSchemaTransaction(database, connection);
+ }
+
/**
* Returns an iterator that iterates over all objects in the store and makes their CDOIDs available for processing.
* This method is supposed to be called very infrequently, for example during the recovery from a crash.
@@ -1248,7 +1260,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
// rawImportPackageUnits(in, fromCommitTime, toCommitTime, packageUnits, monitor.fork());
- IDBSchemaTransaction schemaTransaction = store.getDatabase().openSchemaTransaction();
+ IDBSchemaTransaction schemaTransaction = openSchemaTransaction();
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
index eff058236c..7790ff04dc 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
@@ -41,6 +41,7 @@ import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
/**
@@ -56,6 +57,10 @@ public class ExternalReferenceManager extends Lifecycle
private static final String EXTERNAL_REFS_COMMITTIME = "COMMITTIME";
+ private static final DBType DEFAULT_URI_COLUMN_TYPE = DBType.VARCHAR;
+
+ private static final int DEFAULT_URI_COLUMN_LENGTH = 1024;
+
private static final int NULL = 0;
private IDBTable table;
@@ -181,7 +186,7 @@ public class ExternalReferenceManager extends Lifecycle
{
super.doActivate();
- final IDBStore store = idHandler.getStore();
+ IDBStore store = idHandler.getStore();
IDBDatabase database = store.getDatabase();
table = database.getSchema().getTable(EXTERNAL_REFS);
@@ -192,9 +197,16 @@ public class ExternalReferenceManager extends Lifecycle
@Override
public void run(IDBSchema schema)
{
+ DBType idColumnType = idHandler.getDBType();
+ int idColumnLength = store.getIDColumnLength();
+
+ Map<String, String> properties = store.getProperties();
+ DBType uriColumnType = DBType.getTypeByKeyword(properties.getOrDefault("externalRefsURIColumnType", DEFAULT_URI_COLUMN_TYPE.getKeyword()));
+ int uriColumnLength = Integer.parseInt(properties.getOrDefault("externalRefsURIColumnLength", Integer.toString(DEFAULT_URI_COLUMN_LENGTH)));
+
table = schema.addTable(EXTERNAL_REFS);
- table.addField(EXTERNAL_REFS_ID, idHandler.getDBType(), store.getIDColumnLength(), true);
- table.addField(EXTERNAL_REFS_URI, DBType.VARCHAR, 1024);
+ table.addField(EXTERNAL_REFS_ID, idColumnType, idColumnLength, true);
+ table.addField(EXTERNAL_REFS_URI, uriColumnType, uriColumnLength);
table.addField(EXTERNAL_REFS_COMMITTIME, DBType.BIGINT);
table.addIndex(IDBIndex.Type.PRIMARY_KEY, EXTERNAL_REFS_ID);
table.addIndex(IDBIndex.Type.NON_UNIQUE, EXTERNAL_REFS_URI);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java
index 1537e506e1..fb0ceed5c8 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java
@@ -23,6 +23,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
+import org.eclipse.net4j.spi.db.DBAdapter;
import java.sql.Clob;
import java.sql.ResultSet;
@@ -185,7 +186,7 @@ public class SQLQueryHandler implements IQueryHandler
for (int i = 0; i < indexes.length; i++)
{
Object parameter = info.getParameters().get(key);
- // parameter = convertToSQL(parameter);
+ parameter = convertToSQL(parameter);
stmt.setObject(indexes[i], parameter);
}
}
@@ -262,16 +263,10 @@ public class SQLQueryHandler implements IQueryHandler
}
}
- @SuppressWarnings("unused")
- private Object convertToSQL(Object value)
+ protected Object convertToSQL(Object value)
{
- if (value instanceof java.util.Date)
- {
- java.util.Date date = (java.util.Date)value;
- value = new java.sql.Date(date.getTime());
- }
-
- return value;
+ DBAdapter dbAdapter = (DBAdapter)accessor.getStore().getDBAdapter();
+ return dbAdapter.convertToSQL(value);
}
private Object convertFromSQL(Object value)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java
index 24df9296d5..e0e34f3efd 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java
@@ -44,9 +44,11 @@ import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBConnection;
+import org.eclipse.net4j.db.IDBDatabase;
import org.eclipse.net4j.db.IDBSchemaTransaction;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBTable;
+import org.eclipse.net4j.spi.db.DBAdapter;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.collection.CloseableIterator;
@@ -583,7 +585,10 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp
{
if (workingCopy == null)
{
- schemaTransaction = getStore().getDatabase().openSchemaTransaction((IDBConnection)connection);
+ DBAdapter dbAdapter = (DBAdapter)store.getDBAdapter();
+ IDBDatabase database = store.getDatabase();
+
+ schemaTransaction = dbAdapter.openSchemaTransaction(database, (IDBConnection)connection);
workingCopy = schemaTransaction.getWorkingCopy();
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
index df1556783e..f5cb243d18 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
@@ -141,7 +141,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping, I
{
if (accessor != null)
{
- IDBSchemaTransaction schemaTransaction = database.openSchemaTransaction();
+ IDBSchemaTransaction schemaTransaction = accessor.openSchemaTransaction();
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
index 3aab913f53..d44ed62c98 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
@@ -111,7 +111,7 @@ public abstract class AbstractListTableMapping extends AbstractBasicListTableMap
{
if (accessor != null)
{
- IDBSchemaTransaction schemaTransaction = database.openSchemaTransaction();
+ IDBSchemaTransaction schemaTransaction = accessor.openSchemaTransaction();
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
index dbac1a5ff0..9f8c1a6291 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
@@ -156,7 +156,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
{
if (accessor != null)
{
- IDBSchemaTransaction schemaTransaction = database.openSchemaTransaction();
+ IDBSchemaTransaction schemaTransaction = accessor.openSchemaTransaction();
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
index cf38d65684..a9c502d9a3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
@@ -150,7 +150,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
{
if (accessor != null)
{
- IDBSchemaTransaction schemaTransaction = database.openSchemaTransaction();
+ IDBSchemaTransaction schemaTransaction = accessor.openSchemaTransaction();
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml b/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml
index 0c8788bda5..519977fbec 100644
--- a/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml
+++ b/plugins/org.eclipse.emf.cdo.server.product/config/cdo-server.xml
@@ -71,6 +71,10 @@
<!-- Maximum number of store accessors (JDBC connections) to keep in the writer pool. The default value is 15. -->
<property name="writerPoolCapacity" value="20"/>
+ <!-- Example for Mysql with 4 bytes per char:
+ <property name="externalRefsURIColumnType" value="VARCHAR"/>
+ <property name="externalRefsURIColumnLength" value="768"/>
+ -->
<mappingStrategy type="horizontal"> <!-- callout -->
<property name="qualifiedNames" value="true"/>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Mysql).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Mysql).launch
index 8a8349be8b..e79e14ed82 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Mysql).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Mysql).launch
@@ -12,5 +12,5 @@
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBMysql"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m&#13;&#10;-Xmx1024m"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms512m&#13;&#10;-Xmx2G"/>
</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests.db/META-INF/MANIFEST.MF
index 9006ad3054..3ac0858ef1 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.tests.db/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.tests.db;singleton:=true
-Bundle-Version: 4.1.0.qualifier
+Bundle-Version: 4.1.1.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -27,12 +27,12 @@ Import-Package: com.mysql.jdbc.jdbc2.optional;version="[5.0.0,6.0.0)",
org.hsqldb.jdbc;version="[2.0.0,3.0.0)",
org.postgresql.ds;version="[9.0.0,10.0.0)",
org.postgresql.ds.common;version="[9.0.0,10.0.0)"
-Export-Package: org.eclipse.emf.cdo.tests.db;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests.all",
- org.eclipse.emf.cdo.tests.db.bugzilla;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests.all",
- org.eclipse.emf.cdo.tests.db.bundle;version="4.1.0";x-internal:=true,
- org.eclipse.emf.cdo.tests.db.capabilities;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests.all",
- org.eclipse.emf.cdo.tests.db.offline;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests.all",
- org.eclipse.emf.cdo.tests.db.performance;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests.all",
- org.eclipse.emf.cdo.tests.db.revisioncache;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests.all",
- org.eclipse.emf.cdo.tests.db.verifier;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests.all"
+Export-Package: org.eclipse.emf.cdo.tests.db;version="4.1.1";x-friends:="org.eclipse.emf.cdo.tests.all",
+ org.eclipse.emf.cdo.tests.db.bugzilla;version="4.1.1";x-friends:="org.eclipse.emf.cdo.tests.all",
+ org.eclipse.emf.cdo.tests.db.bundle;version="4.1.1";x-internal:=true,
+ org.eclipse.emf.cdo.tests.db.capabilities;version="4.1.1";x-friends:="org.eclipse.emf.cdo.tests.all",
+ org.eclipse.emf.cdo.tests.db.offline;version="4.1.1";x-friends:="org.eclipse.emf.cdo.tests.all",
+ org.eclipse.emf.cdo.tests.db.performance;version="4.1.1";x-friends:="org.eclipse.emf.cdo.tests.all",
+ org.eclipse.emf.cdo.tests.db.revisioncache;version="4.1.1";x-friends:="org.eclipse.emf.cdo.tests.all",
+ org.eclipse.emf.cdo.tests.db.verifier;version="4.1.1";x-friends:="org.eclipse.emf.cdo.tests.all"
Automatic-Module-Name: org.eclipse.emf.cdo.tests.db
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/install-db/install-mysql.ant b/plugins/org.eclipse.emf.cdo.tests.db/install-db/install-mysql.ant
new file mode 100644
index 0000000000..35b264938e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests.db/install-db/install-mysql.ant
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<!--
+ Copyright (c) 2020 Eike Stepper (Loehne, Germany) and others.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/epl-v10.html
+
+ Contributors:
+ Eike Stepper - initial API and implementation
+-->
+<project name="install-mysql" default="install-mysql">
+
+ <condition property="isWindows">
+ <os family="windows" />
+ </condition>
+ <fail unless="isWindows" message="This script does only work on Windows!" />
+
+ <!-- No backslashes! -->
+ <property file="${user.home}/install-mysql.properties" />
+ <property name="bin.dir" value="C:/develop/bin" />
+ <property name="mysql.name" value="mysql-5.7.28-winx64" />
+
+ <property name="zip.file" value="${mysql.name}.zip" />
+ <property name="mysql.url" value="https://cdn.mysql.com/archives/mysql-5.7/${zip.file}" />
+
+ <target name="install-mysql">
+ <get src="${mysql.url}" dest="${java.io.tmpdir}/${zip.file}" usetimestamp="true" />
+
+ <property name="mysql.root" value="${bin.dir}/${mysql.name}" />
+ <delete dir="${mysql.root}" includeemptydirs="true" failonerror="false" />
+ <unzip src="${java.io.tmpdir}/${zip.file}" dest="${mysql.root}">
+ <cutdirsmapper dirs="1" />
+ </unzip>
+
+ <mkdir dir="${mysql.root}/data" />
+ <echo message="Initializing data..." />
+ <exec executable="${mysql.root}/bin/mysqld.exe">
+ <arg value="--basedir=${mysql.root}" />
+ <arg value="--datadir=${mysql.root}/data" />
+ <arg value="--pid-file=data.pid" />
+ <arg value="--initialize-insecure" />
+ </exec>
+
+ <echo file="${mysql.root}/server-start.cmd">@rem off
+set BASEDIR=${mysql.root}
+cd %BASEDIR%
+start "MySQL Server" bin\mysqld.exe --basedir=%BASEDIR% --datadir=%BASEDIR%/data --pid-file=data.pid
+ </echo>
+
+ <echo file="${mysql.root}/server-stop.cmd">@rem off
+taskkill /IM mysqld.exe /T /F
+ </echo>
+ </target>
+
+</project>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/pom.xml b/plugins/org.eclipse.emf.cdo.tests.db/pom.xml
index 79cd12da68..52ceade937 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/pom.xml
+++ b/plugins/org.eclipse.emf.cdo.tests.db/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.emf.cdo.tests.db</artifactId>
- <version>4.1.0-SNAPSHOT</version>
+ <version>4.1.1-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AbstractSetupDBConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AbstractSetupDBConfig.java
index 01d9a6b238..64f9a04dfb 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AbstractSetupDBConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AbstractSetupDBConfig.java
@@ -42,7 +42,11 @@ public abstract class AbstractSetupDBConfig extends DBConfig
protected DataSource createDataSource(String repoName)
{
String dbName = getDBName(repoName);
- initDatabase(dbName);
+
+ if (!isRestarting())
+ {
+ initDatabase(dbName);
+ }
try
{
@@ -93,8 +97,12 @@ public abstract class AbstractSetupDBConfig extends DBConfig
stmt = connection.createStatement();
dropDatabase(connection, stmt, dbName);
}
- catch (SQLException ignore)
+ catch (SQLException ex)
{
+ if (ex.getErrorCode() != getErrorCodeDatabaseDoesNotExist())
+ {
+ ex.printStackTrace();
+ }
}
finally
{
@@ -103,6 +111,11 @@ public abstract class AbstractSetupDBConfig extends DBConfig
}
}
+ protected int getErrorCodeDatabaseDoesNotExist()
+ {
+ return 1008;
+ }
+
protected void dropDatabase(Connection connection, Statement stmt, String dbName) throws SQLException
{
stmt.execute("DROP DATABASE " + dbName);
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java
index d50b8814ed..766b4a7b73 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java
@@ -11,6 +11,7 @@
*/
package org.eclipse.emf.cdo.tests.db;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
import org.eclipse.emf.cdo.tests.BranchingTest;
import org.eclipse.emf.cdo.tests.MergingTest;
@@ -33,12 +34,6 @@ public class AllTestsDBMysql extends DBConfigs
}
@Override
- protected void initConfigSuites(TestSuite parent)
- {
- addScenario(parent, new MysqlConfig(), JVM, NATIVE);
- }
-
- @Override
protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
{
// add branching tests for this testsuite
@@ -48,4 +43,19 @@ public class AllTestsDBMysql extends DBConfigs
super.initTestClasses(testClasses, scenario);
}
+
+ @Override
+ protected void initConfigSuites(TestSuite parent)
+ {
+ addScenario(parent, new MysqlConfig(), JVM, NATIVE);
+ addScenario(parent, new MysqlConfig().idGenerationLocation(IDGenerationLocation.STORE), JVM, NATIVE);
+
+ // addScenario(parent, new MysqlConfig().supportingAudits(true).withRanges(true), JVM, NATIVE);
+ // addScenario(parent, new
+ // MysqlConfig().supportingAudits(true).withRanges(true).idGenerationLocation(IDGenerationLocation.STORE), JVM,
+ // NATIVE);
+
+ addScenario(parent, new MysqlConfig().supportingBranches(true).withRanges(true), JVM, NATIVE);
+ addScenario(parent, new MysqlConfig().supportingBranches(true).withRanges(true).idGenerationLocation(IDGenerationLocation.STORE), JVM, NATIVE);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
index 88fd51263a..36f5758c45 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java
@@ -193,7 +193,7 @@ public class DBAnnotationsTest extends AbstractCDOTest
try
{
rset.next();
- assertEquals("CLOB", rset.getString(6));
+ assertEquals(getClobString(), rset.getString(6).toUpperCase());
}
finally
{
@@ -238,7 +238,7 @@ public class DBAnnotationsTest extends AbstractCDOTest
try
{
rset.next();
- assertEquals("SUBJECT", rset.getString(3));
+ assertEquals("SUBJECT", rset.getString(3).toUpperCase());
}
finally
{
@@ -284,7 +284,7 @@ public class DBAnnotationsTest extends AbstractCDOTest
try
{
rset.next();
- assertEquals("TOPIC", rset.getString(4));
+ assertEquals("TOPIC", rset.getString(4).toUpperCase());
}
finally
{
@@ -332,8 +332,8 @@ public class DBAnnotationsTest extends AbstractCDOTest
try
{
rset.next();
- assertEquals("TOPIC", rset.getString(4));
- assertEquals("CLOB", rset.getString(6));
+ assertEquals("TOPIC", rset.getString(4).toUpperCase());
+ assertEquals(getClobString(), rset.getString(6).toUpperCase());
}
finally
{
@@ -384,7 +384,7 @@ public class DBAnnotationsTest extends AbstractCDOTest
String prefix = model1.getName().toUpperCase() + '_';
while (rset.next())
{
- String tableName = rset.getString(3);
+ String tableName = rset.getString(3).toUpperCase();
if ((prefix + "ORDERDETAIL").equalsIgnoreCase(tableName))
{
orderDetailTableCreated = true;
@@ -490,4 +490,9 @@ public class DBAnnotationsTest extends AbstractCDOTest
orderDetail.getEAnnotations().add(annotation);
}
}
+
+ private String getClobString()
+ {
+ return getRepositoryConfig().getName().toLowerCase().startsWith("mysql") ? "LONGTEXT" : "CLOB";
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
index 6a98d83bc0..b6748ad796 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfig.java
@@ -187,12 +187,18 @@ public abstract class DBConfig extends RepositoryConfig
DataSource dataSource = createDataSource(repoName);
IDBConnectionProvider connectionProvider = dbAdapter.createConnectionProvider(dataSource);
- Map<String, String> props = new HashMap<>();
- // props.put(IDBStore.Props.ID_COLUMN_LENGTH, "66");
+ Map<String, String> props = createStoreProperties();
return CDODBUtil.createStore(mappingStrategy, dbAdapter, connectionProvider, props);
}
+ protected Map<String, String> createStoreProperties()
+ {
+ Map<String, String> props = new HashMap<>();
+ // props.put(IDBStore.Props.ID_COLUMN_LENGTH, "66");
+ return props;
+ }
+
protected Map<String, String> createMappingStrategyProperties()
{
Map<String, String> props = new HashMap<>();
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java
index 47b24d761d..64417384f9 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java
@@ -17,27 +17,32 @@ import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import javax.sql.DataSource;
+import java.sql.Connection;
import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Map;
/**
+ * Instructions on how to test with MySQL for Windows:
+ * <ol>
+ * <li> Review and execute <code>/org.eclipse.emf.cdo.tests.db/install-db/install-mysql.ant</code>
+ * <li> Double-click <code>server-start.cmd</code> in the new MySQL installation
+ * <li> Run the "CDO AllTests (Mysql)" launch configuration
+ * <li> When done, double-click <code>server-stop.cmd</code> in the new MySQL installation
+ * </ol>
+ *
+ * @author Eike Stepper
* @author Simon McDuff
*/
public class MysqlConfig extends AbstractSetupDBConfig
{
public static final String DB_ADAPTER_NAME = "Mysql";
- /**
- * Instructions to test with MySQL: - create a mysql instance - set HOST to the host where the DB is running
- * (listening on TCP) - set USER to a user who can create and drop databases (root, essentially) - set PASS to the
- * password of the said user
- */
public static final String HOST = "localhost";
- public static final String SCHEMA = "big";
-
- public static final String USER = "test";
+ public static final String USER = "root";
- public static final String PASS = "0000";
+ public static final String PASS = "";
private static final long serialVersionUID = 1L;
@@ -62,14 +67,39 @@ public class MysqlConfig extends AbstractSetupDBConfig
@Override
protected DataSource createDataSourceForDB(String dbName) throws SQLException
{
+ String url = "jdbc:mysql://" + HOST;
+ if (dbName != null)
+ {
+ url += "/" + dbName;
+ }
+
MysqlDataSource dataSource = new MysqlDataSource();
- dataSource.setUrl("jdbc:mysql://" + HOST + "/" + SCHEMA);
+ dataSource.setUrl(url);
dataSource.setUser(USER);
- if (PASS != null)
+ if (PASS != null && !PASS.isEmpty())
{
dataSource.setPassword(PASS);
}
return dataSource;
}
+
+ @Override
+ protected void initDatabase(Connection connection, Statement stmt, String dbName) throws SQLException
+ {
+ stmt.execute("CREATE DATABASE " + dbName + " CHARACTER SET utf8mb4");
+ }
+
+ @Override
+ protected Map<String, String> createStoreProperties()
+ {
+ Map<String, String> props = super.createStoreProperties();
+
+ // Mysql max key length is 3072 bytes.
+ // Charset utf8mb4 uses 4 bytes per character.
+ // 3072 / 4 = 768
+ props.put("externalRefsURIColumnLength", "768");
+
+ return props;
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java
index a491ec9ed4..8947f6d626 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/Net4jDBTest.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.tests.db;
+import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.internal.db.DBStore;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
@@ -18,7 +19,7 @@ import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBTable;
-import org.eclipse.net4j.db.oracle.OracleAdapter;
+import org.eclipse.net4j.db.mysql.MYSQLAdapter;
import org.eclipse.net4j.spi.db.DBAdapter;
import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -69,24 +70,28 @@ public class Net4jDBTest extends AbstractCDOTest
public void testBinary() throws Exception
{
- if (!isOracle())
+ if (!isDB("oracle", "mysql"))
{
registerColumn(DBType.BINARY, new byte[0]);
}
- byte[] data = new byte[100];
- for (int i = 0; i < data.length; i++)
+ if (!isDB("mysql"))
{
- data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
+ byte[] data = new byte[100];
+ for (int i = 0; i < data.length; i++)
+ {
+ data[i] = (byte)(Math.random() * (Byte.MAX_VALUE - Byte.MIN_VALUE) + Byte.MIN_VALUE);
+ }
+
+ registerColumn(DBType.BINARY, data);
}
- registerColumn(DBType.BINARY, data);
doTest(getName());
}
public void testVarBinary() throws Exception
{
- if (!isOracle())
+ if (!isDB("oracle"))
{
registerColumn(DBType.VARBINARY, new byte[0]);
}
@@ -103,7 +108,7 @@ public class Net4jDBTest extends AbstractCDOTest
public void testLongVarBinary() throws Exception
{
- if (!isOracle())
+ if (!isDB("oracle"))
{
registerColumn(DBType.LONGVARBINARY, new byte[0]);
}
@@ -155,14 +160,18 @@ public class Net4jDBTest extends AbstractCDOTest
{
registerColumn(DBType.CHAR, "0");
registerColumn(DBType.CHAR, "a");
- registerColumn(DBType.CHAR, "\377"); // Fails for DB2
- registerColumn(DBType.CHAR, "\u1234"); // Fails for DB2
- doTest(getName());
- }
- public static void main(String[] args)
- {
- System.out.println((int)'\377');
+ if (!isDB("db2"))
+ {
+ registerColumn(DBType.CHAR, "\377");
+ }
+
+ if (!isDB("db2", "mysql"))
+ {
+ registerColumn(DBType.CHAR, "\u1234");
+ }
+
+ doTest(getName());
}
public void testClob() throws Exception
@@ -214,8 +223,16 @@ public class Net4jDBTest extends AbstractCDOTest
public void testFloat() throws Exception
{
- registerColumn(DBType.FLOAT, Float.MAX_VALUE);
- registerColumn(DBType.FLOAT, Float.MIN_VALUE); // Fails for DB2
+ if (!isDB("mysql"))
+ {
+ registerColumn(DBType.FLOAT, Float.MAX_VALUE);
+ }
+
+ if (!isDB("db2"))
+ {
+ registerColumn(DBType.FLOAT, Float.MIN_VALUE);
+ }
+
registerColumn(DBType.FLOAT, -.1f);
registerColumn(DBType.FLOAT, 3.33333f);
doTest(getName());
@@ -224,7 +241,12 @@ public class Net4jDBTest extends AbstractCDOTest
public void testReal() throws Exception
{
registerColumn(DBType.REAL, Float.MAX_VALUE);
- registerColumn(DBType.REAL, Float.MIN_VALUE); // Fails for DB2
+
+ if (!isDB("db2"))
+ {
+ registerColumn(DBType.REAL, Float.MIN_VALUE);
+ }
+
registerColumn(DBType.REAL, -.1f);
registerColumn(DBType.REAL, 3.33333f);
doTest(getName());
@@ -232,7 +254,7 @@ public class Net4jDBTest extends AbstractCDOTest
public void testDouble() throws Exception
{
- if (!isOracle())
+ if (!isDB("oracle"))
{
registerColumn(DBType.DOUBLE, new Double(Double.MAX_VALUE));
}
@@ -310,12 +332,17 @@ public class Net4jDBTest extends AbstractCDOTest
{
registerColumn(DBType.LONGVARCHAR, "");
- if (!isOracle()) // Only 1 LONGVARCHAR allowed per table
+ if (!isDB("oracle")) // Only 1 LONGVARCHAR allowed per table
{
registerColumn(DBType.LONGVARCHAR, "\n");
registerColumn(DBType.LONGVARCHAR, "\t");
registerColumn(DBType.LONGVARCHAR, "\r");
- registerColumn(DBType.LONGVARCHAR, "\u1234");
+
+ if (!isDB(MYSQLAdapter.NAME))
+ {
+ registerColumn(DBType.LONGVARCHAR, "\u1234");
+ }
+
registerColumn(DBType.LONGVARCHAR, "The quick brown fox jumps over the lazy dog.");
registerColumn(DBType.LONGVARCHAR, "\\,:\",\'");
}
@@ -329,9 +356,9 @@ public class Net4jDBTest extends AbstractCDOTest
registerColumn(DBType.DATE, new GregorianCalendar(1950, 04, 21).getTimeInMillis());
registerColumn(DBType.DATE, new GregorianCalendar(2030, 12, 31).getTimeInMillis());
- if (!isOracle())
+ if (!isDB("oracle", "db2", "mysql"))
{
- registerColumn(DBType.DATE, new GregorianCalendar(0, 0, 0).getTimeInMillis()); // Fails for DB2 and Oracle
+ registerColumn(DBType.DATE, new GregorianCalendar(0, 0, 0).getTimeInMillis());
}
doTest(getName());
@@ -405,6 +432,10 @@ public class Net4jDBTest extends AbstractCDOTest
table.addField(FIELD_NAME + c++, column.getElement1(), value.precision(), value.scale());
break;
+ case BINARY:
+ table.addField(FIELD_NAME + c++, column.getElement1(), 200); // Needed for testBinary().
+ break;
+
default:
table.addField(FIELD_NAME + c++, column.getElement1());
break;
@@ -549,6 +580,11 @@ public class Net4jDBTest extends AbstractCDOTest
private void doTest(String tableName) throws Exception
{
+ if (columns.isEmpty())
+ {
+ return;
+ }
+
DBStore store = (DBStore)getRepository().getStore();
Connection connection = store.getConnection();
@@ -756,9 +792,16 @@ public class Net4jDBTest extends AbstractCDOTest
return 1000L * 60L * minutes;
}
- private boolean isOracle()
+ private boolean isDB(String... dbs)
{
- DBStore store = (DBStore)getRepository().getStore();
- return OracleAdapter.NAME.equals(store.getDBAdapter().getName());
+ for (String db : dbs)
+ {
+ if (db.equalsIgnoreCase(((IDBStore)getRepository().getStore()).getDBAdapter().getName()))
+ {
+ return true;
+ }
+ }
+
+ return false;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
index d8d36ce4c0..dc7e532e4e 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
@@ -15,6 +15,7 @@
package org.eclipse.emf.cdo.tests.db;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.internal.db.SQLQueryHandler;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
@@ -32,9 +33,12 @@ import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.collection.CloseableIterator;
+import org.eclipse.net4j.util.io.IOUtil;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
+import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
@@ -169,7 +173,10 @@ public class SQLQueryTest extends AbstractCDOTest
@CleanRepositoriesBefore(reason = "Query result counting")
public void testDateParameter() throws Exception
{
- Date aDate = new Date();
+ // Mysql TIMESTAMP values do not support milliseconds!
+ Date aDate = new GregorianCalendar(2020, 4, 2, 6, 45, 14).getTime();
+ IOUtil.OUT().println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss-SSS").format(aDate));
+
CDOSession session = openSession();
{
@@ -183,8 +190,14 @@ public class SQLQueryTest extends AbstractCDOTest
transaction.commit();
}
+ String column = "date";
+ if (((IDBStore)getRepository().getStore()).getDBAdapter().isReservedWord(column))
+ {
+ column += "0";
+ }
+
CDOView view = session.openView();
- CDOQuery query = view.createQuery("sql", "SELECT CDO_ID FROM model1_purchaseorder WHERE date0 = :aDate");
+ CDOQuery query = view.createQuery("sql", "SELECT CDO_ID FROM model1_purchaseorder WHERE " + column + " = :aDate");
query.setParameter("aDate", aDate);
List<PurchaseOrder> orders = query.getResult(PurchaseOrder.class);
assertEquals(1, orders.size());
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MultiValuedOfAttributeTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MultiValuedOfAttributeTest.java
index e4694cddad..24871a054d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MultiValuedOfAttributeTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MultiValuedOfAttributeTest.java
@@ -28,6 +28,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import java.util.ArrayList;
import java.util.Date;
+import java.util.GregorianCalendar;
import java.util.List;
/**
@@ -47,10 +48,11 @@ public class MultiValuedOfAttributeTest extends AbstractCDOTest
public void testListOfDate() throws Exception
{
+ // Mysql TIMESTAMP values do not support milliseconds!
List<Date> list = new ArrayList<>();
- list.add(new Date(1000));
- list.add(new Date());
- list.add(new Date(new Date().getTime() - 100));
+ list.add(new GregorianCalendar(2018, 4, 1, 6, 45, 14).getTime());
+ list.add(new GregorianCalendar(2019, 5, 2, 6, 45, 15).getTime());
+ list.add(new GregorianCalendar(2020, 6, 3, 6, 45, 16).getTime());
testMultiValuedIOfAttribute(list, getModel5Package().getGenListOfDate(), getModel5Package().getGenListOfDate_Elements());
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SetFeatureTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SetFeatureTest.java
index 8235ed07c0..5e6d56633f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SetFeatureTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SetFeatureTest.java
@@ -23,13 +23,17 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-import java.sql.Date;
+import java.util.Date;
+import java.util.GregorianCalendar;
/**
* @author Martin Fluegge
*/
public class SetFeatureTest extends AbstractCDOTest
{
+ // Mysql TIMESTAMP values do not support milliseconds!
+ private static final Date DATE = new GregorianCalendar(2020, 4, 2, 6, 45, 14).getTime();
+
public void testUnsettableDateNoDefault_SetDefault() throws Exception
{
testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDate(),
@@ -92,7 +96,7 @@ public class SetFeatureTest extends AbstractCDOTest
public void testNotUnsettableDateNoDefault() throws Exception
{
- testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDate(), new Date(0));
+ testIsSet(getModel2Factory().createNotUnsettable(), getModel2Package().getNotUnsettable_NotUnsettableDate(), DATE);
}
public void testNotUnsettableDateNoDefault_SetDefault() throws Exception
@@ -258,7 +262,7 @@ public class SetFeatureTest extends AbstractCDOTest
public void testNotUnsettableWithDefaultDate() throws Exception
{
- testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package().getNotUnsettableWithDefault_NotUnsettableDate(), new Date(0));
+ testIsSet(getModel2Factory().createNotUnsettableWithDefault(), getModel2Package().getNotUnsettableWithDefault_NotUnsettableDate(), DATE);
}
public void testNotUnsettableWithDefaultDate_SetDefault() throws Exception
@@ -344,7 +348,7 @@ public class SetFeatureTest extends AbstractCDOTest
public void testUnsettableDateNoDefault() throws Exception
{
- testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDate(), new Date(0));
+ testIsSet(getModel2Factory().createUnsettable1(), getModel2Package().getUnsettable1_UnsettableDate(), DATE);
}
public void testUnsettableDoubleNoDefault() throws Exception
@@ -481,7 +485,7 @@ public class SetFeatureTest extends AbstractCDOTest
public void testUnsettableWithDefaultDate() throws Exception
{
- testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package().getUnsettable2WithDefault_UnsettableDate(), new Date(0));
+ testIsSet(getModel2Factory().createUnsettable2WithDefault(), getModel2Package().getUnsettable2WithDefault_UnsettableDate(), DATE);
}
public void testUnsettableWithDefaultDate_SetDefault() throws Exception
diff --git a/plugins/org.eclipse.net4j.db.mysql/.settings/.api_filters b/plugins/org.eclipse.net4j.db.mysql/.settings/.api_filters
index 5658e24753..f050f05d91 100644
--- a/plugins/org.eclipse.net4j.db.mysql/.settings/.api_filters
+++ b/plugins/org.eclipse.net4j.db.mysql/.settings/.api_filters
@@ -7,5 +7,12 @@
<message_argument value="getJDBCDriver()"/>
</message_arguments>
</filter>
+ <filter id="388194388">
+ <message_arguments>
+ <message_argument value="org.eclipse.net4j.db.mysql.MYSQLAdapter"/>
+ <message_argument value="VERSION"/>
+ <message_argument value="5.1.5"/>
+ </message_arguments>
+ </filter>
</resource>
</component>
diff --git a/plugins/org.eclipse.net4j.db.mysql/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.db.mysql/META-INF/MANIFEST.MF
index b97182fab1..5bc9ea9446 100644
--- a/plugins/org.eclipse.net4j.db.mysql/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.db.mysql/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.net4j.db.mysql;singleton:=true
-Bundle-Version: 4.3.0.qualifier
+Bundle-Version: 4.3.1.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.net4j.db;bundle-version="[4.0.0,5.0.0)";visibility:=
Import-Package: com.mysql.jdbc;version="[5.0.0,6.0.0)";resolution:=optional;x-installation:=greedy,
com.mysql.jdbc.jdbc2.optional;version="[5.0.0,6.0.0)";resolution:=optional;x-installation:=greedy,
org.osgi.framework;version="[1.0.0,2.0.0)"
-Export-Package: org.eclipse.net4j.db.internal.mysql.bundle;version="4.3.0";x-internal:=true,
- org.eclipse.net4j.db.mysql;version="4.3.0"
+Export-Package: org.eclipse.net4j.db.internal.mysql.bundle;version="4.3.1";x-internal:=true,
+ org.eclipse.net4j.db.mysql;version="4.3.1"
Eclipse-RegisterBuddy: org.eclipse.net4j.db
Automatic-Module-Name: org.eclipse.net4j.db.mysql
diff --git a/plugins/org.eclipse.net4j.db.mysql/pom.xml b/plugins/org.eclipse.net4j.db.mysql/pom.xml
index 33da43acc5..0fae3c5ee3 100644
--- a/plugins/org.eclipse.net4j.db.mysql/pom.xml
+++ b/plugins/org.eclipse.net4j.db.mysql/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.net4j.db.mysql</artifactId>
- <version>4.3.0-SNAPSHOT</version>
+ <version>4.3.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/mysql/MYSQLAdapter.java b/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/mysql/MYSQLAdapter.java
index ab718ba4ca..f0c6c50b74 100644
--- a/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/mysql/MYSQLAdapter.java
+++ b/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/mysql/MYSQLAdapter.java
@@ -11,12 +11,14 @@
package org.eclipse.net4j.db.mysql;
import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.spi.db.DBAdapter;
import com.mysql.jdbc.ConnectionProperties;
+import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import java.sql.Connection;
import java.sql.SQLException;
@@ -31,43 +33,26 @@ public class MYSQLAdapter extends DBAdapter
{
public static final String NAME = "mysql"; //$NON-NLS-1$
- public static final String VERSION = "5.1.5"; //$NON-NLS-1$
-
- private static final String[] RESERVED_WORDS = { "ACCESSIBLE", "ACTION", "ADD", "ALL", "ALTER", "ANALYZE", "AND", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "AS", //$NON-NLS-1$
- "ASC", "ASENSITIVE", "BEFORE", "BETWEEN", "BIGINT", "BINARY", "BIT", "BLOB", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "BOTH", "BY", "CALL", "CASCADE", "CASE", "CHANGE", "CHAR", "CHARACTER", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "CHECK", "COLLATE", "COLUMN", "COLUMNS", "CONDITION", "CONNECTION", "CONSTRAINT", "CONTINUE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "CONVERT", "CREATE", "CROSS", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "DATABASE", "DATABASES", "DATE", "DAY_HOUR", "DAY_MICROSECOND", "DAY_MINUTE", "DAY_SECOND", "DEC", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "DECIMAL", "DECLARE", "DEFAULT", "DELAYED", "DELETE", "DESC", "DESCRIBE", "DETERMINISTIC", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "DISTINCT", "DISTINCTROW", "DIV", "DOUBLE", "DROP", "DUAL", "EACH", "ELSE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "ELSEIF", "ENCLOSED", "ENUM", "ESCAPED", "EXISTS", "EXIT", "EXPLAIN", "FALSE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "FETCH", "FIELDS", "FLOAT", "FLOAT4", "FLOAT8", "FOR", "FORCE", "FOREIGN", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "FROM", "FULLTEXT", "GENERAL", "GOTO", "GRANT", "GROUP", "HAVING", "HIGH_PRIORITY", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "HOUR_MICROSECOND", "HOUR_MINUTE", "HOUR_SECOND", "IF", "IGNORE", "IGNORE_SERVER_IDS", "IN", "INDEX", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "INFILE", "INNER", "INOUT", "INSENSITIVE", "INSERT", "INT", "INT1", "INT2", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "INT3", "INT4", "INT8", "INTEGER", "INTERVAL", "INTO", "IS", "ITERATE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "JOIN", "KEY", "KEYS", "KILL", "LABEL", "LEADING", "LEAVE", "LEFT", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "LIKE", "LIMIT", "LINEAR", "LINES", "LOAD", "LOCALTIME", "LOCALTIMESTAMP", "LOCK", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "LONG", "LONGBLOB", "LONGTEXT", "LOOP", "LOW_PRIORITY", "MASTER_HEARTBEAT_PERIOD", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- "MASTER_SSL_VERIFY_SERVER_CERT", "MATCH", //$NON-NLS-1$ //$NON-NLS-2$
- "MAXVALUE", "MEDIUMBLOB", "MEDIUMINT", "MEDIUMTEXT", "MIDDLEINT", "MINUTE_MICROSECOND", "MINUTE_SECOND", "MOD", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "MODIFIES", "NATURAL", "NO", "NOT", "NO_WRITE_TO_BINLOG", "NULL", "NUMERIC", "ON", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "OPTIMIZE", "OPTION", "OPTIONALLY", "OR", "ORDER", "OUT", "OUTER", "OUTFILE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "PRECISION", "PRIMARY", "PRIVILEGES", "PROCEDURE", "PURGE", "RAID0", "RANGE", "READ", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "READS", "READ_WRITE", "REAL", "REFERENCES", "REGEXP", "RELEASE", "RENAME", "REPEAT", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "REPLACE", "REQUIRE", "RESIGNAL", "RESTRICT", "RETURN", "REVOKE", "RIGHT", "RLIKE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "SCHEMA", "SCHEMAS", "SECOND_MICROSECOND", "SELECT", "SENSITIVE", "SEPARATOR", "SET", "SHOW", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "SIGNAL", "SLOW", "SMALLINT", "SONAME", "SPATIAL", "SPECIFIC", "SQL", "SQL_BIG_RESULT", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "SQL_CALC_FOUND_ROWS", "SQLEXCEPTION", "SQL_SMALL_RESULT", "SQLSTATE", "SQLWARNING", "SSL", "STARTING", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "STRAIGHT_JOIN", //$NON-NLS-1$
- "TABLE", "TABLES", "TERMINATED", "TEXT", "THEN", "TIME", "TIMESTAMP", "TINYBLOB", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "TINYINT", "TINYTEXT", "TO", "TRAILING", "TRIGGER", "TRUE", "UNDO", "UNION", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "UNIQUE", "UNLOCK", "UNSIGNED", "UPDATE", "UPGRADE", "USAGE", "USE", "USING", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "UTC_DATE", "UTC_TIME", "UTC_TIMESTAMP", "VALUES", "VARBINARY", "VARCHAR", "VARCHARACTER", "VARYING", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "WHEN", "WHERE", "WHILE", "WITH", "WRITE", "X509", "XOR", "YEAR_MONTH", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
- "ZEROFILL" }; //$NON-NLS-1$
+ public static final String VERSION = "5.7.28"; //$NON-NLS-1$
+
+ private static final String[] RESERVED_WORDS = { "ACCESSIBLE", "ADD", "ALL", "ALTER", "ANALYZE", "AND", "AS", "ASC", "ASENSITIVE", "BEFORE", "BETWEEN",
+ "BIGINT", "BINARY", "BLOB", "BOTH", "BY", "CALL", "CASCADE", "CASE", "CHANGE", "CHAR", "CHARACTER", "CHECK", "COLLATE", "COLUMN", "CONDITION",
+ "CONSTRAINT", "CONTINUE", "CONVERT", "CREATE", "CROSS", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR", "DATABASE",
+ "DATABASES", "DAY_HOUR", "DAY_MICROSECOND", "DAY_MINUTE", "DAY_SECOND", "DEC", "DECIMAL", "DECLARE", "DEFAULT", "DELAYED", "DELETE", "DESC", "DESCRIBE",
+ "DETERMINISTIC", "DISTINCT", "DISTINCTROW", "DIV", "DOUBLE", "DROP", "DUAL", "EACH", "ELSE", "ELSEIF", "ENCLOSED", "ESCAPED", "EXISTS", "EXIT", "EXPLAIN",
+ "FALSE", "FETCH", "FLOAT", "FLOAT4", "FLOAT8", "FOR", "FORCE", "FOREIGN", "FROM", "FULLTEXT", "GENERATED", "GET", "GRANT", "GROUP", "HAVING",
+ "HIGH_PRIORITY", "HOUR_MICROSECOND", "HOUR_MINUTE", "HOUR_SECOND", "IF", "IGNORE", "IN", "INDEX", "INFILE", "INNER", "INOUT", "INSENSITIVE", "INSERT",
+ "INT", "INT1", "INT2", "INT3", "INT4", "INT8", "INTEGER", "INTERVAL", "INTO", "IO_AFTER_GTIDS", "IO_BEFORE_GTIDS", "IS", "ITERATE", "JOIN", "KEY", "KEYS",
+ "KILL", "LEADING", "LEAVE", "LEFT", "LIKE", "LIMIT", "LINEAR", "LINES", "LOAD", "LOCALTIME", "LOCALTIMESTAMP", "LOCK", "LONG", "LONGBLOB", "LONGTEXT",
+ "LOOP", "LOW_PRIORITY", "MASTER_BIND", "MASTER_SSL_VERIFY_SERVER_CERT", "MATCH", "MAXVALUE", "MEDIUMBLOB", "MEDIUMINT", "MEDIUMTEXT", "MIDDLEINT",
+ "MINUTE_MICROSECOND", "MINUTE_SECOND", "MOD", "MODIFIES", "NATURAL", "NO_WRITE_TO_BINLOG", "NOT", "NULL", "NUMERIC", "ON", "OPTIMIZE", "OPTIMIZER_COSTS",
+ "OPTION", "OPTIONALLY", "OR", "ORDER", "OUT", "OUTER", "OUTFILE", "PARTITION", "PRECISION", "PRIMARY", "PROCEDURE", "PURGE", "RANGE", "READ",
+ "READ_WRITE", "READS", "REAL", "REFERENCES", "REGEXP", "RELEASE", "RENAME", "REPEAT", "REPLACE", "REQUIRE", "RESIGNAL", "RESTRICT", "RETURN", "REVOKE",
+ "RIGHT", "RLIKE", "SCHEMA", "SCHEMAS", "SECOND_MICROSECOND", "SELECT", "SENSITIVE", "SEPARATOR", "SET", "SHOW", "SIGNAL", "SMALLINT", "SPATIAL",
+ "SPECIFIC", "SQL", "SQL_BIG_RESULT", "SQL_CALC_FOUND_ROWS", "SQL_SMALL_RESULT", "SQLEXCEPTION", "SQLSTATE", "SQLWARNING", "SSL", "STARTING", "STORED",
+ "STRAIGHT_JOIN", "TABLE", "TERMINATED", "THEN", "TINYBLOB", "TINYINT", "TINYTEXT", "TO", "TRAILING", "TRIGGER", "TRUE", "UNDO", "UNION", "UNIQUE",
+ "UNLOCK", "UNSIGNED", "UPDATE", "USAGE", "USE", "USING", "UTC_DATE", "UTC_TIME", "UTC_TIMESTAMP", "VALUES", "VARBINARY", "VARCHAR", "VARCHARACTER",
+ "VARYING", "VIRTUAL", "WHEN", "WHERE", "WHILE", "WITH", "WRITE", "XOR", "YEAR_MONTH", "ZEROFILL" };
public MYSQLAdapter()
{
@@ -99,8 +84,23 @@ public class MYSQLAdapter extends DBAdapter
switch (type)
{
case VARCHAR:
+ if (field.isIndexed())
+ {
+ // Use VARCHAR(length)
+ break;
+ }
+
+ if (field.getPrecision() != getDefaultDBLength(DBType.VARCHAR))
+ {
+ // Use VARCHAR(length)
+ break;
+ }
+
+ return "LONGTEXT"; //$NON-NLS-1$
+
case CLOB:
return "LONGTEXT"; //$NON-NLS-1$
+
case BLOB:
return "LONGBLOB"; //$NON-NLS-1$
}
@@ -176,4 +176,101 @@ public class MYSQLAdapter extends DBAdapter
return super.modifyConnection(connection);
}
+
+ /**
+ * @author Eike Stepper
+ */
+ @SuppressWarnings("unused")
+ private static final class ReservedWordGenerator
+ {
+ /**
+ * From https://dev.mysql.com/doc/refman/5.7/en/keywords.html
+ */
+ private static final String[] WORDS = { "ACCESSIBLE", "ACCOUNT", "ACTION", "ADD", "AFTER", "AGAINST", "AGGREGATE", "ALGORITHM", "ALL", "ALTER", "ALWAYS",
+ "ANALYSE", "ANALYZE", "AND", "ANY", "AS", "ASC", "ASCII", "ASENSITIVE", "AT", "AUTO_INCREMENT", "AUTOEXTEND_SIZE", "AVG", "AVG_ROW_LENGTH", "BACKUP",
+ "BEFORE", "BEGIN", "BETWEEN", "BIGINT", "BINARY", "BINLOG", "BIT", "BLOB", "BLOCK", "BOOL", "BOOLEAN", "BOTH", "BTREE", "BY", "BYTE", "CACHE", "CALL",
+ "CASCADE", "CASCADED", "CASE", "CATALOG_NAME", "CHAIN", "CHANGE", "CHANGED", "CHANNEL", "CHAR", "CHARACTER", "CHARSET", "CHECK", "CHECKSUM", "CIPHER",
+ "CLASS_ORIGIN", "CLIENT", "CLOSE", "COALESCE", "CODE", "COLLATE", "COLLATION", "COLUMN", "COLUMN_FORMAT", "COLUMN_NAME", "COLUMNS", "COMMENT", "COMMIT",
+ "COMMITTED", "COMPACT", "COMPLETION", "COMPRESSED", "COMPRESSION", "CONCURRENT", "CONDITION", "CONNECTION", "CONSISTENT", "CONSTRAINT",
+ "CONSTRAINT_CATALOG", "CONSTRAINT_NAME", "CONSTRAINT_SCHEMA", "CONTAINS", "CONTEXT", "CONTINUE", "CONVERT", "CPU", "CREATE", "CROSS", "CUBE", "CURRENT",
+ "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR", "CURSOR_NAME", "DATA", "DATABASE", "DATABASES", "DATAFILE", "DATE",
+ "DATETIME", "DAY", "DAY_HOUR", "DAY_MICROSECOND", "DAY_MINUTE", "DAY_SECOND", "DEALLOCATE", "DEC", "DECIMAL", "DECLARE", "DEFAULT", "DEFAULT_AUTH",
+ "DEFINER", "DELAY_KEY_WRITE", "DELAYED", "DELETE", "DES_KEY_FILE", "DESC", "DESCRIBE", "DETERMINISTIC", "DIAGNOSTICS", "DIRECTORY", "DISABLE",
+ "DISCARD", "DISK", "DISTINCT", "DISTINCTROW", "DIV", "DO", "DOUBLE", "DROP", "DUAL", "DUMPFILE", "DUPLICATE", "DYNAMIC", "EACH", "ELSE", "ELSEIF",
+ "ENABLE", "ENCLOSED", "ENCRYPTION", "END", "ENDS", "ENGINE", "ENGINES", "ENUM", "ERROR", "ERRORS", "ESCAPE", "ESCAPED", "EVENT", "EVENTS", "EVERY",
+ "EXCHANGE", "EXECUTE", "EXISTS", "EXIT", "EXPANSION", "EXPIRE", "EXPLAIN", "EXPORT", "EXTENDED", "EXTENT_SIZE", "FALSE", "FAST", "FAULTS", "FETCH",
+ "FIELDS", "FILE", "FILE_BLOCK_SIZE", "FILTER", "FIRST", "FIXED", "FLOAT", "FLOAT4", "FLOAT8", "FLUSH", "FOLLOWS", "FOR", "FORCE", "FOREIGN", "FORMAT",
+ "FOUND", "FROM", "FULL", "FULLTEXT", "FUNCTION", "GENERAL", "GENERATED", "GEOMETRY", "GEOMETRYCOLLECTION", "GET", "GET_FORMAT", "GLOBAL", "GRANT",
+ "GRANTS", "GROUP", "GROUP_REPLICATION", "HANDLER", "HASH", "HAVING", "HELP", "HIGH_PRIORITY", "HOST", "HOSTS", "HOUR", "HOUR_MICROSECOND",
+ "HOUR_MINUTE", "HOUR_SECOND", "IDENTIFIED", "IF", "IGNORE", "IGNORE_SERVER_IDS", "IMPORT", "IN", "INDEX", "INDEXES", "INFILE", "INITIAL_SIZE", "INNER",
+ "INOUT", "INSENSITIVE", "INSERT", "INSERT_METHOD", "INSTALL", "INSTANCE", "INT", "INT1", "INT2", "INT3", "INT4", "INT8", "INTEGER", "INTERVAL", "INTO",
+ "INVOKER", "IO", "IO_AFTER_GTIDS", "IO_BEFORE_GTIDS", "IO_THREAD", "IPC", "IS", "ISOLATION", "ISSUER", "ITERATE", "JOIN", "JSON", "KEY",
+ "KEY_BLOCK_SIZE", "KEYS", "KILL", "LANGUAGE", "LAST", "LEADING", "LEAVE", "LEAVES", "LEFT", "LESS", "LEVEL", "LIKE", "LIMIT", "LINEAR", "LINES",
+ "LINESTRING", "LIST", "LOAD", "LOCAL", "LOCALTIME", "LOCALTIMESTAMP", "LOCK", "LOCKS", "LOGFILE", "LOGS", "LONG", "LONGBLOB", "LONGTEXT", "LOOP",
+ "LOW_PRIORITY", "MASTER", "MASTER_AUTO_POSITION", "MASTER_BIND", "MASTER_CONNECT_RETRY", "MASTER_DELAY", "MASTER_HEARTBEAT_PERIOD", "MASTER_HOST",
+ "MASTER_LOG_FILE", "MASTER_LOG_POS", "MASTER_PASSWORD", "MASTER_PORT", "MASTER_RETRY_COUNT", "MASTER_SERVER_ID", "MASTER_SSL", "MASTER_SSL_CA",
+ "MASTER_SSL_CAPATH", "MASTER_SSL_CERT", "MASTER_SSL_CIPHER", "MASTER_SSL_CRL", "MASTER_SSL_CRLPATH", "MASTER_SSL_KEY", "MASTER_SSL_VERIFY_SERVER_CERT",
+ "MASTER_TLS_VERSION", "MASTER_USER", "MATCH", "MAX_CONNECTIONS_PER_HOUR", "MAX_QUERIES_PER_HOUR", "MAX_ROWS", "MAX_SIZE", "MAX_STATEMENT_TIME",
+ "MAX_UPDATES_PER_HOUR", "MAX_USER_CONNECTIONS", "MAXVALUE", "MEDIUM", "MEDIUMBLOB", "MEDIUMINT", "MEDIUMTEXT", "MEMORY", "MERGE", "MESSAGE_TEXT",
+ "MICROSECOND", "MIDDLEINT", "MIGRATE", "MIN_ROWS", "MINUTE", "MINUTE_MICROSECOND", "MINUTE_SECOND", "MOD", "MODE", "MODIFIES", "MODIFY", "MONTH",
+ "MULTILINESTRING", "MULTIPOINT", "MULTIPOLYGON", "MUTEX", "MYSQL_ERRNO", "NAME", "NAMES", "NATIONAL", "NATURAL", "NCHAR", "NDB", "NDBCLUSTER", "NEVER",
+ "NEW", "NEXT", "NO", "NO_WAIT", "NO_WRITE_TO_BINLOG", "NODEGROUP", "NONBLOCKING", "NONE", "NOT", "NULL", "NUMBER", "NUMERIC", "NVARCHAR", "OFFSET",
+ "OLD_PASSWORD", "ON", "ONE", "ONLY", "OPEN", "OPTIMIZE", "OPTIMIZER_COSTS", "OPTION", "OPTIONALLY", "OPTIONS", "OR", "ORDER", "OUT", "OUTER", "OUTFILE",
+ "OWNER", "PACK_KEYS", "PAGE", "PARSE_GCOL_EXPR", "PARSER", "PARTIAL", "PARTITION", "PARTITIONING", "PARTITIONS", "PASSWORD", "PHASE", "PLUGIN",
+ "PLUGIN_DIR", "PLUGINS", "POINT", "POLYGON", "PORT", "PRECEDES", "PRECISION", "PREPARE", "PRESERVE", "PREV", "PRIMARY", "PRIVILEGES", "PROCEDURE",
+ "PROCESSLIST", "PROFILE", "PROFILES", "PROXY", "PURGE", "QUARTER", "QUERY", "QUICK", "RANGE", "READ", "READ_ONLY", "READ_WRITE", "READS", "REAL",
+ "REBUILD", "RECOVER", "REDO_BUFFER_SIZE", "REDOFILE", "REDUNDANT", "REFERENCES", "REGEXP", "RELAY", "RELAY_LOG_FILE", "RELAY_LOG_POS", "RELAY_THREAD",
+ "RELAYLOG", "RELEASE", "RELOAD", "REMOVE", "RENAME", "REORGANIZE", "REPAIR", "REPEAT", "REPEATABLE", "REPLACE", "REPLICATE_DO_DB", "REPLICATE_DO_TABLE",
+ "REPLICATE_IGNORE_DB", "REPLICATE_IGNORE_TABLE", "REPLICATE_REWRITE_DB", "REPLICATE_WILD_DO_TABLE", "REPLICATE_WILD_IGNORE_TABLE", "REPLICATION",
+ "REQUIRE", "RESET", "RESIGNAL", "RESTORE", "RESTRICT", "RESUME", "RETURN", "RETURNED_SQLSTATE", "RETURNS", "REVERSE", "REVOKE", "RIGHT", "RLIKE",
+ "ROLLBACK", "ROLLUP", "ROTATE", "ROUTINE", "ROW", "ROW_COUNT", "ROW_FORMAT", "ROWS", "RTREE", "SAVEPOINT", "SCHEDULE", "SCHEMA", "SCHEMA_NAME",
+ "SCHEMAS", "SECOND", "SECOND_MICROSECOND", "SECURITY", "SELECT", "SENSITIVE", "SEPARATOR", "SERIAL", "SERIALIZABLE", "SERVER", "SESSION", "SET",
+ "SHARE", "SHOW", "SHUTDOWN", "SIGNAL", "SIGNED", "SIMPLE", "SLAVE", "SLOW", "SMALLINT", "SNAPSHOT", "SOCKET", "SOME", "SONAME", "SOUNDS", "SOURCE",
+ "SPATIAL", "SPECIFIC", "SQL", "SQL_AFTER_GTIDS", "SQL_AFTER_MTS_GAPS", "SQL_BEFORE_GTIDS", "SQL_BIG_RESULT", "SQL_BUFFER_RESULT", "SQL_CACHE",
+ "SQL_CALC_FOUND_ROWS", "SQL_NO_CACHE", "SQL_SMALL_RESULT", "SQL_THREAD", "SQL_TSI_DAY", "SQL_TSI_HOUR", "SQL_TSI_MINUTE", "SQL_TSI_MONTH",
+ "SQL_TSI_QUARTER", "SQL_TSI_SECOND", "SQL_TSI_WEEK", "SQL_TSI_YEAR", "SQLEXCEPTION", "SQLSTATE", "SQLWARNING", "SSL", "STACKED", "START", "STARTING",
+ "STARTS", "STATS_AUTO_RECALC", "STATS_PERSISTENT", "STATS_SAMPLE_PAGES", "STATUS", "STOP", "STORAGE", "STORED", "STRAIGHT_JOIN", "STRING",
+ "SUBCLASS_ORIGIN", "SUBJECT", "SUBPARTITION", "SUBPARTITIONS", "SUPER", "SUSPEND", "SWAPS", "SWITCHES", "TABLE", "TABLE_CHECKSUM", "TABLE_NAME",
+ "TABLES", "TABLESPACE", "TEMPORARY", "TEMPTABLE", "TERMINATED", "TEXT", "THAN", "THEN", "TIME", "TIMESTAMP", "TIMESTAMPADD", "TIMESTAMPDIFF",
+ "TINYBLOB", "TINYINT", "TINYTEXT", "TO", "TRAILING", "TRANSACTION", "TRIGGER", "TRIGGERS", "TRUE", "TRUNCATE", "TYPE", "TYPES", "UNCOMMITTED",
+ "UNDEFINED", "UNDO", "UNDO_BUFFER_SIZE", "UNDOFILE", "UNICODE", "UNINSTALL", "UNION", "UNIQUE", "UNKNOWN", "UNLOCK", "UNSIGNED", "UNTIL", "UPDATE",
+ "UPGRADE", "USAGE", "USE", "USE_FRM", "USER", "USER_RESOURCES", "USING", "UTC_DATE", "UTC_TIME", "UTC_TIMESTAMP", "VALIDATION", "VALUE", "VALUES",
+ "VARBINARY", "VARCHAR", "VARCHARACTER", "VARIABLES", "VARYING", "VIEW", "VIRTUAL", "WAIT", "WARNINGS", "WEEK", "WEIGHT_STRING", "WHEN", "WHERE",
+ "WHILE", "WITH", "WITHOUT", "WORK", "WRAPPER", "WRITE", "X509", "XA", "XID", "XML", "XOR", "YEAR", "YEAR_MONTH", "ZEROFILL" };
+
+ private static final String DB_NAME = "generate_reserved_words";
+
+ /**
+ * @since 4.3
+ */
+ public static void main(String[] args) throws SQLException
+ {
+ MysqlDataSource dataSource = new MysqlDataSource();
+ dataSource.setUrl("jdbc:mysql://localhost");
+ dataSource.setUser("root");
+ // dataSource.setPassword("12345");
+
+ Connection connection = dataSource.getConnection();
+
+ try
+ {
+ try
+ {
+ DBUtil.execute(connection, "DROP DATABASE " + DB_NAME);
+ }
+ catch (Exception ignore)
+ {
+ }
+
+ DBUtil.execute(connection, "CREATE DATABASE " + DB_NAME);
+ DBUtil.execute(connection, "USE " + DB_NAME);
+
+ generateReservedWords(connection, WORDS);
+ }
+ finally
+ {
+ connection.close();
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
index 1828847f7a..1e8b718df2 100644
--- a/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.net4j.db;singleton:=true
-Bundle-Version: 4.8.1.qualifier
+Bundle-Version: 4.9.0.qualifier
Bundle-Activator: org.eclipse.net4j.internal.db.bundle.OM$Activator
Bundle-Vendor: %providerName
Bundle-ClassPath: .
@@ -11,17 +11,17 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.net4j.util;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.net4j.db.jdbc;bundle-version="[4.0.0,5.0.0)"
-Export-Package: org.eclipse.net4j.db;version="4.8.1",
- org.eclipse.net4j.db.ddl;version="4.8.1",
- org.eclipse.net4j.db.ddl.delta;version="4.8.1",
- org.eclipse.net4j.db.dml;version="4.8.1",
- org.eclipse.net4j.internal.db;version="4.8.1";x-internal:=true,
- org.eclipse.net4j.internal.db.bundle;version="4.8.1";x-internal:=true,
- org.eclipse.net4j.internal.db.ddl;version="4.8.1";x-friends:="org.eclipse.emf.cdo.server.db",
- org.eclipse.net4j.internal.db.ddl.delta;version="4.8.1";x-internal:=true,
- org.eclipse.net4j.internal.db.dml;version="4.8.1";x-internal:=true,
- org.eclipse.net4j.spi.db;version="4.8.1",
- org.eclipse.net4j.spi.db.ddl;version="4.8.1"
+Export-Package: org.eclipse.net4j.db;version="4.9.0",
+ org.eclipse.net4j.db.ddl;version="4.9.0",
+ org.eclipse.net4j.db.ddl.delta;version="4.9.0",
+ org.eclipse.net4j.db.dml;version="4.9.0",
+ org.eclipse.net4j.internal.db;version="4.9.0";x-internal:=true,
+ org.eclipse.net4j.internal.db.bundle;version="4.9.0";x-internal:=true,
+ org.eclipse.net4j.internal.db.ddl;version="4.9.0";x-friends:="org.eclipse.emf.cdo.server.db",
+ org.eclipse.net4j.internal.db.ddl.delta;version="4.9.0";x-internal:=true,
+ org.eclipse.net4j.internal.db.dml;version="4.9.0";x-internal:=true,
+ org.eclipse.net4j.spi.db;version="4.9.0",
+ org.eclipse.net4j.spi.db.ddl;version="4.9.0"
Bundle-ActivationPolicy: lazy
Eclipse-BuddyPolicy: registered
Automatic-Module-Name: org.eclipse.net4j.db
diff --git a/plugins/org.eclipse.net4j.db/pom.xml b/plugins/org.eclipse.net4j.db/pom.xml
index 93cbe888c6..24f88fcb97 100644
--- a/plugins/org.eclipse.net4j.db/pom.xml
+++ b/plugins/org.eclipse.net4j.db/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.net4j.db</artifactId>
- <version>4.8.1-SNAPSHOT</version>
+ <version>4.9.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBField.java
index a47a51cfdb..492f19fd8b 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBField.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBField.java
@@ -48,6 +48,16 @@ public interface IDBField extends IDBSchemaElement, PositionProvider
public void setNotNull(boolean notNull);
+ /**
+ * @since 4.9
+ */
+ public boolean isIndexed();
+
+ /**
+ * @since 4.9
+ */
+ public IDBIndex[] getIndices();
+
@Override
public String getFullName();
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java
index f9b4ea9512..3dd6210d74 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java
@@ -12,6 +12,7 @@ package org.eclipse.net4j.internal.db.ddl;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBSchemaElement;
import org.eclipse.net4j.db.ddl.IDBSchemaVisitor;
@@ -22,6 +23,7 @@ import org.eclipse.net4j.spi.db.ddl.InternalDBTable;
import java.io.IOException;
import java.io.Writer;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -219,6 +221,39 @@ public class DBField extends DBSchemaElement implements InternalDBField
}
@Override
+ public boolean isIndexed()
+ {
+ String name = getName();
+
+ for (IDBIndex index : table.getIndices())
+ {
+ if (index.getField(name) != null)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public IDBIndex[] getIndices()
+ {
+ List<IDBIndex> indices = new ArrayList<>();
+ String name = getName();
+
+ for (IDBIndex index : table.getIndices())
+ {
+ if (index.getField(name) != null)
+ {
+ indices.add(index);
+ }
+ }
+
+ return indices.toArray(new IDBIndex[indices.size()]);
+ }
+
+ @Override
public int getPosition()
{
return position;
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBField.java
index e1156a23d1..5bd343a21f 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBField.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBField.java
@@ -12,6 +12,7 @@ package org.eclipse.net4j.internal.db.ddl;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.ddl.IDBField;
+import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.spi.db.ddl.InternalDBField;
@@ -116,6 +117,18 @@ public final class DelegatingDBField extends DelegatingDBSchemaElement implement
}
@Override
+ public boolean isIndexed()
+ {
+ return getDelegate().isIndexed();
+ }
+
+ @Override
+ public IDBIndex[] getIndices()
+ {
+ return getDelegate().getIndices();
+ }
+
+ @Override
public String formatPrecision()
{
return getDelegate().formatPrecision();
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
index 721f6f67ad..3750d03ece 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java
@@ -15,7 +15,10 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnection;
import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBSchemaTransaction;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBSchema;
@@ -159,6 +162,14 @@ public abstract class DBAdapter implements IDBAdapter
}
/**
+ * @since 4.9
+ */
+ public IDBSchemaTransaction openSchemaTransaction(IDBDatabase database, IDBConnection currentConnection)
+ {
+ return database.openSchemaTransaction(currentConnection);
+ }
+
+ /**
* @since 4.2
*/
@Override
@@ -1263,6 +1274,14 @@ public abstract class DBAdapter implements IDBAdapter
}
/**
+ * @since 4.9
+ */
+ public Object convertToSQL(Object value)
+ {
+ return value;
+ }
+
+ /**
* @since 4.2
*/
public static int getDefaultDBLength(DBType type)
@@ -1271,6 +1290,32 @@ public abstract class DBAdapter implements IDBAdapter
}
/**
+ * @since 4.9
+ */
+ protected static void generateReservedWords(Connection connection, String[] words) throws SQLException
+ {
+ for (int i = 0; i < words.length; i++)
+ {
+ String word = words[i];
+
+ try
+ {
+ String sql = "CREATE TABLE table" + i + " (" + word + " INT)";
+ DBUtil.execute(connection, sql);
+ }
+ catch (Exception ex)
+ {
+ if (i != 0)
+ {
+ System.out.print(", ");
+ }
+
+ System.out.println("\"" + word + "\"");
+ }
+ }
+ }
+
+ /**
* @since 4.2
* @author Eike Stepper
*/

Back to the top