db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1506827 [4/4] - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/services/context/ impl/sql/compile/
Date Thu, 25 Jul 2013 07:12:49 GMT
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?rev=1506827&r1=1506826&r2=1506827&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 Thu Jul 25 07:12:46 2013
@@ -40,35 +40,36 @@ class UnaryArithmeticOperatorNode extend
 	private final static String[] UNARY_OPERATORS = {"+","-","SQRT", "ABS/ABSVAL"};
 	private final static String[] UNARY_METHODS = {"plus","minus","sqrt", "absolute"};
 
-   private final OperatorType operatorType;
-
-    public enum OperatorType {PLUS(0), MINUS(1), SQRT(2), ABS(3);
-
-        private int representation;
-
-        private OperatorType(int repr) {
-            this.representation = repr;
-        }
-
-        public int getVal() { return representation; }
-    }
+    // Allowed kinds
+    final static int K_PLUS = 0;
+    final static int K_MINUS = 1;
+    final static int K_SQRT = 2;
+    final static int K_ABS = 3;
     
     /**
+     * This class is used to hold logically different objects for
+     * space efficiency. {@code kind} represents the logical object
+     * type. See also {@link ValueNode#isSameNodeKind}.
+     */
+    final int kind;
+
+    /**
      * @param operand The operand of the node
-     * @param type unary operator identity
+     * @param kind unary operator identity
      * @param cm context manager
      * @throws StandardException
      */
     UnaryArithmeticOperatorNode(
             ValueNode operand,
-            OperatorType type,
+            int kind,
             ContextManager cm) throws StandardException {
         super(operand,
-              UNARY_OPERATORS[type.getVal()],
-              UNARY_METHODS[type.getVal()],
+              UNARY_OPERATORS[kind],
+              UNARY_METHODS[kind],
               cm);
-        this.operatorType = type;
+        this.kind = kind;
     }
+
     /**
      * Unary + and - require their type to be set if
      * they wrap another node (e.g. a parameter) that
@@ -78,8 +79,8 @@ class UnaryArithmeticOperatorNode extend
     @Override
     public boolean requiresTypeFromContext()
     {
-        if (operatorType == OperatorType.PLUS ||
-            operatorType == OperatorType.MINUS) {
+        if (kind == K_PLUS ||
+            kind == K_MINUS) {
             return operand.requiresTypeFromContext(); 
         }
         return false;
@@ -91,8 +92,8 @@ class UnaryArithmeticOperatorNode extend
     @Override
     public boolean isParameterNode()
     {
-        if (operatorType == OperatorType.PLUS ||
-            operatorType == OperatorType.MINUS) {
+        if (kind == K_PLUS ||
+            kind == K_MINUS) {
             return operand.isParameterNode(); 
         }
         return false;
@@ -112,8 +113,8 @@ class UnaryArithmeticOperatorNode extend
     @Override
 	void bindParameter() throws StandardException
 	{
-       if (operatorType == OperatorType.SQRT ||
-            operatorType == OperatorType.ABS)
+       if (kind == K_SQRT ||
+            kind == K_ABS)
 		{
 			operand.setType(
 				new DataTypeDescriptor(TypeId.getBuiltInTypeId(Types.DOUBLE), true));
@@ -121,8 +122,8 @@ class UnaryArithmeticOperatorNode extend
 		}
         
 		//Derby-582 add support for dynamic parameter for unary plus and minus
-       if (operatorType == OperatorType.MINUS ||
-            operatorType == OperatorType.PLUS)
+       if (kind == K_MINUS ||
+            kind == K_PLUS)
 			return;
         
         // Not expected to get here since only the above types are supported
@@ -149,20 +150,20 @@ class UnaryArithmeticOperatorNode extend
 	{
 		//Return with no binding, if the type of unary minus/plus parameter is not set yet.
        if (operand.requiresTypeFromContext() &&
-                ((operatorType == OperatorType.PLUS ||
-                  operatorType == OperatorType.MINUS))
+                ((kind == K_PLUS ||
+                  kind == K_MINUS))
 				&& operand.getTypeServices() == null)
 				return this;
 
         bindOperand(fromList, subqueryList, aggregates);
 
-       if (operatorType == OperatorType.SQRT ||
-            operatorType == OperatorType.ABS)
+       if (kind == K_SQRT ||
+            kind == K_ABS)
 		{
 			bindSQRTABS();
 		}
-       else if (operatorType == OperatorType.PLUS ||
-                 operatorType == OperatorType.MINUS)
+       else if (kind == K_PLUS ||
+                 kind == K_MINUS)
 		{
             checkOperandIsNumeric(operand.getTypeId());
 		}
@@ -183,7 +184,7 @@ class UnaryArithmeticOperatorNode extend
 	    {
 	        throw StandardException.newException(
                     SQLState.LANG_UNARY_ARITHMETIC_BAD_TYPE, 
-                   (operatorType == OperatorType.PLUS) ? "+" : "-",
+                   (kind == K_PLUS) ? "+" : "-",
 	                        operandType.getSQLTypeName());
 	    }
 	    
@@ -202,7 +203,7 @@ class UnaryArithmeticOperatorNode extend
 									throws StandardException
 	{
 		/* Unary + doesn't do anything.  Just return the operand */
-       if (operatorType == OperatorType.PLUS)
+       if (kind == K_PLUS)
 			operand.generateExpression(acb, mb);
 		else
 			super.generateExpression(acb, mb);
@@ -242,7 +243,7 @@ class UnaryArithmeticOperatorNode extend
 						getOperatorString(), operandType.getSQLTypeName());
 
 		/* For SQRT, if operand is not a DOUBLE, convert it to DOUBLE */
-       if (operatorType == OperatorType.SQRT &&
+       if (kind == K_SQRT &&
             jdbcType != Types.DOUBLE)
 		{
             operand = new CastNode(
@@ -267,4 +268,10 @@ class UnaryArithmeticOperatorNode extend
         }
 		super.setType(descriptor);
 	}
+
+    @Override
+    boolean isSameNodeKind(ValueNode o) {
+        return super.isSameNodeKind(o) &&
+                ((UnaryArithmeticOperatorNode)o).kind == kind;
+    }
 }

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?rev=1506827&r1=1506826&r2=1506827&view=diff
==============================================================================
--- 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 Thu Jul 25 07:12:46 2013
@@ -29,7 +29,6 @@ import org.apache.derby.iapi.reference.S
 import org.apache.derby.iapi.services.classfile.VMOpcode;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.context.ContextManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.DataValueFactory;
