db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r545609 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/types/ impl/sql/compile/
Date Fri, 08 Jun 2007 20:07:39 GMT
Author: djd
Date: Fri Jun  8 13:07:38 2007
New Revision: 545609

URL: http://svn.apache.org/viewvc?view=rev&rev=545609
Log:
DERBY-2775 (partial) Add getNullabilityType() method to DataTypeDescriptor to return
a DataTypeDescriptor with the nullability changed. Returns the same object if the
nullability would be unchanged.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.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/ParameterNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java?view=diff&rev=545609&r1=545608&r2=545609
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java Fri
Jun  8 13:07:38 2007
@@ -252,6 +252,7 @@
 											isNullable,
 											maximumWidth);
 	}
+    
 	/*
 	** Instance fields & methods
 	*/
@@ -910,6 +911,21 @@
 	{
 		typeDescriptor.setNullability(nullable);
 	}
+    
+    /**
+     * Return a type descriptor identical to the this type
+     * with the exception of its nullability. If the nullablity
+     * required matches the nullability of this then this is returned.
+     * 
+     * @param isNullable True to return a nullable type, false otherwise.
+     */
+    public DataTypeDescriptor getNullabilityType(boolean isNullable)
+    {
+        if (isNullable() == isNullable)
+            return this;
+        
+        return new DataTypeDescriptor(this, isNullable);
+    }
 
 	/**
 	  Compare if two TypeDescriptors are exactly the same

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java?view=diff&rev=545609&r1=545608&r2=545609
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java
Fri Jun  8 13:07:38 2007
@@ -240,7 +240,7 @@
 			throw StandardException.newException(SQLState.LANG_BINARY_LOGICAL_NON_BOOLEAN);
 		}
 
-		return new DataTypeDescriptor(leftType,
+		return leftType.getNullabilityType(
 					leftType.isNullable() || rightType.isNullable());
 	}
 }

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=545609&r1=545608&r2=545609
==============================================================================
--- 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 13:07:38 2007
@@ -383,8 +383,7 @@
 			QueryTreeNode cast = getNodeFactory().getNode(
 						C_NodeTypes.CAST_NODE,
 						thenElseList.elementAt(0), 
-						new DataTypeDescriptor(
-								bcon.getLeftOperand().getTypeServices(), true),
+						bcon.getLeftOperand().getTypeServices().getNullabilityType(true),
 						getContextManager());
 			thenElseList.setElementAt(cast,0);
 		} else {

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=545609&r1=545608&r2=545609
==============================================================================
--- 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 13:07:38 2007
@@ -164,14 +164,13 @@
 			"typeServices not initialized");
 
 		/* Make sure the type is nullable. */
-		if ( ! descriptor.isNullable())
-		{
-			/*
-			** Generate a new descriptor with all the same properties as
-			** the given one, except that it is nullable.
-			*/
-			descriptor = new DataTypeDescriptor(descriptor, true);
-		}
+
+		/*
+		 ** Generate a new descriptor with all the same properties as
+		 ** the given one, except that it is nullable.
+		 */
+		descriptor = descriptor.getNullabilityType(true);
+		
 
         if (userParameterTypes != null)
 		    userParameterTypes[parameterNumber] = descriptor;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?view=diff&rev=545609&r1=545608&r2=545609
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java Fri
Jun  8 13:07:38 2007
@@ -2275,14 +2275,7 @@
 			dts = getTrueNode().getTypeServices();
 		}
 
-		/* If datatype of underlying resultSet is nullable, reuse it, otherwise
-		 * we need to generate a new one.
-		 */
-		if (! dts.isNullable())
-		{
-			dts = new DataTypeDescriptor(dts, true);
-		}
-		setType(dts);
+		setType(dts.getNullabilityType(true));
 	}
         
     /**



Mime
View raw message