db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r561806 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile: AggregateNode.java QueryTreeNode.java ResultColumn.java ResultSetNode.java
Date Wed, 01 Aug 2007 14:13:02 GMT
Author: djd
Date: Wed Aug  1 07:13:01 2007
New Revision: 561806

URL: http://svn.apache.org/viewvc?view=rev&rev=561806
Log:
In tracing the types of various nodes created by the failing query for DERBY-2937 I saw
that some nodes had types of CHAR(0) which makes no sense. These were NULL constant nodes
where no type attributes were being passed in. Change QueryTreeNode.getNullNode() to
have a DataTypeDescriptor as a parameter and set the type of the constant node to be that
type. 

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.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/ResultSetNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java?view=diff&rev=561806&r1=561805&r2=561806
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java Wed
Aug  1 07:13:01 2007
@@ -498,18 +498,14 @@
 	{
 		String	className = aggregatorClassName.toString();
 
-		TypeId compTypeId = TypeId.getSQLTypeForJavaType(className);
+		DataTypeDescriptor compType =
+            DataTypeDescriptor.getSQLDataTypeDescriptor(className);
 
 		/*
 		** Create a null of the right type.  The proper aggregators
 		** are created dynamically by the SortObservers
 		*/
-		ConstantNode nullNode = getNullNode(
-				compTypeId,
-				getContextManager(),
-				getTypeServices().getCollationType(),
-				getTypeServices().getCollationDerivation()
-				); // no params
+		ConstantNode nullNode = getNullNode(compType);
 
 		nullNode.bindExpression(
 						null,	// from
@@ -574,9 +570,7 @@
 		** Create a result column with the aggrergate operand
 		** it.
 		*/
-		return getNullNode(this.getTypeId(),
-							getContextManager(), this.getTypeServices().getCollationType(),
-							this.getTypeServices().getCollationDerivation());
+		return getNullNode(getTypeServices());
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java?view=diff&rev=561806&r1=561805&r2=561806
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/QueryTreeNode.java Wed
Aug  1 07:13:01 2007
@@ -743,177 +743,117 @@
 	}
 
 	/**
-	 * Get a ConstantNode to represent a typed null value. Then set it's 
-	 * collation type and derivation
+	 * Get a ConstantNode to represent a typed null value. 
 	 *
-	 * @param typeId	The TypeId of the datatype of the null value
-	 * @param cm		The ContextManager
-	 * @param collationType The collation type of the ConstantNode
-	 * @param collationDerivation The Collation Derivation of the ConstantNode
+	 * @param type Type of the null node.
 	 *
 	 * @return	A ConstantNode with the specified type, and a value of null
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public  ConstantNode getNullNode(TypeId typeId,
-			ContextManager cm, int collationType, int collationDerivation)
+	public  ConstantNode getNullNode(DataTypeDescriptor type)
 		throws StandardException
 	{
-		QueryTreeNode constantNode = null;
-		NodeFactory nf = getNodeFactory();
-
-		switch (typeId.getJDBCTypeId())
+        int constantNodeType;
+		switch (type.getTypeId().getJDBCTypeId())
 		{
 		  case Types.VARCHAR:
-			constantNode =  nf.getNode(
-										C_NodeTypes.VARCHAR_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.VARCHAR_CONSTANT_NODE;
 			break;
 
 		  case Types.CHAR:
-			constantNode = nf.getNode(
-										C_NodeTypes.CHAR_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.CHAR_CONSTANT_NODE;
 			break;
 
 		  case Types.TINYINT:
-			constantNode = nf.getNode(
-										C_NodeTypes.TINYINT_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.TINYINT_CONSTANT_NODE;
 			break;
 
 		  case Types.SMALLINT:
-			constantNode = nf.getNode(
-										C_NodeTypes.SMALLINT_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.SMALLINT_CONSTANT_NODE;
 			break;
 
 		  case Types.INTEGER:
-			constantNode = nf.getNode(
-										C_NodeTypes.INT_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.INT_CONSTANT_NODE;
 			break;
 
 		  case Types.BIGINT:
-			constantNode = nf.getNode(
-										C_NodeTypes.LONGINT_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.LONGINT_CONSTANT_NODE;
 			break;
 
 		  case Types.REAL:
-			constantNode = nf.getNode(
-										C_NodeTypes.FLOAT_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.FLOAT_CONSTANT_NODE;
 			break;
 
 		  case Types.DOUBLE:
-			constantNode = nf.getNode(
-										C_NodeTypes.DOUBLE_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.DOUBLE_CONSTANT_NODE;
 			break;
 
 		  case Types.NUMERIC:
 		  case Types.DECIMAL:
-			constantNode = nf.getNode(
-										C_NodeTypes.DECIMAL_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.DECIMAL_CONSTANT_NODE;
 			break;
 
 		  case Types.DATE:
 		  case Types.TIME:
 		  case Types.TIMESTAMP:
-			constantNode = nf.getNode(
-										C_NodeTypes.USERTYPE_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.USERTYPE_CONSTANT_NODE;
 			break;
 
 		  case Types.BINARY:
-			constantNode = nf.getNode(
-										C_NodeTypes.BIT_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.BIT_CONSTANT_NODE;
 			break;
 
 		  case Types.VARBINARY:
-			constantNode = nf.getNode(
-										C_NodeTypes.VARBIT_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.VARBIT_CONSTANT_NODE;
 			break;
 
 		  case Types.LONGVARCHAR:
-			constantNode = nf.getNode(
-										C_NodeTypes.LONGVARCHAR_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.LONGVARCHAR_CONSTANT_NODE;
 			break;
 
 		  case Types.CLOB:
-			constantNode = nf.getNode(
-										C_NodeTypes.CLOB_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.CLOB_CONSTANT_NODE;
 			break;
 
 		  case Types.LONGVARBINARY:
-			constantNode = nf.getNode(
-										C_NodeTypes.LONGVARBIT_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.LONGVARBIT_CONSTANT_NODE;
 			break;
 
 		  case Types.BLOB:
-			constantNode = nf.getNode(
-										C_NodeTypes.BLOB_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.BLOB_CONSTANT_NODE;
 			break;
 
 		  case StoredFormatIds.XML_TYPE_ID:
-			constantNode = nf.getNode(
-										C_NodeTypes.XML_CONSTANT_NODE,
-										typeId,
-										cm);
+              constantNodeType = C_NodeTypes.XML_CONSTANT_NODE;
 			break;
+            
+          case Types.BOOLEAN:
+              constantNodeType = C_NodeTypes.BOOLEAN_CONSTANT_NODE;
+              break;
 
 		  default:
-			if (typeId.getSQLTypeName().equals("BOOLEAN"))
-			{
-				constantNode = nf.getNode(
-										C_NodeTypes.BOOLEAN_CONSTANT_NODE,
-										typeId,
-										cm);
-			}
-			else if (typeId.userType())
+			if (type.getTypeId().userType())
 			{
-				constantNode = nf.getNode(
-										C_NodeTypes.USERTYPE_CONSTANT_NODE,
-										typeId,
-										cm);
+                constantNodeType = C_NodeTypes.USERTYPE_CONSTANT_NODE;
 			}
 			else
 			{
 				if (SanityManager.DEBUG)
 				SanityManager.THROWASSERT( "Unknown type " + 
-						typeId.getSQLTypeName() + " in getNullNode");
+                        type.getTypeId().getSQLTypeName() + " in getNullNode");
 				return null;
 			}
 		}
+        
+        ConstantNode constantNode = (ConstantNode) getNodeFactory().getNode(
+                constantNodeType,
+                type.getTypeId(),
+                cm);
+
+        constantNode.setType(type.getNullabilityType(true));
 
-		ConstantNode cn = (ConstantNode) constantNode;
-		cn.getTypeServices().setCollationType(collationType);
-		cn.getTypeServices().setCollationDerivation(collationDerivation);
-		return cn;
+		return constantNode;
 	}
 
 	/**

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=561806&r1=561805&r2=561806
==============================================================================
--- 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 Wed
Aug  1 07:13:01 2007
@@ -319,9 +319,7 @@
 	void setExpressionToNullNode()
 		throws StandardException
 	{
-		expression = getNullNode(getTypeId(), 
-									getContextManager(), getTypeServices().getCollationType(),
-									getTypeServices().getCollationDerivation());
+		expression = getNullNode(getTypeServices());
 	}
 
 	/**
@@ -680,9 +678,7 @@
         	//eg insert into table1 values(1,null)
         	//When this method is executed for the sql above, we don't know
         	//the type of the null at this point.
-            expression = getNullNode( typeId, getContextManager(),
-            		StringDataValue.COLLATION_TYPE_UCS_BASIC,
-					StringDataValue.COLLATION_DERIVATION_IMPLICIT);
+            expression = getNullNode(bindingRC.getTypeServices());
         else if( ( expression instanceof ColumnReference) && expression.getTypeServices()
== null)
         {
             // The expression must be a reference to a null column in a values table.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java?view=diff&rev=561806&r1=561805&r2=561806
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java Wed
Aug  1 07:13:01 2007
@@ -1184,12 +1184,7 @@
                 newResultColumn = (ResultColumn) getNodeFactory().getNode(
                     C_NodeTypes.RESULT_COLUMN,
                     colType,
-                    getNullNode(
-                        colType.getTypeId(),
-                        getContextManager(), 
-						colType.getCollationType(),
-                        colType.getCollationDerivation()
-                        ),
+                    getNullNode(colType),
                     getContextManager()
                     );
             }



Mime
View raw message