You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2014/02/14 19:28:22 UTC

svn commit: r1568436 [2/2] - /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java?rev=1568436&r1=1568435&r2=1568436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ProjectRestrictNode.java Fri Feb 14 18:28:21 2014
@@ -113,7 +113,7 @@ class ProjectRestrictNode extends Single
                         ContextManager   cm)
 	{
         super(childResult, tableProperties, cm);
-        resultColumns = projection;
+        setResultColumns( projection );
         this.restriction = restriction;
         this.restrictionList = restrictionList;
         this.projectSubquerys = projectSubquerys;
@@ -246,7 +246,7 @@ class ProjectRestrictNode extends Single
 
 		CostEstimate childCost;
 
-		costEstimate = getCostEstimate(optimizer);
+		setCostEstimate( getCostEstimate( optimizer ) );
 
 		/*
 		** Don't re-optimize a child result set that has already been fully
@@ -286,7 +286,7 @@ class ProjectRestrictNode extends Single
 															outerCost,
 															rowOrdering);
 			/* Copy child cost to this node's cost */
-			costEstimate.setCost(
+			getCostEstimate().setCost(
 							childCost.getEstimatedCost(),
 							childCost.rowCount(),
 							childCost.singleScanRowCount());
@@ -320,9 +320,9 @@ class ProjectRestrictNode extends Single
 											   outerCost.rowCount());
 
 			/* Copy child cost to this node's cost */
-			childCost = childResult.costEstimate;
+			childCost = childResult.getCostEstimate();
 
-			costEstimate.setCost(
+			getCostEstimate().setCost(
 							childCost.getEstimatedCost(),
 							childCost.rowCount(),
 							childCost.singleScanRowCount());
@@ -370,7 +370,7 @@ class ProjectRestrictNode extends Single
 			optimizer.considerCost(this, restrictionList, getCostEstimate(), outerCost);
 		}
 
-		return costEstimate;
+		return getCostEstimate();
 	}
 
 	/**
@@ -1028,7 +1028,7 @@ class ProjectRestrictNode extends Single
 		childResult = childResult.preprocess(numTables, gbl, fromList);
 
 		/* Build the referenced table map */
-		referencedTableMap = (JBitSet) childResult.getReferencedTableMap().clone();
+		setReferencedTableMap( (JBitSet) childResult.getReferencedTableMap().clone() );
 
 		return this;
 	}
@@ -1064,7 +1064,7 @@ class ProjectRestrictNode extends Single
 
 		/* Build a list of the single table predicates that we can push down */
         PredicateList pushPList =
-                predicateList.getPushablePredicates(referencedTableMap);
+            predicateList.getPushablePredicates(getReferencedTableMap());
 
 		/* If this is a PRN above a SelectNode, probably due to a 
 		 * view or derived table which couldn't be flattened, then see
@@ -1210,9 +1210,9 @@ class ProjectRestrictNode extends Single
 
 		// RESOLVE: SHOULD FACTOR IN THE NON-OPTIMIZABLE PREDICATES THAT
 		// WERE NOT PUSHED DOWN
-        costEstimate = getOptimizerFactory().getCostEstimate();
+        setCostEstimate( getOptimizerFactory().getCostEstimate() );
 
-		costEstimate.setCost(childResult.getCostEstimate().getEstimatedCost(),
+		getCostEstimate().setCost(childResult.getCostEstimate().getEstimatedCost(),
 							childResult.getCostEstimate().rowCount(),
 							childResult.getCostEstimate().singleScanRowCount());
 
@@ -1234,11 +1234,13 @@ class ProjectRestrictNode extends Single
 		** that optimization was done directly on the child node,
 		** in which case the cost estimate will be null here.
 		*/
-		if (costEstimate == null)
+		if (super.getCostEstimate() == null)
+        {
 			return childResult.getCostEstimate();
+        }
 		else
 		{
-			return costEstimate;
+			return super.getCostEstimate();
 		}
 	}
 
@@ -1252,20 +1254,26 @@ class ProjectRestrictNode extends Single
     CostEstimate getFinalCostEstimate()
 		throws StandardException
 	{
-		if (finalCostEstimate != null)
-		// we already set it, so just return it.
-			return finalCostEstimate;
+		if (getCandidateFinalCostEstimate() != null)
+        {
+            // we already set it, so just return it.
+			return getCandidateFinalCostEstimate();
+        }
 
 		// If the child result set is an Optimizable, then this node's
 		// final cost is that of the child.  Otherwise, this node must
 		// hold "trulyTheBestAccessPath" for it's child so we pull
 		// the final cost from there.
 		if (childResult instanceof Optimizable)
-			finalCostEstimate = childResult.getFinalCostEstimate();
+        {
+			setCandidateFinalCostEstimate( childResult.getFinalCostEstimate() );
+        }
 		else
-			finalCostEstimate = getTrulyTheBestAccessPath().getCostEstimate();
+        {
+			setCandidateFinalCostEstimate( getTrulyTheBestAccessPath().getCostEstimate() );
+        }
 
-		return finalCostEstimate;
+		return getCandidateFinalCostEstimate();
 	}
 
     /**
@@ -1285,7 +1293,7 @@ class ProjectRestrictNode extends Single
 							throws StandardException
 	{
 		if (SanityManager.DEBUG)
-        SanityManager.ASSERT(resultColumns != null, "Tree structure bad");
+            SanityManager.ASSERT(getResultColumns() != null, "Tree structure bad");
 
         //
         // If we are projecting and restricting the stream from a table
@@ -1310,6 +1318,7 @@ class ProjectRestrictNode extends Single
 	 *
 	 * @exception StandardException		Thrown on error
 	 */
+
     @Override
     void generateResultSet(ExpressionClassBuilder acb, MethodBuilder mb)
 									throws StandardException
@@ -1346,7 +1355,7 @@ class ProjectRestrictNode extends Single
 				childResult.generateResultSet(acb, mb);
 			else
 				childResult.generate((ActivationClassBuilder)acb, mb);
-			costEstimate = childResult.getFinalCostEstimate();
+			setCostEstimate( childResult.getFinalCostEstimate() );
 			return;
 		}
 
@@ -1385,7 +1394,7 @@ class ProjectRestrictNode extends Single
 		// Map the result columns to the source columns
 
         ResultColumnList.ColumnMapping mappingArrays =
-            resultColumns.mapSourceColumns();
+            getResultColumns().mapSourceColumns();
 
         int[] mapArray = mappingArrays.mapArray;
         boolean[] cloneMap = mappingArrays.cloneMap;
@@ -1454,15 +1463,15 @@ class ProjectRestrictNode extends Single
 		 */
 		if (projectSubquerys != null && projectSubquerys.size() > 0)
 		{
-			projectSubquerys.setPointOfAttachment(resultSetNumber);
+			projectSubquerys.setPointOfAttachment(getResultSetNumber());
 		}
 		if (restrictSubquerys != null && restrictSubquerys.size() > 0)
 		{
-			restrictSubquerys.setPointOfAttachment(resultSetNumber);
+			restrictSubquerys.setPointOfAttachment(getResultSetNumber());
 		}
 
 		// Load our final cost estimate.
-		costEstimate = getFinalCostEstimate();
+		setCostEstimate( getFinalCostEstimate() );
 
 		// if there is no restriction, we just want to pass null.
 		if (restriction == null)
@@ -1517,14 +1526,14 @@ class ProjectRestrictNode extends Single
 			// as-is, with the performance trade-off as discussed above.)
 
 			/* Generate the Row function for the projection */
-			resultColumns.generateCore(acb, mb, false);
+			getResultColumns().generateCore(acb, mb, false);
 		}
 		else
 		{
 		   	mb.pushNull(ClassName.GeneratedMethod);
 		}
 		
-		mb.push(resultSetNumber);
+		mb.push(getResultSetNumber());
 
 		// if there is no constant restriction, we just want to pass null.
 		if (constantRestriction == null)
@@ -1566,10 +1575,10 @@ class ProjectRestrictNode extends Single
 		
 		mb.push(mapArrayItem);
         mb.push(cloneMapItem);
-		mb.push(resultColumns.reusableResult());
+		mb.push(getResultColumns().reusableResult());
 		mb.push(doesProjection);
