db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r511283 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/impl/sql/catalog/ engine/org/apache/derby/jdbc/ engine/org/apache/derby/loc/ shared/org/apache/derby/shared/common/reference/ testing/or...
Date Sat, 24 Feb 2007 15:10:24 GMT
Author: mamta
Date: Sat Feb 24 07:10:23 2007
New Revision: 511283

URL: http://svn.apache.org/viewvc?view=rev&rev=511283
Log:
DERBY-2334 Accept the new collation attribute and store it in services.properties file. Will
be used for language based collation ordering.

This patch has code for new JDBC url attribute collation in DataDictionaryImpl.java'boot method.
Once the value for this attribute is validated, it is converted to database property derby.database.collation.
This property will get saved in the property conglomerate. 


Patch description in brief 
1)Changes in DataDictionaryImpl.java will validate the value for the optional collation attribute
and use the default UCS_BASIC if no value supplied (this is all at database create time).
This JDBC url attribute will be saved as database property derby.database.collation in the
property conglomerate. 
2)All the JDBC url attributes are defined in Attribute.java. Added collation to that file.
Removed existing attribute collate which is not
used anywhere in the Derby code. Removal of unused "collate" attribute will save confusion
in future between the new "collation" attribute 
and unused "collate" attribute.
3)The 2 valid values for collation attribute are defined in Property.java. They are UCS_BASIC
and TERRITORY_BASED. Also, the database property is defined in this file for collation attribute.

4)Changes in Driver20 class adds the new string attribute so it can be detected by the generic
GUI tools through getPropertyInfo method. 
5)Added new SQLState and message id for new attribute in messages.xml, SQLState.java and MessageId.java

6)Needed to update master GetPropertyInfoTest.out so it is aware of the new collation attribute.



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/MessageId.java
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/GetPropertyInfoTest.out

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java?view=diff&rev=511283&r1=511282&r2=511283
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Attribute.java Sat Feb
24 07:10:23 2007
@@ -151,12 +151,6 @@
 	*/
 	String TERRITORY = "territory";
 
-	/**
-		Set the collation sequence of the database, currently on IDENTITY
-        will be supported (strings will sort according to binary comparison).
-	*/
-	String COLLATE = "collate";
-
     /**
         Attribute for encrypting a database.
         Specifies the cryptographic services provider.
@@ -243,4 +237,19 @@
      */
     String DRDA_SECTKN_IN = "drdaSecTokenIn";
     String DRDA_SECTKN_OUT = "drdaSecTokenOut";
+
+	/**
+		Optional JDBC url attribute (at the database create time only) It can 
+		be set to one of the following 2 values
+		1) UCS_BASIC (This means codepoint based collation. This will also be 
+		the default collation used by Derby if no collation attribute is 
+		specified on the JDBC url at the database create time. This collation 
+		is what Derby 10.2 and prior have supported)
+		2)TERRITORY_BASED (the collation will be based on language 
+		region specified by the exisiting Derby attribute called territory. 
+		If the territory attribute is not specified at the database create 
+		time, Derby will use java.util.Locale.getDefault to determine the 
+		territory for the newly created database. 
+	*/
+	String COLLATION = "collation";
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java?view=diff&rev=511283&r1=511282&r2=511283
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Property.java Sat Feb
24 07:10:23 2007
@@ -842,6 +842,13 @@
 	public static final String SERVICE_PROTOCOL = "derby.serviceProtocol";
 	public static final String SERVICE_LOCALE = "derby.serviceLocale";
 
