db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From banda...@apache.org
Subject svn commit: r329295 [1/2] - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/sql/compile/ engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/suites/ te...
Date Fri, 28 Oct 2005 20:57:35 GMT
Author: bandaram
Date: Fri Oct 28 13:57:08 2005
New Revision: 329295

URL: http://svn.apache.org/viewcvs?rev=329295&view=rev
Log:
DERBY-582: Allow unary plus/minus operators with parameters. Here is the email from Mamta with details:

I have a new patch to allow dynamic parameters for unary minus and unary plus
operator. This is based on the feedback from Jeff and Dan. The unary minus/plus
parameters will determine their types depending on the context. For this, I
have added requiresTypeFromContext to ValueNode which always returns false.
ParameterNode always returns true for this method. UnaryOperatorNode's
requiresTypeFromContext calls the operand's requiresTypeFromContext if operand
is not null. SimpleStringOperatorNode(subclass of UnaryOperatorNode) ends up
overriding this method and returns false because functions lower and upper are
always typed to String and do not need to get their type from the context.
 
I have added 2 methods to UnaryOperatorNode.java, namely getParameterOperand()
and isUnaryMinusOrPlusWithParameter(). There are few places in engine, where
we need to access the underlying parameter and that is when
getParameterOperand() gets used. This is required to directly call the
ParameterNode methods such as  getDefaultValue(), getParameterNumber() etc
isUnaryMinusOrPlusWithParameter() is required so that engine can catch edge
cases like select * from t1 where -? and c11=c11 or +? ie such a use of
-?/+? should be disallowed, same as what we do for ? parameters.
 
Also, as mentioned in the earlier review packages, the binding code for unary
minus/unary plus dynamic parameters will not be executed until the type of
these parameters can be determined. The type gets detemined when the setType
method is called. For this reason, setType method is overridden in
UnaryArithmeticOperatorNode. After setting the type, this method calls the
binding code to make sure all the bind time rules are enforced.
 
I have also consolidated the 2 type setting methods into one, namely setType.
This setType is overwritten in ParameterNode so it can also set the type in
the array of parameter types in StatementNode. Hopefully, this will make the
type setting code much cleaner.
 
I have added several new tests to check this functionality and these tests are in unaryArithmeticDynamicParameter.java. The test will get run in both embedded and network server modes.

Submitted by Mamta Satoor (msatoor@gmail.com)

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/unaryArithmeticDynamicParameter.out   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/unaryArithmeticDynamicParameter.java   (with props)
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/JoinStrategy.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizablePredicate.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.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/BinaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.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/FromBaseTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashJoinStrategy.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.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/Predicate.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/PredicateList.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/ResultColumnList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticClassFieldReferenceNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/build.xml

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/JoinStrategy.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/JoinStrategy.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/JoinStrategy.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/JoinStrategy.java Fri Oct 28 13:57:08 2005
@@ -115,7 +115,8 @@
 	 * @return	The extra selectivity due to non-base predicates
 	 */
 	double nonBasePredicateSelectivity(Optimizable innerTable,
-										OptimizablePredicateList predList);
+										OptimizablePredicateList predList)
+	throws StandardException;
 
 	/**
 	 * Put back and base predicates that were removed from the list by

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizablePredicate.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizablePredicate.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizablePredicate.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/OptimizablePredicate.java Fri Oct 28 13:57:08 2005
@@ -133,7 +133,8 @@
 	 *
 	 * @param optTable	The Optimizable that this predicate restricts
 	 */
-	double selectivity(Optimizable optTable);
+	double selectivity(Optimizable optTable)
+	throws StandardException;
 
 	/**
 	 * Get the position of the index column that this predicate restricts.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseColumnNode.java Fri Oct 28 13:57:08 2005
@@ -67,7 +67,7 @@
 	public void init(
 							Object columnName,
 							Object tableName,
-				   			Object dts)
+				   			Object dts) throws StandardException
 	{
 		this.columnName = (String) columnName;
 		this.tableName = (TableName) tableName;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryListOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -164,7 +164,7 @@
 		rightOperandList.bindExpression(fromList, subqueryList, aggregateVector);
 
 		/* Is there a ? parameter on the left? */
-		if (leftOperand.isParameterNode())
+		if (leftOperand.requiresTypeFromContext())
 		{
 			ValueNode rightOperand = (ValueNode) rightOperandList.elementAt(0);
 
@@ -178,7 +178,7 @@
 			}
 
 			/* Set the left operand to the type of right parameter. */
-			((ParameterNode) leftOperand).setDescriptor(rightOperandList.getTypeServices());
+			leftOperand.setType(rightOperandList.getTypeServices());
 		}
 
 		/* Is there a ? parameter on the right? */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryLogicalOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- 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 Oct 28 13:57:08 2005
@@ -93,6 +93,13 @@
 		//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/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -313,26 +313,26 @@
 			return bindXMLExists();
 
 		/* Is there a ? parameter on the left? */
-		if (leftOperand.isParameterNode())
+		if (leftOperand.requiresTypeFromContext())
 		{
 			/*
 			** It's an error if both operands are ? parameters.
 			*/
-			if (rightOperand.isParameterNode())
+			if (rightOperand.requiresTypeFromContext())
 			{
 				throw StandardException.newException(SQLState.LANG_BINARY_OPERANDS_BOTH_PARMS, 
 																	operator);
 			}
 
 			/* Set the left operand to the type of right parameter. */
-			((ParameterNode) leftOperand).setDescriptor(rightOperand.getTypeServices());
+			leftOperand.setType(rightOperand.getTypeServices());
 		}
 
 		/* Is there a ? parameter on the right? */
-		if (rightOperand.isParameterNode())
+		if (rightOperand.requiresTypeFromContext())
 		{
 			/* Set the right operand to the type of the left parameter. */
-			((ParameterNode) rightOperand).setDescriptor(leftOperand.getTypeServices());
+			rightOperand.setType(leftOperand.getTypeServices());
 		}
 
 		return genSQLJavaSQLTree();
@@ -382,16 +382,16 @@
         }
 
         // Is there a ? parameter on the left?
-        if (leftOperand.isParameterNode())
+        if (leftOperand.requiresTypeFromContext())
         {
             // Set the left operand to be a VARCHAR, which should be
             // long enough to hold the XPath expression.
-            ((ParameterNode) leftOperand).setDescriptor(
+            leftOperand.setType(
                 DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR));
         }
 
         // Is there a ? parameter on the right?