-		mb.push(costEstimate.rowCount());
-		mb.push(costEstimate.getEstimatedCost());
+		mb.push(getCostEstimate().rowCount());
+		mb.push(getCostEstimate().getEstimatedCost());
 
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getProjectRestrictResultSet",
                     ClassName.NoPutResultSet, 11);
@@ -1664,14 +1673,14 @@ class ProjectRestrictNode extends Single
 				/* We get a shallow copy of the ResultColumnList and its 
 				 * ResultColumns.  (Copy maintains ResultColumn.expression for now.)
 				 */
-				prRCList = resultColumns;
-				setResultColumns(resultColumns.copyListAndObjects());
+				prRCList = getResultColumns();
+				setResultColumns(getResultColumns().copyListAndObjects());
 
 				/* Replace ResultColumn.expression with new VirtualColumnNodes
 				 * in the NormalizeResultSetNode's ResultColumnList.  (VirtualColumnNodes include
 				 * pointers to source ResultSetNode, this, and source ResultColumn.)
 				 */
-				prRCList.genVirtualColumnNodes(this, resultColumns);
+				prRCList.genVirtualColumnNodes(this, getResultColumns());
 
 				/* Finally, we create the new MaterializeResultSetNode */
                 mrsn = new MaterializeResultSetNode(
@@ -1680,9 +1689,9 @@ class ProjectRestrictNode extends Single
 									tableProperties,
 									getContextManager());
 				// Propagate the referenced table map if it's already been created
-				if (referencedTableMap != null)
+				if (getReferencedTableMap() != null)
 				{
-					mrsn.setReferencedTableMap((JBitSet) referencedTableMap.clone());
+					mrsn.setReferencedTableMap((JBitSet) getReferencedTableMap().clone());
 				}
 				return mrsn;
 			}
@@ -1779,7 +1788,7 @@ class ProjectRestrictNode extends Single
 
 		HashSet<BaseColumnNode> columns = new HashSet<BaseColumnNode>();
 
-        for (ResultColumn rc : resultColumns) {
+        for (ResultColumn rc : getResultColumns()) {
 			BaseColumnNode bc = rc.getBaseColumnNode();
 			if (bc == null) return false;
 			columns.add(bc);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java?rev=1568436&r1=1568435&r2=1568436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultSetNode.java Fri Feb 14 18:28:21 2014
@@ -60,22 +60,22 @@ import org.apache.derby.shared.common.sa
 
 public abstract class ResultSetNode extends QueryTreeNode
 {
-	int					resultSetNumber;
+	private int					resultSetNumber;
 	/* Bit map of referenced tables under this ResultSetNode */
-	JBitSet				referencedTableMap;
-	ResultColumnList	resultColumns;
-	boolean				statementResultSet;
-	boolean				cursorTargetTable;
-	boolean				insertSource;
-
-	CostEstimate 		costEstimate;
-	CostEstimate		scratchCostEstimate;
-	Optimizer			optimizer;
+	private JBitSet				referencedTableMap;
+	private ResultColumnList	resultColumns;
+	private boolean				statementResultSet;
+	private boolean				cursorTargetTable;
+	private boolean				insertSource;
+
+	private CostEstimate 		costEstimate;
+	private CostEstimate		scratchCostEstimate;
+	private Optimizer			optimizer;
 
 	// Final cost estimate for this result set node, which is the estimate
 	// for this node with respect to the best join order for the top-level
 	// query. Subclasses will set this value where appropriate.
-	CostEstimate		finalCostEstimate;
+	private CostEstimate		candidateFinalCostEstimate;
 
     ResultSetNode(ContextManager cm) {
         super(cm);
@@ -127,17 +127,35 @@ public abstract class ResultSetNode exte
 		}
 	}
 
+    /** Return true if this is a statement result set */
+    boolean isStatementResultSet() { return statementResultSet; }
+
+    /** Return true if this is a cursor target table */
+    boolean isCursorTargetTable() { return cursorTargetTable; }
+
+    /** Set whether this is a cursor target table */
+    void    setCursorTargetTable( boolean yesOrNo ) { cursorTargetTable = yesOrNo; }
+
+    /** Get the scratch estimate */
+    CostEstimate    getScratchCostEstimate() { return scratchCostEstimate; }
+
+    /** Set the scratch estimate */
+    void    setScratchCostEstimate( CostEstimate ce ) { scratchCostEstimate = ce; }
+
 	/**
 	 * Get the resultSetNumber in this ResultSetNode. Expected to be set during
-	 * generate().
+	 * generate(). Must be public in order to satisfy the Optimizable contract.
 	 *
 	 * @return int 	The resultSetNumber.
 	 */
 
-	public int getResultSetNumber()
+    public  int getResultSetNumber()
 	{
 		return resultSetNumber;
 	}
+    
+    void    setResultSetNumber( int rsn ) { resultSetNumber = rsn; }
+    
 
 	/**
 	 * Get the CostEstimate for this ResultSetNode.
@@ -146,18 +164,12 @@ public abstract class ResultSetNode exte
 	 */
     CostEstimate getCostEstimate()
 	{
-		if (SanityManager.DEBUG)
-		{
-			if (costEstimate == null)
-			{
-				SanityManager.THROWASSERT(
-					"costEstimate is not expected to be null for " +
-					getClass().getName());
-			}
-		}
 		return costEstimate;
 	}
 
+    /** Set the CostEstimate for this ResultSetNode */
+    void    setCostEstimate( CostEstimate ce ) { costEstimate = ce; }
+
 	/**
 	 * Get the final CostEstimate for this ResultSetNode.
 	 *
@@ -168,16 +180,22 @@ public abstract class ResultSetNode exte
 	{
 		if (SanityManager.DEBUG)
 		{
-			if (finalCostEstimate == null)
+			if (candidateFinalCostEstimate == null)
 			{
 				SanityManager.THROWASSERT(
-					"finalCostEstimate is not expected to be null for " +
+					"candidateFinalCostEstimate is not expected to be null for " +
 					getClass().getName());
 			}
 		}
-		return finalCostEstimate;
+		return candidateFinalCostEstimate;
 	}
 
+    /** Get the final cost estimate which we've set so far */
+    CostEstimate    getCandidateFinalCostEstimate() { return candidateFinalCostEstimate; }
+
+    /** Set the final cost estimate */
+    void    setCandidateFinalCostEstimate( CostEstimate ce ) { candidateFinalCostEstimate = ce; }
+
 	/**
 	 * Assign the next resultSetNumber to the resultSetNumber in this ResultSetNode. 
 	 * Expected to be done during generate().
@@ -315,6 +333,9 @@ public abstract class ResultSetNode exte
 		insertSource = true;
 	}
 
+    /** Return true if this is the source result set for an INSERT */
+    boolean isInsertSource() { return insertSource; }
+    
 	/**
 	 * Verify that a SELECT * is valid for this type of subquery.
 	 *
@@ -797,7 +818,8 @@ public abstract class ResultSetNode exte
 	}
 
 	/**
-	 * Get the referencedTableMap for this ResultSetNode
+	 * Get the referencedTableMap for this ResultSetNode. Must be public
+     * in order to satisfy the Optimizable contract.
 	 *
 	 * @return JBitSet	Referenced table map for this ResultSetNode
 	 */
@@ -1497,6 +1519,12 @@ public abstract class ResultSetNode exte
 		return (OptimizerImpl)optimizer;
 	}
 
+    /** Get the optimizer being used on this result set */
+    Optimizer   getOptimizer()  { return optimizer; }
+
+    /** Set the optimizer for use on this result set */
+    void    setOptimizer( Optimizer opt ) { optimizer = opt; }
+
 	/**
 	 * Get a cost estimate to use for this ResultSetNode.
 	 *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowCountNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowCountNode.java?rev=1568436&r1=1568435&r2=1568436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowCountNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowCountNode.java Fri Feb 14 18:28:21 2014
@@ -78,7 +78,7 @@ public final class RowCountNode extends 
         throws StandardException {
 
         super(childResult, null, cm);
-        resultColumns = rcl;
+        setResultColumns( rcl );
 
         this.offset = offset;
         this.fetchFirst = fetchFirst;
@@ -103,14 +103,14 @@ public final class RowCountNode extends 
          */
         assignResultSetNumber();
 
-        costEstimate = childResult.getFinalCostEstimate();
+        setCostEstimate( childResult.getFinalCostEstimate() );
 
         acb.pushGetResultSetFactoryExpression(mb);
 
         childResult.generate(acb, mb); // arg1
 
         acb.pushThisAsActivation(mb);  // arg2
-        mb.push(resultSetNumber);      // arg3
+        mb.push(getResultSetNumber());      // arg3
 
         boolean dynamicOffset = false;
         boolean dynamicFetchFirst = false;
@@ -131,8 +131,8 @@ public final class RowCountNode extends 
 
         mb.push( hasJDBClimitClause );  // arg6
 
-        mb.push(costEstimate.rowCount()); // arg7
-        mb.push(costEstimate.getEstimatedCost()); // arg8
+        mb.push(getCostEstimate().rowCount()); // arg7
+        mb.push(getCostEstimate().getEstimatedCost()); // arg8
 
         mb.callMethod(VMOpcode.INVOKEINTERFACE,
                       (String) null,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java?rev=1568436&r1=1568435&r2=1568436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/RowResultSetNode.java Fri Feb 14 18:28:21 2014
@@ -68,10 +68,10 @@ class RowResultSetNode extends FromTable
                      Properties tableProperties,
                      ContextManager cm) {
         super(null /* correlationName */, tableProperties, cm);
-        resultColumns = valuesClause;
+        setResultColumns( valuesClause );
 
-        if (resultColumns != null) {
-			resultColumns.markInitialSize();
+        if (getResultColumns() != null) {
+			getResultColumns().markInitialSize();
         }
 	}
 
@@ -116,8 +116,8 @@ class RowResultSetNode extends FromTable
 			InsertNode target, boolean inOrder, int[] colMap)
 		throws StandardException
 	{
-		if (!inOrder || resultColumns.size() < target.resultColumnList.size()) {
-			resultColumns = getRCLForInsert(target, colMap);
+		if (!inOrder || getResultColumns().size() < target.resultColumnList.size()) {
+			setResultColumns( getRCLForInsert(target, colMap) );
 		}
 		return this;
 	}
@@ -144,17 +144,17 @@ class RowResultSetNode extends FromTable
 		** fetched.  Is this true, and if not, does it make a difference?
 		** There's nothing to optimize in this case.
 		*/
-		if (costEstimate == null)
+		if (getCostEstimate() == null)
 		{
-			costEstimate = getOptimizerFactory().getCostEstimate();
+			setCostEstimate( getOptimizerFactory().getCostEstimate() );
 		}
 
-		costEstimate.setCost(0.0d, 1.0d, 1.0d);
+		getCostEstimate().setCost(0.0d, 1.0d, 1.0d);
 
 		/* A single row is always ordered */
 		rowOrdering.optimizableAlwaysOrdered(this);
 
-		return costEstimate;
+		return getCostEstimate();
 	}
 
 	/**
@@ -205,7 +205,7 @@ class RowResultSetNode extends FromTable
 		 *		VALUES DEFAULT;
 		 * so we need to check for that here and throw an exception if found.
 		 */
-		resultColumns.checkForInvalidDefaults();
+		getResultColumns().checkForInvalidDefaults();
 
 		/* Believe it or not, a values clause can contain correlated column references
 		 * and subqueries.  In order to get correlated column resolution working 
@@ -224,7 +224,7 @@ class RowResultSetNode extends FromTable
 		}
 		setLevel(nestingLevel);
 		fromListParam.insertElementAt(this, 0);
-		resultColumns.bindExpressions(fromListParam, subquerys,
+		getResultColumns().bindExpressions(fromListParam, subquerys,
                                       aggregates);
 		// Pop ourselves back out of the FROM list
 		fromListParam.removeElementAt(0);
@@ -234,7 +234,7 @@ class RowResultSetNode extends FromTable
 			throw StandardException.newException(SQLState.LANG_NO_AGGREGATES_IN_WHERE_CLAUSE);
 		}
 
-		SelectNode.checkNoWindowFunctions(resultColumns, "VALUES");
+		SelectNode.checkNoWindowFunctions(getResultColumns(), "VALUES");
 
         for (int i = 0; i < qec.size(); i++) {
             final OrderByList obl = qec.getOrderByList(i);
@@ -301,9 +301,9 @@ class RowResultSetNode extends FromTable
 		** in our RCL.
 		*/
 		if (bindingRCL == null)
-			bindingRCL = resultColumns;
+			bindingRCL = getResultColumns();
 
-		resultColumns.bindUntypedNullsToResultColumns(bindingRCL);
+		getResultColumns().bindUntypedNullsToResultColumns(bindingRCL);
 	}
 
 	/**
@@ -433,8 +433,8 @@ class RowResultSetNode extends FromTable
 		}
 
 		/* Allocate a dummy referenced table map */ 
