db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1495305 [11/21] - in /db/derby/code/trunk: java/engine/org/apache/derby/ java/engine/org/apache/derby/catalog/types/ java/engine/org/apache/derby/iapi/services/io/ java/engine/org/apache/derby/iapi/sql/ java/engine/org/apache/derby/iapi/sq...
Date Fri, 21 Jun 2013 07:47:52 GMT
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NOPStatementNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NOPStatementNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NOPStatementNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NOPStatementNode.java Fri Jun 21 07:47:47 2013
@@ -21,10 +21,10 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.services.context.ContextManager;
-
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.context.ContextManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 
 /**
  * A NOPStatement node is for statements that don't do anything.  At the
@@ -33,9 +33,15 @@ import org.apache.derby.iapi.reference.S
  * executed in the parser, so the statements don't do anything at execution
  */
 
-public class NOPStatementNode extends StatementNode
+class NOPStatementNode extends StatementNode
 {
-	public String statementToString()
+
+    NOPStatementNode(ContextManager cm) {
+        super(cm);
+        setNodeType(C_NodeTypes.NOP_STATEMENT_NODE);
+    }
+
+    String statementToString()
 	{
 		return "NO-OP";
 	}
@@ -47,6 +53,7 @@ public class NOPStatementNode extends St
 	 *
 	 * @exception StandardException		Always thrown to stop after parsing
 	 */
+    @Override
 	public void bindStatement() throws StandardException
 	{
 		/*

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NestedLoopJoinStrategy.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NestedLoopJoinStrategy.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NestedLoopJoinStrategy.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NestedLoopJoinStrategy.java Fri Jun 21 07:47:47 2013
@@ -21,28 +21,23 @@
 
 package org.apache.derby.impl.sql.compile;
 
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.compile.CostEstimate;
 import org.apache.derby.iapi.sql.compile.ExpressionClassBuilderInterface;
 import org.apache.derby.iapi.sql.compile.JoinStrategy;
 import org.apache.derby.iapi.sql.compile.Optimizable;
-import org.apache.derby.iapi.sql.compile.Optimizer;
-import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
 import org.apache.derby.iapi.sql.compile.OptimizablePredicate;
-
-import org.apache.derby.iapi.sql.dictionary.DataDictionary;
+import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
+import org.apache.derby.iapi.sql.compile.Optimizer;
 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
-
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
 import org.apache.derby.iapi.store.access.StoreCostController;
 import org.apache.derby.iapi.store.access.TransactionController;
 
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-public class NestedLoopJoinStrategy extends BaseJoinStrategy {
-	public NestedLoopJoinStrategy() {
+class NestedLoopJoinStrategy extends BaseJoinStrategy {
+    NestedLoopJoinStrategy() {
 	}
 
 
@@ -267,10 +262,10 @@ public class NestedLoopJoinStrategy exte
 			 */
 			if (!genInListVals)
 			{
-				Predicate pred = null;
 				for (int i = storeRestrictionList.size() - 1; i >= 0; i--)
 				{
-					pred = (Predicate)storeRestrictionList.getOptPredicate(i);
+                    Predicate pred =
+                            (Predicate)storeRestrictionList.getOptPredicate(i);
 					if (pred.isInListProbePredicate())
 					{
 						SanityManager.THROWASSERT("Found IN-list probing " +
@@ -322,6 +317,7 @@ public class NestedLoopJoinStrategy exte
 		return false;
 	}
 
+    @Override
 	public String toString() {
 		return getName();
 	}
@@ -331,8 +327,9 @@ public class NestedLoopJoinStrategy exte
 	 * outermost table of a join.
 	 *
 	 * @return Whether or not this join strategy
-	 * can be used on the outermose table of a join.
+     * can be used on the outermost table of a join.
 	 */
+    @Override
 	protected boolean validForOutermostTable()
 	{
 		return true;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NewInvocationNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NewInvocationNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NewInvocationNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NewInvocationNode.java Fri Jun 21 07:47:47 2013
@@ -21,38 +21,27 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.services.loader.ClassInspector;
-
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.compiler.LocalField;
-
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
+import java.lang.reflect.Member;
+import java.lang.reflect.Modifier;
+import java.util.List;
+import org.apache.derby.catalog.TypeDescriptor;
 import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.compiler.LocalField;
+import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.i18n.MessageService;
-
-
+import org.apache.derby.iapi.services.loader.ClassInspector;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-
-import org.apache.derby.iapi.reference.SQLState;
-
-
 import org.apache.derby.iapi.util.JBitSet;
 
-import org.apache.derby.catalog.TypeDescriptor;
-
-import java.lang.reflect.Member;
-import java.lang.reflect.Modifier;
-
-import java.util.List;
-
 /**
  * A NewInvocationNode represents a new object() invocation.
  *
  */
-public class NewInvocationNode extends MethodCallNode
+class NewInvocationNode extends MethodCallNode
 {
 	// Whether or not to do a single instantiation
 	private boolean singleInstantiation = false;
@@ -62,30 +51,32 @@ public class NewInvocationNode extends M
 	private boolean isBuiltinVTI = false;
 
 	/**
-	 * Initializer for a NewInvocationNode. Parameters are:
+     * Constructor for a NewInvocationNode. Parameters are:
 	 *
-	 * <ul>
-	 * <li>javaClassName		The full package.class name of the class</li>
-	 * <li>parameterList		The parameter list for the constructor</li>
-	 * </ul>
+     *
+     * @param javaClassName     The full package.class name of the class
+     * @param params            The parameter list for the constructor
+     * @param delimitedIdentifier
+     * @param cm                The context manager
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public void init(
-					Object javaClassName,
-					Object params,
-					Object delimitedIdentifier)
+    NewInvocationNode(
+            String javaClassName,
+            List<ValueNode> params,
+            boolean delimitedIdentifier,
+            ContextManager cm)
 		throws StandardException
 	{
-		super.init("<init>");
-		addParms((List) params);
+        super("<init>", cm);
+        setNodeType(C_NodeTypes.NEW_INVOCATION_NODE);
+        addParms(params);
 
-		this.javaClassName = (String) javaClassName;
-		this.delimitedIdentifier =
-				 ((Boolean) delimitedIdentifier).booleanValue();
+        this.javaClassName = javaClassName;
+        this.delimitedIdentifier = delimitedIdentifier;
 	}
 
-	/* This version of the "init" method is used for mapping a table name
+    /* This constructor is used for mapping a table name
 	 * or table function name to a corresponding VTI class name.  The VTI
 	 * is then invoked as a regular NEW invocation node.
 	 *
@@ -116,16 +107,19 @@ public class NewInvocationNode extends M
 	 * @param params Parameter list for the VTI constructor.
 	 * @param delimitedIdentifier Whether or not the target class name
 	 *  is a delimited identifier.
+     * @param cm context manager
 	 */
-	public void init(
-					Object vtiTableFuncName,
-					Object tableDescriptor,
-					Object params,
-					Object delimitedIdentifier)
+    NewInvocationNode(
+                    TableName vtiTableFuncName,
+                    TableDescriptor tableDescriptor,
+                    List<ValueNode> params,
+                    boolean delimitedIdentifier,
+                    ContextManager cm)
 		throws StandardException
 	{
-		super.init("<init>");
-		addParms((List) params);
+        super("<init>", cm);
+        setNodeType(C_NodeTypes.NEW_INVOCATION_NODE);
+        addParms(params);
 
 		if (SanityManager.DEBUG)
 		{
@@ -138,8 +132,8 @@ public class NewInvocationNode extends M
 				"be null, but neither or both of them were null.");
 		}
 
-		TableName vtiName = (TableName)vtiTableFuncName;
-		TableDescriptor td = (TableDescriptor)tableDescriptor;
+        TableName vtiName = vtiTableFuncName;
+        TableDescriptor td = tableDescriptor;
 		boolean isTableFunctionVTI = (vtiTableFuncName != null);
 		if (isTableFunctionVTI)
 		{
@@ -193,7 +187,7 @@ public class NewInvocationNode extends M
 	/**
 	 * Report whether this node represents a builtin VTI.
 	 */
-	public  boolean isBuiltinVTI()  { return isBuiltinVTI; }
+     boolean isBuiltinVTI()  { return isBuiltinVTI; }
 
 	/**
 	 * Mark this node as only needing to
@@ -339,6 +333,7 @@ public class NewInvocationNode extends M
 	 *						or a VirtualColumnNode.
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
     boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
 		throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NextSequenceNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NextSequenceNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NextSequenceNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NextSequenceNode.java Fri Jun 21 07:47:47 2013
@@ -20,36 +20,39 @@
  */
 package org.apache.derby.impl.sql.compile;
 
+import java.sql.Types;
+import java.util.List;
 import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.reference.ClassName;
-import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.reference.SQLState;
+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.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.CompilerContext;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-import org.apache.derby.iapi.sql.dictionary.SequenceDescriptor;
 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
-
-import java.sql.Types;
-import java.util.List;
+import org.apache.derby.iapi.sql.dictionary.SequenceDescriptor;
 
 /**
  * A class that represents a value obtained from a Sequence using 'NEXT VALUE'
  */
-public class NextSequenceNode extends ValueNode {
+class NextSequenceNode extends ValueNode {
 
     private TableName sequenceName;
     private SequenceDescriptor sequenceDescriptor;
 
     /**
-     * Initializer for a NextSequenceNode
+     * Constructor for a NextSequenceNode
      *
      * @param sequenceName The name of the sequence being called
-     * @throws org.apache.derby.iapi.error.StandardException
-     *          Thrown on error
+     * @param cm           The context manager
      */
-    public void init(Object sequenceName) throws StandardException {
-        this.sequenceName = (TableName) sequenceName;
+    NextSequenceNode(TableName sequenceName,
+                     ContextManager cm) {
+        super(cm);
+        setNodeType(C_NodeTypes.NEXT_SEQUENCE_NODE);
+        this.sequenceName = sequenceName;
     }
 
     /**
@@ -63,9 +66,11 @@ public class NextSequenceNode extends Va
      * @return The new top of the expression tree.
      * @throws StandardException Thrown on error
      */
-    ValueNode bindExpression(
-            FromList fromList, SubqueryList subqueryList, List aggregates, boolean forQueryRewrite)
-            throws StandardException
+    @Override
+    ValueNode bindExpression(FromList fromList,
+                             SubqueryList subqueryList,
+                             List<AggregateNode> aggregates,
+                             boolean forQueryRewrite) throws StandardException
     {
         //
         // Higher level bind() logic may try to redundantly re-bind this node. Unfortunately,
@@ -120,6 +125,7 @@ public class NextSequenceNode extends Va
     }
 
 
+    @Override
     void generateExpression
         (
          ExpressionClassBuilder acb, MethodBuilder mb)
@@ -172,7 +178,7 @@ public class NextSequenceNode extends Va
      *
      * @return This object as a String
      */
-
+    @Override
     public String toString() {
         if (SanityManager.DEBUG) {
             return super.toString();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NonStaticMethodCallNode.java?rev=1495305&r1=1495304&r2=1495305&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 Jun 21 07:47:47 2013
@@ -21,32 +21,25 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.reference.SQLState;
+import java.lang.reflect.Modifier;
+import java.util.List;
 import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.store.access.Qualifier;
-
-
-import org.apache.derby.iapi.sql.compile.Visitor;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
-import org.apache.derby.iapi.services.loader.ClassInspector;
-
+import org.apache.derby.iapi.reference.SQLState;
+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.services.loader.ClassInspector;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.sql.compile.Visitor;
+import org.apache.derby.iapi.store.access.Qualifier;
 import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
-
-
-import java.lang.reflect.Modifier;
-
-import java.util.List;
 
 /**
  * A NonStaticMethodCallNode is really a node to represent a (static or non-static)
  * method call from an object (as opposed to a static method call from a class.
  */
-public class NonStaticMethodCallNode extends MethodCallNode
+class NonStaticMethodCallNode extends MethodCallNode
 {
 	/*
 	** The receiver for a non-static method call is an object, represented
@@ -58,19 +51,20 @@ public class NonStaticMethodCallNode ext
 	private boolean isStatic;
 
 	/**
-	 * Initializer for a NonStaticMethodCallNode
+     * Constructor for a NonStaticMethodCallNode
 	 *
 	 * @param methodName	The name of the method to call
 	 * @param receiver		A JavaValueNode representing the receiving object
+     * @param cm            The context manager
 	 * @exception StandardException		Thrown on error
 	 */
-	public void init(
-							Object methodName,
-							Object receiver)
+    NonStaticMethodCallNode(String methodName,
+                            ValueNode receiver,
+                            ContextManager cm)
 			throws StandardException
 	{
-		super.init(methodName);
-
+        super(methodName, cm);
+        setNodeType(C_NodeTypes.NON_STATIC_METHOD_CALL_NODE);
 		/*
 		** If the receiver is a Java value that has been converted to a
 		** SQL value, get rid of the conversion and just use the Java value
@@ -84,11 +78,8 @@ public class NonStaticMethodCallNode ext
 		}
 		else
 		{
-			this.receiver = (JavaValueNode) getNodeFactory().
-								getNode(
-									C_NodeTypes.SQL_TO_JAVA_VALUE_NODE,
-									receiver,
-									getContextManager());
+            this.receiver =
+                new SQLToJavaValueNode(receiver, getContextManager());
 //            System.out.println("NonStaticMethodCallNode.init() receiver = "+receiver);
 // get nulpointer because not .bind?
 //            System.out.println("\ttypecompiler = "+((ValueNode)receiver).getTypeCompiler());
@@ -197,6 +188,7 @@ public class NonStaticMethodCallNode ext
 	 *						or a VirtualColumnNode.
 	 * @exception StandardException			Thrown on error
 	 */
+    @Override
     boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
 		throws StandardException
 	{
@@ -233,6 +225,7 @@ public class NonStaticMethodCallNode ext
 	 *
 	 * @return	The variant type for the underlying expression.
 	 */
+    @Override
     int getOrderableVariantType() throws StandardException
 	{
 		int receiverVariant = receiver.getOrderableVariantType();
@@ -261,6 +254,7 @@ public class NonStaticMethodCallNode ext
 	 *
 	 * @exception StandardException			Thrown on error
 	 */
+    @Override
     JavaValueNode remapColumnReferencesToExpressions()
 		throws StandardException
 	{
@@ -278,8 +272,8 @@ public class NonStaticMethodCallNode ext
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
-	public void printSubNodes(int depth)
+    @Override
+    void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
 		{
@@ -307,6 +301,7 @@ public class NonStaticMethodCallNode ext
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
     void preprocess(int numTables,
 							FromList outerFromList,
 							SubqueryList outerSubqueryList,
@@ -428,6 +423,7 @@ public class NonStaticMethodCallNode ext
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
     boolean generateReceiver(ExpressionClassBuilder acb,
 											MethodBuilder mb)
 									throws StandardException
@@ -451,6 +447,7 @@ public class NonStaticMethodCallNode ext
 	 *
 	 * @exception StandardException on error
 	 */
+    @Override
 	void acceptChildren(Visitor v)
 		throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NormalizeResultSetNode.java Fri Jun 21 07:47:47 2013
@@ -21,16 +21,15 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.reference.ClassName;
-
+import java.util.Properties;
 import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.reference.ClassName;
+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.services.sanity.SanityManager;
-
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
 
 /**
  *
@@ -521,7 +520,7 @@ import org.apache.derby.iapi.services.cl
  *
  */
 
-public class NormalizeResultSetNode extends SingleChildResultSetNode
+class NormalizeResultSetNode extends SingleChildResultSetNode
 {
 	/**
 	 * this indicates if the normalize is being performed for an Update
@@ -532,8 +531,8 @@ public class NormalizeResultSetNode exte
 	private boolean forUpdate;
 
 	/**
-	 * Initializer for a NormalizeResultSetNode.
-	 ** ColumnReferences must continue to point to the same ResultColumn, so
+     * Constructor  for a NormalizeResultSetNode.
+     * ColumnReferences must continue to point to the same ResultColumn, so
 	 * that ResultColumn must percolate up to the new PRN.  However,
 	 * that ResultColumn will point to a new expression, a VirtualColumnNode, 
 	 * which points to the FromTable and the ResultColumn that is the source for
@@ -549,28 +548,29 @@ public class NormalizeResultSetNode exte
 	 * sort has to agree with what the sort expects.
 	 * (insert into t1 (smallintcol) values 1 union all values 2;
 	 *
-	 * @param childResult	The child ResultSetNode
+     * @param chldRes   The child ResultSetNode
      * @param targetResultColumnList The target resultColumnList from 
      *                          the InsertNode or UpdateNode. These will
      *                          be the types used for the NormalizeResultSetNode.
 	 * @param tableProperties	Properties list associated with the table
 	 * @param forUpdate 	tells us if the normalize operation is being
 	 * performed on behalf of an update statement. 
+     * @param cm                The context manager
 	 * @throws StandardException 
 	 */
 
-	public void init(
-							Object childResult,
-                            Object targetResultColumnList,
-							Object tableProperties,
-							Object forUpdate) throws StandardException
+    NormalizeResultSetNode(ResultSetNode chldRes,
+                           ResultColumnList targetResultColumnList,
+                           Properties tableProperties,
+                           boolean forUpdate,
+                           ContextManager cm) throws StandardException
 	{
-		super.init(childResult, tableProperties);
-		this.forUpdate = ((Boolean)forUpdate).booleanValue();
+        super(chldRes, tableProperties, cm);
+        setNodeType(C_NodeTypes.NORMALIZE_RESULT_SET_NODE);
+        this.forUpdate = forUpdate;
 
-		ResultSetNode rsn  = (ResultSetNode) childResult;
-		ResultColumnList rcl = rsn.getResultColumns();
-		ResultColumnList targetRCL = (ResultColumnList) targetResultColumnList;
+        ResultColumnList rcl = chldRes.getResultColumns();
+        ResultColumnList targetRCL = targetResultColumnList;
         
 		/* We get a shallow copy of the ResultColumnList and its 
 		 * ResultColumns.  (Copy maintains ResultColumn.expression for now.)
@@ -582,7 +582,7 @@ public class NormalizeResultSetNode exte
 		 * detailed explanation of how this works.
 		 */
 		ResultColumnList prRCList = rcl;
-		rsn.setResultColumns(rcl.copyListAndObjects());
+        chldRes.setResultColumns(rcl.copyListAndObjects());
 		// Remove any columns that were generated.
 		prRCList.removeGeneratedGroupingColumns();
         // And also columns that were added for ORDER BY (DERBY-6006).
@@ -592,11 +592,11 @@ public class NormalizeResultSetNode exte
 		 * in the NormalizeResultSetNode's ResultColumnList.  (VirtualColumnNodes include
 		 * pointers to source ResultSetNode, rsn, and source ResultColumn.)
 		 */
-		prRCList.genVirtualColumnNodes(rsn, rsn.getResultColumns());
+        prRCList.genVirtualColumnNodes(chldRes, chldRes.getResultColumns());
         
 		this.resultColumns = prRCList;
 		// Propagate the referenced table map if it's already been created
-		if (rsn.getReferencedTableMap() != null)
+        if (chldRes.getReferencedTableMap() != null)
 		    {
 			setReferencedTableMap((JBitSet) getReferencedTableMap().clone());
 		    }
@@ -618,6 +618,7 @@ public class NormalizeResultSetNode exte
 	 *
 	 * @exception StandardException		Thrown on error
      */
+    @Override
     void generate(ActivationClassBuilder acb, MethodBuilder mb)
 							throws StandardException
 	{
@@ -656,6 +657,7 @@ public class NormalizeResultSetNode exte
 	 * set the Information gathered from the parent table that is 
      * required to perform a referential action on dependent table.
 	 */
+    @Override
     void setRefActionInfo(long fkIndexConglomId,
 								 int[]fkColArray, 
 								 String parentResultSetId,
@@ -674,6 +676,7 @@ public class NormalizeResultSetNode exte
 	 *
 	 * @param orderByList	The order by list
 	 */
+    @Override
 	void pushOrderByList(OrderByList orderByList)
 	{
 		childResult.pushOrderByList(orderByList);
@@ -687,6 +690,7 @@ public class NormalizeResultSetNode exte
      * @param fetchFirst the OFFSET FIRST, if any
      * @param hasJDBClimitClause true if the clauses were added by (and have the semantics of) a JDBC limit clause
      */
+    @Override
     void pushOffsetFetchFirst( ValueNode offset, ValueNode fetchFirst, boolean hasJDBClimitClause )
     {
         childResult.pushOffsetFetchFirst( offset, fetchFirst, hasJDBClimitClause );

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NotNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NotNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NotNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NotNode.java Fri Jun 21 07:47:47 2013
@@ -21,26 +21,14 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-import org.apache.derby.iapi.services.compiler.LocalField;
-import org.apache.derby.iapi.reference.ClassName;
-
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
+import java.lang.reflect.Modifier;
 import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.types.DataValueDescriptor;
-import org.apache.derby.iapi.types.BooleanDataValue;
-import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-
-import org.apache.derby.impl.sql.compile.ExpressionClassBuilder;
+import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
-
-import java.lang.reflect.Modifier;
+import org.apache.derby.iapi.services.compiler.LocalField;
+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;
 
 /**
  * A NotNode represents a NOT operator. Preprocessing will eliminate the 
@@ -51,18 +39,18 @@ import java.lang.reflect.Modifier;
 
 public final class NotNode extends UnaryLogicalOperatorNode
 {
-	/**
-	 * Initializer for a NotNode
-	 *
-	 * @param operand	The operand of the NOT
-	 */
+    /**
+     * @param operand The operand of the NOT
+     * @param cm context manager
+     * @throws StandardException
+     */
+    NotNode(ValueNode operand, ContextManager cm)
+            throws StandardException {
+        super(operand, "not", cm);
+        setNodeType(C_NodeTypes.NOT_NODE);
+    }
 
-	public void init(Object operand)
-	{
-		super.init(operand, "not");
-	}
-
-	/**
+    /**
 	 * Eliminate NotNodes in the current query block.  We traverse the tree, 
 	 * inverting ANDs and ORs and eliminating NOTs as we go.  We stop at 
 	 * ComparisonOperators and boolean expressions.  We invert 
@@ -76,6 +64,7 @@ public final class NotNode extends Unary
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	ValueNode eliminateNots(boolean underNotNode) 
 					throws StandardException
 	{
@@ -90,7 +79,7 @@ public final class NotNode extends Unary
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
 									throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericConstantNode.java Fri Jun 21 07:47:47 2013
@@ -21,16 +21,14 @@
 
 package	org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
+import java.sql.Types;
 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.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
+import org.apache.derby.iapi.types.DataTypeUtilities;
+import org.apache.derby.iapi.types.NumberDataValue;
 import org.apache.derby.iapi.types.SQLDouble;
 import org.apache.derby.iapi.types.SQLInteger;
 import org.apache.derby.iapi.types.SQLLongint;
@@ -38,157 +36,197 @@ import org.apache.derby.iapi.types.SQLRe
 import org.apache.derby.iapi.types.SQLSmallint;
 import org.apache.derby.iapi.types.SQLTinyint;
 import org.apache.derby.iapi.types.TypeId;
-import org.apache.derby.iapi.types.DataTypeUtilities;
-import org.apache.derby.iapi.types.NumberDataValue;
-
-import java.sql.Types;
 
 public final class NumericConstantNode extends ConstantNode
 {
-	/**
-	 * Initializer for a typed null node
-	 *
-	 * @param arg1	The TypeId for the type of node OR An object containing the value of the constant.
-	 *
-	 * @exception StandardException
-	 */
-	public void init(Object arg1)
-		throws StandardException
-	{
-		int precision = 0, scal = 0, maxwidth = 0;
-		Boolean isNullable;
-		boolean valueInP; // value in Predicate-- if TRUE a value was passed in
-		TypeId  typeId = null;
-		int typeid = 0;
-
-		if (arg1 instanceof TypeId)
-		{
-			typeId = (TypeId)arg1;
-			isNullable = Boolean.TRUE;
-			valueInP = false;
-			maxwidth = 0;
+    /**
+     * Constructor for a typed null node
+     * @param t type
+     * @param cm context manager
+     * @throws StandardException
+     */
+    NumericConstantNode(TypeId t, ContextManager cm)
+            throws StandardException {
+        super(cm);
+        setType(t,
+                getPrecision(t, null),
+                getScale(t, null),
+                true,
+                getMaxWidth(t, null));
+        setNodeType(getNodeType(t));
+    }
+
+    /**
+     * @param value An object containing the value of the constant.
+     * @param cm context manager
+     * @throws StandardException
+     */
+    NumericConstantNode(TypeId t, Object value, ContextManager cm)
+            throws StandardException {
+        super(cm);
+        setNodeType(getNodeType(t));
+        setType(t,
+                getPrecision(t, value),
+                getScale(t, value),
+                false,
+                getMaxWidth(t, value));
+        setValue(t, value);
+    }
+
+    private int getPrecision(TypeId t, Object val) throws StandardException {
+        int foo = t.getJDBCTypeId();
+       //switch (t.getJDBCTypeId()) {
+        switch (foo) {
+       case Types.TINYINT:
+           return TypeId.SMALLINT_PRECISION; // FIXME
+       case Types.INTEGER:
+           return TypeId.INT_PRECISION;
+       case Types.SMALLINT:
+           return TypeId.SMALLINT_PRECISION;
+       case Types.BIGINT:
+           return TypeId.LONGINT_PRECISION;
+       case Types.DECIMAL:
+            if (val != null) {
+               NumberDataValue constantDecimal =
+                    getDataValueFactory().getDecimalDataValue((String)val);
+               return constantDecimal.getDecimalValuePrecision();
+            } else {
+                return TypeId.DECIMAL_PRECISION;
+            }
+       case Types.DOUBLE:
+           return TypeId.DOUBLE_PRECISION;
+       case Types.REAL:
+           return TypeId.REAL_PRECISION;
+       default:
+           if (SanityManager.DEBUG) {
+                SanityManager.NOTREACHED();
+           }
+           return 0;
 		}
+    }
 
-		else	
-		{
-			isNullable = Boolean.FALSE;
-			valueInP = true;
-		}
-
-		
-		switch (getNodeType())
-		{
-		case C_NodeTypes.TINYINT_CONSTANT_NODE:
-			precision = TypeId.SMALLINT_PRECISION;
-			scal = TypeId.SMALLINT_SCALE;
-			if (valueInP)
-			{
-				maxwidth = TypeId.SMALLINT_MAXWIDTH;
-				typeid = Types.TINYINT;
-				setValue(new SQLTinyint((Byte) arg1));
-			} 
-			break;
-
-		case C_NodeTypes.INT_CONSTANT_NODE:
-			precision = TypeId.INT_PRECISION;
-			scal = TypeId.INT_SCALE;
-			if (valueInP)
-			{
-				maxwidth = TypeId.INT_MAXWIDTH;
-				typeid = Types.INTEGER;
-				setValue(new SQLInteger((Integer) arg1));
-			}
-			break;
-
-		case C_NodeTypes.SMALLINT_CONSTANT_NODE:
-			precision = TypeId.SMALLINT_PRECISION;
-			scal = TypeId.SMALLINT_SCALE;
-			if (valueInP)
-			{
-				maxwidth = TypeId.SMALLINT_MAXWIDTH;
-				typeid = Types.SMALLINT;
-				setValue(new SQLSmallint((Short) arg1));
-			}
-			break;
-
-		case C_NodeTypes.LONGINT_CONSTANT_NODE:
-			precision = TypeId.LONGINT_PRECISION;
-			scal = TypeId.LONGINT_SCALE;
-			if (valueInP)
-			{
-				maxwidth = TypeId.LONGINT_MAXWIDTH;
-				typeid = Types.BIGINT;
-				setValue(new SQLLongint((Long) arg1));
-			}
-			break;
-			
-		case C_NodeTypes.DECIMAL_CONSTANT_NODE:
-			if (valueInP)
-			{
-
-				NumberDataValue constantDecimal = getDataValueFactory().getDecimalDataValue((String) arg1);
-
-				typeid = Types.DECIMAL;
-				precision = constantDecimal.getDecimalValuePrecision();
-				scal = constantDecimal.getDecimalValueScale();
-				/* be consistent with our convention on maxwidth, see also
-				 * exactNumericType(), otherwise we get format problem, b 3923
-				 */
-				maxwidth = DataTypeUtilities.computeMaxWidth(precision, scal);
-				setValue(constantDecimal);
-			}
-			else
-			{
-				precision = TypeCompiler.DEFAULT_DECIMAL_PRECISION;
-				scal = TypeCompiler.DEFAULT_DECIMAL_SCALE;
-				maxwidth = TypeId.DECIMAL_MAXWIDTH;
-			}
-			break;
-												   
-		case C_NodeTypes.DOUBLE_CONSTANT_NODE:
-			precision = TypeId.DOUBLE_PRECISION;
-			scal = TypeId.DOUBLE_SCALE;
-			if (valueInP)
-			{
-				maxwidth = TypeId.DOUBLE_MAXWIDTH;
-				typeid = Types.DOUBLE;
-				setValue(new SQLDouble((Double) arg1));
-			}
-			break;
-
-		case C_NodeTypes.FLOAT_CONSTANT_NODE:
-			precision = TypeId.REAL_PRECISION;
-			scal = TypeId.REAL_SCALE;
-			if (valueInP)
-			{
-				maxwidth = TypeId.REAL_MAXWIDTH;
-				typeid = Types.REAL;
-				setValue(new SQLReal((Float) arg1));
-			}
-			break;
-			
-		default:
-			if (SanityManager.DEBUG)
-			{
-				// we should never really come here-- when the class is created
-				// it should have the correct nodeType set.
-				SanityManager.THROWASSERT(
-								"Unexpected nodeType = " + getNodeType());
-			}
-			break;
-		}
-		
-		setType(
-				   (typeId != null) ?  typeId :
-				     TypeId.getBuiltInTypeId(typeid),
-
-				   precision, 
-				   scal, 
-				   isNullable.booleanValue(), 
-				   maxwidth);
-	}
+    private int getScale(TypeId t, Object val) throws StandardException {
+       switch (t.getJDBCTypeId()) {
+       case Types.TINYINT:
+           return TypeId.SMALLINT_SCALE; // FIXME
+       case Types.INTEGER:
+           return TypeId.INT_SCALE;
+       case Types.SMALLINT:
+           return TypeId.SMALLINT_SCALE;
+       case Types.BIGINT:
+           return TypeId.LONGINT_SCALE;
+       case Types.DECIMAL:
+            if (val != null) {
+               NumberDataValue constantDecimal =
+                        getDataValueFactory().getDecimalDataValue((String)val);
+               return constantDecimal.getDecimalValueScale();
+            } else {
+                return TypeId.DECIMAL_SCALE;
+            }
+       case Types.DOUBLE:
+            return TypeId.DOUBLE_SCALE;
+       case Types.REAL:
+           return TypeId.REAL_SCALE;
+       default:
+           if (SanityManager.DEBUG) {
+                SanityManager.NOTREACHED();
+           }
+           return 0;
+        }
+    }
+
+    private int getMaxWidth(TypeId t, Object val) throws StandardException {
+       switch (t.getJDBCTypeId()) {
+       case Types.TINYINT:
+           return val != null ? TypeId.SMALLINT_MAXWIDTH : 0; // FIXME
+       case Types.INTEGER:
+           return val != null ? TypeId.INT_MAXWIDTH : 0;
+       case Types.SMALLINT:
+           return val != null ? TypeId.SMALLINT_MAXWIDTH : 0;
+       case Types.BIGINT:
+           return val != null ? TypeId.LONGINT_MAXWIDTH: 0;
+       case Types.DECIMAL:
+            if (val != null) {
+               NumberDataValue constantDecimal =
+                        getDataValueFactory().getDecimalDataValue((String) val);
+               int precision = constantDecimal.getDecimalValuePrecision();
+               int scal = constantDecimal.getDecimalValueScale();
+               /* be consistent with our convention on maxwidth, see also
+                * exactNumericType(), otherwise we get format problem, b 3923
+                */
+               return DataTypeUtilities.computeMaxWidth(precision, scal);
+            } else {
+                return TypeId.DECIMAL_MAXWIDTH;
+            }
+       case Types.DOUBLE:
+           return val != null ? TypeId.DOUBLE_MAXWIDTH : 0;
+       case Types.REAL:
+           return val != null ? TypeId.REAL_MAXWIDTH : 0;
+       default:
+           if (SanityManager.DEBUG) {
+                SanityManager.NOTREACHED();
+           }
+           return 0;
+       }
+    }
+
+    private int getNodeType(TypeId t) {
+       switch (t.getJDBCTypeId()) {
+       case Types.TINYINT:
+           return C_NodeTypes.TINYINT_CONSTANT_NODE;
+       case Types.INTEGER:
+           return C_NodeTypes.INT_CONSTANT_NODE;
+       case Types.SMALLINT:
+           return C_NodeTypes.SMALLINT_CONSTANT_NODE;
+       case Types.BIGINT:
+           return C_NodeTypes.BIGINT_CONSTANT_NODE;
+       case Types.DECIMAL:
+            return C_NodeTypes.DECIMAL_CONSTANT_NODE;
+       case Types.DOUBLE:
+           return C_NodeTypes.DOUBLE_CONSTANT_NODE;
+       case Types.REAL:
+           return C_NodeTypes.REAL_CONSTANT_NODE;
+       default:
+           if (SanityManager.DEBUG) {
+                SanityManager.NOTREACHED();
+           }
+           return 0;
+       }
+    }
+
+    private void setValue(TypeId t, Object value ) throws StandardException {
+       switch (t.getJDBCTypeId()) {
+       case Types.TINYINT:
+           setValue(new SQLTinyint((Byte)value));
+            break;
+       case Types.INTEGER:
+           setValue(new SQLInteger((Integer)value));
+            break;
+       case Types.SMALLINT:
+           setValue(new SQLSmallint((Short)value));
+            break;
+       case Types.BIGINT:
+           setValue(new SQLLongint((Long)value));
+            break;
+       case Types.DECIMAL:
+            NumberDataValue constantDecimal =
+                    getDataValueFactory().getDecimalDataValue((String)value);
+            setValue(constantDecimal);
+            break;
+       case Types.DOUBLE:
+           setValue(new SQLDouble((Double)value));
+            break;
+       case Types.REAL:
+           setValue(new SQLReal((Float)value));
+            break;
+       default:
+           if (SanityManager.DEBUG) {
+                SanityManager.NOTREACHED();
+           }
+       }
+    }
 
-	/**
+    /**
 	 * Return an Object representing the bind time value of this
 	 * expression tree.  If the expression tree does not evaluate to
 	 * a constant at bind time then we return null.
@@ -200,6 +238,7 @@ public final class NumericConstantNode e
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	Object getConstantValueAsObject()
 		throws StandardException
 	{
@@ -237,10 +276,10 @@ public final class NumericConstantNode e
 		case C_NodeTypes.DOUBLE_CONSTANT_NODE:
 			mb.push(value.getDouble());
 			break;
-		case C_NodeTypes.FLOAT_CONSTANT_NODE:
+        case C_NodeTypes.REAL_CONSTANT_NODE:
 			mb.push(value.getFloat());
 			break;
-		case C_NodeTypes.LONGINT_CONSTANT_NODE:
+        case C_NodeTypes.BIGINT_CONSTANT_NODE:
 			mb.push(value.getLong());
 			break;
 		default:

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java Fri Jun 21 07:47:47 2013
@@ -21,29 +21,19 @@
 
 package org.apache.derby.impl.sql.compile;
 
-import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
-import org.apache.derby.iapi.services.context.ContextService;
-
-import org.apache.derby.iapi.services.loader.ClassFactory;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.services.io.StoredFormatIds;
-
 import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.types.DataTypeDescriptor;
-import org.apache.derby.iapi.types.NumberDataValue;
-import org.apache.derby.iapi.types.TypeId;
-
-import org.apache.derby.iapi.sql.compile.TypeCompiler;
-
 import org.apache.derby.iapi.reference.ClassName;
 import org.apache.derby.iapi.reference.Limits;
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.compiler.LocalField;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.io.StoredFormatIds;
+import org.apache.derby.iapi.services.loader.ClassFactory;
+import org.apache.derby.iapi.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.TypeCompiler;
+import org.apache.derby.iapi.types.DataTypeDescriptor;
+import org.apache.derby.iapi.types.NumberDataValue;
+import org.apache.derby.iapi.types.TypeId;
 
 /**
  * This class implements TypeId for the SQL numeric datatype.
@@ -74,7 +64,7 @@ public final class NumericTypeCompiler e
 			case StoredFormatIds.INT_TYPE_ID:
 				return "int";
 
-			case StoredFormatIds.LONGINT_TYPE_ID:
+            case StoredFormatIds.BIGINT_TYPE_ID:
 				return "long";
 
 			case StoredFormatIds.REAL_TYPE_ID:
@@ -104,6 +94,7 @@ public final class NumericTypeCompiler e
 	 * @return String		The method call name for getting the
 	 *						corresponding primitive Java type.
 	 */
+    @Override
 	public String getPrimitiveMethodName()
 	{
 		int formatId = getStoredFormatIdFromTypeId();
@@ -115,7 +106,7 @@ public final class NumericTypeCompiler e
 			case StoredFormatIds.INT_TYPE_ID:
 				return "getInt";
 
-			case StoredFormatIds.LONGINT_TYPE_ID:
+            case StoredFormatIds.BIGINT_TYPE_ID:
 				return "getLong";
 
 			case StoredFormatIds.REAL_TYPE_ID:
@@ -156,7 +147,7 @@ public final class NumericTypeCompiler e
 			case StoredFormatIds.INT_TYPE_ID:
 				return TypeCompiler.INT_MAXWIDTH_AS_CHAR;
 
-			case StoredFormatIds.LONGINT_TYPE_ID:
+            case StoredFormatIds.BIGINT_TYPE_ID:
 				return TypeCompiler.LONGINT_MAXWIDTH_AS_CHAR;
 
 			case StoredFormatIds.REAL_TYPE_ID:
@@ -183,11 +174,11 @@ public final class NumericTypeCompiler e
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public DataTypeDescriptor
-	resolveArithmeticOperation(DataTypeDescriptor leftType,
-								DataTypeDescriptor rightType,
-								String operator)
-							throws StandardException
+    @Override
+    public DataTypeDescriptor resolveArithmeticOperation(
+            DataTypeDescriptor leftType,
+            DataTypeDescriptor rightType,
+            String operator) throws StandardException
 	{
 		NumericTypeCompiler higherTC;
 		DataTypeDescriptor	higherType;
@@ -330,6 +321,7 @@ public final class NumericTypeCompiler e
 		Return the method name to get a Derby DataValueDescriptor
 		object of the correct type. This implementation returns "getDataValue".
 	*/
+    @Override
 	String dataValueMethodName()
 	{
 		if (getStoredFormatIdFromTypeId() == StoredFormatIds.DECIMAL_TYPE_ID)
@@ -352,7 +344,7 @@ public final class NumericTypeCompiler e
 			case StoredFormatIds.INT_TYPE_ID:
 				return "getNullInteger";
 
-			case StoredFormatIds.LONGINT_TYPE_ID:
+            case StoredFormatIds.BIGINT_TYPE_ID:
 				return "getNullLong";
 
 			case StoredFormatIds.REAL_TYPE_ID:
@@ -482,7 +474,6 @@ public final class NumericTypeCompiler e
 		long lscale = (long)leftType.getScale();
 		long rscale = (long)rightType.getScale();
 		long lprec = (long)leftType.getPrecision();
-		long rprec = (long)rightType.getPrecision();
 
 		/*
 		** Retain greatest scale, take sum of left
@@ -498,11 +489,10 @@ public final class NumericTypeCompiler e
 			** Take max left scale + right precision - right scale + 1, 
 			** or 4, whichever is biggest 
 			*/
-			LanguageConnectionContext lcc = (LanguageConnectionContext)
-				(ContextService.getContext(LanguageConnectionContext.CONTEXT_ID)); 
-
 			// Scale: 31 - left precision + left scale - right scale
-				val = Math.max(NumberDataValue.MAX_DECIMAL_PRECISION_SCALE - lprec + lscale - rscale, 0);
+            val = Math.max(NumberDataValue.MAX_DECIMAL_PRECISION_SCALE
+                               - lprec + lscale - rscale,
+                           0);
 
 		}
 		else if (TypeCompiler.AVG_OP.equals(operator))
@@ -526,7 +516,7 @@ public final class NumericTypeCompiler e
 		return (int)val;
 	}
 
-
+    @Override
 	public void generateDataValue(MethodBuilder mb, int collationType,
 			LocalField field)
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OperatorNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OperatorNode.java Fri Jun 21 07:47:47 2013
@@ -25,6 +25,7 @@ import java.lang.reflect.Modifier;
 import org.apache.derby.iapi.services.classfile.VMOpcode;
 import org.apache.derby.iapi.services.compiler.LocalField;
 import org.apache.derby.iapi.services.compiler.MethodBuilder;
+import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.types.SqlXmlUtil;
 
 /**
@@ -33,6 +34,10 @@ import org.apache.derby.iapi.types.SqlXm
  */
 abstract class OperatorNode extends ValueNode {
 
+    OperatorNode(ContextManager cm) {
+        super(cm);
+    }
+
     /**
      * <p>
      * Generate code that pushes an SqlXmlUtil instance onto the stack. The

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptTraceViewer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptTraceViewer.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptTraceViewer.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptTraceViewer.java Fri Jun 21 07:47:47 2013
@@ -25,7 +25,6 @@ import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
-
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.sql.dictionary.OptionalTool;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerFactoryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerFactoryImpl.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerFactoryImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerFactoryImpl.java Fri Jun 21 07:47:47 2013
@@ -21,6 +21,10 @@
 
 package org.apache.derby.impl.sql.compile;
 
+import java.util.Properties;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.services.monitor.ModuleControl;
+import org.apache.derby.iapi.services.property.PropertyUtil;
 import org.apache.derby.iapi.sql.compile.CostEstimate;
 import org.apache.derby.iapi.sql.compile.JoinStrategy;
 import org.apache.derby.iapi.sql.compile.OptimizableList;
@@ -28,25 +32,9 @@ import org.apache.derby.iapi.sql.compile
 import org.apache.derby.iapi.sql.compile.Optimizer;
 import org.apache.derby.iapi.sql.compile.OptimizerFactory;
 import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
-
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
-import org.apache.derby.iapi.store.access.TransactionController;
-
 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
 
-import org.apache.derby.iapi.services.monitor.ModuleControl;
-import org.apache.derby.iapi.services.context.ContextManager;
-import org.apache.derby.iapi.services.property.PropertyUtil;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.error.StandardException;
-
-import org.apache.derby.iapi.reference.Property;
-
-import java.util.Properties;
-
 /**
 	This is simply the factory for creating an optimizer.
  */
@@ -67,6 +55,10 @@ public class OptimizerFactoryImpl
 	*/
 	protected JoinStrategy[] joinStrategySet;
 
+    /* Do join order optimization by default */
+    private boolean joinOrderOptimization = true;
+
+
 	//
 	// ModuleControl interface
 	//
@@ -74,7 +66,19 @@ public class OptimizerFactoryImpl
 	public void boot(boolean create, Properties startParams)
 			throws StandardException {
 
-		/*
+        /*
+        ** This system property determines whether to optimize join order
+        ** by default.  It is used mainly for testing - there are many tests
+        ** that assume the join order is fixed.
+        */
+        String opt =
+            PropertyUtil.getSystemProperty(Optimizer.JOIN_ORDER_OPTIMIZATION);
+        if (opt != null)
+        {
+            joinOrderOptimization = Boolean.parseBoolean(opt);
+        }
+
+        /*
 		** This property determines whether to use rule-based or cost-based
 		** optimization.  It is used mainly for testing - there are many tests
 		** that assume rule-based optimization.  The default is cost-based
@@ -221,5 +225,11 @@ public class OptimizerFactoryImpl
 	{
 		return maxMemoryPerTable;
 	}
+
+    @Override
+    public boolean doJoinOrderOptimization()
+    {
+        return joinOrderOptimization;
+    }
 }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerImpl.java Fri Jun 21 07:47:47 2013
@@ -21,37 +21,30 @@
 
 package org.apache.derby.impl.sql.compile;
 
+import java.util.HashMap;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.io.ArrayUtil;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.error.StandardException;
-
+import org.apache.derby.iapi.sql.compile.AccessPath;
+import org.apache.derby.iapi.sql.compile.CostEstimate;
 import org.apache.derby.iapi.sql.compile.JoinStrategy;
+import org.apache.derby.iapi.sql.compile.OptTrace;
 import org.apache.derby.iapi.sql.compile.Optimizable;
 import org.apache.derby.iapi.sql.compile.OptimizableList;
 import org.apache.derby.iapi.sql.compile.OptimizablePredicate;
 import org.apache.derby.iapi.sql.compile.OptimizablePredicateList;
 import org.apache.derby.iapi.sql.compile.Optimizer;
-import org.apache.derby.iapi.sql.compile.OptTrace;
-import org.apache.derby.iapi.sql.compile.CostEstimate;
 import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
 import org.apache.derby.iapi.sql.compile.RowOrdering;
-import org.apache.derby.iapi.sql.compile.AccessPath;
-
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
-
 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;
 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
-
-import org.apache.derby.iapi.reference.SQLState;
-
 import org.apache.derby.iapi.util.JBitSet;
 import org.apache.derby.iapi.util.StringUtil;
 
-import java.util.HashMap;
-
 /**
  * Optimizer uses OptimizableList to keep track of the best join order as it
  * builds it.  For each available slot in the join order, we cost all of the
@@ -129,8 +122,6 @@ class OptimizerImpl implements Optimizer
 	private RowOrdering currentRowOrdering = new RowOrderingImpl();
 	private RowOrdering bestRowOrdering = new RowOrderingImpl();
 
-	private boolean	conglomerate_OneRowResultSet;
-
 	// max memory use per table
 	private int maxMemoryPerTable;
 
@@ -474,8 +465,8 @@ class OptimizerImpl implements Optimizer
 				// proceed with normal timeout logic.
 				if (firstLookOrder == null)
 					firstLookOrder = new int[numOptimizables];
-				for (int i = 0; i < numOptimizables; i++)
-					firstLookOrder[i] = bestJoinOrder[i];
+                System.arraycopy(
+                        bestJoinOrder, 0, firstLookOrder, 0, numOptimizables);
 				permuteState = JUMPING;
 
 				/* If we already assigned at least one position in the
@@ -1150,12 +1141,11 @@ class OptimizerImpl implements Optimizer
 		** cost.
 		*/
 		double newCost = currentCost.getEstimatedCost();
-		double pullCost = 0.0;
 		CostEstimate pullCostEstimate =
 						pullMe.getBestAccessPath().getCostEstimate();
 		if (pullCostEstimate != null)
 		{
-			pullCost = pullCostEstimate.getEstimatedCost();
+            double pullCost = pullCostEstimate.getEstimatedCost();
 
 			newCost -= pullCost;
 
@@ -1219,7 +1209,7 @@ class OptimizerImpl implements Optimizer
 			if (pullMe.considerSortAvoidancePath())
 			{
 				AccessPath ap = pullMe.getBestSortAvoidancePath();
-				double	   prevEstimatedCost = 0.0d;
+                double     prevEstimatedCost;
 
 				/*
 				** Subtract the sort avoidance cost estimate of the
@@ -1379,7 +1369,6 @@ class OptimizerImpl implements Optimizer
 		JBitSet	                predMap         = new JBitSet(numTablesInQuery);
 		JBitSet                 curTableNums    = null;
 		BaseTableNumbersVisitor btnVis          = null;
-		boolean                 pushPredNow     = false;
 		int                     tNum;
 		Predicate               pred;
 
@@ -1446,7 +1435,7 @@ class OptimizerImpl implements Optimizer
 			 * We can check for this condition by seeing if predMap is empty,
 			 * which is what the following line does.
 			 */
-			pushPredNow = (predMap.getFirstSetBit() == -1);
+            boolean pushPredNow = (predMap.getFirstSetBit() == -1);
 
 			/* If the predicate is scoped, there's more work to do. A
 			 * scoped predicate's "referenced map" may not be in sync
@@ -1841,11 +1830,11 @@ class OptimizerImpl implements Optimizer
 		** we use 2 loops.
 		*/
 		bestJoinOrderUsedPredsFromAbove = usingPredsPushedFromAbove;
-		for (int i = 0; i < numOptimizables; i++)
-		{
-			bestJoinOrder[i] = proposedJoinOrder[i];
-		}
-		for (int i = 0; i < numOptimizables; i++)
+
+        System.arraycopy(
+                proposedJoinOrder, 0, bestJoinOrder, 0, numOptimizables);
+
+        for (int i = 0; i < numOptimizables; i++)
 		{
 			optimizableList.getOptimizable(bestJoinOrder[i]).
 				rememberAsBest(planType, this);
@@ -2007,11 +1996,7 @@ class OptimizerImpl implements Optimizer
 				throws StandardException
 	{
 		/* CHOOSE BEST CONGLOMERATE HERE */
-		ConglomerateDescriptor	conglomerateDescriptor = null;
-		ConglomerateDescriptor	bestConglomerateDescriptor = null;
 		AccessPath bestAp = optimizable.getBestAccessPath();
-		int lockMode = optimizable.getCurrentAccessPath().getLockMode();
-
 
 		/*
 		** If the current conglomerate better than the best so far?
@@ -2115,7 +2100,9 @@ class OptimizerImpl implements Optimizer
 		** If all else fails, and no conglomerate has been picked yet,
 		** pick this one.
 		*/
-		bestConglomerateDescriptor = bestAp.getConglomerateDescriptor();
+        ConglomerateDescriptor bestConglomerateDescriptor =
+            bestAp.getConglomerateDescriptor();
+
 		if (bestConglomerateDescriptor == null)
 		{
 			bestAp.setCostEstimate(
@@ -2138,8 +2125,6 @@ class OptimizerImpl implements Optimizer
 
 			optimizable.rememberJoinStrategyAsBest(bestAp);
 		}
-
-		return;
 	}
 
 	/**
@@ -2468,10 +2453,10 @@ class OptimizerImpl implements Optimizer
 		// number of rows is the number of rows returned by the innermost
 		// optimizable.
 		finalCostEstimate = getNewCostEstimate(0.0d, 0.0d, 0.0d);
-		CostEstimate ce = null;
-		for (int i = 0; i < bestJoinOrder.length; i++)
+
+        for (int i = 0; i < bestJoinOrder.length; i++)
 		{
-			ce = optimizableList.getOptimizable(bestJoinOrder[i])
+            CostEstimate ce = optimizableList.getOptimizable(bestJoinOrder[i])
 					.getTrulyTheBestAccessPath().getCostEstimate();
 
 			finalCostEstimate.setCost(
@@ -2615,7 +2600,7 @@ class OptimizerImpl implements Optimizer
 		return 2;
 	}
 
-	public CostEstimateImpl getNewCostEstimate(double theCost,
+    CostEstimateImpl getNewCostEstimate(double theCost,
 							double theRowCount,
 							double theSingleScanRowCount)
 	{
@@ -2654,8 +2639,9 @@ class OptimizerImpl implements Optimizer
 				if (savedJoinOrders != null)
 				{
 					savedJoinOrders.remove(planKey);
-					if (savedJoinOrders.size() == 0)
+                    if (savedJoinOrders.isEmpty()) {
 						savedJoinOrders = null;
+                    }
 				}
 			}
 			else if (action == FromTable.ADD_PLAN)
@@ -2672,9 +2658,8 @@ class OptimizerImpl implements Optimizer
 				if (joinOrder == null)
 					joinOrder = new int[numOptimizables];
 
-				// Now copy current bestJoinOrder and save it.
-				for (int i = 0; i < bestJoinOrder.length; i++)
-					joinOrder[i] = bestJoinOrder[i];
+                System.arraycopy(
+                        bestJoinOrder, 0, joinOrder, 0, bestJoinOrder.length);
 
 				savedJoinOrders.put(planKey, joinOrder);
 			}
@@ -2691,10 +2676,8 @@ class OptimizerImpl implements Optimizer
 					joinOrder = savedJoinOrders.get(planKey);
 					if (joinOrder != null)
 					{
-						// Load the join order we found into our
-						// bestJoinOrder array.
-						for (int i = 0; i < joinOrder.length; i++)
-							bestJoinOrder[i] = joinOrder[i];
+                        System.arraycopy(
+                            joinOrder, 0, bestJoinOrder, 0, joinOrder.length);
 					}
 				}
 			}
@@ -2730,7 +2713,7 @@ class OptimizerImpl implements Optimizer
 	 * @param pList List of predicates to add to this OptimizerImpl's
 	 *  own list for pushing.
 	 */
-	void addScopedPredicatesToList(PredicateList pList)
+    void addScopedPredicatesToList(PredicateList pList, ContextManager cm)
 		throws StandardException
 	{
 		if ((pList == null) || (pList == predicateList))
@@ -2740,7 +2723,7 @@ class OptimizerImpl implements Optimizer
 		if (predicateList == null)
 		// in this case, there is no 'original' predicateList, so we
 		// can just create one.
-			predicateList = new PredicateList();
+            predicateList = new PredicateList(cm);
 
 		// First, we need to go through and remove any predicates in this
 		// optimizer's list that may have been pushed here from outer queries
@@ -2748,7 +2731,7 @@ class OptimizerImpl implements Optimizer
 		// predicate was pushed from an outer query because it will have
 		// been scoped to the node for which this OptimizerImpl was
 		// created.
-		Predicate pred = null;
+        Predicate pred;
 		for (int i = predicateList.size() - 1; i >= 0; i--) {
 			pred = (Predicate)predicateList.getOptPredicate(i);
 			if (pred.isScopedForPush())
@@ -2770,8 +2753,6 @@ class OptimizerImpl implements Optimizer
 				pList.removeOptPredicate(i);
 			}
 		}
-
-		return;
 	}
 
     /** Get the trace machinery */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerTracer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerTracer.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerTracer.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OptimizerTracer.java Fri Jun 21 07:47:47 2013
@@ -23,12 +23,11 @@ package org.apache.derby.impl.sql.compil
 
 import java.io.PrintWriter;
 import java.sql.SQLException;
-
 import org.apache.derby.iapi.db.OptimizerTrace;
 import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.services.context.ContextService;
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.services.loader.ClassFactory;
-import org.apache.derby.iapi.services.context.ContextService;
 import org.apache.derby.iapi.sql.compile.CompilerContext;
 import org.apache.derby.iapi.sql.compile.OptTrace;
 import org.apache.derby.iapi.sql.dictionary.OptionalTool;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrNode.java Fri Jun 21 07:47:47 2013
@@ -22,28 +22,29 @@
 package	org.apache.derby.impl.sql.compile;
 
 import java.util.List;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
-import org.apache.derby.iapi.services.sanity.SanityManager;
 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;
 
-
-public class OrNode extends BinaryLogicalOperatorNode
+class OrNode extends BinaryLogicalOperatorNode
 {
 	/* Is this the 1st OR in the OR chain? */
 	private boolean firstOr;
 
 	/**
-	 * Initializer for an OrNode
+     * Constructor for an OrNode
 	 *
 	 * @param leftOperand	The left operand of the OR
 	 * @param rightOperand	The right operand of the OR
+     * @param cm            The context manager
 	 */
 
-	public void init(Object leftOperand, Object rightOperand)
+    OrNode(ValueNode leftOperand, ValueNode rightOperand, ContextManager cm)
 	{
-		super.init(leftOperand, rightOperand, "or");
+        super(leftOperand, rightOperand, "or", cm);
 		this.shortCircuitValue = true;
+        setNodeType(C_NodeTypes.OR_NODE);
 	}
 
 	/**
@@ -70,7 +71,7 @@ public class OrNode extends BinaryLogica
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-
+    @Override
     ValueNode bindExpression(
         FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates)
 			throws StandardException
@@ -95,7 +96,8 @@ public class OrNode extends BinaryLogica
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ValueNode preprocess(int numTables,
+    @Override
+    ValueNode preprocess(int numTables,
 								FromList outerFromList,
 								SubqueryList outerSubqueryList,
 								PredicateList outerPredicateList) 
@@ -146,10 +148,10 @@ public class OrNode extends BinaryLogica
 						 * below.  But if we're running in SANE mode, do a
 						 * quick check to make sure that's still valid.
 					 	 */
-						BinaryRelationalOperatorNode bron = null;
 						if (left instanceof BinaryRelationalOperatorNode)
 						{
- 							bron = (BinaryRelationalOperatorNode)left;
+                            BinaryRelationalOperatorNode bron =
+                                    (BinaryRelationalOperatorNode)left;
 							if (!bron.isInListProbeNode())
 							{
 								SanityManager.THROWASSERT(
@@ -212,9 +214,7 @@ public class OrNode extends BinaryLogica
 			/* So, can we convert the OR chain? */
 			if (convert)
 			{
-				ValueNodeList vnl = (ValueNodeList) getNodeFactory().getNode(
-													C_NodeTypes.VALUE_NODE_LIST,
-													getContextManager());
+                ValueNodeList vnl = new ValueNodeList(getContextManager());
 				// Build the IN list 
 				for (ValueNode vn = this; vn instanceof OrNode; vn = ((OrNode) vn).getRightOperand())
 				{
@@ -246,12 +246,8 @@ public class OrNode extends BinaryLogica
 					}
 				}
 
-				InListOperatorNode ilon =
-							(InListOperatorNode) getNodeFactory().getNode(
-											C_NodeTypes.IN_LIST_OPERATOR_NODE,
-											cr,
-											vnl,
-											getContextManager());
+                InListOperatorNode ilon =
+                        new InListOperatorNode(cr, vnl, getContextManager());
 
 				// Transfer the result type info to the IN list
 				ilon.setType(getTypeServices());
@@ -285,6 +281,7 @@ public class OrNode extends BinaryLogica
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+    @Override
 	ValueNode eliminateNots(boolean underNotNode) 
 					throws StandardException
 	{
@@ -296,13 +293,8 @@ public class OrNode extends BinaryLogica
 		}
 
 		/* Convert the OrNode to an AndNode */
-		AndNode	andNode;
-
-		andNode = (AndNode) getNodeFactory().getNode(
-													C_NodeTypes.AND_NODE,
-													leftOperand,
-													rightOperand,
-													getContextManager());
+       AndNode andNode =
+                new AndNode(leftOperand, rightOperand, getContextManager());
 		andNode.setType(getTypeServices());
 		return andNode;
 	}
@@ -335,7 +327,8 @@ public class OrNode extends BinaryLogica
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
-	public ValueNode changeToCNF(boolean underTopAndNode) 
+    @Override
+    ValueNode changeToCNF(boolean underTopAndNode)
 					throws StandardException
 	{
 		OrNode curOr = this;
@@ -345,17 +338,10 @@ public class OrNode extends BinaryLogica
 		 */
 		if (rightOperand instanceof AndNode)
 		{
-			BooleanConstantNode	falseNode;
-
-			falseNode = (BooleanConstantNode) getNodeFactory().getNode(
-											C_NodeTypes.BOOLEAN_CONSTANT_NODE,
-											Boolean.FALSE,
-											getContextManager());
-			rightOperand = (ValueNode) getNodeFactory().getNode(
-												C_NodeTypes.OR_NODE,
-												rightOperand,
-												falseNode,
-												getContextManager());
+           BooleanConstantNode falseNode =
+                    new BooleanConstantNode(false, getContextManager());
+            rightOperand =
+                    new OrNode(rightOperand, falseNode, getContextManager());
 			((OrNode) rightOperand).postBindFixup();
 		}
 
@@ -370,18 +356,10 @@ public class OrNode extends BinaryLogica
 		/* Add the false BooleanConstantNode if not there yet */
 		if (!(curOr.getRightOperand().isBooleanFalse()))
 		{
-			BooleanConstantNode	falseNode;
-
-			falseNode = (BooleanConstantNode) getNodeFactory().getNode(
-											C_NodeTypes.BOOLEAN_CONSTANT_NODE,
-											Boolean.FALSE,
-											getContextManager());
-			curOr.setRightOperand(
-					(ValueNode) getNodeFactory().getNode(
-												C_NodeTypes.OR_NODE,
-												curOr.getRightOperand(),
-												falseNode,
-												getContextManager()));
+           BooleanConstantNode falseNode =
+                    new BooleanConstantNode(false, getContextManager());
+            curOr.setRightOperand(new OrNode(
+                    curOr.getRightOperand(), falseNode, getContextManager()));
 			((OrNode) curOr.getRightOperand()).postBindFixup();
 		}
 
@@ -441,7 +419,8 @@ public class OrNode extends BinaryLogica
 	 *
 	 * @return		Boolean which reflects validity of the tree.
 	 */
-	public boolean verifyChangeToCNF()
+    @Override
+    boolean verifyChangeToCNF()
 	{
 		boolean isValid = true;
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByColumn.java Fri Jun 21 07:47:47 2013
@@ -23,6 +23,7 @@ package	org.apache.derby.impl.sql.compil
 
 import org.apache.derby.iapi.error.StandardException;
 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;
 import org.apache.derby.iapi.sql.compile.Visitor;
@@ -35,7 +36,7 @@ import org.apache.derby.iapi.sql.compile
  * columns in that query, and that positions are within range.
  *
  */
-public class OrderByColumn extends OrderedColumn {
+class OrderByColumn extends OrderedColumn {
 
 	private ResultColumn	resultCol;
 	private boolean			ascending = true;
@@ -51,13 +52,16 @@ public class OrderByColumn extends Order
 
 
    	/**
-	 * Initializer.
+     * Constructor.
 	 *
 	 * @param expression            Expression of this column
+     * @param cm                    The context manager
 	 */
-	public void init(Object expression)
+    OrderByColumn(ValueNode expression, ContextManager cm)
 	{
-		this.expression = (ValueNode)expression;
+        super(cm);
+        setNodeType(C_NodeTypes.ORDER_BY_COLUMN);
+        this.expression = expression;
 	}
 	
 	/**
@@ -66,6 +70,7 @@ public class OrderByColumn extends Order
 	 *
 	 * @return	This object as a String
 	 */
+    @Override
 	public String toString() {
 		if (SanityManager.DEBUG) {
 			return
@@ -84,7 +89,8 @@ public class OrderByColumn extends Order
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-	public void printSubNodes(int depth)
+    @Override
+    void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
 		{
@@ -105,7 +111,7 @@ public class OrderByColumn extends Order
 	/**
 	 * Mark the column as descending order
 	 */
-	public void setDescending() {
+    void setDescending() {
 		ascending = false;
 	}
 
@@ -115,14 +121,15 @@ public class OrderByColumn extends Order
 	 *
 	 * @return true if ascending, false if descending
 	 */
-	public boolean isAscending() {
+    @Override
+    boolean isAscending() {
 		return ascending;
 	}
 
 	/**
 	 * Mark the column as ordered NULL values lower than non-NULL values.
 	 */
-	public void setNullsOrderedLow() {
+    void setNullsOrderedLow() {
 		nullsOrderedLow = true;
 	}
 
@@ -132,7 +139,8 @@ public class OrderByColumn extends Order
 	 *
 	 * @return true if NULLs ordered low, false if NULLs ordered high
 	 */
-	public boolean isNullsOrderedLow() {
+    @Override
+    boolean isNullsOrderedLow() {
 		return nullsOrderedLow;
 	}
 
@@ -195,7 +203,7 @@ public class OrderByColumn extends Order
 	 * @exception StandardException		Thrown on error
 	 * @exception StandardException		Thrown when column not found
 	 */
-	public void bindOrderByColumn(ResultSetNode target, OrderByList oblist)
+    void bindOrderByColumn(ResultSetNode target, OrderByList oblist)
 				throws StandardException 
 	{
 		this.list = oblist;
@@ -244,9 +252,6 @@ public class OrderByColumn extends Order
 					((SelectNode)target).hasDistinct() &&
 					!expressionMatch(target))
 			{
-				String col=null;
-				boolean match=false;
-
                 CollectNodesVisitor<ColumnReference> collectNodesVisitor =
                     new CollectNodesVisitor<ColumnReference>(
                         ColumnReference.class);
@@ -254,8 +259,8 @@ public class OrderByColumn extends Order
 
                 for (ColumnReference cr1 : collectNodesVisitor.getList())
 				{//visits through the columns in this OrderByColumn
-					col=cr1.getColumnName();
-					match = columnMatchFound(target,cr1);
+                    String col=cr1.getColumnName();
+                    boolean match = columnMatchFound(target,cr1);
 					/* breaks if a match not found, this is needed
 					 * because all column references in this
 					 * OrderByColumn should be there in the select
@@ -377,7 +382,7 @@ public class OrderByColumn extends Order
 	 * @param target	The result set being selected from
 	 *
 	 */
-	public void pullUpOrderByColumn(ResultSetNode target)
+    void pullUpOrderByColumn(ResultSetNode target)
 				throws StandardException 
 	{
         ResultColumnList targetCols = target.getResultColumns();
@@ -390,20 +395,16 @@ public class OrderByColumn extends Order
                     cr.getColumnName(), cr.getTableNameNode());
 
 			if(resultCol == null){
-				resultCol = (ResultColumn) getNodeFactory().getNode(C_NodeTypes.RESULT_COLUMN,
-										    cr.getColumnName(),
-										    cr,
-										    getContextManager());
+               resultCol = new ResultColumn(
+                        cr.getColumnName(), cr, getContextManager());
 				targetCols.addResultColumn(resultCol);
                 addedColumnOffset = targetCols.getOrderBySelect();
 				targetCols.incOrderBySelect();
 			}
 			
 		}else if(!isReferedColByNum(expression)){
-			resultCol = (ResultColumn) getNodeFactory().getNode(C_NodeTypes.RESULT_COLUMN,
-									    null,
-									    expression,
-									    getContextManager());
+           resultCol = new ResultColumn(
+                    (String)null, expression, getContextManager());
 			targetCols.addResultColumn(resultCol);
             addedColumnOffset = targetCols.getOrderBySelect();
 			targetCols.incOrderBySelect();
@@ -465,10 +466,7 @@ public class OrderByColumn extends Order
 	
 	private ResultColumn resolveColumnReference(ResultSetNode target,
 							   ColumnReference cr)
-	throws StandardException{
-		
-		ResultColumn resultCol = null;
-		
+            throws StandardException {
 		int					sourceTableNumber = -1;
 		
 		//bug 5716 - for db2 compatibility - no qualified names allowed in order by clause when union/union all operator is used 
@@ -514,7 +512,8 @@ public class OrderByColumn extends Order
 
 		ResultColumnList	targetCols = target.getResultColumns();
 
-		resultCol = targetCols.getOrderByColumnToBind(cr.getColumnName(),
+        ResultColumn resCol = targetCols.getOrderByColumnToBind(
+                            cr.getColumnName(),
 							cr.getTableNameNode(),
 							sourceTableNumber,
 							this);
@@ -523,15 +522,15 @@ public class OrderByColumn extends Order
          * order by clause may be found in the user specified select list now even though it was
          * not found when pullUpOrderByColumn was called.
          */
-        if( resultCol == null && addedColumnOffset >= 0)
+        if( resCol == null && addedColumnOffset >= 0)
             resolveAddedColumn(target);
 							
-		if (resultCol == null || resultCol.isNameGenerated()){
+        if (resCol == null || resCol.isNameGenerated()){
 			String errString = cr.columnName;
 			throw StandardException.newException(SQLState.LANG_ORDER_BY_COLUMN_NOT_FOUND, errString);
 		}
 
-		return resultCol;
+        return resCol;
 
 	}
 
@@ -576,6 +575,7 @@ public class OrderByColumn extends Order
 	 *
 	 * @exception StandardException on error
 	 */
+    @Override
 	void acceptChildren(Visitor v)
 		throws StandardException
 	{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByList.java Fri Jun 21 07:47:47 2013
@@ -21,30 +21,25 @@
 
 package	org.apache.derby.impl.sql.compile;
 
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.reference.ClassName;
+import org.apache.derby.iapi.reference.Limits;
+import org.apache.derby.iapi.reference.SQLState;
+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.services.sanity.SanityManager;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 import org.apache.derby.iapi.sql.compile.CompilerContext;
-import org.apache.derby.iapi.sql.compile.Optimizable;
 import org.apache.derby.iapi.sql.compile.CostEstimate;
+import org.apache.derby.iapi.sql.compile.Optimizable;
 import org.apache.derby.iapi.sql.compile.OptimizableList;
 import org.apache.derby.iapi.sql.compile.RequiredRowOrdering;
 import org.apache.derby.iapi.sql.compile.RowOrdering;
-import org.apache.derby.iapi.sql.compile.C_NodeTypes;
-
-import org.apache.derby.iapi.error.StandardException;
-import org.apache.derby.iapi.services.sanity.SanityManager;
-
-import org.apache.derby.iapi.services.compiler.MethodBuilder;
-
 import org.apache.derby.iapi.store.access.ColumnOrdering;
 import org.apache.derby.iapi.store.access.SortCostController;
-
 import org.apache.derby.iapi.types.DataValueDescriptor;
-
-import org.apache.derby.iapi.reference.ClassName;
-import org.apache.derby.iapi.reference.Limits;
-import org.apache.derby.iapi.reference.SQLState;
-
 import org.apache.derby.iapi.util.JBitSet;
-import org.apache.derby.iapi.services.classfile.VMOpcode;
 
 /**
  * An OrderByList is an ordered list of columns in the ORDER BY clause.
@@ -53,7 +48,7 @@ import org.apache.derby.iapi.services.cl
  * and the last column in the list is the least significant.
  *
  */
-public class OrderByList extends OrderedColumnList
+class OrderByList extends OrderedColumnList
 						implements RequiredRowOrdering {
 
 	private boolean allAscending = true;
@@ -74,12 +69,17 @@ public class OrderByList extends Ordered
     private boolean isTableValueCtorOrdering;
 
     /**
+     * Constructor.
      * Initialize with the type of the result set this {@code OrderByList} is
      * attached to, e.g. {@code SELECT}, {@code VALUES} or a set operation.
-     * @param rs The result set this {@code OrderByList} is ordering.
+     * @param rs The result set this {@code OrderByList} is ordering. May be
+     *           null
+     * @param cm The context manager
     */
-   public void init(Object rs) {
-        this.isTableValueCtorOrdering =
+   OrderByList(ResultSetNode rs, ContextManager cm) {
+       super(cm);
+       setNodeType(C_NodeTypes.ORDER_BY_LIST);
+       this.isTableValueCtorOrdering =
                 (rs instanceof UnionNode &&
                 ((UnionNode)rs).tableConstructor()) ||
                 rs instanceof RowResultSetNode;
@@ -90,7 +90,7 @@ public class OrderByList extends Ordered
 	
 		@param column	The column to add to the list
 	 */
-	public void addOrderByColumn(OrderByColumn column) 
+    void addOrderByColumn(OrderByColumn column)
 	{
 		addElement(column);
 
@@ -113,7 +113,7 @@ public class OrderByList extends Ordered
 	
 		@param position	The column to get from the list
 	 */
-	public OrderByColumn getOrderByColumn(int position) {
+    OrderByColumn getOrderByColumn(int position) {
 		if (SanityManager.DEBUG)
 		SanityManager.ASSERT(position >=0 && position < size());
 		return (OrderByColumn) elementAt(position);
@@ -126,7 +126,7 @@ public class OrderByList extends Ordered
 	 * 	@param target	The underlying result set
 	 *	@exception StandardException		Thrown on error
 	 */
-	public void bindOrderByColumns(ResultSetNode target)
+    void bindOrderByColumns(ResultSetNode target)
 					throws StandardException {
 
 		/* Remember the target for use in optimization */
@@ -188,7 +188,7 @@ public class OrderByList extends Ordered
 		@param target	The underlying result set
 	
 	 */
-	public void pullUpOrderByColumns(ResultSetNode target)
+    void pullUpOrderByColumns(ResultSetNode target)
 					throws StandardException {
 
 		/* Remember the target for use in optimization */
@@ -214,12 +214,10 @@ public class OrderByList extends Ordered
 	 */
 	boolean isInOrderPrefix(ResultColumnList sourceRCL)
 	{
-		boolean inOrderPrefix = true;
-		int rclSize = sourceRCL.size();
-
 		if (SanityManager.DEBUG)
 		{
-			if (size() > sourceRCL.size())
+            int rclSize = sourceRCL.size();
+            if (size() > rclSize)
 			{
 				SanityManager.THROWASSERT(
 					"size() (" + size() + 
@@ -267,9 +265,7 @@ public class OrderByList extends Ordered
 	ResultColumnList reorderRCL(ResultColumnList resultColumns)
 		throws StandardException
 	{
-		ResultColumnList newRCL = (ResultColumnList) getNodeFactory().getNode(
-												C_NodeTypes.RESULT_COLUMN_LIST,
-												getContextManager());
+        ResultColumnList newRCL = new ResultColumnList(getContextManager());
 
 		/* The new RCL starts with the ordering columns */
 		int size = size();
@@ -843,10 +839,10 @@ public class OrderByList extends Ordered
 		return false;
 	}
 
-
+    @Override
 	public String toString() {
 
-		StringBuffer buff = new StringBuffer();
+        StringBuilder buff = new StringBuilder();
 
 		if (columnOrdering != null) {
 			for (int i = 0; i < columnOrdering.length; i++) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByNode.java?rev=1495305&r1=1495304&r2=1495305&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/OrderByNode.java Fri Jun 21 07:47:47 2013
@@ -21,10 +21,13 @@
 
 package	org.apache.derby.impl.sql.compile;
 
+import java.util.Properties;
 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.services.sanity.SanityManager;
 import org.apache.derby.iapi.sql.ResultColumnDescriptor;
+import org.apache.derby.iapi.sql.compile.C_NodeTypes;
 
 /**
  * An OrderByNode represents a result set for a sort operation
@@ -33,54 +36,48 @@ import org.apache.derby.iapi.sql.ResultC
  * is required.
  *
  */
-public class OrderByNode extends SingleChildResultSetNode
+class OrderByNode extends SingleChildResultSetNode
 {
 
 	OrderByList		orderByList;
 
 	/**
-	 * Initializer for a OrderByNode.
+     * Constructor for a OrderByNode.
 	 *
-	 * @param childResult	The child ResultSetNode
+     * @param childRes      The child ResultSetNode
 	 * @param orderByList	The order by list.
  	 * @param tableProperties	Properties list associated with the table
-    *
+     * @param cm            The context manager
+     *
 	 * @exception StandardException		Thrown on error
 	 */
-	public void init(
-						Object childResult,
-						Object orderByList,
-						Object tableProperties)
-		throws StandardException
-	{
-		ResultSetNode child = (ResultSetNode) childResult;
-
-		super.init(childResult, tableProperties);
-
-		this.orderByList = (OrderByList) orderByList;
-
-		ResultColumnList prRCList;
-
-		/*
-			We want our own resultColumns, which are virtual columns
-			pointing to the child result's columns.
-
-			We have to have the original object in the distinct node,
-			and give the underlying project the copy.
-		 */
-
-		/* We get a shallow copy of the ResultColumnList and its 
-		 * ResultColumns.  (Copy maintains ResultColumn.expression for now.)
-		 */
-		prRCList = child.getResultColumns().copyListAndObjects();
-		resultColumns = child.getResultColumns();
-		child.setResultColumns(prRCList);
+    OrderByNode(ResultSetNode childRes,
+                OrderByList orderByList,
+                Properties tableProperties,
+                ContextManager cm) throws StandardException {
+        super(childRes, tableProperties, cm);
+        setNodeType(C_NodeTypes.ORDER_BY_NODE);
+
+        this.orderByList = orderByList;
+
+        // We want our own resultColumns, which are virtual columns pointing to
+        // the child result's columns.
+        //
+        // We have to have the original object in the distinct node, and give
+        // the underlying project the copy.
+        //
+        // We get a shallow copy of the ResultColumnList and its ResultColumns.
+        // (Copy maintains ResultColumn.expression for now.)
+        final ResultColumnList prRCList =
+            childRes.getResultColumns().copyListAndObjects();
+        this.resultColumns = childRes.getResultColumns();
+        childRes.setResultColumns(prRCList);
 
 		/* Replace ResultColumn.expression with new VirtualColumnNodes
 		 * in the DistinctNode's RCL.  (VirtualColumnNodes include
 		 * pointers to source ResultSetNode, this, and source ResultColumn.)
 		 */
-		resultColumns.genVirtualColumnNodes(this, prRCList);
+        this.resultColumns.genVirtualColumnNodes(this, prRCList);
 	}
 
 
@@ -90,8 +87,8 @@ public class OrderByNode extends SingleC
 	 *
 	 * @param depth		The depth of this node in the tree
 	 */
-
-	public void printSubNodes(int depth)
+    @Override
+    void printSubNodes(int depth)
 	{
 		if (SanityManager.DEBUG)
 		{
@@ -105,7 +102,7 @@ public class OrderByNode extends SingleC
 		}
 	}
 
-
+    @Override
 	ResultColumnDescriptor[] makeResultDescriptors()
 	{
 	    return childResult.makeResultDescriptors();
@@ -113,10 +110,11 @@ public class OrderByNode extends SingleC
 
     /**
      * generate the distinct result set operating over the source
-	 * resultset.
+     * result set.
      *
 	 * @exception StandardException		Thrown on error
      */
+    @Override
     void generate(ActivationClassBuilder acb, MethodBuilder mb)
 							throws StandardException
 	{



Mime
View raw message