Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv Class ProjectRestrictNode

extends SingleChildResultSetNode
Class Inheritance
Imports
java.util.HashSet, .Properties, .Set, org.apache.derby.catalog.UUID, org.apache.derby.catalog.types.ReferencedColumnsDescriptorImpl, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.ClassName, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.AccessPath, .CostEstimate, .Optimizable, .OptimizablePredicate, .OptimizablePredicateList, .Optimizer, .RequiredRowOrdering, .RowOrdering, .Visitor, org.apache.derby.iapi.sql.dictionary.DataDictionary, org.apache.derby.iapi.store.access.TransactionController, org.apache.derby.iapi.util.JBitSet

A ProjectRestrictNode represents a result set for any of the basic DML operations: SELECT, INSERT, UPDATE, and DELETE. For INSERT with a VALUES clause, restriction will be null. For both INSERT and UPDATE, the resultColumns in the selectList will contain the names of the columns being inserted into or updated.

Note

A ProjectRestrictNode extends FromTable since it can exist in a FromList.

Field Summary

Modifier and TypeField and Description
private boolean
pack-priv ValueNode
constantRestriction

Constant expressions to be evaluated here.

private boolean
pack-priv SubqueryList
projectSubquerys

List of subqueries in projection

pack-priv ValueNode
restriction

The ValueNode for the restriction to be evaluated here.

pack-priv PredicateList
restrictionList

Restriction as a PredicateList

pack-priv SubqueryList
restrictSubquerys

List of subqueries in restriction

private String
private boolean
validatingCheckConstraints

Used with validatingBaseTableCID to validating deferred check constraints.

Inherited from org.apache.derby.impl.sql.compile.SingleChildResultSetNode:
childResulthasTrulyTheBestAccessPath

Constructor Summary

AccessConstructor and Description
pack-priv
ProjectRestrictNode(ResultSetNode
The child ResultSetNode
childResult
,
ResultColumnList
The result column list for the projection
projection
,
ValueNode
An expression representing the restriction to be evaluated here.
restriction
,
PredicateList
Restriction as a PredicateList
restrictionList
,
SubqueryList
List of subqueries in the projection
projectSubquerys
,
SubqueryList
List of subqueries in the restriction
restrictSubquerys
,
Properties
Properties list associated with the table
tableProperties
,
ContextManager
The context manager
cm
)

