db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r553016 - in /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile: BinaryLogicalOperatorNode.java CastNode.java ResultColumn.java SelectNode.java UnaryArithmeticOperatorNode.java UnaryOperatorNode.java
Date Tue, 03 Jul 2007 23:16:12 GMT
Author: djd
Date: Tue Jul  3 16:16:11 2007
New Revision: 553016

URL: http://svn.apache.org/viewvc?view=rev&rev=553016
Log:
DERBY-2809 Merge of 552070 from trunk.
Cleanup in UnaryOperatorNode, removing specific method for unary +?,-?

Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java?view=diff&rev=553016&r1=553015&r2=553016
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java
Tue Jul  3 16:16:11 2007
@@ -90,13 +90,6 @@
 		//following is to check if we have something like "? AND 1=1" or "2>1 OR ?" 
 		if (leftOperand.isParameterNode() || rightOperand.isParameterNode())
 			throw StandardException.newException(SQLState.LANG_NON_BOOLEAN_WHERE_CLAUSE, "PARAMETER"
);
-		//following 2 ifs are to check if we have something like "+? AND 1=1" or "2>1 OR -?"
ie -?/+? by themselves 
-		if ((leftOperand instanceof UnaryOperatorNode) &&
-				((UnaryOperatorNode)leftOperand).isUnaryMinusOrPlusWithParameter())
-			throw StandardException.newException(SQLState.LANG_NON_BOOLEAN_WHERE_CLAUSE, "PARAMETER"
);
-		if ((rightOperand instanceof UnaryOperatorNode) &&
-				((UnaryOperatorNode)rightOperand).isUnaryMinusOrPlusWithParameter())
-			throw StandardException.newException(SQLState.LANG_NON_BOOLEAN_WHERE_CLAUSE, "PARAMETER"
);
 
 		super.bindExpression(fromList, subqueryList, aggregateVector);
 

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?view=diff&rev=553016&r1=553015&r2=553016
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
Tue Jul  3 16:16:11 2007
@@ -397,9 +397,12 @@
 													));
 		}
 
+        // Obviously the type of a parameter that
+        // requires its type from context (a parameter)
+        // gets its type from the type of the CAST.
 		if (castOperand.requiresTypeFromContext())
 		{
-			bindParameter();
+            castOperand.setType(getTypeServices());
 		}
 
 		/*
@@ -798,20 +801,6 @@
 	public boolean constantExpression(PredicateList whereClause)
 	{
 		return castOperand.constantExpression(whereClause);
-	}
-
-	/**
-	 * By default unary operators don't accept ? parameters as operands.
-	 * This can be over-ridden for particular unary operators.
-	 *
-	 * @exception StandardException		Always thrown to indicate a
-	 *									? parameter where it isn't allowed.
-	 */
-
-	void bindParameter()
-					throws StandardException
-	{
-		castOperand.setType(getTypeServices());
 	}
 
 	/**

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java?view=diff&rev=553016&r1=553015&r2=553016
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
Tue Jul  3 16:16:11 2007
@@ -1315,9 +1315,6 @@
 	{
 		if ((expression != null) && (expression.isParameterNode()))
 			throw StandardException.newException(SQLState.LANG_PARAM_IN_SELECT_LIST);
-		if ((expression != null) && (expression instanceof UnaryOperatorNode) &&
-				((UnaryOperatorNode)expression).isUnaryMinusOrPlusWithParameter())
-			throw StandardException.newException(SQLState.LANG_PARAM_IN_SELECT_LIST);
 	}
 
 	/*

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java?view=diff&rev=553016&r1=553015&r2=553016
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
Tue Jul  3 16:16:11 2007
@@ -475,9 +475,6 @@
 			 */
 			if (whereClause.isParameterNode())
 				throw StandardException.newException(SQLState.LANG_NON_BOOLEAN_WHERE_CLAUSE, "PARAMETER"
);
-			if ((whereClause instanceof UnaryOperatorNode) &&
-					((UnaryOperatorNode)whereClause).isUnaryMinusOrPlusWithParameter())
-				throw StandardException.newException(SQLState.LANG_NON_BOOLEAN_WHERE_CLAUSE, "PARAMETER"
);
 			
 			whereClause = whereClause.checkIsBoolean();
 			getCompilerContext().popCurrentPrivType();

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java?view=diff&rev=553016&r1=553015&r2=553016
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
Tue Jul  3 16:16:11 2007
@@ -97,6 +97,14 @@
             return operand.requiresTypeFromContext(); 
         return false;
     }
+    
+    /**
+     * A +? or a -? is considered a parameter.
+     */
+    public boolean isParameterNode()
+    {
+        return requiresTypeFromContext();
+    }
 
 	/**
      * For SQRT and ABS the parameter becomes a DOUBLE.

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java?view=diff&rev=553016&r1=553015&r2=553016
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
Tue Jul  3 16:16:11 2007
@@ -553,22 +553,6 @@
 	}
 
 	/**
-	 * Returns true if this UnaryOperatorNode is for -?/+?.
-	 * This is required to check -?/+? say in the following sql
-	 * select * from t1 where -? and c11=c11 or +?
-	 * 
-	 * @return	True if this +?/-? node
-	 */
-	public boolean isUnaryMinusOrPlusWithParameter()
-	{
-		if (operand !=null && operand instanceof ParameterNode && operand.requiresTypeFromContext()
&& 
-				(operator!= null && (operator.equals("-") || operator.equals("+"))))
-			return true;
-		else
-			return false;
-	}
-
-	/**
 	 * By default unary operators don't accept ? parameters as operands.
 	 * This can be over-ridden for particular unary operators.
 	 *
@@ -640,9 +624,6 @@
 											MethodBuilder mb)
 									throws StandardException
 	{
-		if (operand == null)
-			return;
-
 		// For XML operator we do some extra work.
 		boolean xmlGen = (operatorType == XMLPARSE_OP) ||
 			(operatorType == XMLSERIALIZE_OP);



Mime
View raw message