-		referencedTableMap = new JBitSet(numTables);
-		referencedTableMap.set(tableNumber);
+		setReferencedTableMap( new JBitSet(numTables) );
+		getReferencedTableMap().set(tableNumber);
 
         // If we have more than 1 ORDERBY columns, we may be able to
         // remove duplicate columns, e.g., "ORDER BY 1, 1, 2".
@@ -495,14 +495,14 @@ class RowResultSetNode extends FromTable
 		/* We get a shallow copy of the ResultColumnList and its 
 		 * ResultColumns.  (Copy maintains ResultColumn.expression for now.)
 		 */
-		prRCList = resultColumns;
-		resultColumns = resultColumns.copyListAndObjects();
+		prRCList = getResultColumns();
+		setResultColumns( getResultColumns().copyListAndObjects() );
 
 		/* Replace ResultColumn.expression with new VirtualColumnNodes
 		 * in the ProjectRestrictNode's ResultColumnList.  (VirtualColumnNodes include
 		 * pointers to source ResultSetNode, this, and source ResultColumn.)
 		 */
-		prRCList.genVirtualColumnNodes(this, resultColumns);
+		prRCList.genVirtualColumnNodes(this, getResultColumns());
 
 		/* Put the new predicate in a list */
         predList = new PredicateList(getContextManager());
@@ -552,7 +552,7 @@ class RowResultSetNode extends FromTable
 		** Don't flatten if select list contains something
 		** that isn't clonable
 		*/
-		if ( ! resultColumns.isCloneable())
+		if ( ! getResultColumns().isCloneable())
 		{
 			return false;
 		}
@@ -605,10 +605,10 @@ class RowResultSetNode extends FromTable
 		** CostEstimate object, so we can represent the cost of this node.
 		** This seems like overkill, but it's just an object allocation...
 		*/
-        costEstimate = getOptimizerFactory().getCostEstimate();
+        setCostEstimate( getOptimizerFactory().getCostEstimate() );
 
 		// RESOLVE: THE COST SHOULD TAKE SUBQUERIES INTO ACCOUNT
-		costEstimate.setCost(0.0d, outerRows, outerRows);
+		getCostEstimate().setCost(0.0d, outerRows, outerRows);
 
 		subquerys.optimize(dataDictionary, outerRows);
 		return this;
