db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r541370 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/compile/ iapi/types/ impl/sql/compile/
Date Thu, 24 May 2007 17:54:15 GMT
Author: djd
Date: Thu May 24 10:54:14 2007
New Revision: 541370

URL: http://svn.apache.org/viewvc?view=rev&rev=541370
Log:
Add DataValueFactory.generateNull*Char() methods that take a collation type.
Use these methods in TypeCompiler.generateNull() to avoid having to push
another data value factory instance at generation time. ExpressionClassBuilder
no longer needs to be passed to the generate methods of TypeCompiler thus
that argument is removed and the class becomes package private again.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java?view=diff&rev=541370&r1=541369&r2=541370
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java Thu
May 24 10:54:14 2007
@@ -25,7 +25,6 @@
 
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.compiler.LocalField;
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
 
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.TypeId;
@@ -179,15 +178,13 @@
 	 * type. The stack must contain a DataValueFactory and a null or a value
 	 * of the correct type (interfaceName()).
 	 *
-	 * @param eb The ExpressionClassBuilder for the class we're generating
 	 * @param mb	The method to put the expression in
 	 * @param collationType For character DVDs, this will be used to determine
 	 *   what Collator should be associated with the DVD which in turn will 
 	 *   decide whether to generate CollatorSQLcharDVDs or SQLcharDVDs.
 	 */
 
-	void generateNull(ExpressionClassBuilder eb,
-			MethodBuilder mb, int collationType);
+	void generateNull(MethodBuilder mb, int collationType);
 
 
 	/**
@@ -202,7 +199,6 @@
 	 * 
 	 * The stack must contain data value factory value.
 	 * 
-	 * @param eb The ExpressionClassBuilder for the class we're generating
 	 * @param mb	The method to put the expression in
 	 * @param collationType For character DVDs, this will be used to determine
 	 *   what Collator should be associated with the DVD which in turn will 
@@ -211,7 +207,6 @@
 	 * @param field LocalField
 	 */
 	void generateDataValue(
-			ExpressionClassBuilder eb,
 			MethodBuilder mb, int collationType, 
 			LocalField field);
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java?view=diff&rev=541370&r1=541369&r2=541370
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java Thu
May 24 10:54:14 2007
@@ -633,35 +633,67 @@
         
     // ------ CHAR
         /**
-         * Get a SQL char with a SQL null value. If the supplied value
+         * Get a SQL CHAR (UCS_BASIC) with a SQL null value. If the supplied value
          * is null then get a new value, otherwise set it to null and return 
          * that value.
          */
         StringDataValue         getNullChar(StringDataValue dataValue);
+        
+        /**
+         * Get a SQL CHAR set to NULL with collation set to collationType.
+         * If the supplied value is null then get a new value,
+         * otherwise set it to null and return that value.
+         */
+        StringDataValue         getNullChar(StringDataValue dataValue,
+                int collationType);
 
         /**
-         * Get a SQL varchar with a SQL null value. If the supplied value
+         * Get a SQL VARCHAR (UCS_BASIC) with a SQL null value. If the supplied value
          * is null then get a new value, otherwise set it to null and return 
          * that value.
          *
          */
         StringDataValue         getNullVarchar(StringDataValue dataValue);
+        
+        /**
+         * Get a SQL VARCHAR set to NULL with collation set to collationType.
+         * If the supplied value is null then get a new value,
+         * otherwise set it to null and return that value.
+         */
+        StringDataValue         getNullVarchar(StringDataValue dataValue,
+                int collationType);
 
         /**
-         * Get a SQL long varchar with a SQL null value. If the supplied value
+         * Get a SQL LONG VARCHAR (UCS_BASIC) with a SQL null value. If the supplied value
          * is null then get a new value, otherwise set it to null and return 
          * that value.
          *
          */
         StringDataValue         getNullLongvarchar(StringDataValue dataValue);
