db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From banda...@apache.org
Subject svn commit: r370217 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
Date Wed, 18 Jan 2006 19:03:48 GMT
Author: bandaram
Date: Wed Jan 18 11:03:46 2006
New Revision: 370217

URL: http://svn.apache.org/viewcvs?rev=370217&view=rev
Log:
DERBY-808: PreparedStatements could take longer to execute than equivalent statements, because
of incorect code in search clause transitive closure method.

Handle the case of ParameterNodes, in addition to ConstantNodes on the rightside.

Submitted by Satheesh Bandaram(satheesh@sourcery.org)

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

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java?rev=370217&r1=370216&r2=370217&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.java Wed
Jan 18 11:03:46 2006
@@ -2037,7 +2037,10 @@
 				ValueNode left = bcon.getLeftOperand();
 				ValueNode right = bcon.getRightOperand();
 
-				if (left instanceof ColumnReference && right instanceof ConstantNode)
+				// RESOLVE: Consider using variant type of the expression, instead of
+				// ConstantNode or ParameterNode in the future.
+				if (left instanceof ColumnReference && 
+					  (right instanceof ConstantNode || right instanceof ParameterNode))
 				{
 					searchClauses.addElement(predicate);
 				}
@@ -2077,8 +2080,14 @@
 			else
 			{
 				searchCR = (ColumnReference) ((BinaryComparisonOperatorNode) ro).getLeftOperand();
-				ConstantNode currCN = (ConstantNode) ((BinaryComparisonOperatorNode) ro).getRightOperand();
-				searchODV = (DataValueDescriptor) currCN.getValue();
+
+				// Don't get value for parameterNode since not known yet.
+				if (((BinaryComparisonOperatorNode) ro).getRightOperand() instanceof ConstantNode)
+				{
+					ConstantNode currCN = (ConstantNode) ((BinaryComparisonOperatorNode) ro).getRightOperand();
+					searchODV = (DataValueDescriptor) currCN.getValue();
+				}
+				else searchODV = null;
 			}
 			// Cache the table and column numbers of searchCR
 			int tableNumber = searchCR.getTableNumber();
@@ -2152,8 +2161,12 @@
 					else
 					{
 						searchCR2 = (ColumnReference) ((BinaryComparisonOperatorNode) ro2).getLeftOperand();
-						ConstantNode currCN = (ConstantNode) ((BinaryComparisonOperatorNode) ro2).getRightOperand();
-						currODV = (DataValueDescriptor) currCN.getValue();
+						if (((BinaryComparisonOperatorNode) ro2).getRightOperand() instanceof ConstantNode)
+						{
+							ConstantNode currCN = (ConstantNode) ((BinaryComparisonOperatorNode) ro2).getRightOperand();
+							currODV = (DataValueDescriptor) currCN.getValue();
+						}
+						else currODV = null;
 					}
 
 					/* Is this a match? A match is a search clause with



Mime
View raw message