summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-17 07:17:43 (EDT)
committerEike Stepper2007-08-17 07:17:43 (EDT)
commit83bde01e1debbc28ada1db52b28858a0c576223a (patch)
tree187e4f54da0ac5272259484c76d428930e118cc9
parentb970d76bc01183a792d9e1ccfb17e1dc7e9316f2 (diff)
downloadcdo-83bde01e1debbc28ada1db52b28858a0c576223a.zip
cdo-83bde01e1debbc28ada1db52b28858a0c576223a.tar.gz
cdo-83bde01e1debbc28ada1db52b28858a0c576223a.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/config/cdo.server.xml2
-rw-r--r--plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java28
-rw-r--r--plugins/org.eclipse.net4j.db/reserved_words/Copy of ansi.txt231
-rw-r--r--plugins/org.eclipse.net4j.db/reserved_words/derby.txt208
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java45
5 files changed, 509 insertions, 5 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/config/cdo.server.xml b/plugins/org.eclipse.emf.cdo.ui/config/cdo.server.xml
index 1314671..a37ef6e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/config/cdo.server.xml
+++ b/plugins/org.eclipse.emf.cdo.ui/config/cdo.server.xml
@@ -3,7 +3,7 @@
<repository name="repo1">
<store type="db">
- <mappingStrategy type="Horizontal"/>
+ <mappingStrategy type="horizontal"/>
<dbAdapter name="derby"/>
<dataSource
driverClass="org.apache.derby.jdbc.EmbeddedDataSource"
diff --git a/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java b/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java
index b3067ee..07af1f3 100644
--- a/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java
+++ b/plugins/org.eclipse.net4j.db.derby/src/org/eclipse/net4j/db/internal/derby/DerbyAdapter.java
@@ -17,12 +17,34 @@ import org.eclipse.net4j.internal.db.DBField;
import org.apache.derby.jdbc.EmbeddedDriver;
import java.sql.Driver;
+import java.util.Arrays;
/**
* @author Eike Stepper
*/
public class DerbyAdapter extends DBAdapter
{
+ private static final String[] RESERVED_WORDS = { "ADD", "ALL", "ALLOCATE", "ALTER", "AND", "ANY", "ARE", "AS", "ASC",
+ "ASSERTION", "AT", "AUTHORIZATION", "AVG", "BEGIN", "BETWEEN", "BIGINT", "BIT", "BOOLEAN", "BOTH", "BY", "CALL",
+ "CASCADE", "CASCADED", "CASE", "CAST", "CHAR", "CHARACTER", "CHECK", "CLOSE", "COALESCE", "COLLATE", "COLLATION",
+ "COLUMN", "COMMIT", "CONNECT", "CONNECTION", "CONSTRAINT", "CONSTRAINTS", "CONTINUE", "CONVERT", "CORRESPONDING",
+ "CREATE", "CURRENT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR", "DEALLOCATE",
+ "DEC", "DECIMAL", "DECLARE", "DEFAULT", "DEFERRABLE", "DEFERRED", "DELETE", "DESC", "DESCRIBE", "DIAGNOSTICS",
+ "DISCONNECT", "DISTINCT", "DOUBLE", "DROP", "ELSE", "END", "END-EXEC", "ESCAPE", "EXCEPT", "EXCEPTION", "EXEC",
+ "EXECUTE", "EXISTS", "EXPLAIN", "EXTERNAL", "FALSE", "FETCH", "FIRST", "FLOAT", "FOR", "FOREIGN", "FOUND",
+ "FROM", "FULL", "FUNCTION", "GET", "GETCURRENTCONNECTION", "GLOBAL", "GO", "GOTO", "GRANT", "GROUP", "HAVING",
+ "HOUR", "IDENTITY", "IMMEDIATE", "IN", "INDICATOR", "INITIALLY", "INNER", "INOUT", "INPUT", "INSENSITIVE",
+ "INSERT", "INT", "INTEGER", "INTERSECT", "INTO", "IS", "ISOLATION", "JOIN", "KEY", "LAST", "LEFT", "LIKE",
+ "LOWER", "LTRIM", "MATCH", "MAX", "MIN", "MINUTE", "NATIONAL", "NATURAL", "NCHAR", "NVARCHAR", "NEXT", "NO",
+ "NOT", "NULL", "NULLIF", "NUMERIC", "OF", "ON", "ONLY", "OPEN", "OPTION", "OR", "ORDER", "OUTER", "OUTPUT",
+ "OVERLAPS", "PAD", "PARTIAL", "PREPARE", "PRESERVE", "PRIMARY", "PRIOR", "PRIVILEGES", "PROCEDURE", "PUBLIC",
+ "READ", "REAL", "REFERENCES", "RELATIVE", "RESTRICT", "REVOKE", "RIGHT", "ROLLBACK", "ROWS", "RTRIM", "SCHEMA",
+ "SCROLL", "SECOND", "SELECT", "SESSION_USER", "SET", "SMALLINT", "SOME", "SPACE", "SQL", "SQLCODE", "SQLERROR",
+ "SQLSTATE", "SUBSTR", "SUBSTRING", "SUM", "SYSTEM_USER", "TABLE", "TEMPORARY", "TIMEZONE_HOUR",
+ "TIMEZONE_MINUTE", "TO", "TRANSACTION", "TRANSLATE", "TRANSLATION", "TRIM", "TRUE", "UNION", "UNIQUE", "UNKNOWN",
+ "UPDATE", "UPPER", "USER", "USING", "VALUES", "VARCHAR", "VARYING", "VIEW", "WHENEVER", "WHERE", "WITH", "WORK",
+ "WRITE", "XML", "XMLEXISTS", "XMLPARSE", "XMLQUERY", "XMLSERIALIZE", "YEAR" };
+
public DerbyAdapter()
{
super("derby", "10.2.2.0");
@@ -46,4 +68,10 @@ public class DerbyAdapter extends DBAdapter
return super.getTypeName(field);
}
+
+ @Override
+ protected boolean isReservedWord(String word)
+ {
+ return Arrays.binarySearch(RESERVED_WORDS, word.toUpperCase()) >= 0;
+ }
}
diff --git a/plugins/org.eclipse.net4j.db/reserved_words/Copy of ansi.txt b/plugins/org.eclipse.net4j.db/reserved_words/Copy of ansi.txt
new file mode 100644
index 0000000..ff56656
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/reserved_words/Copy of ansi.txt
@@ -0,0 +1,231 @@
+ABSOLUTE
+ACTION
+ADD
+ALL
+ALLOCATE
+ALTER
+AND
+ANY
+ARE
+AS
+ASC
+ASSERTION
+AT
+AUTHORIZATION
+AVG
+BEGIN
+BETWEEN
+BIT
+BIT_LENGTH
+BOTH
+BY
+CASCADE
+CASCADED
+CASE
+CAST
+CATALOG
+CHAR
+CHARACTER
+CHAR_
+LENGTH
+CHARACTER_LENGTH
+CHECK
+CLOSE
+COALESCE
+COLLATE
+COLLATION
+COLUMN
+COMMIT
+CONNECT
+CONNECTION
+CONSTRAINT
+CONSTRAINTS
+CONTINUE
+CONVERT
+CORRESPONDING
+COUNT
+CREATE
+CROSS
+CURRENT
+CURRENT_DATE
+CURRENT_TIME
+CURRENT_TIMESTAMP
+CURRENT_
+USER
+CURSOR
+DATE
+DAY
+DEALLOCATE
+DEC
+DECIMAL
+DECLARE
+DEFAULT
+DEFERRABLE
+DEFERRED
+DELETE
+DESC
+DESCRIBE
+DESCRIPTOR
+DIAGNOSTICS
+DISCONNECT
+DISTINCT
+DOMAIN
+DOUBLE
+DROP
+ELSE
+END
+END-EXEC
+ESCAPE
+EXCEPT
+EXCEPTION
+EXEC
+EXECUTE
+EXISTS
+EXTERNAL
+EXTRACT
+FALSE
+FETCH
+FIRST
+FLOAT
+FOR
+FOREIGN
+FOUND
+FROM
+FULL
+GET
+GLOBAL
+GO
+GOTO
+GRANT
+GROUP
+HAVING
+HOUR
+IDENTITY
+IMMEDIATE
+IN
+INDICATOR
+INITIALLY
+INNER
+INPUT
+INSENSITIVE
+INSERT
+INT
+INTEGER
+INTERSECT
+INTERVAL
+INTO
+IS
+ISOLATION
+JOIN
+KEY
+LANGUAGE
+LAST
+LEADING
+LEFT
+LEVEL
+LIKE
+LOCAL
+LOWER
+MATCH
+MAX
+MIN
+MINUTE
+MODULE
+MONTH
+NAMES
+NATIONAL
+NATURAL
+NCHAR
+NEXT
+NO
+NOT
+NULL
+NULLIF
+NUMERIC
+OCTET_LENGTH
+OF
+ON
+ONLY
+OPEN
+OPTION
+OR
+ORDER
+OUTER
+OUTPUT
+OVERLAPS
+PAD
+PARTIAL
+POSITION
+PRECISION
+PREPARE
+PRESERVE
+PRIMARY
+PRIOR
+PRIVILEGES
+PROCEDURE
+PUBLIC
+READ
+REAL
+REFERENCES
+RELATIVE
+RESTRICT
+REVOKE
+RIGHT
+ROLLBACK
+ROWS
+SCHEMA
+SCROLL
+SECOND
+SECTION
+SELECT
+SESSION
+SESSION_
+USER
+SET
+SIZE
+SMALLINT
+SOME
+SPACE
+SQL
+SQLCODE
+SQLERROR
+SQLSTATE
+SUBSTRING
+SUM
+SYSTEM_USER
+TABLE
+TEMPORARY
+THEN
+TIME
+TIMESTAMP
+TIMEZONE_
+HOUR
+TIMEZONE_MINUTE
+TO
+TRAILING
+TRANSACTION
+TRANSLATE
+TRANSLATION
+TRIM
+TRUE
+UNION
+UNIQUE
+UNKNOWN
+UPDATE
+UPPER
+USAGE
+USER
+USING
+VALUE
+VALUES
+VARCHAR
+VARYING
+VIEW
+WHEN
+WHENEVER
+WHERE
+WITH
+WORK
+WRITE
+YEAR
+ZONE
diff --git a/plugins/org.eclipse.net4j.db/reserved_words/derby.txt b/plugins/org.eclipse.net4j.db/reserved_words/derby.txt
new file mode 100644
index 0000000..fe7e130
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/reserved_words/derby.txt
@@ -0,0 +1,208 @@
+ADD
+ALL
+ALLOCATE
+ALTER
+AND
+ANY
+ARE
+AS
+ASC
+ASSERTION
+AT
+AUTHORIZATION
+AVG
+BEGIN
+BETWEEN
+BIGINT
+BIT
+BOOLEAN
+BOTH
+BY
+CALL
+CASCADE
+CASCADED
+CASE
+CAST
+CHAR
+CHARACTER
+CHECK
+CLOSE
+COALESCE
+COLLATE
+COLLATION
+COLUMN
+COMMIT
+CONNECT
+CONNECTION
+CONSTRAINT
+CONSTRAINTS
+CONTINUE
+CONVERT
+CORRESPONDING
+CREATE
+CURRENT
+CURRENT_DATE
+CURRENT_TIME
+CURRENT_TIMESTAMP
+CURRENT_USER
+CURSOR
+DEALLOCATE
+DEC
+DECIMAL
+DECLARE
+DEFAULT
+DEFERRABLE
+DEFERRED
+DELETE
+DESC
+DESCRIBE
+DIAGNOSTICS
+DISCONNECT
+DISTINCT
+DOUBLE
+DROP
+ELSE
+END
+END-EXEC
+ESCAPE
+EXCEPT
+EXCEPTION
+EXEC
+EXECUTE
+EXISTS
+EXPLAIN
+EXTERNAL
+FALSE
+FETCH
+FIRST
+FLOAT
+FOR
+FOREIGN
+FOUND
+FROM
+FULL
+FUNCTION
+GET
+GETCURRENTCONNECTION
+GLOBAL
+GO
+GOTO
+GRANT
+GROUP
+HAVING
+HOUR
+IDENTITY
+IMMEDIATE
+IN
+INDICATOR
+INITIALLY
+INNER
+INOUT
+INPUT
+INSENSITIVE
+INSERT
+INT
+INTEGER
+INTERSECT
+INTO
+IS
+ISOLATION
+JOIN
+KEY
+LAST
+LEFT
+LIKE
+LOWER
+LTRIM
+MATCH
+MAX
+MIN
+MINUTE
+NATIONAL
+NATURAL
+NCHAR
+NVARCHAR
+NEXT
+NO
+NOT
+NULL
+NULLIF
+NUMERIC
+OF
+ON
+ONLY
+OPEN
+OPTION
+OR
+ORDER
+OUTER
+OUTPUT
+OVERLAPS
+PAD
+PARTIAL
+PREPARE
+PRESERVE
+PRIMARY
+PRIOR
+PRIVILEGES
+PROCEDURE
+PUBLIC
+READ
+REAL
+REFERENCES
+RELATIVE
+RESTRICT
+REVOKE
+RIGHT
+ROLLBACK
+ROWS
+RTRIM
+SCHEMA
+SCROLL
+SECOND
+SELECT
+SESSION_USER
+SET
+SMALLINT
+SOME
+SPACE
+SQL
+SQLCODE
+SQLERROR
+SQLSTATE
+SUBSTR
+SUBSTRING
+SUM
+SYSTEM_USER
+TABLE
+TEMPORARY
+TIMEZONE_HOUR
+TIMEZONE_MINUTE
+TO
+TRANSACTION
+TRANSLATE
+TRANSLATION
+TRIM
+TRUE
+UNION
+UNIQUE
+UNKNOWN
+UPDATE
+UPPER
+USER
+USING
+VALUES
+VARCHAR
+VARYING
+VIEW
+WHENEVER
+WHERE
+WITH
+WORK
+WRITE
+XML
+XMLEXISTS
+XMLPARSE
+XMLQUERY
+XMLSERIALIZE
+YEAR
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
index f6f51da..a580244 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
@@ -90,14 +90,14 @@ public abstract class DBAdapter implements IDBAdapter
validateTable((DBTable)table, statement);
}
- public String mangleFieldName(String name, int attempt)
+ public String mangleTableName(String name, int attempt)
{
- return name;
+ return mangleName(name, getMaximumTableNameLength(), attempt);
}
- public String mangleTableName(String name, int attempt)
+ public String mangleFieldName(String name, int attempt)
{
- return name;
+ return mangleName(name, getMaximumFieldNameLength(), attempt);
}
@Override
@@ -177,6 +177,43 @@ public abstract class DBAdapter implements IDBAdapter
throw new IllegalArgumentException("Unknown type: " + type);
}
+ protected int getMaximumTableNameLength()
+ {
+ return 128;
+ }
+
+ protected int getMaximumFieldNameLength()
+ {
+ return 128;
+ }
+
+ protected String mangleName(String name, int max, int attempt)
+ {
+ if (isReservedWord(name))
+ {
+ String suffix = "_" + String.valueOf(attempt);
+ if (name.length() + suffix.length() > max)
+ {
+ name = name.substring(0, max - suffix.length()) + suffix;
+ }
+ else
+ {
+ name += suffix;
+ }
+ }
+ else if (name.length() > max)
+ {
+ name = name.substring(0, max);
+ }
+
+ return name;
+ }
+
+ protected boolean isReservedWord(String word)
+ {
+ return false;
+ }
+
protected void validateTable(DBTable table, Statement statement) throws DBException
{
try