@@ -46,26 +45,34 @@ class UnaryDateTimestampOperatorNode ext
     private static final String TIMESTAMP_METHOD_NAME = "getTimestamp";
     private static final String DATE_METHOD_NAME = "getDate";
     
-    enum OperatorType {DATE, TIMESTAMP};
+    // Allowed kinds
+    final static int K_DATE = 0;
+    final static int K_TIMESTAMP = 1;
+
+    /**
+     * This class is used to hold logically different objects for
+     * space efficiency. {@code kind} represents the logical object
+     * type. See also {@link ValueNode#isSameNodeKind}.
+     */
+    final int kind;
 
     /**
      * @param operand The operand of the function
-     * @param type The type of the result, Date or Timestamp.
+     * @param kind The kind of the result, Date or Timestamp.
      * @param cm context manager
      * @throws StandardException
      */
     UnaryDateTimestampOperatorNode(
             ValueNode operand,
-            OperatorType type,
+            int kind,
             ContextManager cm) throws StandardException {
         super(operand,
-                type == OperatorType.DATE ? "date" : "timestamp",
-                type == OperatorType.DATE ?
-                    DATE_METHOD_NAME : TIMESTAMP_METHOD_NAME,
+                kind == K_DATE ? "date" : "timestamp",
+                kind == K_DATE ? DATE_METHOD_NAME : TIMESTAMP_METHOD_NAME,
                 cm);
-        setNodeType(C_NodeTypes.UNARY_DATE_TIMESTAMP_OPERATOR_NODE);
+        this.kind = kind;
         setType(DataTypeDescriptor.getBuiltInDataTypeDescriptor(
-                type == OperatorType.DATE ? Types.DATE : Types.TIMESTAMP));
+                kind == K_DATE ? Types.DATE : Types.TIMESTAMP));
     }
 
     /**
@@ -180,4 +187,10 @@ class UnaryDateTimestampOperatorNode ext
         mb.cast( ClassName.DataValueDescriptor);
         mb.callMethod( VMOpcode.INVOKEINTERFACE, (String) null, methodName, getTypeCompiler().interfaceName(), 1);
     } // end of generateExpression
+
+    @Override
+    boolean isSameNodeKind(ValueNode o) {
+        return super.isSameNodeKind(o) &&
+                ((UnaryDateTimestampOperatorNode)o).kind == kind;
+    }
 }

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?rev=1506827&r1=1506826&r2=1506827&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 Thu Jul 25 07:12:46 2013
@@ -51,11 +51,6 @@ class UnaryOperatorNode extends Operator
 	String	operator;
 	String	methodName;
     
-    /**
-     * Operator type, only valid for XMLPARSE and XMLSERIALIZE.
-     */
-	private int operatorType;
-
 	String		resultInterfaceType;
 	String		receiverInterfaceType;
 
@@ -78,8 +73,18 @@ class UnaryOperatorNode extends Operator
     // node implementations, in its other mode it is a concrete
     // class for XMLPARSE and XMLSERIALIZE.
 
-    final static int XMLPARSE_OP = 0;
-    final static int XMLSERIALIZE_OP = 1;
+    // Allowed kinds
+    final static int K_XMLPARSE = 0;
+    final static int K_XMLSERIALIZE = 1;
+    final static int K_BASE = 2; // when UnaryOperatorNode is used as
+                                 // a base class
+
+    /**
+     * This class is used to hold logically different objects for
+     * space efficiency. {@code kind} represents the logical object
+     * type. See also {@link ValueNode#isSameNodeKind}.
+     */
+    final int kind;
 
 	// NOTE: in the following 4 arrays, order
 	// IS important.
@@ -110,6 +115,10 @@ class UnaryOperatorNode extends Operator
     /** Whether or not an XMLParse operator should preserve whitespace. */
     private boolean preserveWhitespace;
 
+    /**
+     * When UnaryOperatorNode is used as an base class, this
+     * constructor is used as {@code super}.
+     */
     UnaryOperatorNode(ValueNode operand,
             String operator,
             String methodNameOrAddedArgs,
@@ -118,47 +127,50 @@ class UnaryOperatorNode extends Operator
         this.operand = operand;
         this.operator = operator;
         this.methodName = methodNameOrAddedArgs;
-        this.operatorType = -1;
+        this.kind = K_BASE;
     }
 
+    /**
+     * When UnaryOperatorNode is used as an base class, this
+     * constructor is used as {@code super}.
+     */
     UnaryOperatorNode(ValueNode operand, ContextManager cm) {
         super(cm);
         this.operand = operand;
-        this.operatorType = -1;
+        this.kind = K_BASE;
     }
 
 	/**
-     * Constructor for a UnaryOperatorNode.
+     * Constructor for a UnaryOperatorNode when used as a concrete class.
 	 *
      * @param operand       The operand of the node
-     * @param operatorType  Either 1) the name of the operator,
-     *                      OR 2) an Integer holding the operatorType
-     *                      for this operator.
+     * @param kind          The kind of operator
+     * @param targetType    The DTD of the target type
+     * @param preserveWhiteSpace {@code true} if white space is to be preserved
+     *                      (relevant for kind == XMLPARSE only)
      * @param cm            The context manager
 	 */
