Buggy code:
public class ProjectRestrictNode extends SingleChildResultSetNode { public ValueNode restriction ; ValueNode constantRestriction = null ; public PredicateList restrictionList ; SubqueryList projectSubquerys ; SubqueryList restrictSubquerys ; private boolean accessPathModified ; private boolean accessPathConsidered ; private boolean childResultOptimized ; private boolean materialize ; private boolean getTableNumberHere ; public void init ( Object childResult , Object projection , Object restriction , Object restrictionList , Object projectSubquerys , Object restrictSubquerys , Object tableProperties ) { } public boolean nextAccessPath ( Optimizer optimizer , OptimizablePredicateList predList , RowOrdering rowOrdering ) throws StandardException { } public void rememberAsBest ( int planType , Optimizer optimizer ) throws StandardException { } void printRememberingBestAccessPath ( int planType , AccessPath bestPath ) { } public void startOptimizing ( Optimizer optimizer , RowOrdering rowOrdering ) { } public int getTableNumber ( ) { } public CostEstimate optimizeIt ( Optimizer optimizer , OptimizablePredicateList predList , CostEstimate outerCost , RowOrdering rowOrdering ) throws StandardException { CostEstimate childCost ; costEstimate = getCostEstimate ( optimizer ) ; <START_BUG> addOrLoadBestPlanMapping ( true , this ) ; <END_BUG> if ( ( childResult ) instanceof Optimizable ) { childCost = ( ( Optimizable ) ( childResult ) ) . optimizeIt ( optimizer , restrictionList , outerCost , rowOrdering ) ; costEstimate . setCost ( childCost . getEstimatedCost ( ) , childCost . rowCount ( ) , childCost . singleScanRowCount ( ) ) ; } else if ( ! ( accessPathModified ) ) { if ( SanityManager . DEBUG ) { if ( ! ( ( ( childResult ) instanceof SelectNode ) || ( ( childResult ) instanceof RowResultSetNode ) ) ) { SanityManager . THROWASSERT ( ( ( "childResult<seq2seq4repair_space>is<seq2seq4repair_space>expected<seq2seq4repair_space>to<seq2seq4repair_space>be<seq2seq4repair_space>instanceof<seq2seq4repair_space>" + "SelectNode<seq2seq4repair_space>or<seq2seq4repair_space>RowResultSetNode<seq2seq4repair_space>-<seq2seq4repair_space>it<seq2seq4repair_space>is<seq2seq4repair_space>a<seq2seq4repair_space>" ) + ( childResult . getClass ( ) . getName ( ) ) ) ) ; } } childResult = childResult . optimize ( optimizer . getDataDictionary ( ) , restrictionList , outerCost . rowCount ( ) ) ; childCost = childResult . costEstimate ; costEstimate . setCost ( childCost . getEstimatedCost ( ) , childCost . rowCount ( ) , childCost . singleScanRowCount ( ) ) ; optimizer . considerCost ( this , restrictionList , getCostEstimate ( ) , outerCost ) ; } return costEstimate ; } public boolean feasibleJoinStrategy ( OptimizablePredicateList predList , Optimizer optimizer ) throws StandardException { } public AccessPath getCurrentAccessPath ( ) { } public AccessPath getBestAccessPath ( ) { } public AccessPath getBestSortAvoidancePath ( ) { } public AccessPath getTrulyTheBestAccessPath ( ) { } public void rememberSortAvoidancePath ( ) { } public boolean considerSortAvoidancePath ( ) { } public boolean pushOptPredicate ( OptimizablePredicate optimizablePredicate ) throws StandardException { } public void pullOptPredicates ( OptimizablePredicateList optimizablePredicates ) throws StandardException { } public Optimizable modifyAccessPath ( JBitSet outerTables ) throws StandardException { } private Optimizable replaceWithHashTableNode ( ) throws StandardException { } public void verifyProperties ( DataDictionary dDictionary ) throws StandardException { } public boolean legalJoinOrder ( JBitSet assignedTableMap ) { } public double uniqueJoin ( OptimizablePredicateList predList ) throws StandardException { } PredicateList getRestrictionList ( ) { } String getUserSpecifiedJoinStrategy ( ) { } public void printSubNodes ( int depth ) { } public ResultSetNode preprocess ( int numTables , GroupByList gbl , FromList fromList ) throws StandardException { } public void pushExpressions ( PredicateList predicateList ) throws StandardException { } public ResultSetNode addNewPredicate ( Predicate predicate ) throws StandardException { } public boolean flattenableInFromSubquery ( FromList fromList ) { } public ResultSetNode ensurePredicateList ( int numTables ) throws StandardException { } public ResultSetNode optimize ( DataDictionary dataDictionary , PredicateList predicates , double outerRows ) throws StandardException { } public CostEstimate getCostEstimate ( ) { } public CostEstimate getFinalCostEstimate ( ) throws StandardException { } public void generate ( ActivationClassBuilder acb , MethodBuilder mb ) throws StandardException { } public void generateResultSet ( ExpressionClassBuilder acb , MethodBuilder mb ) throws StandardException { } private void generateMinion ( ExpressionClassBuilder acb , MethodBuilder mb , boolean genChildResultSet ) throws StandardException { } boolean nopProjectRestrict ( ) { } public void generateNOPProjectRestrict ( ) throws StandardException { } public ResultSetNode considerMaterialization ( JBitSet outerTables ) throws StandardException { } protected FromTable getFromTableByName ( String name , String schemaName , boolean exactMatch ) throws StandardException { } public int updateTargetLockMode ( ) { } boolean isPossibleDistinctScan ( Set distinctColumns ) { } void markForDistinctScan ( ) { } public Visitable accept ( Visitor v ) throws StandardException { } public void setRefActionInfo ( long fkIndexConglomId , int [ ] fkColArray , String parentResultSetId , boolean dependentScan ) { } }

Fix:
updateBestPlanMap ( ADD_PLAN , this ) ;