+        
+        /**
+         * Get a SQL LONG VARCHAR set to NULL with collation set to collationType.
+         * If the supplied value is null then get a new value,
+         * otherwise set it to null and return that value.
+         */
+        StringDataValue         getNullLongvarchar(StringDataValue dataValue,
+                int collationType);
 
         /**
-         * Get a SQL long varchar with a SQL null value. If the supplied value
+         * Get a SQL CLOB (UCS_BASIC) with a SQL null value. If the supplied value
          * is null then get a new value, otherwise set it to null and return 
          * that value.
          *
          */
         StringDataValue         getNullClob(StringDataValue dataValue);
+
+        /**
+         * Get a SQL CLOB set to NULL with collation set to collationType.
+         * If the supplied value is null then get a new value,
+         * otherwise set it to null and return that value.
+         */
+        StringDataValue         getNullClob(StringDataValue dataValue,
+                int collationType);
 
         /**
          * Get a SQL national char with a SQL null value. If the supplied value

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java?view=diff&rev=541370&r1=541369&r2=541370
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java
Thu May 24 10:54:14 2007
@@ -866,6 +866,23 @@
                         return dataValue;
                 }
         }
+        /**
+         * Get a SQL CHAR set to NULL with collation set to collationType.
+         * If the supplied value is null then get a new value,
+         * otherwise set it to null and return that value.
+         */
+        public StringDataValue         getNullChar(StringDataValue previous,
+                int collationType)
+        {
+            if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
+                return getNullChar(previous);
+            
+            if (previous == null)
+                return new CollatorSQLChar(getCharacterCollator(collationType));
+            
+            previous.setToNull();
+            return previous;
+         }
 
         public StringDataValue          getNullVarchar(StringDataValue dataValue)
         {
@@ -879,6 +896,24 @@
                         return dataValue;
                 }
         }
+        
+        /**
+         * Get a SQL VARCHAR set to NULL with collation set to collationType.
+         * If the supplied value is null then get a new value,
+         * otherwise set it to null and return that value.
+         */
+        public StringDataValue         getNullVarchar(StringDataValue previous,
+                int collationType)
+        {
+            if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
+                return getNullChar(previous);
+            
+            if (previous == null)
+                return new CollatorSQLVarchar(getCharacterCollator(collationType));
+            
+            previous.setToNull();
+            return previous;
+        }
 
         public StringDataValue          getNullLongvarchar(StringDataValue dataValue)
         {
@@ -892,6 +927,24 @@
                         return dataValue;
                 }
         }
+        
+        /**
+         * Get a SQL LONG VARCHAR set to NULL with collation set to collationType.
+         * If the supplied value is null then get a new value,
+         * otherwise set it to null and return that value.
+         */
+        public StringDataValue         getNullLongvarchar(StringDataValue previous,
+                int collationType)
+        {
+            if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
+                return getNullChar(previous);
+            
+            if (previous == null)
+                return new CollatorSQLLongvarchar(getCharacterCollator(collationType));
+            
+            previous.setToNull();
+            return previous;
+        }
 
         public StringDataValue          getNullClob(StringDataValue dataValue)
         {
@@ -904,6 +957,24 @@
                         dataValue.setToNull();
                         return dataValue;
                 }
+        }
+        
+        /**
+         * Get a SQL CLOB set to NULL with collation set to collationType.
+         * If the supplied value is null then get a new value,
+         * otherwise set it to null and return that value.
+         */
+        public StringDataValue         getNullClob(StringDataValue previous,
+                int collationType)
+        {
+            if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
+                return getNullChar(previous);
+            
+            if (previous == null)
+                return new CollatorSQLClob(getCharacterCollator(collationType));
+            
+            previous.setToNull();
+            return previous;
         }
 
         public StringDataValue          getNullNationalChar(StringDataValue dataValue)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java?view=diff&rev=541370&r1=541369&r2=541370
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
Thu May 24 10:54:14 2007
@@ -34,13 +34,10 @@
 import org.apache.derby.iapi.types.DataValueFactory;
 import org.apache.derby.iapi.types.NumberDataValue;
 import org.apache.derby.iapi.types.SQLInteger;