-    UnaryOperatorNode(int                nodeType,
-                      ValueNode          operand,
-                      int                operatorType,
+    UnaryOperatorNode(ValueNode          operand,
+                      int                kind,
                       DataTypeDescriptor targetType,
                       boolean            preserveWhiteSpace,
                       ContextManager     cm)
 	{
         super(cm);
-        setNodeType(nodeType);
         this.operand = operand;
-        this.operatorType = operatorType;
-        this.operator = UnaryOperators[this.operatorType];
-        this.methodName = UnaryMethodNames[this.operatorType];
-        this.resultInterfaceType = UnaryResultTypes[this.operatorType];
-        this.receiverInterfaceType = UnaryArgTypes[this.operatorType];
+        this.kind = kind;
+        this.operator = UnaryOperators[this.kind];
+        this.methodName = UnaryMethodNames[this.kind];
+        this.resultInterfaceType = UnaryResultTypes[this.kind];
+        this.receiverInterfaceType = UnaryArgTypes[this.kind];
 
-        if (operatorType == XMLSERIALIZE_OP) {
+        if (kind == K_XMLSERIALIZE) {
             this.targetType = targetType;
-        } else if (operatorType == XMLPARSE_OP) {
+        } else if (kind == K_XMLPARSE) {
             this.preserveWhitespace = preserveWhiteSpace;
         } else if (SanityManager.DEBUG) {
             SanityManager.THROWASSERT(
-                    "Don't know how to handle operator type " + operatorType);
+                    "Don't know how to handle operator type " + kind);
         }
 	}
 
@@ -170,7 +182,6 @@ class UnaryOperatorNode extends Operator
 	void setOperator(String operator)
 	{
 		this.operator = operator;
-		this.operatorType = -1;
 	}
 
 	/**
@@ -191,7 +202,6 @@ class UnaryOperatorNode extends Operator
 	void setMethodName(String methodName)
 	{
 		this.methodName = methodName;
-		this.operatorType = -1;
 	}
 
 	/**
@@ -291,10 +301,13 @@ class UnaryOperatorNode extends Operator
 				throws StandardException
 	{
         bindOperand(fromList, subqueryList, aggregates);
-        if (operatorType == XMLPARSE_OP)
+
+        if (kind == K_XMLPARSE) {
             bindXMLParse();
-        else if (operatorType == XMLSERIALIZE_OP)
+        } else if (kind == K_XMLSERIALIZE) {
             bindXMLSerialize();
+        }
+
         return this;
 	}
 
@@ -539,7 +552,7 @@ class UnaryOperatorNode extends Operator
 
 	void bindParameter() throws StandardException
 	{
-		if (operatorType == XMLPARSE_OP)
+        if (kind == K_XMLPARSE)
 		{
 			/* SQL/XML[2006] allows both binary and character strings for
 			 * the XMLParse parameter (section 10.16:Function).  The spec
@@ -571,7 +584,7 @@ class UnaryOperatorNode extends Operator
 			throw StandardException.newException(
 				SQLState.LANG_XMLPARSE_UNKNOWN_PARAM_TYPE);
 		}
-		else if (operatorType == XMLSERIALIZE_OP) {
+        else if (kind == K_XMLSERIALIZE) {
         // For now, since JDBC has no type defined for XML, we
         // don't allow binding to an XML parameter.
 	        throw StandardException.newException(
@@ -597,7 +610,7 @@ class UnaryOperatorNode extends Operator
 									throws StandardException
 	{
 		String resultTypeName = 
-			(operatorType == -1)
+            (kind == K_BASE)
 				? getTypeCompiler().interfaceName()
 				: resultInterfaceType;
 			
@@ -651,7 +664,7 @@ class UnaryOperatorNode extends Operator
 								"cannot get interface without operand");
 		}
 
-		if (operatorType != -1)
+        if (kind != K_BASE)
 			return receiverInterfaceType;
 		
 		return operand.getTypeCompiler().interfaceName();
@@ -714,11 +727,13 @@ class UnaryOperatorNode extends Operator
     int addXmlOpMethodParams(ExpressionClassBuilder acb,
 		MethodBuilder mb, LocalField resultField) throws StandardException
     {
-        if ((operatorType != XMLPARSE_OP) && (operatorType != XMLSERIALIZE_OP))
-        // nothing to do.
+        if ((kind != K_XMLPARSE) &&
+                (kind != K_XMLSERIALIZE)) {
+            // nothing to do.
             return 0;
+        }
 
-        if (operatorType == XMLSERIALIZE_OP) {
+        if (kind == K_XMLSERIALIZE) {
         // We push the target type's JDBC type id as well as
         // the maximum width, since both are required when
         // we actually perform the operation, and both are
@@ -767,17 +782,19 @@ class UnaryOperatorNode extends Operator
      * @throws StandardException 
      * {@inheritDoc}
      */
-    protected boolean isEquivalent(ValueNode o) throws StandardException
+    boolean isEquivalent(ValueNode o) throws StandardException
     {
-    	if (isSameNodeType(o)) 
-    	{
-		// the first condition in the || covers the case when 
-	    	// both operands are null.
+        if (isSameNodeKind(o)) {
     		UnaryOperatorNode other = (UnaryOperatorNode)o;
     		return (operator.equals(other.operator) && 
-			((operand == other.operand)|| 
-			 ((operand != null) && operand.isEquivalent(other.operand))));
+                   ((operand == other.operand)||
+                   ((operand != null) && operand.isEquivalent(other.operand))));
     	}
     	return false;
     }
+
+    @Override
+    boolean isSameNodeKind(ValueNode o) {
+        return super.isSameNodeKind(o) && ((UnaryOperatorNode)o).kind == kind;
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java?rev=1506827&r1=1506826&r2=1506827&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UnionNode.java Thu Jul 25 07:12:46 2013
@@ -29,7 +29,6 @@ import org.apache.derby.iapi.services.cl
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.CostEstimate;
 import org.apache.derby.iapi.sql.compile.Optimizable;
 import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
@@ -78,7 +77,6 @@ class UnionNode extends SetOperatorNode
               ContextManager cm) throws StandardException {
 
         super(leftResult, rightResult, all, tableProperties, cm);
-        setNodeType(C_NodeTypes.UNION_NODE);
 
         // Is this a UNION ALL for a table constructor?
         this.tableConstructor = tableConstructor;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UntypedNullConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UntypedNullConstantNode.java?rev=1506827&r1=1506826&r2=1506827&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UntypedNullConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UntypedNullConstantNode.java Thu Jul 25 07:12:46 2013
@@ -26,7 +26,6 @@ import org.apache.derby.iapi.error.Stand
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 
@@ -46,7 +45,6 @@ public final class UntypedNullConstantNo
    UntypedNullConstantNode(ContextManager cm)
 	{
        super(cm);
-        setNodeType(C_NodeTypes.UNTYPED_NULL_CONSTANT_NODE);
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java?rev=1506827&r1=1506826&r2=1506827&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UpdateNode.java Thu Jul 25 07:12:46 2013
@@ -25,7 +25,6 @@ import java.lang.reflect.Modifier;
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import org.apache.derby.catalog.DefaultInfo;
 import org.apache.derby.catalog.UUID;
@@ -38,7 +37,6 @@ import org.apache.derby.iapi.services.co
 import org.apache.derby.iapi.services.io.FormatableBitSet;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.StatementType;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.conn.Authorizer;
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
 import org.apache.derby.iapi.sql.dictionary.CheckConstraintDescriptor;
@@ -95,7 +93,6 @@ public final class UpdateNode extends DM
                ContextManager cm)
 	{
         super(resultSet, cm);
-        setNodeType(C_NodeTypes.UPDATE_NODE);
         this.targetTableName = targetTableName;
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserTypeConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserTypeConstantNode.java?rev=1506827&r1=1506826&r2=1506827&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserTypeConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserTypeConstantNode.java Thu Jul 25 07:12:46 2013
@@ -34,7 +34,6 @@ import org.apache.derby.iapi.services.co
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.io.StoredFormatIds;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.TypeCompiler;
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.SQLDate;
@@ -68,7 +67,6 @@ class UserTypeConstantNode extends Const
     UserTypeConstantNode(TypeId t, ContextManager cm)
             throws StandardException {
         super(t, true, TypeDescriptor.MAXIMUM_WIDTH_UNKNOWN, cm);
-        setNodeType(C_NodeTypes.USERTYPE_CONSTANT_NODE);
     }
 
     UserTypeConstantNode(Date d, ContextManager cm)
@@ -79,7 +77,6 @@ class UserTypeConstantNode extends Const
               cm);
         setValue(new SQLDate(d));
         val = d;
-        setNodeType(C_NodeTypes.USERTYPE_CONSTANT_NODE);
     }
 
     UserTypeConstantNode(Time t, ContextManager cm)
@@ -90,7 +87,6 @@ class UserTypeConstantNode extends Const
               cm);
         setValue(new SQLTime(t));
         val = t;