-        if (rightOperand.isParameterNode())
+        if (rightOperand.requiresTypeFromContext())
         {
             // For now, since JDBC has no type defined for XML, we
             // don't allow binding to an XML parameter.
@@ -619,6 +619,7 @@
 	//following method is no-op here but in concatenation node, this method is used to check if resultField is null,
 	//and if yes, then we want it to be initialized to NULL SQLxxx type object
 	protected void initializeResultField(ExpressionClassBuilder acb, MethodBuilder mb, LocalField resultField)
+	throws StandardException
 	{
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BinaryRelationalOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -710,7 +710,7 @@
 		if (considerParameters)
 		{
 			return (node instanceof ConstantNode) ||
-						((node.isParameterNode()) &&
+						((node.requiresTypeFromContext()) &&
 						 (((ParameterNode)node).getDefaultValue() != null));
 		}
 		else
@@ -738,9 +738,14 @@
 		{
 			return ((ConstantNode)node).getValue();
 		}
-		else if (node.isParameterNode())
+		else if (node.requiresTypeFromContext())
 		{
-			return ((ParameterNode)node).getDefaultValue();
+			ParameterNode pn;
+			if (node instanceof UnaryOperatorNode) 
+	  			pn = ((UnaryOperatorNode)node).getParameterOperand();
+			else
+	  			pn = (ParameterNode) (node);
+			return pn.getDefaultValue();
 		}
 		else
 		{	
@@ -754,6 +759,7 @@
 	 * selectivity otherwise.
 	 */
 	protected double booleanSelectivity(Optimizable optTable)
+	throws StandardException
 	{
 		TypeId	typeId = null;
 		double				retval = -1.0d;
@@ -990,6 +996,7 @@
 	/** return the selectivity of this predicate.
 	 */
 	public double selectivity(Optimizable optTable)
+	throws StandardException
 	{
 		double retval = booleanSelectivity(optTable);
 		

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Fri Oct 28 13:57:08 2005
@@ -403,7 +403,7 @@
 			destCTI = castTarget.getTypeId();
 		}
 
-		if (castOperand.isParameterNode())
+		if (castOperand.requiresTypeFromContext())
 		{
 			bindParameter();
 		}
@@ -819,7 +819,7 @@
 	void bindParameter()
 					throws StandardException
 	{
-		((ParameterNode) castOperand).setDescriptor(castTarget);
+		castOperand.setType(castTarget);
 	}
 
 	/**
@@ -887,7 +887,7 @@
 		 * They'll get an exception, as expected, if the
 		 * conversion cannot be performed.
 		 */
-		else if (castOperand.isParameterNode())
+		else if (castOperand.requiresTypeFromContext())
 		{
 			sourceCTI = destCTI;
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CoalesceFunctionNode.java Fri Oct 28 13:57:08 2005
@@ -147,7 +147,7 @@
 		//find the first non-param argument. The generated method will generate code to call coalesce on this argument
 		for (int index = 0; index < argumentsListSize; index++)
 		{
-			if (!(((ValueNode) argumentsList.elementAt(index)).isParameterNode()))
+			if (!(((ValueNode) argumentsList.elementAt(index)).requiresTypeFromContext()))
 			{
 				firstNonParameterNode = (ValueNode) argumentsList.elementAt(index);
 				break;
@@ -157,7 +157,7 @@
 		//make sure these arguments are compatible to each other before coalesce can be allowed
 		for (int index = 0; index < argumentsListSize; index++)
 		{
-			if (((ValueNode) argumentsList.elementAt(index)).isParameterNode()) //since we don't know the type of param, can't check for compatibility
+			if (((ValueNode) argumentsList.elementAt(index)).requiresTypeFromContext()) //since we don't know the type of param, can't check for compatibility
 				continue;
 				argumentsList.compatible((ValueNode) argumentsList.elementAt(index));
 		}
@@ -168,9 +168,9 @@
 		//set all the parameter types to the type of the result type
 		for (int index = 0; index < argumentsListSize; index++)
 		{
-			if (((ValueNode) argumentsList.elementAt(index)).isParameterNode())
+			if (((ValueNode) argumentsList.elementAt(index)).requiresTypeFromContext())
 			{
-				((ParameterNode) argumentsList.elementAt(index)).setDescriptor(getTypeServices());
+				((ValueNode)argumentsList.elementAt(index)).setType(getTypeServices());
 				break;
 			}
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnDefinitionNode.java Fri Oct 28 13:57:08 2005
@@ -591,6 +591,7 @@
 	public boolean defaultTypeIsValid(TypeId columnType,
 		DataTypeDescriptor columnDesc, TypeId defaultType,
 		ValueNode defaultNode, String defaultText)
+	throws StandardException
 	{
 
 		if (defaultText.length() > Limits.DB2_CHAR_MAXWIDTH)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ColumnReference.java Fri Oct 28 13:57:08 2005
@@ -1018,7 +1018,7 @@
 	 * @return	The DataTypeServices from this Node.  This
 	 *		may be null if the node isn't bound yet.
 	 */
-	public DataTypeDescriptor getTypeServices()
+	public DataTypeDescriptor getTypeServices() throws StandardException
 	{
         DataTypeDescriptor dtd = super.getTypeServices();
         if( dtd == null && source != null)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConcatenationOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -94,9 +94,9 @@
 			maximum length for that type.
 		*/
 
-		if (leftOperand.isParameterNode())
+		if (leftOperand.requiresTypeFromContext())
 		{
-			if (rightOperand.isParameterNode())
+			if (rightOperand.requiresTypeFromContext())
 			{
 				throw StandardException.newException(SQLState.LANG_BINARY_OPERANDS_BOTH_PARMS,
 																	operator);
@@ -137,13 +137,13 @@
 					leftType = TypeId.getBuiltInTypeId(Types.VARCHAR);
 			}
 
-		((ParameterNode) leftOperand).setDescriptor(new DataTypeDescriptor(leftType, true));
+		leftOperand.setType(new DataTypeDescriptor(leftType, true));
 		}
 
 		/*
 			Is there a ? parameter on the right?
 		*/
-		if (rightOperand.isParameterNode())
+		if (rightOperand.requiresTypeFromContext())
 		{
 			TypeId 	rightType;
 
@@ -180,7 +180,7 @@
 					rightType = TypeId.getBuiltInTypeId(Types.VARCHAR);
 			}
 		
-		((ParameterNode) rightOperand).setDescriptor(
+		rightOperand.setType(
 							new DataTypeDescriptor(
 										rightType,
 										true));
@@ -491,6 +491,7 @@
 	 *worry about field coming in as null
 	*/
 	protected void initializeResultField(ExpressionClassBuilder acb, MethodBuilder mb, LocalField resultField)
+	throws StandardException
 	{
 		mb.conditionalIfNull();//get the field on the stack and if it is null
 			acb.generateNull(mb, getTypeCompiler());// yes, it is, hence create a NULL SQLxxx type object and put that on stack

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ConditionalNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- 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 Oct 28 13:57:08 2005
@@ -175,9 +175,9 @@
 		 * If it is a ? parameter on the left, then set type to boolean,
 		 * otherwise verify that the result type is boolean.
 		 */
-		if (testCondition.isParameterNode())
+		if (testCondition.requiresTypeFromContext())
 		{
-			((ParameterNode) testCondition).setDescriptor(
+			testCondition.setType(
 							new DataTypeDescriptor(
 										TypeId.BOOLEAN_ID,
 										true));
@@ -207,7 +207,7 @@
 			DataTypeDescriptor dts;
 			ValueNode typeExpression;
 
-			if (thenExpression.isParameterNode())
+			if (thenExpression.requiresTypeFromContext())
 			{
 				dts = elseExpression.getTypeServices();
 			}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java Fri Oct 28 13:57:08 2005
@@ -1239,7 +1239,7 @@
 						if (firstColumn != null && leftOpnd instanceof LikeEscapeOperatorNode)
 						{
 							LikeEscapeOperatorNode likeNode = (LikeEscapeOperatorNode) leftOpnd;
-							if (likeNode.getLeftOperand().isParameterNode())
+							if (likeNode.getLeftOperand().requiresTypeFromContext())
 							{
 								ValueNode receiver = ((TernaryOperatorNode) likeNode).getReceiver();
 								if (receiver instanceof ColumnReference)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HasVariantValueNodeVisitor.java Fri Oct 28 13:57:08 2005
@@ -115,7 +115,7 @@
 	{
 		if (node instanceof ValueNode)
 		{
-			if (ignoreParameters && ((ValueNode)node).isParameterNode())
+			if (ignoreParameters && ((ValueNode)node).requiresTypeFromContext())
 				return node;
 				
 			if (((ValueNode)node).getOrderableVariantType() <= variantType)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashJoinStrategy.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashJoinStrategy.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashJoinStrategy.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/HashJoinStrategy.java Fri Oct 28 13:57:08 2005
@@ -172,7 +172,8 @@
 	/** @see JoinStrategy#nonBasePredicateSelectivity */
 	public double nonBasePredicateSelectivity(
 										Optimizable innerTable,
-										OptimizablePredicateList predList) {
+										OptimizablePredicateList predList) 
+	throws StandardException {
 		double retval = 1.0;
 
 		if (predList != null) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/IsNullNode.java Fri Oct 28 13:57:08 2005
@@ -146,8 +146,7 @@
 		** for a varchar.
 		*/
 
-		((ParameterNode) operand).setDescriptor(
-							new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.VARCHAR), true));
+		operand.setType(new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.VARCHAR), true));
 	}
 
 	/* RelationalOperator interface */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JavaValueNode.java Fri Oct 28 13:57:08 2005
@@ -74,7 +74,7 @@
 	/* Name of field holding receiver value, if any */
 	private LocalField receiverField;
 
-	public boolean isPrimitiveType()
+	public boolean isPrimitiveType() throws StandardException
 	{
 		JSQLType	myType = getJSQLType();
 		
@@ -82,7 +82,7 @@
 		else { return ( myType.getCategory() == JSQLType.JAVA_PRIMITIVE ); }
 	}
 
-	public String getJavaTypeName()
+	public String getJavaTypeName() throws StandardException
 	{
 		JSQLType	myType = getJSQLType();
 
@@ -156,9 +156,7 @@
 	  *	@return	the corresponding JSQLType
 	  *
 	  */
-	public	JSQLType	getJSQLType
-	(
-    )
+	public	JSQLType	getJSQLType() throws StandardException
 	{ return jsqlType; }
 
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/JoinNode.java Fri Oct 28 13:57:08 2005
@@ -907,7 +907,7 @@
 			/* If joinClause is a parameter, (where ?), then we assume
 			 * it will be a nullable boolean.
 			 */
-			if (joinClause.isParameterNode())
+			if (joinClause.requiresTypeFromContext())
 			{
 				joinClause.setType(new DataTypeDescriptor(TypeId.BOOLEAN_ID, true));
 			}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -147,8 +147,7 @@
 		** for a varchar.
 		*/
 
-		((ParameterNode) operand).setDescriptor(
-							DataTypeDescriptor.getBuiltInDataTypeDescriptor(parameterType, true, 
+		operand.setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(parameterType, true, 
 												parameterWidth));
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LikeEscapeOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -164,7 +164,7 @@
 
 		// pattern must be a string or a parameter
 
-		if (!(leftOperand.isParameterNode()) && !(leftOperand.getTypeId().isStringTypeId()))
+		if (!(leftOperand.requiresTypeFromContext()) && !(leftOperand.getTypeId().isStringTypeId()))
 			throw StandardException.newException(SQLState.LANG_DB2_FUNCTION_INCOMPATIBLE,
 													 "LIKE", "FUNCTION");
 
@@ -177,7 +177,7 @@
 
 		// escape must be a string or a parameter
 		if ((rightOperand != null) && 
-			!(rightOperand.isParameterNode()) && 
+			!(rightOperand.requiresTypeFromContext()) && 
 			!(rightOperand.getTypeId().isStringTypeId()))
 		{
 			throw StandardException.newException(SQLState.LANG_DB2_FUNCTION_INCOMPATIBLE,
@@ -193,9 +193,9 @@
 		 *  the left, since it won't match if it is any longer than it.
 		 */
 
-		if (receiver.isParameterNode())
+		if (receiver.requiresTypeFromContext())
 		{
-			((ParameterNode) receiver).setDescriptor(
+			receiver.setType(
 							new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.VARCHAR), true));
 		}
 
@@ -206,7 +206,7 @@
 		 *  REMIND: should nullability be copied, or set to true?
 		 */
 
-		if (leftOperand.isParameterNode())
+		if (leftOperand.requiresTypeFromContext())
 		{
 			/*
 			 * Set the pattern to the type of the left parameter, if
@@ -214,11 +214,11 @@
 			 */
 			if (receiver.getTypeId().isStringTypeId())
 			{
-				((ParameterNode) leftOperand).setDescriptor(receiver.getTypeServices());
+				leftOperand.setType(receiver.getTypeServices());
 			}
 			else
 			{
-				((ParameterNode) leftOperand).setDescriptor(
+				leftOperand.setType(
 							new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.VARCHAR), true));
 			}
 		}
@@ -229,7 +229,7 @@
 		 *  both will be max length.  nullability is set to true.
 		 */
 
-		if (rightOperand != null && rightOperand.isParameterNode())
+		if (rightOperand != null && rightOperand.requiresTypeFromContext())
 		{
 			/*
 			 * Set the pattern to the type of the left parameter, if
@@ -237,11 +237,11 @@
 			 */
 			if (receiver.getTypeId().isStringTypeId())
 			{
-				((ParameterNode) rightOperand).setDescriptor(receiver.getTypeServices());
+				rightOperand.setType(receiver.getTypeServices());
 			}
 			else
 			{
-				((ParameterNode) rightOperand).setDescriptor(
+				rightOperand.setType(
 							new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.VARCHAR), true));
 			}
 		}
@@ -526,7 +526,7 @@
 		 * beginning of execution.
 		 */
 		if (!(leftOperand instanceof CharConstantNode) &&
-			!(leftOperand.isParameterNode()))
+			!(leftOperand.requiresTypeFromContext()))
 		{
 			return this;
 		}
@@ -604,11 +604,11 @@
 		   Currently for a national string we do not add a < than operator
 		   since we don't know (?) how to calculate such a string.
 		 */
-		if ( lessThanString != null || ( leftOperand.isParameterNode() &&
+		if ( lessThanString != null || ( leftOperand.requiresTypeFromContext() &&
                                          ! receiver.getTypeId().isNationalStringTypeId() ))
 		{
 			QueryTreeNode likeLTopt;
-			if (leftOperand.isParameterNode())
+			if (leftOperand.requiresTypeFromContext())
 			{
 				likeLTopt = setupOptimizeStringFromParameter(leftOperand, rightOperand,
 								"lessThanStringFromParameter");
@@ -650,7 +650,7 @@
 		 */
 
 		ValueNode likeGEopt;
-		if (leftOperand.isParameterNode()) {
+		if (leftOperand.requiresTypeFromContext()) {
 
 			// Create an expression off the parameter
 			// new SQLChar(Like.greaterEqualString(?));

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java Fri Oct 28 13:57:08 2005
@@ -645,8 +645,7 @@
 			{		
 				/* Set the type information in the null constant node */
 				DataTypeDescriptor dts = DataTypeDescriptor.getSQLDataTypeDescriptor(parmTypeNames[i]);
-				((SQLToJavaValueNode)methodParms[i]).value.setDescriptor(
-																	dts);
+				((SQLToJavaValueNode)methodParms[i]).value.setType(dts);
 
 				/* Set the correct java type name */
 				methodParms[i].setJavaTypeName(parmTypeNames[i]);
@@ -1058,7 +1057,7 @@
 			if (methodParms[index] instanceof SQLToJavaValueNode)
 			{
 				SQLToJavaValueNode stjvn = (SQLToJavaValueNode) methodParms[index];
-				if (stjvn.value.isParameterNode())
+				if (stjvn.value.requiresTypeFromContext())
 				{
 					isParam[index] = true;
 				}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java Fri Oct 28 13:57:08 2005
@@ -152,11 +152,9 @@
 			//	then we have a type for it. Binding can continue.
 			//
 
-			if (SQLValue.isParameterNode())
+			if (SQLValue.requiresTypeFromContext())
 			{
-				ParameterNode	unnamedParameter = (ParameterNode) SQLValue;
-
-				if ( unnamedParameter.getTypeServices() == null )
+				if ( SQLValue.getTypeServices() == null )
 				{ throw StandardException.newException(SQLState.LANG_PARAMETER_RECEIVER, methodName); }
 			}
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ParameterNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- 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 Oct 28 13:57:08 2005
@@ -180,21 +180,12 @@
 	 * @return	Nothing
 	 */
 
-	public void setDescriptor(DataTypeDescriptor descriptor)
+	public void setType(DataTypeDescriptor descriptor) throws StandardException
 	{
 		if (SanityManager.DEBUG)
 		SanityManager.ASSERT(typeServices != null,
 			"typeServices not initialized");
 
-		// if type already determined, there's nothing to do.
-		// this can occur if a named parameter ("?paramName") is
-		// set equal to a unnamed parameter ("?") in a COPY PUBLICATION
-		// statement. in this case, the named parameter may be referenced
-		// multiple times. each time it must resolve to the same "?"
-		// parameter.
-
-		if ( typeServices[parameterNumber] != null ) { return; }
-
 		/* Make sure the type is nullable. */
 		if ( ! descriptor.isNullable())
 		{
@@ -207,7 +198,10 @@
 
 		typeServices[parameterNumber] = descriptor;
 
-		setType(descriptor);
+		//make sure we are calling super's setType. We will get into
+		//an infinite loop if this setType ends up calling the local
+		//setType method
+		super.setType(descriptor);
 
 		if ( getJSQLType() == null ) { setJSQLType(  new JSQLType( descriptor ) ); }
 	}
@@ -236,7 +230,7 @@
 	 * Bind this expression.  A parameter can't figure out what its type
 	 * is without knowing where it appears, so this method does nothing.
 	 * It is up to the node that points to this parameter node to figure
-	 * out the type of the parameter and set it, using the setDescriptor()
+	 * out the type of the parameter and set it, using the setType()
 	 * method above.
 	 *
 	 * @param fromList		The FROM list for the query this
@@ -387,7 +381,7 @@
 		// in "bindExpression" because at the time of bindExpression,
 		// we don't know yet what the type is going to be (only when
 		// the node that points to this parameter calls
-		// "setDescriptor" do we figure out the type).
+		// "setType" do we figure out the type).
 			throw StandardException.newException(
 				SQLState.LANG_ATTEMPT_TO_BIND_XML);
 		}
@@ -467,7 +461,7 @@
 		/* The constructor portion is done */
 	}
 
-	public TypeId getTypeId()
+	public TypeId getTypeId() throws StandardException
 	{
 		return (returnOutputParameter != null) ?
 			returnOutputParameter.getTypeId() : super.getTypeId();
@@ -593,6 +587,14 @@
 	DataValueDescriptor getDefaultValue()
 	{
 		return defaultValue;
+	}
+
+	/**
+	 * @see ValueNode#requiresTypeFromContext
+	 */
+	public boolean requiresTypeFromContext()
+	{
+		return true;
 	}
 	
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Predicate.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Predicate.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Predicate.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/Predicate.java Fri Oct 28 13:57:08 2005
@@ -244,6 +244,7 @@
 
 	/** @see OptimizablePredicate#selectivity */
 	public double selectivity(Optimizable optTable)
+	throws StandardException
 	{
 		return andNode.getLeftOperand().selectivity(optTable);
 	}

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=329295&r1=329294&r2=329295&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 Fri Oct 28 13:57:08 2005
@@ -1049,6 +1049,7 @@
 	 * @return ValueNode	The rebuilt expression tree.
 	 */
 	public ValueNode restoreConstantPredicates()
+	throws StandardException
 	{
 		AndNode			nextAnd;
 		AndNode			falseAnd = null;
@@ -1145,6 +1146,7 @@
 	 * @return ValueNode	The rebuilt expression tree.
 	 */
 	public ValueNode restorePredicates()
+	throws StandardException
 	{
 		AndNode			nextAnd;
 		AndNode			falseAnd = null;
@@ -3649,6 +3651,7 @@
 	 * Compute selectivity the old fashioned way.
 	 */
 	private double selectivityNoStatistics(Optimizable optTable)
+	throws StandardException
 	{
 		double selectivity = 1.0;
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumn.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- 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 Fri Oct 28 13:57:08 2005
@@ -138,7 +138,7 @@
 	 *
 	 * @return	The newly initialized ResultColumn
 	 */
-	public void init(Object arg1, Object arg2)
+	public void init(Object arg1, Object arg2) throws StandardException
 	{
 		// RESOLVE: This is something of a hack - it is not obvious that
 		// the first argument being null means it should be treated as
@@ -282,7 +282,7 @@
 		return dataTypeServices;
 	}
 
-	public DataTypeDescriptor getExpressionType()
+	public DataTypeDescriptor getExpressionType() throws StandardException
 	{
 		return (expression == null) ?
 			dataTypeServices :
@@ -574,11 +574,11 @@
 		** Don't do it if this result column doesn't have a type yet.
 		** This can happen if the parameter is part of a table constructor.
 		*/
-		if (expression.isParameterNode())
+		if (expression.requiresTypeFromContext())
 		{
 			if (getTypeServices() != null)
 			{
-				((ParameterNode) expression).setDescriptor(getTypeServices());
+				expression.setType(getTypeServices());
 			}
 		}
 
@@ -977,7 +977,7 @@
 		** parameters.  So don't even bother in this
 		** case.
 		*/
-		if (expression.isParameterNode())
+		if (expression.requiresTypeFromContext())
 		{
 			return false;
 		}
@@ -1051,8 +1051,8 @@
 		** parameters.  So don't even bother in this
 		** case.
 		*/
-		if ((otherExpression != null) && (otherExpression.isParameterNode()) ||
-			(expression.isParameterNode()))
+		if ((otherExpression != null) && (otherExpression.requiresTypeFromContext()) ||
+			(expression.requiresTypeFromContext()))
 		{
 			return false;
 		}
@@ -1294,12 +1294,12 @@
 	}
 
 	/**
-	 * Look for and reject ? parameter under this ResultColumn.  This is
+	 * Look for and reject ?/-?/+? parameter under this ResultColumn.  This is
 	 * called for SELECT statements.
 	 *
 	 * @return	Nothing
 	 *
-	 * @exception StandardException		Thrown if a ? parameter was found
+	 * @exception StandardException		Thrown if a ?/-?/+? parameter was found
 	 *									directly under this ResultColumn.
 	 */
 
@@ -1307,6 +1307,9 @@
 	{
 		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);
 	}
 
 	/*
@@ -1710,7 +1713,7 @@
 	 * @return	The TypeId from this Node.  This
 	 *		may be null if the node isn't bound yet.
 	 */
-	public TypeId getTypeId()
+	public TypeId getTypeId() throws StandardException
 	{
         TypeId t = super.getTypeId();
         if( t == null)
@@ -1731,7 +1734,7 @@
 	 * @return	The DataTypeServices from this Node.  This
 	 *		may be null if the node isn't bound yet.
 	 */
-	public DataTypeDescriptor getTypeServices()
+	public DataTypeDescriptor getTypeServices() throws StandardException
 	{
         DataTypeDescriptor dtd = super.getTypeServices();
         if( dtd == null && expression != null)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java Fri Oct 28 13:57:08 2005
@@ -1532,7 +1532,7 @@
 	 *
 	 * @return Nothing.
 	 */
-	public void copyTypesAndLengthsToSource(ResultColumnList sourceRCL)
+	public void copyTypesAndLengthsToSource(ResultColumnList sourceRCL) throws StandardException
 	{
 		/* Source and target can have different lengths. */
 		int size = (size() > sourceRCL.size()) ? size() : sourceRCL.size();
@@ -2279,7 +2279,7 @@
 	 *
 	 * @return boolean	Whether or not there is an exact UNION type match on the 2 RCLs.
 	 */
-	public boolean isExactTypeAndLengthMatch(ResultColumnList otherRCL)
+	public boolean isExactTypeAndLengthMatch(ResultColumnList otherRCL) throws StandardException
 	{
 		int size = size();
 		for (int index = 0; index < size; index++)
@@ -2843,7 +2843,7 @@
 	 *
 	 * @return boolean	Whether or not the type information is consistent
 	 */
-	public boolean hasConsistentTypeInfo()
+	public boolean hasConsistentTypeInfo() throws StandardException
 	{
 		boolean isConsistent = true;
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- 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 Fri Oct 28 13:57:08 2005
@@ -329,7 +329,7 @@
 
 			ValueNode re = rc.getExpression();
 
-			if (re.isParameterNode())
+			if (re.requiresTypeFromContext())
 			{
 				ResultColumn	typeCol =
 					(ResultColumn) typeColumns.elementAt(index);
@@ -338,8 +338,7 @@
 				** We found a ? - set its type to the type of the
 				** corresponding column of the target table.
 				*/
-				((ParameterNode) re).setDescriptor(
-										typeCol.getTypeServices());
+				re.setType(typeCol.getTypeServices());
 			}
 			else if (re instanceof CharConstantNode)
 			{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SQLToJavaValueNode.java Fri Oct 28 13:57:08 2005
@@ -103,6 +103,7 @@
 	  *
 	  */
 	public String getJavaTypeName()
+	throws StandardException
 	{
 		JSQLType	myType = getJSQLType();
 
@@ -143,15 +144,18 @@
 	  *	@return	the corresponding JSQLType
 	  *
 	  */
-	public	JSQLType	getJSQLType
-	(
-    )
+	public	JSQLType	getJSQLType	() throws StandardException
 	{
 		if ( jsqlType == null )
 		{
-			if ( value.isParameterNode() ) 
+			if ( value.requiresTypeFromContext()) 
 			{
-				jsqlType = ((ParameterNode) value).getJSQLType();
+  				ParameterNode pn;
+	  			if (value instanceof UnaryOperatorNode) 
+	  				pn = ((UnaryOperatorNode)value).getParameterOperand();
+	  			else
+	  				pn = (ParameterNode) (value);
+				jsqlType = pn.getJSQLType();
 			}
 			else
 			{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java Fri Oct 28 13:57:08 2005
@@ -528,12 +528,13 @@
 				throw StandardException.newException(SQLState.LANG_NO_AGGREGATES_IN_WHERE_CLAUSE);
 			}
 
-			/* If whereClause is a parameter, (where ?), then we should catch it and throw exception
+			/* If whereClause is a parameter, (where ?/where -?/where +?), then we should catch it and throw exception
 			 */
 			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();
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -249,6 +249,7 @@
 	 * @return	The number of new types found in the RowResultSetNode
 	 */
 	int getParamColumnTypes(DataTypeDescriptor[] types, RowResultSetNode rrsn)
+	 throws StandardException
 	{
 		int	numTypes = 0;
 
@@ -259,7 +260,7 @@
 			{
 				ResultColumn rc =
 					(ResultColumn) rrsn.getResultColumns().elementAt(i);
-				if ( ! (rc.getExpression().isParameterNode()))
+				if ( ! (rc.getExpression().requiresTypeFromContext()))
 				{
 					types[i] = rc.getExpressionType();
 					numTypes++;
@@ -294,14 +295,13 @@
 		{
 			ResultColumn	rc = (ResultColumn) rrcl.elementAt(index);
 
-			if (rc.getExpression().isParameterNode())
+			if (rc.getExpression().requiresTypeFromContext())
 			{
 				/*
 				** We found a ? - set its type to the type from the
 				** type array.
 				*/
-				((ParameterNode) rc.getExpression()).setDescriptor(
-											types[index]);
+				rc.getExpression().setType(types[index]);
 			}
 		}
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -146,8 +146,7 @@
 		** for a bit.
 		*/
 
-		((ParameterNode) operand).setDescriptor(
-							DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR));
+		operand.setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR));
 	}
 
 	/**
@@ -156,5 +155,15 @@
 	 */
 	public String getReceiverInterfaceName() {
 	    return ClassName.StringDataValue;
+	}
+
+	/**
+	 * @see ValueNode#requiresTypeFromContext
+	 */
+	public boolean requiresTypeFromContext()
+	{
+	    //should return false because lower(?)/upper(?) are bound to varchar and hence don't
+	    //require their type to be set from the context. 
+	    return false;
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticClassFieldReferenceNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticClassFieldReferenceNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticClassFieldReferenceNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticClassFieldReferenceNode.java Fri Oct 28 13:57:08 2005
@@ -229,6 +229,7 @@
 	 */
 	public void generateExpression(ExpressionClassBuilder acb,
 											MethodBuilder mb)
+	throws StandardException
 	{
 		/*
 		** Generate the following:

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java Fri Oct 28 13:57:08 2005
@@ -381,7 +381,7 @@
 				}
 
 				boolean isParameterMarker = true;
-				if ((sqlParamNode == null) || !sqlParamNode.isParameterNode())
+				if ((sqlParamNode == null) || !sqlParamNode.requiresTypeFromContext())
 				{
 					if (parameterMode != JDBC30Translation.PARAMETER_MODE_IN) {
 					 
@@ -395,7 +395,11 @@
 				{
 					if (applicationParameterNumbers == null)
 						applicationParameterNumbers = new int[parameterCount];
-					applicationParameterNumbers[p] = ((ParameterNode) sqlParamNode).getParameterNumber();
+		  			if (sqlParamNode instanceof UnaryOperatorNode) {
+		  				ParameterNode pn = ((UnaryOperatorNode)sqlParamNode).getParameterOperand();
+		  				applicationParameterNumbers[p] = pn.getParameterNumber();
+		  			} else
+						applicationParameterNumbers[p] = ((ParameterNode) sqlParamNode).getParameterNumber();
 				}
 
 				// this is the SQL type of the procedure parameter.
@@ -416,7 +420,7 @@
 					// type of the procedure parameter.
 					if (sqlParamNode instanceof UntypedNullConstantNode)
 					{
-						sqlParamNode.setDescriptor(paramdtd);
+						sqlParamNode.setType(paramdtd);
 					}
 					else
 					{
@@ -504,7 +508,7 @@
 				// only force the type for a ? so that the correct type shows up
 				// in parameter meta data
 				if (isParameterMarker)
-					sqlParamNode.setDescriptor(paramdtd);
+					sqlParamNode.setType(paramdtd);
 			}
 
 			if (sigParameterCount != parameterCount) {
@@ -547,7 +551,6 @@
 	{
 		int parameterMode;
 
-
 		SQLToJavaValueNode sql2j = null;
 		if (methodParms[parameterNumber] instanceof SQLToJavaValueNode)
 			sql2j = (SQLToJavaValueNode) methodParms[parameterNumber];
@@ -562,10 +565,15 @@
 			parameterMode = JDBC30Translation.PARAMETER_MODE_IN;
 
 			if (sql2j != null) {
-				if (sql2j.getSQLValueNode().isParameterNode()) {
+				if (sql2j.getSQLValueNode().requiresTypeFromContext()) {
+	  				ParameterNode pn;
+		  			if (sql2j.getSQLValueNode() instanceof UnaryOperatorNode) 
+		  				pn = ((UnaryOperatorNode)sql2j.getSQLValueNode()).getParameterOperand();
+		  			else
+		  				pn = (ParameterNode) (sql2j.getSQLValueNode());
 
 					// applicationParameterNumbers is only set up for a procedure.
-					int applicationParameterNumber = ((ParameterNode) (sql2j.getSQLValueNode())).getParameterNumber();
+					int applicationParameterNumber = pn.getParameterNumber();
 
 					String parameterType = methodParameterTypes[parameterNumber];
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- 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 Oct 28 13:57:08 2005
@@ -526,9 +526,9 @@
 		 * A ? parameter to the left of this subquery gets type of the
 		 * subquery's sole column.
 		 */
-		if (leftOperand != null && leftOperand.isParameterNode())
+		if (leftOperand != null && leftOperand.requiresTypeFromContext())
 		{
-			((ParameterNode) leftOperand).setDescriptor(
+			leftOperand.setType(
 				((ResultColumn) resultColumns.elementAt(0)).getTypeServices());
 		}
 
@@ -712,8 +712,7 @@
 				additionalEQ = additionalEQ &&
 								((leftOperand instanceof ConstantNode) ||
 								 (leftOperand instanceof ColumnReference) ||
-
-								 (leftOperand.isParameterNode()));
+								 (leftOperand.requiresTypeFromContext()));
 				/* If we got this far and we are an expression subquery
 				 * then we want to set leftOperand to be the left side
 				 * of the comparison in case we pull the comparison into
@@ -851,7 +850,7 @@
 	 *
 	 * @return Whether or not the NOT IN or ALL subquery can be flattened.
 	 */
-	private boolean canAllBeFlattened ()
+	private boolean canAllBeFlattened () throws StandardException
 	{
 		boolean result = false;
 		if (isNOT_IN() || isALL())

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TernaryOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -539,7 +539,7 @@
 		// handle parameters here
 
 		/* Is there a ? parameter for the receiver? */
-		if (receiver.isParameterNode())
+		if (receiver.requiresTypeFromContext())
 		{
 			/*
 			** According to the SQL standard, if trim has a ? receiver,
@@ -547,14 +547,14 @@
 			** for a varchar.
 			*/
 	
-			((ParameterNode) receiver).setDescriptor(getVarcharDescriptor());
+			receiver.setType(getVarcharDescriptor());
 		}
 
 		/* Is there a ? parameter on the left? */
-		if (leftOperand.isParameterNode())
+		if (leftOperand.requiresTypeFromContext())
 		{
 			/* Set the left operand type to varchar. */
-			((ParameterNode) leftOperand).setDescriptor(getVarcharDescriptor());
+			leftOperand.setType(getVarcharDescriptor());
 		}
 
 		bindToBuiltIn();
@@ -626,17 +626,17 @@
 		 * left/firstOperand's.  If the left/firstOperand are both parameters,
 		 * both will be max length.
 		 */
-		if( receiver.isParameterNode())
+		if( receiver.requiresTypeFromContext())
 		{
-			if( leftOperand.isParameterNode())
+			if( leftOperand.requiresTypeFromContext())
 			{
-				((ParameterNode) receiver).setDescriptor(getVarcharDescriptor());
+				receiver.setType(getVarcharDescriptor());
 			}
 			else
 			{
 				if( leftOperand.getTypeId().isStringTypeId() )
 				{
-					((ParameterNode) receiver).setDescriptor(
+					receiver.setType(
 							         leftOperand.getTypeServices());
 				}
 			}
@@ -646,17 +646,17 @@
 		 * Is there a ? parameter for the second arg.  Copy the receiver's.
 		 * If the receiver are both parameters, both will be max length.
 		 */
-		if(leftOperand.isParameterNode())
+		if(leftOperand.requiresTypeFromContext())
 		{
-			if(receiver.isParameterNode())
+			if(receiver.requiresTypeFromContext())
 			{
-				((ParameterNode) leftOperand).setDescriptor(getVarcharDescriptor());
+				leftOperand.setType(getVarcharDescriptor());
 			}
 			else
 			{
 				if( receiver.getTypeId().isStringTypeId() )
 				{
-					((ParameterNode) leftOperand).setDescriptor(
+					leftOperand.setType(
 							         receiver.getTypeServices());
 				}
 			}
@@ -665,9 +665,9 @@
 		/*
 		 * Is there a ? paramter for the third arg.  It will be an int.
 		 */
-		if( rightOperand.isParameterNode())
+		if( rightOperand.requiresTypeFromContext())
 		{
-			((ParameterNode) rightOperand).setDescriptor(
+			rightOperand.setType(
 				new DataTypeDescriptor(TypeId.INTEGER_ID, true)); 
 		}
 
@@ -735,7 +735,7 @@
 		// handle parameters here
 
 		/* Is there a ? parameter for the receiver? */
-		if (receiver.isParameterNode())
+		if (receiver.requiresTypeFromContext())
 		{
 			/*
 			** According to the SQL standard, if substr has a ? receiver,
@@ -743,22 +743,22 @@
 			** for a varchar.
 			*/
 	
-			((ParameterNode) receiver).setDescriptor(getVarcharDescriptor());
+			receiver.setType(getVarcharDescriptor());
 		}
 
 		/* Is there a ? parameter on the left? */
-		if (leftOperand.isParameterNode())
+		if (leftOperand.requiresTypeFromContext())
 		{
 			/* Set the left operand type to int. */
-			((ParameterNode) leftOperand).setDescriptor(							
+			leftOperand.setType(							
 				new DataTypeDescriptor(TypeId.INTEGER_ID, true)); 
 		}
 
 		/* Is there a ? parameter on the right? */
-		if ((rightOperand != null) && rightOperand.isParameterNode())
+		if ((rightOperand != null) && rightOperand.requiresTypeFromContext())
 		{
 			/* Set the right operand type to int. */
-			((ParameterNode) rightOperand).setDescriptor(							
+			rightOperand.setType(							
 				new DataTypeDescriptor(TypeId.INTEGER_ID, true)); 
 		}
 
@@ -865,9 +865,9 @@
 
     private boolean bindParameter( ValueNode arg, int jdbcType) throws StandardException
     {
-        if( arg.isParameterNode() && arg.getTypeId() == null)
+        if( arg.requiresTypeFromContext() && arg.getTypeId() == null)
         {
-            ((ParameterNode) arg).setDescriptor( new DataTypeDescriptor(TypeId.getBuiltInTypeId( jdbcType), true));
+            arg.setType( new DataTypeDescriptor(TypeId.getBuiltInTypeId( jdbcType), true));
             return true;
         }
         return false;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TimestampOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -85,12 +85,19 @@
 		rightOperand = rightOperand.bindExpression(fromList, subqueryList, 
 			aggregateVector);
 
-        TypeId leftTypeId = leftOperand.getTypeId();
+		//Set the type if there is a parameter involved here 
+		if (leftOperand.requiresTypeFromContext())
+			leftOperand.setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor( Types.DATE));
+		//Set the type if there is a parameter involved here 
+		if (rightOperand.requiresTypeFromContext())
+			rightOperand.setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor( Types.TIME));
+
+		TypeId leftTypeId = leftOperand.getTypeId();
         TypeId rightTypeId = rightOperand.getTypeId();
-        if( !(leftTypeId.isStringTypeId() || leftTypeId.getJDBCTypeId() == Types.DATE || leftOperand.isParameterNode()))
+        if( !(leftOperand.requiresTypeFromContext() || leftTypeId.isStringTypeId() || leftTypeId.getJDBCTypeId() == Types.DATE))
             throw StandardException.newException(SQLState.LANG_BINARY_OPERATOR_NOT_SUPPORTED, 
                                                  operator, leftTypeId.getSQLTypeName(), rightTypeId.getSQLTypeName());
-        if( !(rightTypeId.isStringTypeId() || rightTypeId.getJDBCTypeId() == Types.TIME || rightOperand.isParameterNode()))
+        if( !(rightOperand.requiresTypeFromContext() || rightTypeId.isStringTypeId() || rightTypeId.getJDBCTypeId() == Types.TIME))
             throw StandardException.newException(SQLState.LANG_BINARY_OPERATOR_NOT_SUPPORTED, 
                                                  operator, leftTypeId.getSQLTypeName(), rightTypeId.getSQLTypeName());
         setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor( Types.TIMESTAMP));

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -52,7 +52,23 @@
 
 	private int operatorType;
 
-
+	//when the bindExpression method is called during the normal binding phase,
+	//unary minus and unary plus dynamic parameters are not ready for
+	//binding because the type of these dynamic parameters is not yet set.
+	//For eg, consider sql select * from t1 where c1 = -?
+	//bindExpression on -? gets called from BinaryComparisonOperatorNode's
+	//bindExpression but the parameter type has not been set yet for -?
+	//Later on, in BinaryComparisonOperatorNode's bindExpression, the type
+	//of the -? gets set to the type of c1 by the setType call. 
+	//Now, at this point, we are ready to finish binding phase for -? 
+	//(This class's setType method calls the bindExpression to finish binding)
+	//In order to accomplish binding later on, we need to save the following 
+	//3 objects during first call to bindExpression and then later this 
+	//gets used in setType method when it calls the bindExpression method.
+	FromList localCopyFromList;
+	SubqueryList localCopySubqueryList;
+	Vector localAggregateVector;
+  
 	/**
 	 * Initializer for a UnaryArithmeticOperatorNode
 	 *
@@ -103,9 +119,12 @@
 	{
 		if (operatorType == SQRT || operatorType == ABSOLUTE)
 		{
-			((ParameterNode) operand).setDescriptor(
+			operand.setType(
 				new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.DOUBLE), true));
 		}
+		//Derby-582 add support for dynamic parameter for unary plus and minus
+		else if (operatorType == UNARY_MINUS || operatorType == UNARY_PLUS) 
+			return;
 		else if (operand.getTypeServices() == null)
 		{
 			throw StandardException.newException(SQLState.LANG_UNARY_OPERAND_PARM, operator);
@@ -128,6 +147,14 @@
 		Vector	aggregateVector)
 			throws StandardException
 	{
+		localCopyFromList = fromList;
+		localCopySubqueryList = subqueryList;
+		localAggregateVector = aggregateVector;
+		//Return with no binding, if the type of unary minus/plus parameter is not set yet.
+		if (operand.requiresTypeFromContext() && ((operatorType == UNARY_PLUS || operatorType == UNARY_MINUS))
+				&& operand.getTypeServices() == null)
+				return this;
+
 		super.bindExpression(fromList, subqueryList,
 				aggregateVector);
 
@@ -150,7 +177,7 @@
 		/*
 		** The result type of a +, -, SQRT, ABS is the same as its operand.
 		*/
-		setType(operand.getTypeServices());
+		super.setType(operand.getTypeServices());
 		return this;
 	}
 
@@ -217,5 +244,20 @@
 					getContextManager());
 			((CastNode) operand).bindCastNodeOnly();
 		}
+	}
+
+	/** @see ValueNode#setType */
+	/* We are overwriting this method here because for -?/+?, we now know
+	the type of these dynamic parameters and hence we can do the parameter
+	binding. The setType method will call the binding code after setting
+	the type of the parameter*/
+	public void setType(DataTypeDescriptor descriptor) throws StandardException
+	{
+		operand.setType(descriptor);
+		super.setType(descriptor);
+		//Derby-582 add support for dynamic parameters for unary plus and minus
+		//Now that we know the type of this parameter node, we can do the
+		//binding.
+		bindExpression(localCopyFromList, localCopySubqueryList, localAggregateVector);
 	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java Fri Oct 28 13:57:08 2005
@@ -260,6 +260,28 @@
 	}
 
 	/**
+	 * Get the parameter operand of this unary operator.
+	 * For the example below, for abs unary operator node, we want to get ?
+	 * select * from t1 where -? = max_cni(abs(-?), sqrt(+?))
+	 * 
+	 * This gets called when ParameterNode is needed to get parameter
+	 * specific information like getDefaultValue(), getParameterNumber() etc 
+	 * 
+	 * @return	The parameter operand of this unary operator else null.
+	 */
+	public ParameterNode getParameterOperand()
+	{
+		if (requiresTypeFromContext() == false)
+			return null;
+		else {
+			UnaryOperatorNode tempUON = this;
+			while (!(tempUON.getOperand() instanceof ParameterNode)) 
+				tempUON = (UnaryOperatorNode)tempUON.getOperand();
+			return (ParameterNode)(tempUON.getOperand());
+		}
+	}
+
+	/**
 	 * Set the clause that this node appears in.
 	 *
 	 * @param clause	The clause that this node appears in.
@@ -319,10 +341,14 @@
 			return this;
 		}
 
+		//Return with no binding, if the type of unary minus/plus parameter is not set yet.
+		if (operand.requiresTypeFromContext() && ((operator.equals("-") || operator.equals("+"))) && operand.getTypeServices() == null)
+			return this;
+
 		operand = operand.bindExpression(fromList, subqueryList,
 								aggregateVector);
 
-		if (operand.isParameterNode())
+		if (operand.requiresTypeFromContext())
 			bindParameter();
 
 		/* If the operand is not a built-in type, then generate a bound conversion
@@ -533,6 +559,34 @@
 	}
 
 	/**
+	 * @see ValueNode#requiresTypeFromContext
+	 */
+	public boolean requiresTypeFromContext()
+	{
+		if (operand == null)
+			return false;
+		else
+			return (operand.requiresTypeFromContext()); 
+	}
+
+
+	/**
+	 * 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.
 	 *
@@ -554,7 +608,7 @@
         // an XML string can be arbitrarily long...is this okay?
         // The SQL/XML spec doesn't state what the type of the param
         // should be; only that it "shall be a character type".
-	        ((ParameterNode) operand).setDescriptor(
+	        operand.setType(
  	           DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.CLOB));
 		}
 		else if (operatorType == XMLSERIALIZE_OP) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java Fri Oct 28 13:57:08 2005
@@ -182,7 +182,7 @@
 	 * @return	The DataTypeServices from this ValueNode.  This
 	 *		may be null if the node isn't bound yet.
 	 */
-	public DataTypeDescriptor getTypeServices()
+	public DataTypeDescriptor getTypeServices() throws StandardException
 	{
 		return dataTypeServices;
 	}
@@ -193,7 +193,7 @@
 	 * @return	The TypeId from this ValueNode.  This
 	 *		may be null if the node isn't bound yet.
 	 */
-	public TypeId getTypeId()
+	public TypeId getTypeId() throws StandardException
 	{
 		return typeId;
 	}
@@ -212,7 +212,7 @@
 	 * @return	This ValueNode's TypeCompiler
 	 *
 	 */
-	public TypeCompiler getTypeCompiler()
+	public TypeCompiler getTypeCompiler() throws StandardException
 	{
 		if (typeCompiler == null)
 		{
@@ -227,7 +227,8 @@
 	}
 
 	/**
-	 * Set the DataTypeServices in this ValueNode.
+	 * Set the DataTypeServices for this ValueNode.  This method is
+	 * overridden in ParameterNode.
 	 *
 	 * @param dataTypeServices	The DataTypeServices to set in this
 	 *				ValueNode
@@ -235,7 +236,7 @@
 	 * @return	Nothing
 	 */
 
-	public void setType(DataTypeDescriptor dataTypeServices)
+	public void setType(DataTypeDescriptor dataTypeServices) throws StandardException
 	{
 		this.dataTypeServices = dataTypeServices;
 
@@ -249,20 +250,6 @@
 		typeCompiler = null;
 	}
 
-	/**
-	 * Set the DataTypeServices for this ValueNode.  This method is
-	 * overridden in ParameterNode.
-	 *
-	 * @param descriptor	The DataTypeServices to set for this ValueNode
-	 *
-	 * @return	Nothing
-	 *
-	 */
-
-	public void setDescriptor(DataTypeDescriptor descriptor)
-	{
-		setType(descriptor);
-	}
 
 	/**
 	 * Get the source for this ValueNode.
@@ -768,7 +755,7 @@
 	 * @param oldVN		The ValueNode to copy from.
 	 *
 	 */
-	public void copyFields(ValueNode oldVN)
+	public void copyFields(ValueNode oldVN) throws StandardException
 	{
 		dataTypeServices = oldVN.getTypeServices();
 		typeId = oldVN.getTypeId();
@@ -1010,6 +997,7 @@
 	 * in specific cases, such as the RelationalOperators.
 	 */
 	public double selectivity(Optimizable optTable)
+	throws StandardException
 	{
 		// Return 1 if additional predicates have been generated from this one.
 		if (transformed)
@@ -1172,7 +1160,7 @@
 		 * It is a good = for only the All array if
 		 * the right side is a column from this query block.
 		 */
-		if ((arg1 instanceof ConstantNode) || (arg1.isParameterNode()))
+		if ((arg1 instanceof ConstantNode) || (arg1.requiresTypeFromContext()))
 		{
 			setValueCols(tableColMap, eqOuterCols,
 				((ColumnReference) arg2).getColumnNumber(), resultTable);
@@ -1326,6 +1314,17 @@
 										   int columnNumber, 
 										   boolean isNullOkay)
 		throws StandardException
+	{
+		return false;
+	}
+
+	/**
+	 * Returns TRUE if the type of this node will be determined from the
+	 * context in which it is getting used.
+	 *
+	 * @return Whether this node's type will be determined from the context
+	 */
+	public boolean requiresTypeFromContext()
 	{
 		return false;
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java Fri Oct 28 13:57:08 2005
@@ -184,7 +184,7 @@
 			ValueNode			valueNode;
 
 			valueNode = (ValueNode) elementAt(index);
-			if (valueNode.isParameterNode())
+			if (valueNode.requiresTypeFromContext())
 				continue;
 			DataTypeDescriptor valueNodeDTS = valueNode.getTypeServices();
 
@@ -240,6 +240,7 @@
 	 *			type precendence as the specified value.
 	 */
 	boolean allSamePrecendence(int precedence)
+	throws StandardException
 	{
 		boolean allSame = true;
 		int size = size();
@@ -285,7 +286,7 @@
 		for (int index = 0; index < size; index++)
 		{
 			valueNode = (ValueNode) elementAt(index);
-			if (valueNode.isParameterNode())
+			if (valueNode.requiresTypeFromContext())
 				continue;
 
 
@@ -350,6 +351,7 @@
 	 *					are nullable.
 	 */
 	public boolean isNullable()
+	throws StandardException
 	{
 		int size = size();
 
@@ -374,7 +376,7 @@
 
 		for (int index = 0; index < size; index++)
 		{
-			if (((ValueNode) elementAt(index)).isParameterNode())
+			if (((ValueNode) elementAt(index)).requiresTypeFromContext())
 			{
 				return true;
 			}
@@ -393,7 +395,7 @@
 
 		for (int index = 0; index < size; index++)
 		{
-			if (! (((ValueNode) elementAt(index)).isParameterNode()))
+			if (! (((ValueNode) elementAt(index)).requiresTypeFromContext()))
 			{
 				return false;
 			}
@@ -488,9 +490,9 @@
 		for (int index = 0; index < size; index++)
 		{
 			valueNode = (ValueNode) elementAt(index);
-			if (valueNode.isParameterNode())
+			if (valueNode.requiresTypeFromContext())
 			{
-				((ParameterNode) valueNode).setDescriptor(descriptor);
+				valueNode.setType(descriptor);
 			}
 		}
 	}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java Fri Oct 28 13:57:08 2005
@@ -68,7 +68,7 @@
 	public void init(
 						Object sourceResultSet,
 						Object sourceColumn,
-						Object columnId)
+						Object columnId) throws StandardException
 	{
 		ResultColumn source = (ResultColumn) sourceColumn;
 
@@ -280,7 +280,7 @@
 	 * @return	The DataTypeServices from this Node.  This
 	 *		may be null if the node isn't bound yet.
 	 */
-	public DataTypeDescriptor getTypeServices()
+	public DataTypeDescriptor getTypeServices() throws StandardException
 	{
         DataTypeDescriptor dtd = super.getTypeServices();
         if( dtd == null && sourceColumn != null)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Fri Oct 28 13:57:08 2005
@@ -10356,7 +10356,7 @@
 			setUpAndLinkParameters();
 			// set the type of parameter node, it should be a varchar max Limits.MAX_IDENTIFIER_LENGTH - non nullable
 			ParameterNode p = (ParameterNode)parameterList.elementAt(0);
-			p.setDescriptor(new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.VARCHAR), false, Limits.MAX_IDENTIFIER_LENGTH));
+			p.setType(new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.VARCHAR), false, Limits.MAX_IDENTIFIER_LENGTH));
 		}
 		return setSchema;
 	}

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/unaryArithmeticDynamicParameter.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/unaryArithmeticDynamicParameter.out?rev=329295&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/unaryArithmeticDynamicParameter.out (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/unaryArithmeticDynamicParameter.out Fri Oct 28 13:57:08 2005
@@ -0,0 +1,172 @@
+Test using parameters for unary minus and unary plus
+insert into t1 values(?,+?,-?,?)
+? parameter type is INTEGER
+unary +? parameter type is SMALLINT
+unary -? parameter type is DOUBLE
+select * from t1 where -? in (select c21 from t2)
+unary -? parameter type is INTEGER
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{1,1,1.1,abc}
+	{-1,-1,-1.0,def}
+select * from t1 where c11 = -? and c12 = +? and c13 = ?
+unary -? parameter type is INTEGER
+unary +? parameter type is SMALLINT
+? parameter type is DOUBLE
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{1,1,1.1,abc}
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{-1,-1,-1.0,def}
+select * from t1 where -? = ABS_FUNCT(+?)
+unary -? parameter type is INTEGER
+unary +? parameter type is INTEGER
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{1,1,1.1,abc}
+	{-1,-1,-1.0,def}
+select * from t1 where -? = max_cni(-5,-1)
+unary -? parameter type is INTEGER
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{1,1,1.1,abc}
+	{-1,-1,-1.0,def}
+select * from t1 where -? = max_cni(-?,+?)
+unary -? parameter type is INTEGER
+unary -? parameter type is INTEGER
+unary +? parameter type is INTEGER
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{1,1,1.1,abc}
+	{-1,-1,-1.0,def}
+Try the function again. But use, use sqrt(+?) & abs(-?) functions to send params
+select * from t1 where -? = max_cni(abs(-?), sqrt(+?))
+unary -? parameter type is INTEGER
+unary -? parameter type is DOUBLE
+unary +? parameter type is DOUBLE
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{1,1,1.1,abc}
+	{-1,-1,-1.0,def}
+select * from t1 where c11 between -? and +?
+unary -? parameter type is INTEGER
+unary +? parameter type is INTEGER
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{1,1,1.1,abc}
+select * from t1 where +? not in (-?, +?, 2, ?)
+unary +? parameter type is INTEGER
+unary -? parameter type is INTEGER
+unary +? parameter type is INTEGER
+? parameter type is INTEGER
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{1,1,1.1,abc}
+	{-1,-1,-1.0,def}
+select * from t1 where +? < c12
+unary +? parameter type is SMALLINT
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{1,1,1.1,abc}
+select * from t1 where -? = c11 + ?
+unary -? parameter type is INTEGER
+? parameter type is INTEGER
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{-1,-1,-1.0,def}
+select * from t1 where c11 + ? = -?
+? parameter type is INTEGER
+unary -? parameter type is INTEGER
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{-1,-1,-1.0,def}
+select * from t1 where c11 + c12 = -?
+unary -? parameter type is INTEGER
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{-1,-1,-1.0,def}
+select * from t1 where -? not in (select c21+? from t2)
+unary -? parameter type is INTEGER
+? parameter type is INTEGER
+	 C11,C12,C13,C14
+	 --- --- --- ---
+	{1,1,1.1,abc}
+	{-1,-1,-1.0,def}
+select cast(-? as smallint), cast(+? as int) from t1
+unary -? parameter type is SMALLINT
+unary +? parameter type is INTEGER
+	 1,2
+	 - -
+	{-2,2}
+	{-2,2}
+select nullif(-?,c11) from t1
+unary -? parameter type is INTEGER
+	 1
+	 -
+	{-22}
+	{-22}
+select sqrt(-?) from t1
+unary -? parameter type is DOUBLE
+	 1
+	 -
+	{8.0}
+	{8.0}
+select * from t1 where c11 = any (select -? from t2)
+SQL State : 42X34
+Got expected exception There is a ? parameter in the select list.  This is not allowed.
+Negative test - -?/+? at the beginning and/ at the end of where clause
+select * from t1 where -? and c11=c11 or +?
+SQL State : 42X19
+Got expected exception The WHERE or HAVING clause or CHECK CONSTRAINT definition is a 'PARAMETER' expression.  It must be a BOOLEAN expression.
+Negative test - -?/+? in like escape function
+select * from sys.systables where tablename like -? escape +?
+SQL State : 42X37
+Got expected exception The unary '-' operator is not allowed on the 'VARCHAR' type.
+Negative test - -?/+? in binary timestamp function
+select timestamp(-?,+?) from t1
+SQL State : 42X37
+Got expected exception The unary '-' operator is not allowed on the 'DATE' type.
+Negative test - -? in unary timestamp function
+select timestamp(-?) from t1
+SQL State : 42X36
+Got expected exception The 'timestamp' operator is not allowed to take a ? parameter as an operand.
+Negative test - -? in views
+create view v1 as select * from t1 where c11 = -?
+SQL State : 42X98
+Got expected exception Parameters are not allowed in a VIEW definition.
+Negative test - -? in inner join
+select * from t1 inner join t1 as t333 on -?
+SQL State : 42X37
+Got expected exception The unary '-' operator is not allowed on the 'BOOLEAN' type.
+Negative test - -? by itself in where clause
+select * from t1 where -?
+SQL State : 42X19
+Got expected exception The WHERE or HAVING clause or CHECK CONSTRAINT definition is a 'PARAMETER' expression.  It must be a BOOLEAN expression.
+Negative test - -? is null not allowed because is null allowed on char types only
+select * from t1 where -? is null
+SQL State : 42X37
+Got expected exception The unary '-' operator is not allowed on the 'VARCHAR' type.
+select case when -?=c11 then -? else c12 end from t1
+unary -? parameter type is INTEGER
+unary -? parameter type is SMALLINT
+	 1
+	 -
+	{1}
+	{-22}
+Negative test - unary plus parameters on both sides of / operator
+select * from t1 where c11 = ?/-?
+SQL State : 42X35
+Got expected exception It is not allowed for both operands of '/' to be ? parameters.
+Negative test - unary plus in || operation
+select c11 || +? from t1
+SQL State : 42X37
+Got expected exception The unary '+' operator is not allowed on the 'VARCHAR' type.
+Negative test - unary minus for char column
+select * from t1 where c14 = -?
+SQL State : 42X37
+Got expected exception The unary '-' operator is not allowed on the 'CHAR' type.
+Negative test - unary plus for char column
+select * from t1 where c14 like +?
+SQL State : 42X37
+Got expected exception The unary '+' operator is not allowed on the 'CHAR' type.

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/unaryArithmeticDynamicParameter.out
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall?rev=329295&r1=329294&r2=329295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall Fri Oct 28 13:57:08 2005
@@ -132,6 +132,7 @@
 lang/triggerRecursion.sql
 lang/triggerRefClause.sql
 lang/triggerStream.sql
+lang/unaryArithmeticDynamicParameter.java
 lang/ungroupedAggregatesNegative.sql
 lang/union.sql
 lang/unlimited.sql



Mime
View raw message