db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r545566 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/
Date Fri, 08 Jun 2007 17:29:46 GMT
Author: djd
Date: Fri Jun  8 10:29:43 2007
New Revision: 545566

URL: http://svn.apache.org/viewvc?view=rev&rev=545566
Log:
DERBY-2775 (partial) Some cleanup of type handling in ValueNode towards the aime that the
type of a node is defined by getTypeServices() consistently so that sub-classes can override
getTypeServices() and ensure all other code will get the correct type.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AndNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConstantNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AndNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AndNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AndNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AndNode.java Fri Jun
 8 10:29:43 2007
@@ -152,7 +152,7 @@
 												leftOperand,
 												rightOperand,
 												getContextManager());
-		orNode.setType(dataTypeServices);
+		orNode.setType(getTypeServices());
 		return orNode;
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
Fri Jun  8 10:29:43 2007
@@ -630,12 +630,12 @@
 			 * result set scale consistent, beetle 3901
 			 */
 			int jdbcType;
-			if ((dataTypeServices != null) &&
-				((jdbcType = dataTypeServices.getJDBCTypeId()) == java.sql.Types.DECIMAL ||
+			if ((getTypeServices() != null) &&
+				((jdbcType = getTypeServices().getJDBCTypeId()) == java.sql.Types.DECIMAL ||
 				 jdbcType == java.sql.Types.NUMERIC) &&
 				operator.equals("/"))
 			{
-				mb.push(dataTypeServices.getScale());		// 4th arg
+				mb.push(getTypeServices().getScale());		// 4th arg
 				mb.callMethod(VMOpcode.INVOKEINTERFACE, receiverType, methodName, resultTypeName, 4);
 			}
 			else if (xmlGen) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
Fri Jun  8 10:29:43 2007
@@ -953,14 +953,14 @@
 	{
 		BinaryOperatorNode negation;
 		if (SanityManager.DEBUG)
-			SanityManager.ASSERT(dataTypeServices != null,
+			SanityManager.ASSERT(getTypeServices() != null,
 								 "dataTypeServices is expected to be non-null");
 		/* xxxRESOLVE: look into doing this in place instead of allocating a new node */
 		negation = (BinaryOperatorNode)
 			getNodeFactory().getNode(getNegationNode(),
 									 leftOperand, rightOperand,
 									 getContextManager());
-		negation.setType(dataTypeServices);
+		negation.setType(getTypeServices());
 		return negation;
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BitConstantNode.java
Fri Jun  8 10:29:43 2007
@@ -85,29 +85,6 @@
 		setValue(dvd);
 	}
 
-	/**
-	 * Initializer for non-numeric types.  Needed for our subclasses
-	 *
-	 * @param typeId	The Type ID of the datatype
-	 * @param nullable	True means the constant is nullable
-	 * @param maximumWidth	The maximum number of bytes in the data value
-	 *
-	 * @exception StandardException
-	 */
-	public void init(
-			Object typeId,
-			Object nullable,
-			Object maximumWidth)
-		throws StandardException
-	{
-		init(
-					typeId,
-					ReuseFactory.getInteger(0),
-					ReuseFactory.getInteger(0),
-					nullable,
-					maximumWidth);
-	}
-
 
 	/**
 	 * Return an Object representing the bind time value of this

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Fri Jun
 8 10:29:43 2007
@@ -376,7 +376,7 @@
 		*/
 		if (destCTI.userType())
 		{
-			String className = dataTypeServices.getTypeId().getCorrespondingJavaTypeName();
+			String className = getTypeId().getCorrespondingJavaTypeName();
 
 			verifyClassExist(className);
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
Fri Jun  8 10:29:43 2007
@@ -494,7 +494,7 @@
 			ValueNode cast = (ValueNode) getNodeFactory().getNode(
 								C_NodeTypes.CAST_NODE,
 								thenElseList.elementAt(0), 
-								dataTypeServices,	// cast to dominant type
+                                getTypeServices(),	// cast to dominant type
 								getContextManager());
 			cast = cast.bindExpression(fromList, 
 											subqueryList,
@@ -508,7 +508,7 @@
 			ValueNode cast = (ValueNode) getNodeFactory().getNode(
 								C_NodeTypes.CAST_NODE,
 								thenElseList.elementAt(1), 
-								dataTypeServices,	// cast to dominant type
+                                getTypeServices(),	// cast to dominant type
 								getContextManager());
 			cast = cast.bindExpression(fromList, 
 											subqueryList,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConstantNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConstantNode.java Fri
Jun  8 10:29:43 2007
@@ -22,6 +22,7 @@
 package	org.apache.derby.impl.sql.compile;
 
 import org.apache.derby.iapi.types.DataValueDescriptor;
+import org.apache.derby.iapi.types.TypeId;
 
 import org.apache.derby.iapi.error.StandardException;
 
@@ -82,13 +83,10 @@
 			Object maximumWidth)
 		throws StandardException
 	{
-		/* Fill in the type information in the parent ValueNode */
-		init(
-							typeId,
-							ReuseFactory.getInteger(0),
-							ReuseFactory.getInteger(0),
-							nullable,
-							maximumWidth);
+        setType((TypeId) typeId,
+                ((Boolean) nullable).booleanValue(),
+                ((Integer) maximumWidth).intValue());
+
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InListOperatorNode.java
Fri Jun  8 10:29:43 2007
@@ -315,7 +315,6 @@
 					getContextManager());
 
 			DataTypeDescriptor pType = srcVal.getTypeServices();
-			pNode.setDescriptors(new DataTypeDescriptor [] { pType });
 			pNode.setType(pType);
 
 			/* If we choose to use the new predicate for execution-time

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java Fri
Jun  8 10:29:43 2007
@@ -107,7 +107,7 @@
 
 		if (SanityManager.DEBUG)
 		{
-			SanityManager.ASSERT(dataTypeServices != null,
+			SanityManager.ASSERT(getTypeServices() != null,
 						"dataTypeServices is expected to be non-null");
 		}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java
Fri Jun  8 10:29:43 2007
@@ -179,14 +179,14 @@
 			break;
 		}
 		
-		super.init(
+		setType(
 				   (typeId != null) ?  typeId :
 				     TypeId.getBuiltInTypeId(typeid),
 
-				   ReuseFactory.getInteger(precision), 
-				   ReuseFactory.getInteger(scal), 
-				   isNullable, 
-				   ReuseFactory.getInteger(maxwidth));
+				   precision, 
+				   scal, 
+				   isNullable.booleanValue(), 
+				   maxwidth);
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrNode.java Fri Jun
 8 10:29:43 2007
@@ -305,7 +305,7 @@
 													leftOperand,
 													rightOperand,
 													getContextManager());
-		andNode.setType(dataTypeServices);
+		andNode.setType(getTypeServices());
 		return andNode;
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java Fri
Jun  8 10:29:43 2007
@@ -51,15 +51,22 @@
 	*/
 	private int	parameterNumber;
 
-	/*
-	** Pointer to the array in the DMLStatementNode that holds the
-	** DataTypeServices for the parameters.  When each parameter is
+	/**
+	** Pointer to the array in the CompilerContext that holds array
+    * of types for all the user-visible paramerers..  When each parameter is
 	** bound, it fills in its type descriptor in this array.  Note that
 	** the array is allocated in the parser, but the individual elements
 	** are not filled in until their corresponding parameters are bound.
+    *
+    * This array is not read in this class, but is read from the
+    * CompilerContext on completion of compiling the statement.
+    * 
+    *  In some case a parameter node may exist but is not a visble
+    *  user parameter, in this case typeServices will be null
+    *  so that setting its type will not modify the user's set.
 	*/
 
-	private DataTypeDescriptor[]	typeServices;
+	private DataTypeDescriptor[]	userParameterTypes;
 
 	/*
 	** The default value for this parameter.  Currently, the only
@@ -141,17 +148,7 @@
 
 	void setDescriptors(DataTypeDescriptor[] descriptors)
 	{
-
-        // The following is commented out for #3546, for create publication 
-        // or target ddl creations there could be multiple statements trying
-        // to bind their own parameters. So the following assumptions does not
-        // hold true. 
-
-	//	if (SanityManager.DEBUG)
-	//	SanityManager.ASSERT(typeServices == null,
-	//		"Attempt to re-set typeServices");
-
-		typeServices = descriptors;
+		userParameterTypes = descriptors;
 	}
 
 	/**
@@ -163,7 +160,7 @@
 	public void setType(DataTypeDescriptor descriptor) throws StandardException
 	{
 		if (SanityManager.DEBUG)
-		SanityManager.ASSERT(typeServices != null,
+		SanityManager.ASSERT(userParameterTypes != null,
 			"typeServices not initialized");
 
 		/* Make sure the type is nullable. */
@@ -176,7 +173,8 @@
 			descriptor = new DataTypeDescriptor(descriptor, true);
 		}
 
-		typeServices[parameterNumber] = descriptor;
+        if (userParameterTypes != null)
+		    userParameterTypes[parameterNumber] = descriptor;
 
 		//make sure we are calling super's setType. We will get into
 		//an infinite loop if this setType ends up calling the local

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java Fri
Jun  8 10:29:43 2007
@@ -1739,27 +1739,6 @@
 	}
 
 	/**
-	 * Get the TypeId from this Node.
-	 *
-	 * @return	The TypeId from this Node.  This
-	 *		may be null if the node isn't bound yet.
-	 */
-	public TypeId getTypeId() throws StandardException
-	{
-        TypeId t = super.getTypeId();
-        if( t == null)
-        {
-            if( expression != null)
-            {
-                DataTypeDescriptor dtd = getTypeServices();
-                if( dtd != null)
-                    t = dtd.getTypeId();
-            }
-        }
-        return t;
-	} // end of getTypeId
-
-	/**
 	 * Get the DataTypeServices from this Node.
 	 *
 	 * @return	The DataTypeServices from this Node.  This

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java
Fri Jun  8 10:29:43 2007
@@ -462,7 +462,7 @@
 	  *
 	  * @exception StandardException		Thrown on error
 	  */
-	public	String	getSQLValueInterfaceName()
+	private	String	getSQLValueInterfaceName()
 		throws StandardException
 	{
 		return value.getTypeCompiler().interfaceName();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java?view=diff&rev=545566&r1=545565&r2=545566
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java Fri Jun
 8 10:29:43 2007
@@ -21,42 +21,23 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
-import org.apache.derby.iapi.types.DataValueFactory;
-
-import org.apache.derby.iapi.types.SQLChar;
+import java.util.Vector;
 
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.sql.compile.CompilerContext;
-import org.apache.derby.iapi.sql.compile.Optimizable;
 import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.CompilerContext;
 import org.apache.derby.iapi.sql.compile.NodeFactory;
-
-import org.apache.derby.iapi.reference.SQLState;
-
+import org.apache.derby.iapi.sql.compile.Optimizable;
+import org.apache.derby.iapi.sql.compile.TypeCompiler;
 import org.apache.derby.iapi.store.access.Qualifier;
-
-import org.apache.derby.impl.sql.compile.ActivationClassBuilder;
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.DataValueFactory;
+import org.apache.derby.iapi.types.TypeId;
 import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.services.i18n.MessageService;
-
-import java.lang.reflect.Modifier;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-
-import java.util.Vector;
 
 /**
  * A ValueNode is an abstract class for all nodes that can represent data
@@ -66,8 +47,11 @@
 
 public abstract class ValueNode extends QueryTreeNode
 {
+    /**
+     * The data type for this node.
+     */
 	protected DataTypeDescriptor	dataTypeServices;
-	private TypeId typeId;	   
+   
 	private TypeCompiler typeCompiler;
 
 	// Whether or not additional predicates have been created from this one.
@@ -83,6 +67,44 @@
 	public ValueNode()
 	{
 	}
+    
+    /**
+     * Set this node's type from type components.
+     */
+    final void setType(TypeId typeId,
+            boolean isNullable,
+            int maximumWidth)
+       throws StandardException
+       
+       {
+        setType(
+                new DataTypeDescriptor(
+                            (TypeId) typeId,
+                            isNullable,
+                            maximumWidth
+                        )
+                    );           
+       }
+
+    /**
+     * Set this node's type from type components.
+     */
+    final void setType(TypeId typeId,
+            int precision, int scale,
+            boolean isNullable,
+            int maximumWidth)
+       throws StandardException
+    {
+        setType(
+                new DataTypeDescriptor(
+                            (TypeId) typeId,
+                            precision,
+                            scale,
+                            isNullable,
+                            maximumWidth
+                        )
+                    );   
+    }
 
 	/**
 	 * Initializer for numeric types.
@@ -186,7 +208,10 @@
 	 */
 	public TypeId getTypeId() throws StandardException
 	{
-		return typeId;
+        DataTypeDescriptor dtd = getTypeServices();
+        if (dtd != null)
+            return dtd.getTypeId();
+		return null;
 	}
 
 
@@ -198,23 +223,15 @@
 	}
 
 	/**
-	 * Get the TypeCompiler from this ValueNode, based on its TypeId.
+	 * Get the TypeCompiler from this ValueNode, based on its TypeId
+     * using getTypeId().
 	 *
 	 * @return	This ValueNode's TypeCompiler
 	 *
 	 */
-	public TypeCompiler getTypeCompiler() throws StandardException
+	public final TypeCompiler getTypeCompiler() throws StandardException
 	{
-		if (typeCompiler == null)
-		{
-			/*
-			** getTypeId() is overriddend by parameter node so
-			** don't get smart and remove the extra method call.
-			*/
-			typeCompiler = getTypeCompiler(getTypeId());
-		}
-
-		return typeCompiler;
+		return getTypeCompiler(getTypeId());
 	}
 
 	/**
@@ -229,12 +246,6 @@
 	{
 		this.dataTypeServices = dataTypeServices;
 
-		/* Get this now so we only have to cast it once */
-		if (dataTypeServices == null)
-			typeId = null;
-		else
-			typeId = dataTypeServices.getTypeId();
-
 		// Clear the typeCompiler, just in case type has changed
 		typeCompiler = null;
 	}
@@ -256,9 +267,9 @@
 	 */
 	protected void setCollationUsingCompilationSchema(int collationDerivation)
 	throws StandardException {
-		dataTypeServices.setCollationType(
+        getTypeServices().setCollationType(
 	    	     getSchemaDescriptor(null, false).getCollationType());
-		dataTypeServices.setCollationDerivation(collationDerivation);
+        getTypeServices().setCollationDerivation(collationDerivation);
 	}
 
 
@@ -356,9 +367,9 @@
 	{
 		if (SanityManager.DEBUG)
 		{
-			SanityManager.ASSERT(typeId != null,
+			SanityManager.ASSERT(getTypeId() != null,
 				"genSQLJavaSQLTree() only expected to be called on a bound node");
-			SanityManager.ASSERT(typeId.userType(),
+			SanityManager.ASSERT(getTypeId().userType(),
 				"genSQLJavaSQLTree() only expected to be called on user types");
 		}
 
@@ -426,10 +437,9 @@
 		/* bind() has ensured that this node's type is SQLBoolean */
 		if (SanityManager.DEBUG)
 		SanityManager.ASSERT(
-				dataTypeServices.getTypeId().equals(
-												TypeId.BOOLEAN_ID),
+				getTypeId().isBooleanTypeId(),
 					"Node's type (" +
-					dataTypeServices.getTypeId().getSQLTypeName() +
+					getTypeId().getSQLTypeName() +
 					") is expected to be boolean");
 
 		/* Return ValueNode = false */
@@ -462,7 +472,7 @@
 								this,
 								falseNode,
 								getContextManager());
-		nullableResult = dataTypeServices.isNullable();
+		nullableResult = getTypeServices().isNullable();
 		equalsNode.setType(new DataTypeDescriptor(
 									TypeId.BOOLEAN_ID,
 									nullableResult)
@@ -742,7 +752,6 @@
 	public void copyFields(ValueNode oldVN) throws StandardException
 	{
 		dataTypeServices = oldVN.getTypeServices();
-		typeId = oldVN.getTypeId();
 	}
 
 	/**



Mime
View raw message