-        setNodeType(C_NodeTypes.USERTYPE_CONSTANT_NODE);
     }
 
     UserTypeConstantNode(Timestamp t, ContextManager cm)
@@ -101,7 +97,6 @@ class UserTypeConstantNode extends Const
                 cm);
         setValue(new SQLTimestamp(t));
         val = t;
-        setNodeType(C_NodeTypes.USERTYPE_CONSTANT_NODE);
     }
 
     /**
@@ -117,7 +112,6 @@ class UserTypeConstantNode extends Const
               cm);
         setValue(dvd);
         val = dvd;
-        setNodeType(C_NodeTypes.USERTYPE_CONSTANT_NODE);
     }
 
     private static TypeId getTypeId(DataValueDescriptor dvd) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNode.java?rev=1506827&r1=1506826&r2=1506827&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 Thu Jul 25 07:12:46 2013
@@ -27,7 +27,6 @@ import org.apache.derby.iapi.reference.S
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.Optimizable;
 import org.apache.derby.iapi.sql.compile.TypeCompiler;
 import org.apache.derby.iapi.store.access.Qualifier;
@@ -470,11 +469,11 @@ public abstract class ValueNode extends 
 
         falseNode = new BooleanConstantNode(false, getContextManager());
         equalsNode = new BinaryRelationalOperatorNode(
-								C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
-								this,
-								falseNode,
-                                false,
-								getContextManager());
+                BinaryRelationalOperatorNode.K_EQUALS,
+                this,
+                falseNode,
+                false,
+                getContextManager());
 		nullableResult = getTypeServices().isNullable();
 		equalsNode.setType(new DataTypeDescriptor(
 									TypeId.BOOLEAN_ID,
@@ -495,8 +494,7 @@ public abstract class ValueNode extends 
 	{
 		IsNullNode isNullNode;
 
-       isNullNode = new IsNullNode(
-                this, IsNullNode.Sign.IS_NULL, getContextManager());
+       isNullNode = new IsNullNode(this, false, getContextManager());
 		isNullNode.setType(new DataTypeDescriptor(
 									TypeId.BOOLEAN_ID,
 									false)
@@ -1301,20 +1299,21 @@ public abstract class ValueNode extends 
     abstract boolean isEquivalent(ValueNode other)
 		throws StandardException;
 
-	/**
-	 * Tests if this node is of the same type as the specified node as
-	 * reported by {@link QueryTreeNode#getNodeType()}.
-	 * 
-	 * @param other the node to compare this value node against. 
-	 * 
-	 * @return <code>true</code> if the two nodes are of the same type.  
-	 */
-	protected final boolean isSameNodeType(ValueNode other)
-	{
-		if (other != null) {
-			return other.getNodeType() == getNodeType();
-		}
-		return false;
-	}
-	
+    /**
+     * Some node classes represent several logical node types (to reduce
+     * footprint), which we call <em>kinds</em>.
+     * This means that implementations of {@link #isEquivalent()}
+     * cannot always just use {@code instanceof} to check if the other node
+     * represents the same kind. Hence this method needs to be
+     * implemented by all node classes that represent several kinds.
+     * It is only called from implementations of {@code isEquivalent}.
+     *
+     * @param other The other value node whose kind we want to compare with.
+     * @return {@code true} if {@code this} and {@code o} represent the same
+     *         logical node type, i.e. kind.
+     */
+    boolean isSameNodeKind(ValueNode other) {
+        // Default implementation does not look at kinds.
+        return other != null && other.getClass().equals(this.getClass());
+    }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ValueNodeList.java?rev=1506827&r1=1506826&r2=1506827&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 Thu Jul 25 07:12:46 2013
@@ -27,7 +27,6 @@ import org.apache.derby.iapi.reference.S
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.loader.ClassFactory;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.TypeCompiler;
 import org.apache.derby.iapi.store.access.Qualifier;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
