db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r548822 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/
Date Tue, 19 Jun 2007 18:46:36 GMT
Author: djd
Date: Tue Jun 19 11:46:35 2007
New Revision: 548822

URL: http://svn.apache.org/viewvc?view=rev&rev=548822
Log:
DERBY-2809 (cleanup) Rename bind method to bindOperand() in UnaryOperatorNode since that correctly
reflects its role. Change sub-classes to call the node correctly. Move some of the logic from
UnaryOperatorNode.bindOperator() to the actual sub-classes where it logically lives.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DB2LengthOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.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/SimpleStringOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TestConstraintNode.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/UnaryComparisonOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryDateTimestampOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryLogicalOperatorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java Tue
Jun 19 11:46:35 2007
@@ -287,13 +287,11 @@
 		/* Add ourselves to the aggregateVector before we do anything else */
 		aggregateVector.addElement(this);
 
-		super.bindExpression(
-				fromList, subqueryList,
-				aggregateVector);
-
         // operand being null means a count(*)
 		if (operand != null)
 		{
+            bindOperand(fromList, subqueryList, aggregateVector);
+            
 			/*
 			** Make sure that we don't have an aggregate 
 			** IMMEDIATELY below us.  Don't search below

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DB2LengthOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DB2LengthOperatorNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DB2LengthOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/DB2LengthOperatorNode.java
Tue Jun 19 11:46:35 2007
@@ -81,7 +81,7 @@
 		Vector	aggregateVector)
 			throws StandardException
 	{
-        ValueNode boundExpression = super.bindExpression( fromList, subqueryList, aggregateVector);
+        bindOperand( fromList, subqueryList, aggregateVector);
 
         // This operator is not allowed on XML types.
         TypeId operandType = operand.getTypeId();
@@ -93,7 +93,7 @@
 
         setType( new DataTypeDescriptor( TypeId.getBuiltInTypeId( Types.INTEGER),
                                          operand.getTypeServices().isNullable()));
-        return boundExpression;
+        return this;
     }
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExtractOperatorNode.java
Tue Jun 19 11:46:35 2007
@@ -90,7 +90,7 @@
 		int	operandType;
 		TypeId opTypeId;
 
-		super.bindExpression(fromList, subqueryList,
+		bindOperand(fromList, subqueryList,
 				aggregateVector);
 
 		opTypeId = operand.getTypeId();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/LengthOperatorNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- 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
Tue Jun 19 11:46:35 2007
@@ -94,7 +94,7 @@
 	{
 		TypeId	operandType;
 
-		super.bindExpression(fromList, subqueryList,
+		bindOperand(fromList, subqueryList,
 				aggregateVector);
 
 		/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SimpleStringOperatorNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- 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
Tue Jun 19 11:46:35 2007
@@ -77,7 +77,7 @@
 	{
 		TypeId	operandType;
 
-		super.bindExpression(fromList, subqueryList, 
+		bindOperand(fromList, subqueryList, 
 				aggregateVector);
 
 		/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TestConstraintNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TestConstraintNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TestConstraintNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TestConstraintNode.java
Tue Jun 19 11:46:35 2007
@@ -89,14 +89,13 @@
 		Vector	aggregateVector)
 			throws StandardException
 	{
-		bindUnaryOperator(fromList, subqueryList, aggregateVector);
+		bindOperand(fromList, subqueryList, aggregateVector);
 
 		/*
 		** If the operand is not boolean, cast it.
 		*/
 
-		if ( ! operand.getTypeServices().getTypeId().getSQLTypeName().equals(
-														TypeId.BOOLEAN_NAME))
+		if (!operand.getTypeServices().getTypeId().isBooleanTypeId())
 		{
 			operand = (ValueNode)
 				getNodeFactory().getNode(

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryArithmeticOperatorNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- 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
Tue Jun 19 11:46:35 2007
@@ -154,7 +154,7 @@
 				&& operand.getTypeServices() == null)
 				return this;
 
-		super.bindExpression(fromList, subqueryList,
+		bindOperand(fromList, subqueryList,
 				aggregateVector);
 
 		if (operatorType == SQRT || operatorType == ABSOLUTE)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryComparisonOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryComparisonOperatorNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryComparisonOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryComparisonOperatorNode.java
Tue Jun 19 11:46:35 2007
@@ -74,7 +74,7 @@
 		Vector	aggregateVector)
 			throws StandardException
 	{
-		super.bindExpression(fromList, subqueryList, 
+		bindOperand(fromList, subqueryList, 
 							 aggregateVector);
 
 		/* Set type info for this node */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryDateTimestampOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryDateTimestampOperatorNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryDateTimestampOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryDateTimestampOperatorNode.java
Tue Jun 19 11:46:35 2007
@@ -97,7 +97,7 @@
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	protected ValueNode bindUnaryOperator(
+	public ValueNode bindExpression (
 					FromList fromList, SubqueryList subqueryList,
 					Vector aggregateVector)
 				throws StandardException
@@ -105,7 +105,7 @@
         boolean isIdentity = false; // Is this function the identity operator?
         boolean operandIsNumber = false;
         
-        super.bindUnaryOperator( fromList, subqueryList, aggregateVector);
+        bindOperand( fromList, subqueryList, aggregateVector);
         DataTypeDescriptor operandType = operand.getTypeServices();
         switch( operandType.getJDBCTypeId())
         {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryLogicalOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryLogicalOperatorNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryLogicalOperatorNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryLogicalOperatorNode.java
Tue Jun 19 11:46:35 2007
@@ -71,7 +71,7 @@
 		Vector	aggregateVector)
 			throws StandardException
 	{
-		super.bindExpression(fromList, subqueryList,
+		bindOperand(fromList, subqueryList,
 							 aggregateVector);
 
 		/*
@@ -84,9 +84,8 @@
 		** the grammar, so this test will become useful.
 		*/
 
-		if ( ! operand.getTypeServices().getTypeId().equals(TypeId.BOOLEAN_ID))
+		if ( ! operand.getTypeServices().getTypeId().isBooleanTypeId())
 		{
-operand.treePrint();
 			throw StandardException.newException(SQLState.LANG_UNARY_LOGICAL_NON_BOOLEAN);
 		}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnaryOperatorNode.java?view=diff&rev=548822&r1=548821&r2=548822
==============================================================================
--- 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
Tue Jun 19 11:46:35 2007
@@ -62,7 +62,11 @@
 {
 	String	operator;
 	String	methodName;
-	int operatorType;
+    
+    /**
+     * Operator type, only valid for XMLPARSE and XMLSERIALIZE.
+     */
+	private int operatorType;
 
 	String		resultInterfaceType;
 	String		receiverInterfaceType;
@@ -84,6 +88,12 @@
 	// TernarnyOperatorNode. Subsequent unary operators (whether
 	// XML-related or not) should follow this example when
 	// possible.
+    //
+    // This has lead to this class having somewhat of
+    // a confused personality. In one mode it is really
+    // a parent (abstract) class for various unary operator
+    // node implementations, in its other mode it is a concrete
+    // class for XMLPARSE and XMLSERIALIZE.
 
 	public final static int XMLPARSE_OP = 0;
 	public final static int XMLSERIALIZE_OP = 1;
@@ -286,6 +296,9 @@
 	/**
 	 * Bind this expression.  This means binding the sub-expressions,
 	 * as well as figuring out what the return type is for this expression.
+     * This method is the implementation for XMLPARSE and XMLSERIALIZE.
+     * Sub-classes need to implement their own bindExpression() method
+     * for their own specific rules.
 	 *
 	 * @param fromList		The FROM list for the query this
 	 *				expression is in, for binding columns.
@@ -302,30 +315,29 @@
 					Vector	aggregateVector)
 				throws StandardException
 	{
-		return bindUnaryOperator(fromList, subqueryList, aggregateVector);
+		bindOperand(fromList, subqueryList, aggregateVector);
+        if (operatorType == XMLPARSE_OP)
+            bindXMLParse();
+        else if (operatorType == XMLSERIALIZE_OP)
+            bindXMLSerialize();
+        return this;
 	}
 
 	/**
-	 * Workhorse for bindExpression. This exists so it can be called
-	 * by child classes.
+	 * Bind the operand for this unary operator.
+     * Binding the operator may change the operand node.
+     * Sub-classes bindExpression() methods need to call this
+     * method to bind the operand.
 	 */
-	protected ValueNode bindUnaryOperator(
+	protected void bindOperand(
 					FromList fromList, SubqueryList subqueryList,
 					Vector	aggregateVector)
 				throws StandardException
 	{
-		/*
-		** Operand can be null for COUNT(*) which
-		** is treated like a normal aggregate.
-		*/
-		if (operand == null)
-		{
-			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;
+			return;
 
 		operand = operand.bindExpression(fromList, subqueryList,
 								aggregateVector);
@@ -342,13 +354,6 @@
 		{
 			operand = operand.genSQLJavaSQLTree();
 		}
-
-		if (operatorType == XMLPARSE_OP)
-			bindXMLParse();
-		else if (operatorType == XMLSERIALIZE_OP)
-			bindXMLSerialize();
-
-		return this;
 	}
 
     /**



Mime
View raw message