Constructor for a ProjectRestrictNode.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
acceptChildren(Visitor
the visitor
v
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.acceptChildren.

Accept the visitor for all visitable children of this node.

pack-priv ResultSetNode

Returns:

ResultSetNode The new top of the tree.
addNewPredicate
(Predicate
The predicate to add
predicate
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.addNewPredicate.

Add a new predicate to the list.

pack-priv ResultSetNode

Returns:

Top of the new/same ResultSet tree.
considerMaterialization
(JBitSet outerTables)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.considerMaterialization.

Consider materialization for this ResultSet tree if it is valid and cost effective (It is not valid if incorrect results would be returned.)

public boolean
pack-priv ResultSetNode

Returns:

ResultSetNode A RSN tree with a node which has a PredicateList on top.
ensurePredicateList
(int
The number of tables in the query.
numTables
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.ensurePredicateList.

Ensure that the top of the RSN tree has a PredicateList.

public boolean
feasibleJoinStrategy(OptimizablePredicateList
The predicate list that has been pushed down to this optimizable
predList
,
Optimizer
The optimizer to use.
optimizer
)

Overrides org.apache.derby.impl.sql.compile.FromTable.feasibleJoinStrategy.

Implements org.apache.derby.iapi.sql.compile.Optimizable.feasibleJoinStrategy.

Is the current proposed join strategy for this optimizable feasible given the predicate list?

pack-priv boolean

Returns:

boolean Whether or not the FromSubquery is flattenable.
flattenableInFromSubquery
(FromList
The outer from list
fromList
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.flattenableInFromSubquery.

Evaluate whether or not the subquery in a FromSubquery is flattenable.

pack-priv void
generate(ActivationClassBuilder
The ActivationClassBuilder for the class being built
acb
,
MethodBuilder
The method for the generated code to go into
mb
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

For joins, the tree will be (nodes are left out if the clauses are empty): ProjectRestrictResultSet -- for the having and the select list SortResultSet -- for the group by list ProjectRestrictResultSet -- for the where and the select list (if no group or having) the result set for the fromList

private void
generateMinion(ExpressionClassBuilder
The ExpressionClassBuilder for the class being built
acb
,
MethodBuilder
The method the expression will go into
mb
,
boolean genChildResultSet)

Logic shared by generate() and generateResultSet().

pack-priv void
generateNOPProjectRestrict()

Bypass the generation of this No-Op ProjectRestrict, and just generate its child result set.

pack-priv void
generateResultSet(ExpressionClassBuilder
The ExpressionClassBuilder for the class being built
acb
,
MethodBuilder
The method the expression will go into
mb
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.generateResultSet.

General logic shared by Core compilation.

public AccessPath
public AccessPath
pack-priv CostEstimate

Returns:

The CostEstimate for this ProjectRestrictNode, which is the cost estimate for the child node.
getCostEstimate
()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.getCostEstimate.

Get the CostEstimate for this ProjectRestrictNode.

public AccessPath
pack-priv CostEstimate

Returns:

The final CostEstimate for this ProjectRestrictNode, which is the final cost estimate for the child node.
getFinalCostEstimate
()

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.getFinalCostEstimate.

Get the final CostEstimate for this ProjectRestrictNode.

pack-priv FromTable

Returns:

The FromTable, if any, with the exposed name.
getFromTableByName
(String
The specified name to search for as an exposed name.
name
,
String
Schema name, if non-null.
schemaName
,
boolean
Whether or not we need an exact match on specified schema and table names or match on table id.
exactMatch
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.getFromTableByName.

Determine whether or not the specified name is an exposed name in the current query block.

pack-priv PredicateList

Returns:

The restriction list from this node.
getRestrictionList
()

Return the restriction list from this node.

public int
public AccessPath
pack-priv String

Returns:

The user specified join strategy, if any for this table.
getUserSpecifiedJoinStrategy
()

Overrides org.apache.derby.impl.sql.compile.FromTable.getUserSpecifiedJoinStrategy.

Return the user specified join strategy, if any for this table.

pack-priv boolean

Returns:

Whether or not it is possible to do a distinct scan on this ResultSet tree.
isPossibleDistinctScan
(Set<BaseColumnNode>
the set of distinct columns
distinctColumns
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.isPossibleDistinctScan.

Is it possible to do a distinct scan on this ResultSet tree.

public boolean
legalJoinOrder(JBitSet
The tables that have been placed so far in the join order.
assignedTableMap
)

Overrides org.apache.derby.impl.sql.compile.FromTable.legalJoinOrder.

Implements org.apache.derby.iapi.sql.compile.Optimizable.legalJoinOrder.

Can this Optimizable appear at the current location in the join order.

pack-priv void
markForDistinctScan()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.markForDistinctScan.

Mark the underlying scan as a distinct scan.

public Optimizable
modifyAccessPath(JBitSet
Bit map of the tables that are outer to this one in the join order.
outerTables
)

Overrides org.apache.derby.impl.sql.compile.FromTable.modifyAccessPath.

Implements org.apache.derby.iapi.sql.compile.Optimizable.modifyAccessPath.

Modify the access path for this Optimizable, as necessary.

public boolean
nextAccessPath(Optimizer
Optimizer to use.
optimizer
,
OptimizablePredicateList
The predicate list for this optimizable. The optimizer always passes null, and it is up to the optimizable object to pass along its own predicate list, if appropriate, when delegating this method.
predList
,
RowOrdering
The row ordering for all the outer tables in the join order. This method will add the ordering of the next access path to the given RowOrdering.
rowOrdering
)

Overrides org.apache.derby.impl.sql.compile.FromTable.nextAccessPath.

Implements org.apache.derby.iapi.sql.compile.Optimizable.nextAccessPath.

Choose the next access path to evaluate for this Optimizable.

pack-priv boolean

Returns:

true if this ProjectRestrict is a No-Op.
nopProjectRestrict
()

Determine whether this ProjectRestrict does anything.

pack-priv ResultSetNode

Returns:

ResultSetNode The top of the optimized subtree
optimize
(DataDictionary
The DataDictionary to use for optimization
dataDictionary
,
PredicateList
The PredicateList to optimize. This should be a join predicate.
predicates
,
double
The number of outer joining rows
outerRows
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.optimize.

Optimize this ProjectRestrictNode.

public CostEstimate
optimizeIt(Optimizer
Optimizer to use.
optimizer
,
OptimizablePredicateList
The predicate list to optimize against
predList
,
CostEstimate
The CostEstimate for the outer tables in the join order, telling how many times this Optimizable will be scanned.
outerCost
,
RowOrdering
The row ordering for all the tables in the join order, including this one.
rowOrdering
)

Overrides org.apache.derby.impl.sql.compile.FromTable.optimizeIt.

Implements org.apache.derby.iapi.sql.compile.Optimizable.optimizeIt.

Choose the best access path for this Optimizable.

pack-priv ResultSetNode

Returns:

The generated ProjectRestrictNode atop the original FromTable.
preprocess
(int
Number of tables in the DML Statement
numTables
,
GroupByList
The group by list, if any
gbl
,
FromList
The from list, if any
fromList
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.preprocess.

Put a ProjectRestrictNode on top of each FromTable in the FromList.

pack-priv void
printSubNodes(int
The depth of this node in the tree
depth
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.printSubNodes.

Prints the sub-nodes of this object.

public void
pullOptPredicates(OptimizablePredicateList
The list to put the pulled predicates in.
optimizablePredicates
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.pullOptPredicates.

Implements org.apache.derby.iapi.sql.compile.Optimizable.pullOptPredicates.

Pull all the OptimizablePredicates from this Optimizable and put them in the given OptimizablePredicateList.

pack-priv void
pushExpressions(PredicateList
The PredicateList.
predicateList
)

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.pushExpressions.

Push expressions down to the first ResultSetNode which can do expression evaluation and has the same referenced table map.

pack-priv void
pushOffsetFetchFirst(ValueNode
the OFFSET, if any
offset
,
ValueNode
the OFFSET FIRST, if any
fetchFirst
,
boolean
true if the clauses were added by (and have the semantics of) a JDBC limit clause
hasJDBClimitClause
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.pushOffsetFetchFirst.

Push down the offset and fetch first parameters, if any, to the underlying child result set.

public boolean
pushOptPredicate(OptimizablePredicate
OptimizablePredicate to push down.
optimizablePredicate
)

Overrides org.apache.derby.impl.sql.compile.FromTable.pushOptPredicate.

Implements org.apache.derby.iapi.sql.compile.Optimizable.pushOptPredicate.

Push an OptimizablePredicate down, if this node accepts it.

pack-priv void
pushOrderByList(OrderByList
The order by list
orderByList
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.pushOrderByList.

Push the order by list down from InsertNode into its child result set so that the optimizer has all of the information that it needs to consider sort avoidance.

public void
pushQueryExpressionSuffix()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.pushQueryExpressionSuffix.

Set up a new level for order by and fetch/offset clauses.

public void
rememberAsBest(int
The type of plan (one of Optimizer.NORMAL_PLAN or Optimizer.SORT_AVOIDANCE_PLAN)
planType
,
Optimizer
The OptimizerImpl that is telling this Optimizable to remember its current path as "truly the best".
optimizer
)

Overrides org.apache.derby.impl.sql.compile.FromTable.rememberAsBest.

Implements org.apache.derby.iapi.sql.compile.Optimizable.rememberAsBest.

Remember the current access path as the best one (so far).

public void
private Optimizable

Returns:

The new (same) top of our result set tree.
replaceWithHashTableNode
()

This method creates a HashTableNode between the PRN and it's child when the optimizer chooses hash join on an arbitrary (non-FBT) result set tree.

pack-priv void
setRefActionInfo(long fkIndexConglomId, int[] fkColArray, String parentResultSetId, boolean dependentScan)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.setRefActionInfo.

set the Information gathered from the parent table that is required to perform a referential action on dependent table.

pack-priv void
pack-priv void
public void
startOptimizing(Optimizer optimizer, RowOrdering rowOrdering)

Overrides org.apache.derby.impl.sql.compile.FromTable.startOptimizing.

Implements org.apache.derby.iapi.sql.compile.Optimizable.startOptimizing.

Begin the optimization process for this Optimizable.

public double
uniqueJoin(OptimizablePredicateList
The predicate list to check
predList
)

Overrides org.apache.derby.impl.sql.compile.FromTable.uniqueJoin.

Implements org.apache.derby.iapi.sql.compile.Optimizable.uniqueJoin.

Does this optimizable have a uniqueness condition on the given predicate list, and if so, how many unique keys will be returned per scan.

pack-priv int

Returns:

The lock mode
updateTargetLockMode
()

Overrides org.apache.derby.impl.sql.compile.SingleChildResultSetNode.updateTargetLockMode.

Get the lock mode for the target of an update statement (a delete or update).

public void
verifyProperties(DataDictionary
The DataDictionary to use.
dDictionary
)

Overrides org.apache.derby.impl.sql.compile.FromTable.verifyProperties.

Implements org.apache.derby.iapi.sql.compile.Optimizable.verifyProperties.

Verify that the Properties list with optimizer overrides, if specified, is valid

Inherited from org.apache.derby.impl.sql.compile.SingleChildResultSetNode:
adjustForSortEliminationadjustForSortEliminationchangeAccessPathdecrementLevelforUpdategetChildResultinitAccessPathsisNotExistsisOneRowResultSetisOrderedOnmodifyAccessPathsreferencesSessionSchemareferencesTargetreflectionNeededForProjectionsetChildResultsetLevelsubqueryReferencesTargetupdateBestPlanMap