@@ -45,7 +44,6 @@ class ValueNodeList extends QueryTreeNod
 {
     ValueNodeList(ContextManager cm) {
         super(ValueNode.class, cm);
-        setNodeType(C_NodeTypes.VALUE_NODE_LIST);
     }
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VarbitConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VarbitConstantNode.java?rev=1506827&r1=1506826&r2=1506827&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VarbitConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VarbitConstantNode.java Thu Jul 25 07:12:46 2013
@@ -25,11 +25,22 @@ import java.sql.Types;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.types.TypeId;
 
 public final class VarbitConstantNode extends BitConstantNode
 {
+    // Allowed kinds
+    final static int K_VAR = 0;
+    final static int K_LONGVAR = 1;
+    final static int K_BLOB = 2;
+
+    /**
+     * This class is used to hold logically different objects for
+     * space efficiency. {@code kind} represents the logical object
+     * type. See also {@link ValueNode#isSameNodeKind}.
+     */
+    final int kind;
+
     /**
      * Construct constant node for one of VARBINARY, LONG VARBINARY and
      * BLOB types.
@@ -41,24 +52,22 @@ public final class VarbitConstantNode ex
             throws StandardException {
         super(t, cm);
 
-        int nodeType = 0;
         switch (t.getJDBCTypeId()) {
             case Types.VARBINARY:
-                nodeType = C_NodeTypes.VARBIT_CONSTANT_NODE;
+                kind = K_VAR;
                 break;
             case Types.LONGVARBINARY:
-                nodeType = C_NodeTypes.LONGVARBIT_CONSTANT_NODE;
+                kind = K_LONGVAR;
                 break;
             case Types.BLOB:
-                nodeType = C_NodeTypes.BLOB_CONSTANT_NODE;
+                kind = K_BLOB;
                 break;
             default:
                 if (SanityManager.DEBUG) {
                     SanityManager.NOTREACHED();
                 }
+                kind = -1;
         }
-
-        setNodeType(nodeType);
     }
 
     VarbitConstantNode(
@@ -66,6 +75,11 @@ public final class VarbitConstantNode ex
             int bitLength,
             ContextManager cm) throws StandardException {
         super(hexValue, bitLength, cm);
-        setNodeType(C_NodeTypes.VARBIT_CONSTANT_NODE);
+        kind = K_VAR;
+    }
+
+    @Override
+    boolean isSameNodeKind(ValueNode o) {
+        return super.isSameNodeKind(o) && ((VarbitConstantNode)o).kind == kind;
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/VirtualColumnNode.java?rev=1506827&r1=1506826&r2=1506827&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 Thu Jul 25 07:12:46 2013
@@ -25,7 +25,6 @@ import org.apache.derby.iapi.error.Stand
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 
 /**
@@ -69,7 +68,6 @@ class VirtualColumnNode extends ValueNod
                       ContextManager cm) throws StandardException
 	{
         super(cm);
-        setNodeType(C_NodeTypes.VIRTUAL_COLUMN_NODE);
         this.sourceResultSet = sourceResultSet;
         this.sourceColumn = sourceColumn;
         this.columnId = columnId;
@@ -291,12 +289,13 @@ class VirtualColumnNode extends ValueNod
         sourceColumn.setType(dtd);
     }
     
-    protected boolean isEquivalent(ValueNode o) throws StandardException
+    boolean isEquivalent(ValueNode o) throws StandardException
     {
-    	if (isSameNodeType(o)) {
+        if (isSameNodeKind(o)) {
     		VirtualColumnNode other = (VirtualColumnNode)o;
     		return sourceColumn.isEquivalent(other.sourceColumn);
     	}
+
     	return false;
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowDefinitionNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowDefinitionNode.java?rev=1506827&r1=1506826&r2=1506827&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowDefinitionNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowDefinitionNode.java Thu Jul 25 07:12:46 2013
@@ -25,7 +25,6 @@ import org.apache.derby.iapi.error.Stand
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 
 /**
  * This class represents an OLAP window definition.
@@ -55,7 +54,6 @@ public final class WindowDefinitionNode 
                          OrderByList    orderByList,
                          ContextManager cm) throws StandardException {
         super(windowName != null ? windowName : "IN-LINE", cm);
-        setNodeType(C_NodeTypes.WINDOW_DEFINITION_NODE);
         this.orderByList = orderByList;
 
         if (windowName != null) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowReferenceNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowReferenceNode.java?rev=1506827&r1=1506826&r2=1506827&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowReferenceNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowReferenceNode.java Thu Jul 25 07:12:46 2013
@@ -23,7 +23,6 @@ package org.apache.derby.impl.sql.compil
 
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.context.ContextManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 
 /**
  * Represents a reference to an explicitly defined window
@@ -42,7 +41,6 @@ public final class WindowReferenceNode e
         throws StandardException
     {
         super(windowName, cm);
-        setNodeType(C_NodeTypes.WINDOW_REFERENCE_NODE);
     }
 
     @Override

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java?rev=1506827&r1=1506826&r2=1506827&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/WindowResultSetNode.java Thu Jul 25 07:12:46 2013
@@ -29,7 +29,6 @@ import org.apache.derby.iapi.services.co
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.io.FormatableBitSet;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 
 
 /**
@@ -66,7 +65,6 @@ class WindowResultSetNode extends Single
                         ContextManager           cm) throws StandardException
     {
         super(bottomPR, null, cm);
-        setNodeType(C_NodeTypes.WINDOW_RESULTSET_NODE);
         this.wdn = windowDef;
         this.windowFuncCalls = windowFuncCalls;
         setLevel(nestingLevel);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLConstantNode.java?rev=1506827&r1=1506826&r2=1506827&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/XMLConstantNode.java Thu Jul 25 07:12:46 2013
@@ -24,7 +24,6 @@ package    org.apache.derby.impl.sql.com
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
 import org.apache.derby.iapi.services.context.ContextManager;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.types.TypeId;
 
 public final class XMLConstantNode extends ConstantNode
@@ -32,7 +31,6 @@ public final class XMLConstantNode exten
     XMLConstantNode(TypeId t, ContextManager cm)
             throws StandardException {
         super(t, true, 0, cm);
-        setNodeType(C_NodeTypes.XML_CONSTANT_NODE);
     }
 
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=1506827&r1=1506826&r2=1506827&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 Thu Jul 25 07:12:46 2013
@@ -56,7 +56,6 @@ import org.apache.derby.iapi.services.co
 import org.apache.derby.iapi.services.io.FormatableProperties;
 import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.StatementType;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.CompilerContext;
 import org.apache.derby.iapi.sql.compile.JoinStrategy;
 import org.apache.derby.iapi.sql.compile.OptimizerFactory;
@@ -401,17 +400,17 @@ public class SQLParser
 		{
 		  case BinaryOperatorNode.TIMES:
             return new BinaryArithmeticOperatorNode(
-									C_NodeTypes.BINARY_TIMES_OPERATOR_NODE,
-									leftOperand,
-									rightOperand, 
-									getContextManager());
+                BinaryArithmeticOperatorNode.K_TIMES,
+                leftOperand,
+                rightOperand,
+                getContextManager());
 
 		  case BinaryOperatorNode.DIVIDE:
             return new BinaryArithmeticOperatorNode(
-									C_NodeTypes.BINARY_DIVIDE_OPERATOR_NODE,
-									leftOperand,
-									rightOperand,
-									getContextManager());
+                BinaryArithmeticOperatorNode.K_DIVIDE,
+                leftOperand,
+                rightOperand,
+                getContextManager());
 		  case BinaryOperatorNode.CONCATENATE:
               return new ConcatenationOperatorNode(
 									leftOperand,
@@ -780,11 +779,10 @@ public class SQLParser
            trimChar = new CharConstantNode(" ", getContextManager());
         }
         return new TernaryOperatorNode(
-							C_NodeTypes.TRIM_OPERATOR_NODE,
 							trimSource, // receiver
 							trimChar,   // leftOperand.
 							null,
-                            TernaryOperatorNode.TRIM,
+                            TernaryOperatorNode.K_TRIM,
                             trimSpec.intValue(),
 							cm == null ? getContextManager() : cm);
     }
@@ -1665,11 +1663,10 @@ public class SQLParser
                          ValueNode length) throws StandardException
     {
         return new TernaryOperatorNode(
-	    					C_NodeTypes.SUBSTRING_OPERATOR_NODE,
 		    				stringValue,
 			    			startPosition,
 				    		length,
-                            TernaryOperatorNode.SUBSTRING,
+                            TernaryOperatorNode.K_SUBSTRING,
                             -1,
 						    getContextManager());
     }
@@ -1747,13 +1744,13 @@ public class SQLParser
 			autoIncrementInfo = null;
 		}
 
-        return new ModifyColumnNode(
-			C_NodeTypes.MODIFY_COLUMN_DEFAULT_NODE,
-			columnName,
-			defaultNode,
-			null,
-			autoIncrementInfo,
-			getContextManager());
+        return
+            new ModifyColumnNode(ModifyColumnNode.K_MODIFY_COLUMN_DEFAULT,
+                                 columnName,
+                                 defaultNode,
+                                 null,
+                                 autoIncrementInfo,
+                                 getContextManager());
 	}
 
 	private boolean
@@ -5265,15 +5262,15 @@ isSearchCondition() throws StandardExcep
 		if ( isToken != null )
 		{
             result = new IsNullNode(booleanPrimary,
-                                    IsNullNode.Sign.IS_NULL,
+                                    false,
                                     getContextManager());
 		
-				/* Put the NOT on top of the tree */
+            /* Put the NOT on top of the tree */
 				if (notToken != null)
 				{
-                   result = new NotNode(result, getContextManager());
-				}
-		}
+                result = new NotNode(result, getContextManager());
+            }
+        }
 		else { result = booleanPrimary; }
 
 		return result;