-import org.apache.derby.iapi.types.StringDataValue;
 import org.apache.derby.iapi.types.TypeId;
 
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 
-import org.apache.derby.iapi.reference.ClassName;
-
 import org.apache.derby.iapi.services.compiler.LocalField;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 
@@ -111,13 +108,12 @@
      * 
      * ...,dvd
      * 
-     * @see TypeCompiler#generateNull(ExpressionClassBuilder, MethodBuilder, int)
+     * @see TypeCompiler#generateNull(MethodBuilder, int)
      */
-	public void generateNull(ExpressionClassBuilder e,
-			MethodBuilder mb, int collationType)
+	public void generateNull(MethodBuilder mb, int collationType)
 	{
         int argCount;
-        if (false & pushCollationForDataValue(collationType))
+        if (pushCollationForDataValue(collationType))
         {
             mb.push(collationType);
             argCount = 2;
@@ -162,10 +158,9 @@
      * 
      * ...,dvd
      * 
-     * @see TypeCompiler#generateDataValue(ExpressionClassBuilder, MethodBuilder, int, LocalField)
+     * @see TypeCompiler#generateDataValue(MethodBuilder, int, LocalField)
      */
-    public void generateDataValue(ExpressionClassBuilder eb,
-			MethodBuilder mb, int collationType,
+    public void generateDataValue(MethodBuilder mb, int collationType,
 			LocalField field)
 	{
 
@@ -208,46 +203,6 @@
 			 */
 			mb.putField(field);
 		}
-	}
-
-	/**
-	 * If the collation type is UCS_BASIC, then we have already generated the
-	 * code for the correct DVD and hence simply return from this method. 
-	 * 
-	 * But if the collation type is territory based and we are generating DVDs
-	 * for character types, then we need to generate CollatorSQLxxx type of 
-	 * DVD. This CollatorSQLxxx DVD will be provided by generating following 
-	 * code which works on top of the DVD that has been generated with 
-	 * UCS_BASIC collation.
-	 * DVDwithUCS_BASIC.getValue(DVF.getCharacterCollator(collationType));
-	 * 
-	 * This method will be called only by CharTypeCompiler and ClobTypeCompiler 
-	 * because those are the only type compilers who generate DVDs which are 
-	 * impacted by the collation. Rest of the TypeCompilers generate DVDs which
-	 * are collation in-sensitive.
-	 *
-	 * @param eb The ExpressionClassBuilder for the class we're generating
-	 * @param mb The method to put the expression in
-	 * @param collationType For character DVDs, this will be used to determine
-	 *   what Collator should be associated with the DVD which in turn will 
-	 *   decide whether to generate CollatorSQLcharDVDs or SQLcharDVDs. For 
-	 *   other types of DVDs, this parameter will be ignored.
-	 */
-	void generateCollationSensitiveDataValue(
-			ExpressionClassBuilder eb,
-			MethodBuilder mb, 
-			int collationType){		
-		if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
-			return; 
-		//In case of character DVDs, for territory based collation, we need to 
-		//generate DVDs with territory based RuleBasedCollator and hence we 
-		//need to generate CollatorSQLChar/CollatorSQLVarchar/
-		//CollatorSQLLongvarchar/CollatorSQLClob 
-		eb.pushDataValueFactory(mb);
-		mb.push(collationType);
-		mb.callMethod(VMOpcode.INVOKEINTERFACE, null, "getCharacterCollator",
-				"java.text.RuleBasedCollator", 1);
-		mb.callMethod(VMOpcode.INVOKEINTERFACE, null, "getValue", interfaceName(), 1);
 	}
 
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java?view=diff&rev=541370&r1=541369&r2=541370
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
Thu May 24 10:54:14 2007
@@ -151,17 +151,4 @@
         {
             return collationType != StringDataValue.COLLATION_TYPE_UCS_BASIC;
         }
-
-        /**
-         * Augment the parent's method by ensuring the generated
-         * value is setup for collation if required.
-         * @see BaseTypeCompiler#generateCollationSensitiveDataValue(ExpressionClassBuilder,
MethodBuilder, int)
-         */
-        public void generateNull(
-    			ExpressionClassBuilder eb,
-				MethodBuilder mb, int collationType)
-    	{
-    		super.generateNull(eb, mb, collationType);
-    		generateCollationSensitiveDataValue(eb, mb, collationType);
-    	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java?view=diff&rev=541370&r1=541369&r2=541370
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
Thu May 24 10:54:14 2007
@@ -204,19 +204,6 @@
             return collationType != StringDataValue.COLLATION_TYPE_UCS_BASIC;
         }
 
-        /**
-         * Augment the parent's method by ensuring the generated
-         * value is setup for collation if required.
-         * @see BaseTypeCompiler#generateCollationSensitiveDataValue(ExpressionClassBuilder,
MethodBuilder, int)
-         */
-    	public void generateNull(
-    			ExpressionClassBuilder eb,
-				MethodBuilder mb, int collationType)
-    	{
-    		super.generateNull(eb, mb, collationType);
-    		generateCollationSensitiveDataValue(eb, mb, collationType);
-    	}
-
         String dataValueMethodName()
         {
                 int formatId = getStoredFormatIdFromTypeId();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java?view=diff&rev=541370&r1=541369&r2=541370
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
Thu May 24 10:54:14 2007
@@ -80,7 +80,7 @@
  * FilterClassBuilder. See the documentation on ActivationClassBuilder.
  *
  */
-public abstract	class ExpressionClassBuilder implements ExpressionClassBuilderInterface
+abstract	class ExpressionClassBuilder implements ExpressionClassBuilderInterface
 {
 	///////////////////////////////////////////////////////////////////////
 	//
@@ -870,7 +870,7 @@
 	void generateNull(MethodBuilder mb, TypeCompiler tc, int collationType) {
 		pushDataValueFactory(mb);
 		mb.pushNull(tc.interfaceName());
-		tc.generateNull(this, mb, collationType);
+		tc.generateNull(mb, collationType);
 	}
 
 	/**
@@ -883,7 +883,7 @@
 		pushDataValueFactory(mb);
 		mb.swap(); // need the dvf as the instance
 		mb.cast(tc.interfaceName());
-		tc.generateNull(this, mb, collationType);
+		tc.generateNull(mb, collationType);
 	}
 
 	/**
@@ -896,7 +896,7 @@
 			int collationType, LocalField field) {
 		pushDataValueFactory(mb);
 		mb.swap(); // need the dvf as the instance
-		tc.generateDataValue(this, mb, collationType, field);
+		tc.generateDataValue(mb, collationType, field);
 	}
 
 	

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java?view=diff&rev=541370&r1=541369&r2=541370
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
Thu May 24 10:54:14 2007
@@ -530,8 +530,7 @@
 	}
 
 
-	public void generateDataValue(ExpressionClassBuilder eb,
-			MethodBuilder mb, int collationType,
+	public void generateDataValue(MethodBuilder mb, int collationType,
 			LocalField field)
 	{
 		if (!JVMInfo.J2ME && getTypeId().isDecimalTypeId())
@@ -543,7 +542,7 @@
 			mb.upCast("java.lang.Number");
 		}
 
-		super.generateDataValue(eb, mb, collationType, field);
+		super.generateDataValue(mb, collationType, field);
 	}
 
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java?view=diff&rev=541370&r1=541369&r2=541370
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
Thu May 24 10:54:14 2007
@@ -118,13 +118,13 @@
 		return "getNullObject";
 	}
 
-	public void generateDataValue(ExpressionClassBuilder eb, MethodBuilder mb, int collationType,
+	public void generateDataValue(MethodBuilder mb, int collationType,
 			LocalField field)
 	{
 		// cast the value to an object for method resolution
 		mb.upCast("java.lang.Object");
 
-		super.generateDataValue(eb, mb, collationType, field);
+		super.generateDataValue(mb, collationType, field);
 	}
 
 		



Mime
View raw message