db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abr...@apache.org
Subject svn commit: r566217 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
Date Wed, 15 Aug 2007 15:22:57 GMT
Author: abrown
Date: Wed Aug 15 08:22:56 2007
New Revision: 566217

URL: http://svn.apache.org/viewvc?view=rev&rev=566217
Log:
DERBY-2986: Fix performance regression for queries involving CASE statements
that have multiple WHEN clauses.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java

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=566217&r1=566216&r2=566217
==============================================================================
--- 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
Wed Aug 15 08:22:56 2007
@@ -206,7 +206,8 @@
 	 * @exception             StandardException Thrown on error.
 	 */
 	private DataTypeDescriptor findType(ValueNodeList thenElseList,
-		FromList fromList) throws StandardException
+		FromList fromList, SubqueryList subqueryList, Vector aggregateVector)
+		throws StandardException
 	{
 		/* We need to "prebind" because we want the Types.  Provide
 		 * dummy SubqueryList and AggreateList (we don't care)
@@ -214,11 +215,11 @@
 
 		ValueNode thenNode =
 			((ValueNode)thenElseList.elementAt(0)).bindExpression(
-				fromList, new SubqueryList(), new Vector());
+				fromList, subqueryList, aggregateVector);
 
 		ValueNode elseNode =
 			((ValueNode)thenElseList.elementAt(1)).bindExpression(
-				fromList, new SubqueryList(), new Vector());
+				fromList, subqueryList, aggregateVector);
 
 		DataTypeDescriptor thenType = thenNode.getTypeServices();
 		DataTypeDescriptor elseType = elseNode.getTypeServices();
@@ -257,7 +258,8 @@
 		if (isConditionalNode(thenNode))
 		{
 			theType =
-				findType(((ConditionalNode)thenNode).thenElseList, fromList);
+				findType(((ConditionalNode)thenNode).thenElseList, fromList,
+					subqueryList, aggregateVector);
 		}
 
 		if (theType != null) return theType;
@@ -266,7 +268,8 @@
 		if (isConditionalNode(elseNode))
 		{
 			theType =
-				findType(((ConditionalNode)elseNode).thenElseList, fromList);
+				findType(((ConditionalNode)elseNode).thenElseList, fromList,
+					subqueryList, aggregateVector);
 		}
 
 		if (theType != null) return theType;
@@ -386,14 +389,21 @@
 						thenElseList.elementAt(0), 
 						bcon.getLeftOperand().getTypeServices().getNullabilityType(true),
 						getContextManager());
+
 			thenElseList.setElementAt(cast,0);
+			thenElseList.bindExpression(fromList,
+				subqueryList,
+				aggregateVector);
+
 		} else {
-			recastNullNodes(thenElseList, findType(thenElseList, fromList));
+			/* Following call to "findType()" will indirectly bind the
+			 * expressions in the thenElseList, so no need to call
+			 * "thenElseList.bindExpression(...)" after we do this.
+			 * DERBY-2986.
+			 */
+			recastNullNodes(thenElseList,
+				findType(thenElseList, fromList, subqueryList, aggregateVector));
  		}
-
-		thenElseList.bindExpression(fromList,
-			subqueryList,
-			aggregateVector);
 
 		// Can't get the then and else expressions until after they've been bound
 		ValueNode thenExpression = (ValueNode) thenElseList.elementAt(0);



Mime
View raw message