@@ -5497,7 +5494,7 @@ additiveExpression(ValueNode farLeftOper
 {
 	ValueNode	leftOperand;
 	int			operator;
-	int			nodeType;
+    int         kind;
 }
 {
 	leftOperand = multiplicativeExpression(null, 0)  			
@@ -5510,38 +5507,38 @@ additiveExpression(ValueNode farLeftOper
 		switch (compOp)
 		{
 		  case BinaryOperatorNode.EQ:
-			nodeType = C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE;
+            kind = BinaryRelationalOperatorNode.K_EQUALS;
 			break;
 
 		  case BinaryOperatorNode.NE:
-			nodeType = C_NodeTypes.BINARY_NOT_EQUALS_OPERATOR_NODE;
+            kind = BinaryRelationalOperatorNode.K_NOT_EQUALS;
 			break;
 
 		  case BinaryOperatorNode.LT:
-		  	nodeType = C_NodeTypes.BINARY_LESS_THAN_OPERATOR_NODE;
+            kind = BinaryRelationalOperatorNode.K_LESS_THAN;
 			break;
 
 		  case BinaryOperatorNode.GT:
-			nodeType = C_NodeTypes.BINARY_GREATER_THAN_OPERATOR_NODE;
+            kind = BinaryRelationalOperatorNode.K_GREATER_THAN;
 			break;
 
 		  case BinaryOperatorNode.LE:
-			nodeType = C_NodeTypes.BINARY_LESS_EQUALS_OPERATOR_NODE;
+            kind = BinaryRelationalOperatorNode.K_LESS_EQUALS;
 			break;
 
 		  case BinaryOperatorNode.GE:
-			nodeType = C_NodeTypes.BINARY_GREATER_EQUALS_OPERATOR_NODE;
+            kind = BinaryRelationalOperatorNode.K_GREATER_EQUALS;
 			break;
 
 		  default:
 			if (SanityManager.DEBUG)
 			SanityManager.THROWASSERT("Unknown comparison operator " + compOp);
-			nodeType = 0;
+            kind = -1;
 			break;
 		}
 
         return new BinaryRelationalOperatorNode(
-							nodeType,
+                            kind,
 							farLeftOperand,
 							leftOperand,
                             false,
@@ -5589,19 +5586,17 @@ multiplicativeExpression(ValueNode farLe
 		{
 		  case BinaryOperatorNode.PLUS:
             return new BinaryArithmeticOperatorNode(
-									C_NodeTypes.BINARY_PLUS_OPERATOR_NODE,
-									farLeftOperand,
-									leftOperand,
-									getContextManager()
-									);
+                BinaryArithmeticOperatorNode.K_PLUS,
+                farLeftOperand,
+                leftOperand,
+                getContextManager());
 
 		  case BinaryOperatorNode.MINUS:
               return new BinaryArithmeticOperatorNode(
-									C_NodeTypes.BINARY_MINUS_OPERATOR_NODE,
-									farLeftOperand,
-									leftOperand,
-									getContextManager()
-									);
+                  BinaryArithmeticOperatorNode.K_MINUS,
+                  farLeftOperand,
+                  leftOperand,
+                  getContextManager());
 
 		  default:
 			if (SanityManager.DEBUG)
@@ -5667,14 +5662,14 @@ unaryExpression(ValueNode farLeftOperand
 		{
            value = new UnaryArithmeticOperatorNode(
                value,
-               UnaryArithmeticOperatorNode.OperatorType.MINUS,
+               UnaryArithmeticOperatorNode.K_MINUS,
                getContextManager());
 		}
 		else if ("+".equals(sign))
 		{
            value = new UnaryArithmeticOperatorNode(
                value,
-               UnaryArithmeticOperatorNode.OperatorType.PLUS,
+               UnaryArithmeticOperatorNode.K_PLUS,
                getContextManager());
 		}
 		else if (SanityManager.DEBUG)
@@ -6115,11 +6110,10 @@ timestampArithmeticFuncion() throws Stan
        count = additiveExpression(null,0) <COMMA>
        tstamp1 = additiveExpression(null,0) <RIGHT_PAREN>
     {
-        return new TernaryOperatorNode(C_NodeTypes.TIMESTAMP_ADD_FN_NODE,
-                                       tstamp1,
+        return new TernaryOperatorNode(tstamp1,
                                        intervalType,
                                        count,
-                                       TernaryOperatorNode.TIMESTAMPADD,
+                                       TernaryOperatorNode.K_TIMESTAMPADD,
                                        -1,
                                        getContextManager());
     }
@@ -6128,11 +6122,10 @@ timestampArithmeticFuncion() throws Stan
        tstamp1 = additiveExpression(null,0) <COMMA>
        tstamp2 = additiveExpression(null,0) <RIGHT_PAREN>
     {
-        return new TernaryOperatorNode(C_NodeTypes.TIMESTAMP_DIFF_FN_NODE,
-                                       tstamp2,
+        return new TernaryOperatorNode(tstamp2,
                                        intervalType,
                                        tstamp1,
-                                       TernaryOperatorNode.TIMESTAMPDIFF,
+                                       TernaryOperatorNode.K_TIMESTAMPDIFF,
                                        -1,
                                        getContextManager());
     }
@@ -6220,7 +6213,7 @@ numericValueFunction() throws StandardEx
     {
         return new UnaryArithmeticOperatorNode(
                 value,
-                UnaryArithmeticOperatorNode.OperatorType.SQRT,
+                UnaryArithmeticOperatorNode.K_SQRT,
                 getContextManager());
     }
 |
@@ -6234,7 +6227,8 @@ numericValueFunction() throws StandardEx
 	<IDENTITY_VAL_LOCAL> <LEFT_PAREN> <RIGHT_PAREN>
 	{
         return new SpecialFunctionNode(
-            C_NodeTypes.IDENTITY_VAL_NODE, getContextManager());
+            SpecialFunctionNode.K_IDENTITY_VAL,
+            getContextManager());
 	}
 }
 
@@ -6287,7 +6281,7 @@ absFunction() throws StandardException :
     {
         return new UnaryArithmeticOperatorNode(
                 value,
-                UnaryArithmeticOperatorNode.OperatorType.ABS,
+                UnaryArithmeticOperatorNode.K_ABS,
                 getContextManager());
     }
 }
@@ -6305,8 +6299,9 @@ modFunction() throws StandardException :
             int2 = additiveExpression(null,0) <RIGHT_PAREN>
     {
         return new BinaryArithmeticOperatorNode(
-                C_NodeTypes.MOD_OPERATOR_NODE,
-                int1, int2,
+                BinaryArithmeticOperatorNode.K_MOD,
+                int1,
+                int2,
                 getContextManager());
     }
 }
@@ -6380,7 +6375,6 @@ characterValueFunction() throws Standard
     {
 		// if start is missing, start is equal to 1
         return new TernaryOperatorNode(
-                            C_NodeTypes.LOCATE_FUNCTION_NODE,
                             str1,
                             str2,
                             (value == null) ?
@@ -6389,7 +6383,7 @@ characterValueFunction() throws Standard
                                     ReuseFactory.getInteger(1),
                                     getContextManager() ) :
                                 value,
-                            TernaryOperatorNode.LOCATE,
+                            TernaryOperatorNode.K_LOCATE,
                             -1,
                             getContextManager());
     }
@@ -6521,14 +6515,14 @@ valueExpressionPrimary() throws Standard
 	<CURRENT> (<SCHEMA> | <SQLID>)
 	{
         return new SpecialFunctionNode(
-            C_NodeTypes.CURRENT_SCHEMA_NODE, getContextManager());
+            SpecialFunctionNode.K_CURRENT_SCHEMA, getContextManager());
 	}
 |
 	LOOKAHEAD({getToken(2).kind == ISOLATION}) 
 	<CURRENT> <ISOLATION>
 	{
         return new SpecialFunctionNode(
-            C_NodeTypes.CURRENT_ISOLATION_NODE, getContextManager());
+            SpecialFunctionNode.K_CURRENT_ISOLATION, getContextManager());
 	}
 |
 	/* Omitted "case_expression" */