@@ -700,14 +700,14 @@ class RowResultSetNode extends FromTable
 			throws StandardException
 	{
 		if (SanityManager.DEBUG)
-			SanityManager.ASSERT(resultColumns.visibleSize() <= typeColumns.size(),
+			SanityManager.ASSERT(getResultColumns().visibleSize() <= typeColumns.size(),
 				"More columns in ResultColumnList than in base table");
 
 		/* Look for ? parameters in the result column list */
-		int rclSize = resultColumns.size();
+		int rclSize = getResultColumns().size();
 		for (int index = 0; index < rclSize; index++)
 		{
-            ResultColumn rc = resultColumns.elementAt(index);
+            ResultColumn rc = getResultColumns().elementAt(index);
 			ValueNode re = rc.getExpression();
 
 			if (re.requiresTypeFromContext())
@@ -845,10 +845,10 @@ class RowResultSetNode extends FromTable
 							throws StandardException
 	{
 		if (SanityManager.DEBUG)
-        SanityManager.ASSERT(resultColumns != null, "Tree structure bad");
+            SanityManager.ASSERT(getResultColumns() != null, "Tree structure bad");
 
 		// Get our final cost estimate.
-		costEstimate = getFinalCostEstimate();
+		setCostEstimate( getFinalCostEstimate() );
 
 		/*
 		** Check and see if everything below us is a constant or not.
@@ -881,11 +881,11 @@ class RowResultSetNode extends FromTable
 		acb.pushGetResultSetFactoryExpression(mb);
 
 		acb.pushThisAsActivation(mb);
-		resultColumns.generate(acb, mb);
+		getResultColumns().generate(acb, mb);
 		mb.push(canCache);
-		mb.push(resultSetNumber);
-		mb.push(costEstimate.rowCount());
-		mb.push(costEstimate.getEstimatedCost());
+		mb.push(getResultSetNumber());
+		mb.push(getCostEstimate().rowCount());
+		mb.push(getCostEstimate().getEstimatedCost());
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getRowResultSet",
                 ClassName.NoPutResultSet, 6);
 	}
@@ -899,7 +899,7 @@ class RowResultSetNode extends FromTable
                                  boolean allowDefaults)
 		throws StandardException
 	{
-		resultColumns.replaceOrForbidDefaults(ttd, tcl, allowDefaults);
+		getResultColumns().replaceOrForbidDefaults(ttd, tcl, allowDefaults);
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ScrollInsensitiveResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ScrollInsensitiveResultSetNode.java?rev=1568436&r1=1568435&r2=1568436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ScrollInsensitiveResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ScrollInsensitiveResultSetNode.java Fri Feb 14 18:28:21 2014
@@ -52,7 +52,7 @@ class ScrollInsensitiveResultSetNode  ex
                             Properties tableProperties,
                             ContextManager cm) {
         super(childResult, tableProperties, cm);
-        resultColumns = rcl;
+        setResultColumns( rcl );
 	}
 
     /**
@@ -65,7 +65,7 @@ class ScrollInsensitiveResultSetNode  ex
 							throws StandardException
 	{
 		if (SanityManager.DEBUG)
-        SanityManager.ASSERT(resultColumns != null, "Tree structure bad");
+            SanityManager.ASSERT(getResultColumns() != null, "Tree structure bad");
 
 		/* Get the next ResultSet #, so that we can number this ResultSetNode, its
 		 * ResultColumnList and ResultSet.
@@ -77,7 +77,7 @@ class ScrollInsensitiveResultSetNode  ex
 		// Generate the child ResultSet
 
 		// Get the cost estimate for the child
-		costEstimate = childResult.getFinalCostEstimate();
+		setCostEstimate( childResult.getFinalCostEstimate() );
 
 		int erdNumber = acb.addItem(makeResultDescription());
 
@@ -85,15 +85,15 @@ class ScrollInsensitiveResultSetNode  ex
 
 		childResult.generate(acb, mb);
 		acb.pushThisAsActivation(mb);
-		mb.push(resultSetNumber);
-		mb.push(resultColumns.size());
+		mb.push(getResultSetNumber());
+		mb.push(getResultColumns().size());
 
 		mb.pushThis();
 		mb.callMethod(VMOpcode.INVOKEVIRTUAL, ClassName.BaseActivation, "getScrollable",
 						"boolean", 0);
 
-		mb.push(costEstimate.rowCount());
-		mb.push(costEstimate.getEstimatedCost());
+		mb.push(getCostEstimate().rowCount());
+		mb.push(getCostEstimate().getEstimatedCost());
 
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getScrollInsensitiveResultSet",
 						ClassName.NoPutResultSet, 7);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java?rev=1568436&r1=1568435&r2=1568436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java Fri Feb 14 18:28:21 2014
@@ -144,10 +144,10 @@ class SelectNode extends ResultSetNode
         /* RESOLVE -
 		 * Consider adding selectAggregates and whereAggregates 
 		 */
-        resultColumns = selectList;
+        setResultColumns( selectList );
 
-        if (resultColumns != null) {
-			resultColumns.markInitialSize();
+        if (getResultColumns() != null) {
+			getResultColumns().markInitialSize();
         }
 
         this.fromList = fromList;
@@ -179,7 +179,7 @@ class SelectNode extends ResultSetNode
 			}
 		}
 
-		if (resultColumns != null) {
+		if (getResultColumns() != null) {
 
             // Collect simply contained window functions (note: *not*
             // any inside nested SELECTs) used in result columns, and
@@ -188,7 +188,7 @@ class SelectNode extends ResultSetNode
 			CollectNodesVisitor<WindowFunctionNode> cnvw =
                 new CollectNodesVisitor<WindowFunctionNode>(WindowFunctionNode.class,
                                         SelectNode.class);
-			resultColumns.accept(cnvw);
+			getResultColumns().accept(cnvw);
 			windowFuncCalls = cnvw.getList();
 
 			for (int i=0; i < windowFuncCalls.size(); i++) {
@@ -387,7 +387,7 @@ class SelectNode extends ResultSetNode
 			return null;
 
 		// Loop through the result columns looking for a match
-        for (ResultColumn rc : resultColumns)
+        for (ResultColumn rc : getResultColumns())
 		{
 			if (! (rc.getExpression() instanceof ColumnReference))
 				return null;
@@ -522,7 +522,7 @@ class SelectNode extends ResultSetNode
 		int numDistinctAggs;
 
         if (SanityManager.DEBUG) {
-            SanityManager.ASSERT(fromList != null && resultColumns != null,
+            SanityManager.ASSERT(fromList != null && getResultColumns() != null,
                 "Both fromList and resultColumns are expected to be non-null");
         }
 
@@ -567,7 +567,7 @@ class SelectNode extends ResultSetNode
 
 		fromListParam.setWindows(windows);
 
-		resultColumns.bindExpressions(fromListParam, 
+		getResultColumns().bindExpressions(fromListParam, 
 									  selectSubquerys,
 									  selectAggregates);
 
@@ -690,7 +690,7 @@ class SelectNode extends ResultSetNode
 
   			VerifyAggregateExpressionsVisitor visitor = 
   				new VerifyAggregateExpressionsVisitor(groupByList);
-			resultColumns.accept(visitor);
+			getResultColumns().accept(visitor);
 		}       
 
 		/*
@@ -784,13 +784,13 @@ class SelectNode extends ResultSetNode
 		fromList.bindResultColumns(fromListParam);
 		super.bindResultColumns(fromListParam);
 		/* Only 1012 elements allowed in select list */
-		if (resultColumns.size() > Limits.DB2_MAX_ELEMENTS_IN_SELECT_LIST)
+		if (getResultColumns().size() > Limits.DB2_MAX_ELEMENTS_IN_SELECT_LIST)
 		{
 			throw StandardException.newException(SQLState.LANG_TOO_MANY_ELEMENTS);
 		}
 
         // DERBY-4407: A derived table must have at least one column.
-        if (resultColumns.size() == 0)
+        if (getResultColumns().size() == 0)
         {
             throw StandardException.newException(
                     SQLState.LANG_EMPTY_COLUMN_LIST);
@@ -855,7 +855,7 @@ class SelectNode extends ResultSetNode
 	void pushExpressionsIntoSelect(Predicate predicate)
 		throws StandardException
 	{
-		wherePredicates.pullExpressions(referencedTableMap.size(), predicate.getAndNode());
+		wherePredicates.pullExpressions(getReferencedTableMap().size(), predicate.getAndNode());
 		fromList.pushPredicates(wherePredicates);
 	}
 
@@ -872,7 +872,7 @@ class SelectNode extends ResultSetNode
     void verifySelectStarSubquery(FromList outerFromList, int subqueryType)
 					throws StandardException
 	{
-        for (ResultColumn rc : resultColumns) {
+        for (ResultColumn rc : getResultColumns()) {
             if (!(rc instanceof AllResultColumn)) {
                 continue;
             }
@@ -1057,7 +1057,7 @@ class SelectNode extends ResultSetNode
 		 * we can flatten/optimize any subqueries in the
 		 * select list.
 		 */
-		resultColumns.preprocess(numTables, 
+		getResultColumns().preprocess(numTables, 
 								 fromList, whereSubquerys,
 								 wherePredicates);
 
@@ -1121,7 +1121,7 @@ class SelectNode extends ResultSetNode
 		 */
 
 		// Flatten any flattenable FromSubquerys or JoinNodes
-		fromList.flattenFromTables(resultColumns, 
+		fromList.flattenFromTables(getResultColumns(), 
 								   wherePredicates, 
 								   whereSubquerys,
                                    groupByList,
@@ -1152,7 +1152,7 @@ class SelectNode extends ResultSetNode
                     if (obl.size() == 0)
                     {
                         qec.setOrderByList(i, null);
-                        resultColumns.removeOrderByColumns();
+                        getResultColumns().removeOrderByColumns();
                     }
                 }
             }
@@ -1195,11 +1195,11 @@ class SelectNode extends ResultSetNode
 		 */
 		if (isDistinct && groupByList == null)
 		{
-			int distinctTable =	resultColumns.allTopCRsFromSameTable();
+			int distinctTable =	getResultColumns().allTopCRsFromSameTable();
 			
 			if (distinctTable != -1)
 			{
-				if (fromList.returnsAtMostSingleRow(resultColumns, 
+				if (fromList.returnsAtMostSingleRow(getResultColumns(), 
 											   whereClause, wherePredicates,
 											   getDataDictionary()))
 				{
@@ -1230,7 +1230,7 @@ class SelectNode extends ResultSetNode
                     /* Order by list currently restricted to columns in select
                      * list, so we will always eliminate the order by here.
                      */
-                    if (obl.isInOrderPrefix(resultColumns))
+                    if (obl.isInOrderPrefix(getResultColumns()))
                     {
                         qec.setOrderByList(i, null);
                     }
@@ -1244,7 +1244,7 @@ class SelectNode extends ResultSetNode
                          */
                         newTop = genProjectRestrictForReordering();
                         obl.resetToSourceRCs();
-                        resultColumns = obl.reorderRCL(resultColumns);
+                        setResultColumns( obl.reorderRCL(getResultColumns()) );
                         newTop.getResultColumns().removeOrderByColumns();
                         qec.setOrderByList(i, null);
                     }
@@ -1266,18 +1266,18 @@ class SelectNode extends ResultSetNode
 		fromList.pushPredicates(wherePredicates);
 
 		/* Set up the referenced table map */
-		referencedTableMap = new JBitSet(numTables);
+		setReferencedTableMap( new JBitSet(numTables) );
 		int flSize = fromList.size();
 		for (int index = 0; index < flSize; index++)
 		{
-			referencedTableMap.or(((FromTable) fromList.elementAt(index)).
+			getReferencedTableMap().or(((FromTable) fromList.elementAt(index)).
 													getReferencedTableMap());
 		}
 
 		/* Copy the referenced table map to the new tree top, if necessary */
 		if (newTop != this)
 		{
-			newTop.setReferencedTableMap((JBitSet) referencedTableMap.clone());
+			newTop.setReferencedTableMap((JBitSet) getReferencedTableMap().clone());
 		}
 
 
@@ -1450,7 +1450,7 @@ class SelectNode extends ResultSetNode
 
 		/* Don't flatten if select list contains something that isn't cloneable.
 		 */
-		if (! resultColumns.isCloneable())
+		if (! getResultColumns().isCloneable())
 		{
 			return false;
 		}
@@ -1499,7 +1499,7 @@ class SelectNode extends ResultSetNode
 
         prnRSN = new ProjectRestrictNode(
                 fromList.elementAt(0),   /* Child ResultSet */
-                resultColumns,      /* Projection */
+                getResultColumns(),      /* Projection */
                 whereClause,            /* Restriction */
                 wherePredicates,/* Restriction as PredicateList */
                 selectSubquerys,/* Subquerys in Projection */
@@ -1531,7 +1531,7 @@ class SelectNode extends ResultSetNode
                     nestingLevel,
                     getContextManager());
 			gbn.considerPostOptimizeOptimizations(originalWhereClause != null);
-			gbn.assignCostEstimate(optimizer.getOptimizedCost());
+			gbn.assignCostEstimate(getOptimizer().getOptimizedCost());
 
 			groupByList = null;
 			prnRSN  = gbn.getParent();
@@ -1563,7 +1563,7 @@ class SelectNode extends ResultSetNode
 					getContextManager());
 
 			prnRSN = wrsn.getParent();
-			wrsn.assignCostEstimate(optimizer.getOptimizedCost());
+			wrsn.assignCostEstimate(getOptimizer().getOptimizedCost());
 		}
 
 
@@ -1572,7 +1572,7 @@ class SelectNode extends ResultSetNode
 		{
 			// We first verify that a distinct is valid on the
 			// RCL.
-			resultColumns.verifyAllOrderable();
+			getResultColumns().verifyAllOrderable();
 
 			/* See if we can push duplicate elimination into the store
 			 * via a hash scan.  This is possible iff:
@@ -1601,9 +1601,9 @@ class SelectNode extends ResultSetNode
 			{
 				boolean simpleColumns = true;
 				HashSet<BaseColumnNode> distinctColumns = new HashSet<BaseColumnNode>();
-				int size = resultColumns.size();
+				int size = getResultColumns().size();
 				for (int i = 1; i <= size; i++) {
-					BaseColumnNode bc = resultColumns.getResultColumn(i).getBaseColumnNode();
+					BaseColumnNode bc = getResultColumns().getResultColumn(i).getBaseColumnNode();
 					if (bc == null) {
 						simpleColumns = false;
 						break;
@@ -1621,10 +1621,10 @@ class SelectNode extends ResultSetNode
 				/* We can't do a distinct scan. Determine if we can filter out 
 				 * duplicates without a sorter. 
 				 */
-				boolean inSortedOrder = isOrderedResult(resultColumns, prnRSN, !(orderByAndDistinctMerged));
+				boolean inSortedOrder = isOrderedResult(getResultColumns(), prnRSN, !(orderByAndDistinctMerged));
                 prnRSN = new DistinctNode(
                         prnRSN, inSortedOrder, null, getContextManager());
-				prnRSN.costEstimate = costEstimate.cloneMe();
+				prnRSN.setCostEstimate( getCostEstimate().cloneMe() );
 
                 // Remember whether or not we can eliminate the sort.
                 for (int i=0; i < eliminateSort.length; i++) {
@@ -1646,7 +1646,7 @@ class SelectNode extends ResultSetNode
                                              obl,
                                              null,
                                              getContextManager());
-                    prnRSN.costEstimate = costEstimate.cloneMe();
+                    prnRSN.setCostEstimate( getCostEstimate().cloneMe() );
                 }
 
                 // There may be columns added to the select projection list
@@ -1705,7 +1705,7 @@ class SelectNode extends ResultSetNode
 
 
 		if (wasGroupBy &&
-			resultColumns.numGeneratedColumnsForGroupBy() > 0 &&
+			getResultColumns().numGeneratedColumnsForGroupBy() > 0 &&
 			windows == null) // windows handling already added a PRN which
 							 // obviates this.
 		{
@@ -1762,7 +1762,7 @@ class SelectNode extends ResultSetNode
             }
 
             /* Set the cost of this node in the generated node */
-            prnRSN.costEstimate = costEstimate.cloneMe();
+            prnRSN.setCostEstimate( getCostEstimate().cloneMe() );
         }
 
 		return prnRSN;
@@ -1992,24 +1992,24 @@ class SelectNode extends ResultSetNode
 		}
 
 		/* Get the cost */
-        costEstimate = opt.getOptimizedCost();
+        setCostEstimate( opt.getOptimizedCost() );
 
 		/* Update row counts if this is a scalar aggregate */
 		if ((selectAggregates != null) && (selectAggregates.size() > 0)) 
 		{
-			costEstimate.setEstimatedRowCount((long) outerRows);
-			costEstimate.setSingleScanRowCount(1);
+			getCostEstimate().setEstimatedRowCount((long) outerRows);
+			getCostEstimate().setSingleScanRowCount(1);
 		}
 
-		selectSubquerys.optimize(dataDictionary, costEstimate.rowCount());
+		selectSubquerys.optimize(dataDictionary, getCostEstimate().rowCount());
 
 		if (whereSubquerys != null && whereSubquerys.size() > 0)
 		{
-			whereSubquerys.optimize(dataDictionary, costEstimate.rowCount());
+			whereSubquerys.optimize(dataDictionary, getCostEstimate().rowCount());
 		}
 		
 		if (havingSubquerys != null && havingSubquerys.size() > 0) {
-			havingSubquerys.optimize(dataDictionary, costEstimate.rowCount());
+			havingSubquerys.optimize(dataDictionary, getCostEstimate().rowCount());
 		}
 
         // dispose of the optimizer we created above
@@ -2032,23 +2032,28 @@ class SelectNode extends ResultSetNode
 							OptimizerPlan overridingPlan)
 			throws StandardException
 	{
-		if (optimizer == null)
+		if (getOptimizer() == null)
 		{
 			/* Get an optimizer. */
 			OptimizerFactory optimizerFactory = getLanguageConnectionContext().getOptimizerFactory();
 
-			optimizer = optimizerFactory.getOptimizer(
-											optList,
-											predList,
-											dataDictionary,
-											requiredRowOrdering,
-											getCompilerContext().getNumTables(),
-											overridingPlan,
-								getLanguageConnectionContext());
+			setOptimizer
+                (
+                 optimizerFactory.getOptimizer
+                 (
+                  optList,
+                  predList,
+                  dataDictionary,
+                  requiredRowOrdering,
+                  getCompilerContext().getNumTables(),
+                  overridingPlan,
+                  getLanguageConnectionContext()
+                  )
+                 );
 		}
 
-		optimizer.prepForNextRound();
-		return optimizer;
+		getOptimizer().prepForNextRound();
+		return getOptimizer();
 	}
 
 	/**
@@ -2073,13 +2078,13 @@ class SelectNode extends ResultSetNode
 
 		if (SanityManager.DEBUG)
 		{
-			SanityManager.ASSERT(optimizer != null,
+			SanityManager.ASSERT(getOptimizer() != null,
 				"SelectNode's optimizer not expected to be null when " +
 				"modifying access paths.");
 		}
 
-        ((OptimizerImpl)optimizer).
-                addScopedPredicatesToList(predList, getContextManager());
+        getOptimizerImpl().addScopedPredicatesToList(predList, getContextManager());
+        
 		return modifyAccessPaths();
 	}
 
@@ -2104,10 +2109,10 @@ class SelectNode extends ResultSetNode
 		**
 		** This should be the same optimizer we got above.
 		*/
-		optimizer.modifyAccessPaths();
+		getOptimizer().modifyAccessPaths();
 
 		// Load the costEstimate for the final "best" join order.
-		costEstimate = optimizer.getFinalCost();
+		setCostEstimate( getOptimizer().getFinalCost() );
 
 		if (SanityManager.DEBUG)
 		{
@@ -2175,7 +2180,7 @@ class SelectNode extends ResultSetNode
             leftResultSet = fromList.elementAt(0);
 			leftRCList = leftResultSet.getResultColumns();
 			leftResultSet.setResultColumns(leftRCList.copyListAndObjects());
-			leftRCList.genVirtualColumnNodes(leftResultSet, leftResultSet.resultColumns);
+			leftRCList.genVirtualColumnNodes(leftResultSet, leftResultSet.getResultColumns());
 
 			/* Get right's ResultColumnList, assign shallow copy back to it,
 			 * create new VirtualColumnNodes for the original's 
@@ -2185,7 +2190,7 @@ class SelectNode extends ResultSetNode
             rightResultSet = fromList.elementAt(1);
 			rightRCList = rightResultSet.getResultColumns();
 			rightResultSet.setResultColumns(rightRCList.copyListAndObjects());
-			rightRCList.genVirtualColumnNodes(rightResultSet, rightResultSet.resultColumns);
+			rightRCList.genVirtualColumnNodes(rightResultSet, rightResultSet.getResultColumns());
 			rightRCList.adjustVirtualColumnIds(leftRCList.size());
 
 			/* Concatenate the 2 ResultColumnLists */
@@ -2223,7 +2228,7 @@ class SelectNode extends ResultSetNode
     CostEstimate getFinalCostEstimate()
 		throws StandardException
 	{
-		return optimizer.getFinalCost();
+		return getOptimizer().getFinalCost();
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java?rev=1568436&r1=1568435&r2=1568436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SetOperatorNode.java Fri Feb 14 18:28:21 2014
@@ -91,7 +91,7 @@ abstract class SetOperatorNode extends T
 		 * may have been a "*" in the list.  (We will set the names and
 		 * column types at that time, as expected.)
 		 */
-		resultColumns = leftResultSet.getResultColumns().copyListAndObjects();
+		setResultColumns( leftResultSet.getResultColumns().copyListAndObjects() );
 	}
 
 	/**
@@ -232,7 +232,7 @@ abstract class SetOperatorNode extends T
 				null,						// Subquerys in Restriction
 				null,						// Table properties
 				getContextManager());
-			prnRSN.costEstimate = ce.cloneMe();
+			prnRSN.setCostEstimate( ce.cloneMe() );
 			prnRSN.setReferencedTableMap(topNode.getReferencedTableMap());
 			topNode = prnRSN;
 		}
@@ -624,18 +624,18 @@ abstract class SetOperatorNode extends T
 		/* We need to recreate resultColumns for this node, since there
 		 * may have been 1 or more *'s in the left's SELECT list.
 		 */
-		resultColumns = leftResultSet.getResultColumns().copyListAndObjects();
+		setResultColumns( leftResultSet.getResultColumns().copyListAndObjects() );
 
         // The generated grouping columns of the left result set should not be
         // part of the result from the set operation (DERBY-3764).
-        resultColumns.removeGeneratedGroupingColumns();
+        getResultColumns().removeGeneratedGroupingColumns();
 
-        resultColumns.removeOrderByColumns();
+        getResultColumns().removeOrderByColumns();
 
 		/* Create new expressions with the dominant types after verifying
 		 * union compatibility between left and right sides.
 		 */
-		resultColumns.setUnionResultExpression(rightResultSet.getResultColumns(), tableNumber, level, getOperatorName());
+		getResultColumns().setUnionResultExpression(rightResultSet.getResultColumns(), tableNumber, level, getOperatorName());
 	}
 
 	/**
@@ -861,8 +861,8 @@ abstract class SetOperatorNode extends T
 		rightResultSet = rightResultSet.preprocess(numTables, gbl, fromList);
 
 		/* Build the referenced table map (left || right) */
-		referencedTableMap = (JBitSet) leftResultSet.getReferencedTableMap().clone();
-        referencedTableMap.or(rightResultSet.getReferencedTableMap());
+		setReferencedTableMap( (JBitSet) leftResultSet.getReferencedTableMap().clone() );
+        getReferencedTableMap().or(rightResultSet.getReferencedTableMap());
 
 		/* If this is a UNION without an all and we have
 		 * an order by then we can consider eliminating the sort for the
@@ -888,7 +888,7 @@ abstract class SetOperatorNode extends T
                 /* Order by list currently restricted to columns in select
                  * list, so we will always eliminate the order by here.
                  */
-                if (obl.isInOrderPrefix(resultColumns))
+                if (obl.isInOrderPrefix(getResultColumns()))
                 {
                     obl = null;
                     qec.setOrderByList(i, null);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java?rev=1568436&r1=1568435&r2=1568436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SingleChildResultSetNode.java Fri Feb 14 18:28:21 2014
@@ -61,8 +61,8 @@ abstract class SingleChildResultSetNode 
 
         /* Propagate the child's referenced table map, if one exists */
         if (childResult.getReferencedTableMap() != null) {
-            referencedTableMap =
-                (JBitSet)childResult.getReferencedTableMap().clone();
+            setReferencedTableMap
+                ( (JBitSet)childResult.getReferencedTableMap().clone() );
         }
     }
 
@@ -294,7 +294,7 @@ abstract class SingleChildResultSetNode 
 		childResult = childResult.preprocess(numTables, gbl, fromList);
 
 		/* Build the referenced table map */
-		referencedTableMap = (JBitSet) childResult.getReferencedTableMap().clone();
+		setReferencedTableMap( (JBitSet) childResult.getReferencedTableMap().clone() );
 
 		return this;
 	}
@@ -402,8 +402,8 @@ abstract class SingleChildResultSetNode 
 										predicates,
 										outerRows);
 
-        costEstimate = getOptimizerFactory().getCostEstimate();
-		costEstimate.setCost(childResult.getCostEstimate().getEstimatedCost(),
+        setCostEstimate( getOptimizerFactory().getCostEstimate() );
+		getCostEstimate().setCost(childResult.getCostEstimate().getEstimatedCost(),
 							childResult.getCostEstimate().rowCount(),
 							childResult.getCostEstimate().singleScanRowCount());
 
@@ -540,7 +540,7 @@ abstract class SingleChildResultSetNode 
 	 */
 	protected boolean reflectionNeededForProjection()
 	{
-		return ! (resultColumns.allExpressionsAreColumns(childResult));
+		return ! (getResultColumns().allExpressionsAreColumns(childResult));
 	}
 
 	/**
@@ -578,11 +578,13 @@ abstract class SingleChildResultSetNode 
 		** that optimization was done directly on the child node,
 		** in which case the cost estimate will be null here.
 		*/
-		if (costEstimate == null)
+		if (getCostEstimate() == null)
+        {
 			return childResult.getFinalCostEstimate();
+        }
 		else
 		{
-			return costEstimate;
+			return getCostEstimate();
 		}
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java?rev=1568436&r1=1568435&r2=1568436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SubqueryNode.java Fri Feb 14 18:28:21 2014
@@ -1977,7 +1977,7 @@ class SubqueryNode extends ValueNode
                         new MaterializeSubqueryNode(subRS, getContextManager());
 
 				// Propagate the resultSet's cost estimate to the new node.
-				materialSubNode.costEstimate = resultSet.getFinalCostEstimate();
+				materialSubNode.setCostEstimate( resultSet.getFinalCostEstimate() );
 
 				((ProjectRestrictNode) resultSet).setChildResult(materialSubNode);
 
@@ -2075,8 +2075,8 @@ class SubqueryNode extends ValueNode
 		mb.push(subqResultSetNumber);
 		mb.push(subqueryNumber);
 		mb.push(pointOfAttachment);
-		mb.push(costEstimate.rowCount());
-		mb.push(costEstimate.getEstimatedCost());
+		mb.push( costEstimate.rowCount() );
+		mb.push( costEstimate.getEstimatedCost() );
 
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, resultSetString, ClassName.NoPutResultSet, nargs);
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java?rev=1568436&r1=1568435&r2=1568436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/TableOperatorNode.java Fri Feb 14 18:28:21 2014
@@ -633,9 +633,9 @@ abstract class TableOperatorNode extends
 		}
 
 		/* Build the referenced table map (left || right) */
-		referencedTableMap = (JBitSet) leftResultSet.getReferencedTableMap().clone();
-        referencedTableMap.or(rightResultSet.getReferencedTableMap());
-		referencedTableMap.set(tableNumber);
+		setReferencedTableMap( (JBitSet) leftResultSet.getReferencedTableMap().clone() );
+        getReferencedTableMap().or(rightResultSet.getReferencedTableMap());
+		getReferencedTableMap().set(tableNumber);
 
 		/* Only generate a PRN if this node is not a flattenable join node. */
 		if (isFlattenableJoinNode())
@@ -662,7 +662,7 @@ abstract class TableOperatorNode extends
     @Override
     void projectResultColumns() throws StandardException
     {
-        resultColumns.doProjection();
+        getResultColumns().doProjection();
     }
     
     /**
@@ -687,7 +687,7 @@ abstract class TableOperatorNode extends
 								  double outerRows)
 				throws StandardException
 	{
-        costEstimate = getOptimizerFactory().getCostEstimate();
+        setCostEstimate( getOptimizerFactory().getCostEstimate() );
 
 		/* RESOLVE: This is just a stub for now */
 		leftResultSet = leftResultSet.optimize(
@@ -700,12 +700,12 @@ abstract class TableOperatorNode extends
 											outerRows);
 
 		/* The cost is the sum of the two child costs */
-		costEstimate.setCost(leftResultSet.getCostEstimate().getEstimatedCost(),
+		getCostEstimate().setCost(leftResultSet.getCostEstimate().getEstimatedCost(),
 							 leftResultSet.getCostEstimate().rowCount(),
 							 leftResultSet.getCostEstimate().singleScanRowCount() +
 							 rightResultSet.getCostEstimate().singleScanRowCount());
 
-		costEstimate.add(rightResultSet.costEstimate, costEstimate);
+		getCostEstimate().add(rightResultSet.getCostEstimate(), getCostEstimate());
 
 		return this;
 	}

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=1568436&r1=1568435&r2=1568436&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 Fri Feb 14 18:28:21 2014
@@ -133,7 +133,7 @@ class UnionNode extends SetOperatorNode
 	{
 		if (SanityManager.DEBUG)
 		{
-			SanityManager.ASSERT(resultColumns.size() <= typeColumns.size(),
+			SanityManager.ASSERT(getResultColumns().size() <= typeColumns.size(),
 				"More columns in ResultColumnList than in base table.");
 		}
 
@@ -200,8 +200,8 @@ class UnionNode extends SetOperatorNode
 			rightResultSet = target.enhanceAndCheckForAutoincrement
                 ( rightResultSet, inOrder, colMap, false );
 			if (!inOrder ||
-					resultColumns.size() < target.resultColumnList.size()) {
-				resultColumns = getRCLForInsert(target, colMap);
+                getResultColumns().size() < target.resultColumnList.size()) {
+				setResultColumns( getRCLForInsert(target, colMap) );
 			}
 			return this;
 		} else {
@@ -294,7 +294,7 @@ class UnionNode extends SetOperatorNode
 							 leftResultSet.getCostEstimate().singleScanRowCount() +
 							 rightResultSet.getCostEstimate().singleScanRowCount());
 
-        costEst.add(rightResultSet.costEstimate, costEst);
+        costEst.add(rightResultSet.getCostEstimate(), costEst);
 
 		/*
 		** Get the cost of this result set in the context of the whole plan.
@@ -456,7 +456,7 @@ class UnionNode extends SetOperatorNode
 			 * us would have a tableNumber of -1 instead of our tableNumber.)
 			 */
 			((FromTable)treeTop).setTableNumber(tableNumber);
-			treeTop.setReferencedTableMap((JBitSet) referencedTableMap.clone());
+			treeTop.setReferencedTableMap((JBitSet) getReferencedTableMap().clone());
 			all = true;
 		}
 
@@ -539,7 +539,7 @@ class UnionNode extends SetOperatorNode
 		** the types of the ? parameters come from the columns being inserted
 		** into in that case.
 		*/
-		if (topTableConstructor && ( ! insertSource) )
+		if (topTableConstructor && ( ! isInsertSource()) )
 		{
 			/*
 			** Step through all the rows in the table constructor to
@@ -630,7 +630,7 @@ class UnionNode extends SetOperatorNode
 		assignResultSetNumber();
 
 		// Get our final cost estimate based on the child estimates.
-		costEstimate = getFinalCostEstimate();
+		setCostEstimate( getFinalCostEstimate() );
 
 		// build up the tree.
 
@@ -641,7 +641,7 @@ class UnionNode extends SetOperatorNode
 		leftResultSet.generate(acb, mb);
 
 		/* Do we need a NormalizeResultSet above the left ResultSet? */
-		if (! resultColumns.isExactTypeAndLengthMatch(leftResultSet.getResultColumns()))
+		if (! getResultColumns().isExactTypeAndLengthMatch(leftResultSet.getResultColumns()))
 		{
 			acb.pushGetResultSetFactoryExpression(mb);
 			mb.swap();
@@ -654,7 +654,7 @@ class UnionNode extends SetOperatorNode
 		rightResultSet.generate(acb, mb);
 
 		/* Do we need a NormalizeResultSet above the right ResultSet? */
-		if (! resultColumns.isExactTypeAndLengthMatch(rightResultSet.getResultColumns()))
+		if (! getResultColumns().isExactTypeAndLengthMatch(rightResultSet.getResultColumns()))
 		{
 			acb.pushGetResultSetFactoryExpression(mb);
 			mb.swap();
@@ -674,9 +674,9 @@ class UnionNode extends SetOperatorNode
 		 *  arg7: close method
 		 */
 
-		mb.push(resultSetNumber);
-		mb.push(costEstimate.rowCount());
-		mb.push(costEstimate.getEstimatedCost());
+		mb.push(getResultSetNumber());
+		mb.push(getCostEstimate().rowCount());
+		mb.push(getCostEstimate().getEstimatedCost());
 
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null, "getUnionResultSet",
                 ClassName.NoPutResultSet, 5);
@@ -695,20 +695,22 @@ class UnionNode extends SetOperatorNode
 		throws StandardException
 	{
 		// If we already found it, just return it.
-		if (finalCostEstimate != null)
-			return finalCostEstimate;
+		if (getCandidateFinalCostEstimate() != null)
+        {
+			return getCandidateFinalCostEstimate();
+        }
 
 		CostEstimate leftCE = leftResultSet.getFinalCostEstimate();
 		CostEstimate rightCE = rightResultSet.getFinalCostEstimate();
 
-		finalCostEstimate = getNewCostEstimate();
-		finalCostEstimate.setCost(leftCE.getEstimatedCost(),
+		setCandidateFinalCostEstimate( getNewCostEstimate() );
+		getCandidateFinalCostEstimate().setCost(leftCE.getEstimatedCost(),
 							 leftCE.rowCount(),
 							 leftCE.singleScanRowCount() +
 							 rightCE.singleScanRowCount());
 
-		finalCostEstimate.add(rightCE, finalCostEstimate);
-		return finalCostEstimate;
+		getCandidateFinalCostEstimate().add(rightCE, getCandidateFinalCostEstimate());
+		return getCandidateFinalCostEstimate();
 	}
 
     String getOperatorName()

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=1568436&r1=1568435&r2=1568436&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 Fri Feb 14 18:28:21 2014
@@ -335,7 +335,7 @@ public final class UpdateNode extends DM
 
 		/* Prepend CurrentRowLocation() to the select's result column list. */
 		if (SanityManager.DEBUG)
-		SanityManager.ASSERT((resultSet.resultColumns != null),	
+            SanityManager.ASSERT((resultSet.getResultColumns() != null),	
 							  "resultColumns is expected not to be null at bind time");
 
 		/*
@@ -350,15 +350,18 @@ public final class UpdateNode extends DM
         */
 		/* Normalize the SET clause's result column list for synonym */
 		if (synonymTableName != null)
-			normalizeSynonymColumns( resultSet.resultColumns, targetTable );
+			normalizeSynonymColumns( resultSet.getResultColumns(), targetTable );
 		
 		/* Bind the original result columns by column name */
-		normalizeCorrelatedColumns( resultSet.resultColumns, targetTable );
+		normalizeCorrelatedColumns( resultSet.getResultColumns(), targetTable );
 
-		resultSet.bindResultColumns(targetTableDescriptor,
-					targetVTI,
-					resultSet.resultColumns, this,
-					fromList);
+		resultSet.bindResultColumns
+            (
+             targetTableDescriptor,
+             targetVTI,
+             resultSet.getResultColumns(), this,
+             fromList
+             );
 
         // don't allow overriding of generation clauses
         forbidGenerationOverrides( resultSet.getResultColumns(),

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=1568436&r1=1568435&r2=1568436&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 Fri Feb 14 18:28:21 2014
@@ -79,7 +79,7 @@ class WindowResultSetNode extends Single
         ** nodes above it now point to us).  Map our RCL to its columns.
         */
         newBottomRCL = childResult.getResultColumns().copyListAndObjects();
-        resultColumns = childResult.getResultColumns();
+        setResultColumns( childResult.getResultColumns() );
         childResult.setResultColumns(newBottomRCL);
 
         // Wrao purselved int a project/restrict as per convention.
@@ -102,7 +102,7 @@ class WindowResultSetNode extends Single
         */
         ResultColumnList rclNew = new ResultColumnList(getContextManager());
 
-        for (ResultColumn rc : resultColumns)
+        for (ResultColumn rc : getResultColumns())
         {
             if (!rc.isGenerated()) {
                 rclNew.addElement(rc);
@@ -112,7 +112,7 @@ class WindowResultSetNode extends Single
         // if any columns in the source RCL were generated for an order by
         // remember it in the new RCL as well. After the sort is done it will
         // have to be projected out upstream.
-        rclNew.copyOrderBySelect(resultColumns);
+        rclNew.copyOrderBySelect(getResultColumns());
 
         parent = new ProjectRestrictNode(this, // child
                                          rclNew,
@@ -132,7 +132,7 @@ class WindowResultSetNode extends Single
         /*
          * Set the Windowing RCL to be empty
          */
-        resultColumns = new ResultColumnList(getContextManager());
+        setResultColumns( new ResultColumnList(getContextManager()) );
 
 
         // Add all referenced columns in select list to windowing node's RCL
@@ -165,7 +165,7 @@ class WindowResultSetNode extends Single
         uniqueCols.addAll(getVCVisitor.getList());
 
         ResultColumnList bottomRCL  = childResult.getResultColumns();
-        ResultColumnList windowingRCL = resultColumns;
+        ResultColumnList windowingRCL = getResultColumns();
 
         for (int i= 0; i< uniqueCols.size(); i++) {
             ValueNode crOrVcn = uniqueCols.get(i);
@@ -237,7 +237,7 @@ class WindowResultSetNode extends Single
          * each RC as we process its corresponding window function.
          */
         ResultColumnList bottomRCL  = childResult.getResultColumns();
-        ResultColumnList windowingRCL = resultColumns;
+        ResultColumnList windowingRCL = getResultColumns();
 
         ReplaceWindowFuncCallsWithCRVisitor replaceCallsVisitor =
             new ReplaceWindowFuncCallsWithCRVisitor(
@@ -321,12 +321,12 @@ class WindowResultSetNode extends Single
         assignResultSetNumber();
 
         // Get the final cost estimate from the child.
-        costEstimate = childResult.getFinalCostEstimate();
+        setCostEstimate( childResult.getFinalCostEstimate() );
 
 
         acb.pushGetResultSetFactoryExpression(mb);
 
-        int rclSize = resultColumns.size();
+        int rclSize = getResultColumns().size();
         FormatableBitSet referencedCols = new FormatableBitSet(rclSize);
 
         /*
@@ -334,7 +334,7 @@ class WindowResultSetNode extends Single
          */
 
         for (int index = rclSize-1; index >= 0; index--) {
-            ResultColumn rc = resultColumns.elementAt(index);
+            ResultColumn rc = getResultColumns().elementAt(index);
             ValueNode expr = rc.getExpression();
 
             if (rc.isGenerated() &&
@@ -356,9 +356,9 @@ class WindowResultSetNode extends Single
         mb.upCast(ClassName.NoPutResultSet);
 
         /* row allocator */
-        mb.push(acb.addItem(resultColumns.buildRowTemplate())); // arg 3
+        mb.push(acb.addItem(getResultColumns().buildRowTemplate())); // arg 3
 
-        mb.push(resultSetNumber); //arg 4
+        mb.push(getResultSetNumber()); //arg 4
 
         /* Pass in the erdNumber for the referenced column FormatableBitSet */
         mb.push(erdNumber); // arg 5
@@ -366,8 +366,8 @@ class WindowResultSetNode extends Single
         /* There is no restriction at this level, we just want to pass null. */
         mb.pushNull(ClassName.GeneratedMethod); // arg 6
 
-        mb.push(costEstimate.rowCount()); //arg 7
-        mb.push(costEstimate.getEstimatedCost()); // arg 8
+        mb.push(getCostEstimate().rowCount()); //arg 7
+        mb.push(getCostEstimate().getEstimatedCost()); // arg 8
 
         mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null,
             "getWindowResultSet", ClassName.NoPutResultSet, 8);