+	public static final String COLLATION = "derby.database.collation";
+	// These are the 2 possible values for collation
+	public static final String UCS_BASIC_COLLATION =
+								"UCS_BASIC";
+	public static final String TERRITORY_BASED_COLLATION =
+								"TERRITORY_BASED";
+
     /**
      * db2j.storage.dataNotSyncedAtCheckPoint
      * <p>

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?view=diff&rev=511283&r1=511282&r2=511283
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Sat Feb 24 07:10:23 2007
@@ -21,6 +21,7 @@
 
 package org.apache.derby.impl.sql.catalog;
 
+import org.apache.derby.iapi.reference.Attribute;
 import org.apache.derby.iapi.reference.EngineType;
 import org.apache.derby.iapi.reference.JDBC30Translation;
 import org.apache.derby.iapi.reference.Property;
@@ -671,7 +672,18 @@
 					bootingTC.setProperty(Property.SQL_AUTHORIZATION_PROPERTY,"true",true);
 					usesSqlAuthorization=true;
 				}
-
+				// Get the collation attribute from the JDBC url. It can only have one of
+				// 2 possible values - UCS_BASIC or TERRITORY_BASED
+				// This attribute can only be specified at database create time.
+				String userDefinedCollation = startParams.getProperty(Attribute.COLLATION);		
+				if (userDefinedCollation == null)
+					userDefinedCollation = Property.UCS_BASIC_COLLATION;
+				else {//Invalid value handling
+					if (!userDefinedCollation.equalsIgnoreCase(Property.UCS_BASIC_COLLATION)
+							&& !userDefinedCollation.equalsIgnoreCase(Property.TERRITORY_BASED_COLLATION))
+						throw StandardException.newException(SQLState.INVALID_COLLATION, userDefinedCollation);
+					}
+				bootingTC.setProperty(Property.COLLATION,userDefinedCollation,true);
 			} else {
 				// Get the ids for non-core tables
 				loadDictionaryTables(bootingTC, ddg, startParams);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java?view=diff&rev=511283&r1=511282&r2=511283
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java Sat Feb 24 07:10:23
2007
@@ -189,6 +189,7 @@
 				{Attribute.CRYPTO_KEY_LENGTH, MessageId.CONN_CRYPTO_KEY_LENGTH},
 				{Attribute.CRYPTO_EXTERNAL_KEY, MessageId.CONN_CRYPTO_EXTERNAL_KEY},
 				{Attribute.TERRITORY, MessageId.CONN_LOCALE},
+				{Attribute.COLLATION, MessageId.CONN_COLLATION},
 				{Attribute.USERNAME_ATTR, MessageId.CONN_USERNAME_ATTR},
 				{Attribute.LOG_DEVICE, MessageId.CONN_LOG_DEVICE},
 				{Attribute.ROLL_FORWARD_RECOVERY_FROM, MessageId.CONN_ROLL_FORWARD_RECOVERY_FROM},

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?view=diff&rev=511283&r1=511282&r2=511283
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Sat Feb 24 07:10:23
2007
@@ -3351,6 +3351,12 @@
             </msg>
 
             <msg>
+                <name>XBM03.D</name>
+                <text>Supplied value '{0}' for collation attribute is invalid, expecting
UCS_BASIC or TERRITORY_BASED.</text>
+                <arg>value</arg>
+            </msg>
+
+            <msg>
                 <name>XBM0Y.D</name>
                 <text>Backup database directory {0} not found. Please make sure that
the specified backup path is right.</text>
                 <arg>directoryName</arg>
@@ -6973,6 +6979,11 @@
             <msg>
                 <name>J028</name>
                 <text>backup path for rollforward recovery</text>
+            </msg>
+
+            <msg>
+                <name>J031</name>
+                <text>collation for chararcter datatypes</text>
             </msg>
 
             <msg>

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/MessageId.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/MessageId.java?view=diff&rev=511283&r1=511282&r2=511283
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/MessageId.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/MessageId.java
Sat Feb 24 07:10:23 2007
@@ -111,6 +111,7 @@
 	String CONN_CRYPTO_EXTERNAL_KEY         = "J019"; // external cryptographic key
 	String CONN_BOOT_PASSWORD               = "J020"; // secret cryptographic key
 	String CONN_LOCALE                      = "J021"; // locale for the database
+	String CONN_COLLATION                   = "J031"; // collation info for the character datatypes
 	String CONN_USERNAME_ATTR               = "J022"; // user name
 	String CONN_PASSWORD_ATTR               = "J023"; // user password
 	String CONN_LOG_DEVICE                  = "J025"; // log directory path

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?view=diff&rev=511283&r1=511282&r2=511283
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
Sat Feb 24 07:10:23 2007
@@ -173,6 +173,7 @@
 	String REGISTERED_CLASS_LINAKGE_ERROR		= "XBM0V.S";
 	String REGISTERED_CLASS_INSTANCE_ERROR		= "XBM0W.S";
 	String INVALID_LOCALE_DESCRIPTION			= "XBM0X.D";
+	String INVALID_COLLATION			        = "XBM03.D";
 	String SERVICE_DIRECTORY_NOT_IN_BACKUP      = "XBM0Y.D";
 	String UNABLE_TO_COPY_FILE_FROM_BACKUP      = "XBM0Z.D";
 	String PROPERTY_FILE_NOT_FOUND_IN_BACKUP    = "XBM0Q.D";

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/GetPropertyInfoTest.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/GetPropertyInfoTest.out?view=diff&rev=511283&r1=511282&r2=511283
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/GetPropertyInfoTest.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/GetPropertyInfoTest.out
Sat Feb 24 07:10:23 2007
@@ -5,6 +5,7 @@
 encryptionKeyLength - value: null - description: cryptographic key length - required false
- choices null 
 encryptionKey - value: null - description: external cryptographic key - required false -
choices null 
 territory - value: null - description: territory for the database - required false - choices
null 
+collation - value: null - description: collation for chararcter datatypes - required false
- choices null 
 user - value: null - description: user name - required false - choices null 
 logDevice - value: null - description: log directory path - required false - choices null

 rollForwardRecoveryFrom - value: null - description: backup path for rollforward recovery
- required false - choices null 
@@ -22,6 +23,7 @@
 encryptionKeyLength - value: null - description: cryptographic key length - required false
- choices null 
 encryptionKey - value: null - description: external cryptographic key - required false -
choices null 
 territory - value: null - description: territory for the database - required false - choices
null 
+collation - value: null - description: collation for chararcter datatypes - required false
- choices null 
 user - value: null - description: user name - required false - choices null 
 logDevice - value: null - description: log directory path - required false - choices null

 rollForwardRecoveryFrom - value: null - description: backup path for rollforward recovery
- required false - choices null 



Mime
View raw message