@@ -6871,9 +6865,8 @@ ValueNode
 {
 	value = additiveExpression(null,0) wsOption = xmlPreserveWhitespace() {
         return new UnaryOperatorNode(
-					C_NodeTypes.XML_PARSE_OPERATOR_NODE,
 					value,
-                    UnaryOperatorNode.XMLPARSE_OP,
+                    UnaryOperatorNode.K_XMLPARSE,
                     null, /* N/A for PARSE */
                     wsOption,
 					getContextManager());
@@ -6939,9 +6932,8 @@ ValueNode
 		targetType = xmlSerializeTargetType()
 	{
         return new UnaryOperatorNode(
-					C_NodeTypes.XML_SERIALIZE_OPERATOR_NODE,
 					value,
-                    UnaryOperatorNode.XMLSERIALIZE_OP,
+                    UnaryOperatorNode.K_XMLSERIALIZE,
 					targetType,
                     false, /* N/A for SERIALIZE */
 					getContextManager());
@@ -7064,14 +7056,11 @@ ValueNode
 	)
 	{
         ValueNode vNode = new BinaryOperatorNode(
-			(existsOnly
-				? C_NodeTypes.XML_EXISTS_OPERATOR_NODE
-				: C_NodeTypes.XML_QUERY_OPERATOR_NODE),
 			xqueryExpr,
 			xmlValue,
 			(existsOnly
-                ? BinaryOperatorNode.XMLEXISTS_OP
-                : BinaryOperatorNode.XMLQUERY_OP),
+                ? BinaryOperatorNode.K_XMLEXISTS
+                : BinaryOperatorNode.K_XMLQUERY),
 			getContextManager());
 
 		return vNode;
@@ -7353,7 +7342,7 @@ dateTimeScalarFunction() throws Standard
 	{
        return new UnaryDateTimestampOperatorNode(
             value,
-            UnaryDateTimestampOperatorNode.OperatorType.DATE,
+            UnaryDateTimestampOperatorNode.K_DATE,
             getContextManager());
         }
 |
@@ -7385,7 +7374,7 @@ timestampFunctionCompletion( ValueNode f
 	{
        return new UnaryDateTimestampOperatorNode(
             firstArg,
-            UnaryDateTimestampOperatorNode.OperatorType.TIMESTAMP,
+            UnaryDateTimestampOperatorNode.K_TIMESTAMP,
             getContextManager());
         }
 |
@@ -7449,19 +7438,19 @@ userNode() throws StandardException :
 	<USER>
 	{
         return new SpecialFunctionNode(
-            C_NodeTypes.USER_NODE, getContextManager());
+            SpecialFunctionNode.K_USER, getContextManager());
 	}
 |
 	<CURRENT_USER>
 	{
         return new SpecialFunctionNode(
-            C_NodeTypes.CURRENT_USER_NODE, getContextManager());
+            SpecialFunctionNode.K_CURRENT_USER, getContextManager());
 	}
 |
 	<SESSION_USER>
 	{
         return new SpecialFunctionNode(
-            C_NodeTypes.SESSION_USER_NODE, getContextManager());
+            SpecialFunctionNode.K_SESSION_USER, getContextManager());
 	}
 }
 
@@ -7479,7 +7468,7 @@ currentRoleNode() throws StandardExcepti
 		checkVersion( DataDictionary.DD_VERSION_DERBY_10_5, "ROLES");
 		checkSqlStandardAccess("CURRENT_ROLE");
         return new SpecialFunctionNode(
-            C_NodeTypes.CURRENT_ROLE_NODE, getContextManager());
+            SpecialFunctionNode.K_CURRENT_ROLE, getContextManager());
 	}
 }
 
@@ -11375,7 +11364,7 @@ DB2DefaultOption(String columnName) thro
 	<CURRENT> (<SCHEMA> | <SQLID>)
 	{
         return new SpecialFunctionNode(
-            C_NodeTypes.CURRENT_SCHEMA_NODE, getContextManager());
+            SpecialFunctionNode.K_CURRENT_SCHEMA, getContextManager());
 	}
 |
 	/* Revert DB2 restriction: DERBY-3013. Accept standard SQL CURRENT_USER,
@@ -12318,15 +12307,16 @@ valueSpecification() throws StandardExce
        thenElseList.addElement(new UntypedNullConstantNode(cm));
 		thenElseList.addElement(leftExpression);
 
-        return new ConditionalNode(new BinaryRelationalOperatorNode(
-                                       C_NodeTypes.BINARY_EQUALS_OPERATOR_NODE,
-                                       leftExpression,
-                                       rightExpression,
-                                       false,
-                                       cm),
-                                   thenElseList,
-                                   true, // this node is for nullif
-                                   cm);
+        return new ConditionalNode(
+                   new BinaryRelationalOperatorNode(
+                       BinaryRelationalOperatorNode.K_EQUALS,
+                       leftExpression,
+                       rightExpression,
+                       false,
+                       cm),
+                   thenElseList,
+                   true, // this node is for nullif
+                   cm);
 	}
 |
 	// CASE WHEN P1 THEN [T1 | NULL] (WHEN Pi THEN [Ti | NULL])* [ELSE E | NULL] END
@@ -13085,11 +13075,13 @@ dropColumnDefinition(TableName tableName
 	[ <COLUMN> ] columnName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true)
 				 dropColumnReferentialAction(behavior)
 	{
-        tableElement = new ModifyColumnNode(
-						C_NodeTypes.DROP_COLUMN_NODE,
-						columnName, null,
-						null, null,
-						getContextManager());
+        tableElement =
+            new ModifyColumnNode(ModifyColumnNode.K_DROP_COLUMN,
+                                 columnName,
+                                 null,
+                                 null,
+                                 null,
+                                 getContextManager());
 		tableElementList.addTableElement(tableElement);
         return new AlterTableNode(
 							tableName,
@@ -13153,11 +13145,13 @@ columnAlterClause(String columnName) thr
 	LOOKAHEAD( {getToken(2).kind == DATA} )
 	<SET> <DATA> <TYPE> typeDescriptor = dataTypeDDL()
 	{
-        return new ModifyColumnNode(
-						C_NodeTypes.MODIFY_COLUMN_TYPE_NODE,
-						columnName, null,
-						typeDescriptor, null,
-						getContextManager());
+        return
+            new ModifyColumnNode(ModifyColumnNode.K_MODIFY_COLUMN_TYPE,
+                                 columnName,
+                                 null,
+                                 typeDescriptor,
+                                 null,
+                                 getContextManager());
 	}
 |
 	LOOKAHEAD( {getToken(2).kind == INCREMENT} )
@@ -13165,22 +13159,26 @@ columnAlterClause(String columnName) thr
 	{
 		autoIncrementInfo[QueryTreeNode.AUTOINCREMENT_INC_INDEX] = autoIncrementIncrement;
 		autoIncrementInfo[QueryTreeNode.AUTOINCREMENT_CREATE_MODIFY] = ColumnDefinitionNode.MODIFY_AUTOINCREMENT_INC_VALUE;
-        return new ModifyColumnNode(
-						C_NodeTypes.MODIFY_COLUMN_DEFAULT_NODE,
-						columnName,
-						null, null, autoIncrementInfo,
-						getContextManager());
+        return
+            new ModifyColumnNode(ModifyColumnNode.K_MODIFY_COLUMN_DEFAULT,
+                                 columnName,
+                                 null,
+                                 null,
+                                 autoIncrementInfo,
+                                 getContextManager());
 	}
 |
 	<RESTART> <WITH> autoIncrementRestartWith = exactNumber()
 	{
 		autoIncrementInfo[QueryTreeNode.AUTOINCREMENT_START_INDEX] = autoIncrementRestartWith;
 		autoIncrementInfo[QueryTreeNode.AUTOINCREMENT_CREATE_MODIFY] = ColumnDefinitionNode.MODIFY_AUTOINCREMENT_RESTART_VALUE;
-        return new ModifyColumnNode(
-						C_NodeTypes.MODIFY_COLUMN_DEFAULT_NODE,
-						columnName,
-						null, null, autoIncrementInfo,
-						getContextManager());
+        return
+            new ModifyColumnNode(ModifyColumnNode.K_MODIFY_COLUMN_DEFAULT,
+                                 columnName,
+                                 null,
+                                 null,
+                                 autoIncrementInfo,
+                                 getContextManager());
 	}
 |
 	LOOKAHEAD( {getToken(1).kind == WITH || getToken(1).kind == _DEFAULT ||
@@ -13210,10 +13208,13 @@ columnAlterClause(String columnName) thr
 		// column constraint is specified by setting the right value
 		// in the nullability field of the data type but we don't have
 		// a datatype here.
-        return new ModifyColumnNode(
-								C_NodeTypes.MODIFY_COLUMN_CONSTRAINT_NODE,
-								columnName, null, null, null,
-								getContextManager());
+        return
+            new ModifyColumnNode(ModifyColumnNode.K_MODIFY_COLUMN_CONSTRAINT,
+                                 columnName,
+                                 null,
+                                 null,
+                                 null,
+                                 getContextManager());
 	}
 |
 	LOOKAHEAD({getToken(1).kind == NOT})
@@ -13225,9 +13226,12 @@ columnAlterClause(String columnName) thr
 		// in the nullability field of the data type but we don't have
 		// a datatype here.
         return new ModifyColumnNode(
-								C_NodeTypes.MODIFY_COLUMN_CONSTRAINT_NOT_NULL_NODE,
-								columnName, null, null, null,
-								getContextManager());
+            ModifyColumnNode.K_MODIFY_COLUMN_CONSTRAINT_NOT_NULL,
+            columnName,
+            null,
+            null,
+            null,
+            getContextManager());
 	}
 }
 



Mime
View raw message