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

pack-priv abstract Class SingleChildResultSetNode

extends FromTable
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.compile.WindowResultSetNode, org.apache.derby.impl.sql.compile.DistinctNode, org.apache.derby.impl.sql.compile.MaterializeResultSetNode, org.apache.derby.impl.sql.compile.GroupByNode, org.apache.derby.impl.sql.compile.HashTableNode, org.apache.derby.impl.sql.compile.NormalizeResultSetNode, org.apache.derby.impl.sql.compile.OrderByNode, org.apache.derby.impl.sql.compile.ProjectRestrictNode, org.apache.derby.impl.sql.compile.RowCountNode, org.apache.derby.impl.sql.compile.ScrollInsensitiveResultSetNode
Imports
java.util.List, .Properties, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.AccessPath, .CostEstimate, .Optimizable, .OptimizablePredicateList, .Optimizer, .RequiredRowOrdering, .Visitor, org.apache.derby.iapi.sql.dictionary.DataDictionary, org.apache.derby.iapi.util.JBitSet

A SingleChildResultSetNode represents a result set with a single child.

Field Summary

Modifier and TypeField and Description
pack-priv ResultSetNode
childResult

ResultSetNode under the SingleChildResultSetNode

protected boolean
Inherited from org.apache.derby.impl.sql.compile.FromTable:
ADD_PLANbestAccessPathbestCostEstimatebestSortAvoidancePathcorrelationNamecorrTableNamecurrentAccessPathhashKeyColumnsinitialCapacitylevelLOAD_PLANloadFactormaxCapacityorigTableNameREMOVE_PLANtableNumbertablePropertiestrulyTheBestAccessPathuserSpecifiedJoinStrategy

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

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

Overrides org.apache.derby.impl.sql.compile.FromTable.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.ResultSetNode.addNewPredicate.

Add a new predicate to the list.

pack-priv void
adjustForSortElimination()

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

Notify the underlying result set tree that the optimizer has chosen to "eliminate" a sort.

pack-priv void
adjustForSortElimination(RequiredRowOrdering rowOrdering)

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

Same goal as adjustForSortElimination above, but this version takes a RequiredRowOrdering to allow nodes to adjust based on the ORDER BY clause, if needed.

pack-priv ResultSetNode
changeAccessPath()

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

The optimizer's decision on the access path for a result set may require the generation of extra result sets.

pack-priv void
decrementLevel(int
The amount to decrement by.
decrement
)

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

Decrement (query block) level (0-based) for this FromTable.

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.ResultSetNode.ensurePredicateList.

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

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.ResultSetNode.flattenableInFromSubquery.

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

public boolean
forUpdate()

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

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

Return true if this is the target table of an update

pack-priv ResultSetNode

Returns:

ResultSetNode The childResult from this node.
getChildResult
()

Return the childResult from this node.

pack-priv CostEstimate

Returns:

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

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

Get the final CostEstimate for this node.

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.FromTable.getFromTableByName.

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

public AccessPath
public void
initAccessPaths(Optimizer
The optimizer being used.
optimizer
)

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

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

Init the access paths for this optimizable.

pack-priv boolean

Returns:

Whether or not the underlying ResultSet tree is for a NOT EXISTS.
isNotExists
()

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

Return whether or not the underlying ResultSet tree is for a NOT EXISTS join.

pack-priv boolean

Returns:

Whether or not the underlying ResultSet tree will return a single row.
isOneRowResultSet
()

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

Return whether or not the underlying ResultSet tree will return a single row, at most.

pack-priv boolean

Returns:

Whether the underlying ResultSet tree is ordered on the specified column.
isOrderedOn
(ColumnReference[]
The specified ColumnReference[]
crs
,
boolean
Whether or not the order of the CRs in the array can be permuted
permuteOrdering
,
List<FromBaseTable>
List that is to be filled with the FromBaseTable
fbtHolder
)

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

Return whether or not the underlying ResultSet tree is ordered on the specified columns.

pack-priv ResultSetNode
modifyAccessPaths()

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

Modify the access paths according to the decisions the optimizer made.

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.ResultSetNode.optimize.

Optimize this SingleChildResultSetNode.

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.ResultSetNode.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.ResultSetNode.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.FromTable.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.FromTable.pushExpressions.

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

public boolean

Returns:

true if references SESSION schema tables, else false
referencesSessionSchema
()

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

Return true if the node references SESSION schema tables (temporary or permanent)

pack-priv boolean

Returns:

true if found, else false
referencesTarget
(String
Table name (String) to search for.
name
,
boolean
Whether or not name is for a base table
baseTable
)

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

Search to see if a query references the specifed table name.

protected boolean

Returns:

Whether or not we need to do reflection in order to do the projection.
reflectionNeededForProjection
()

Determine whether we need to do reflection in order to do the projection.

pack-priv void
setChildResult(ResultSetNode
The new childResult for this node.
childResult
)

Set the childResult for this node.

pack-priv void
setLevel(int
The query block level for this FromTable.
level
)

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

Set the (query block) level (0-based) for this FromTable.

pack-priv boolean

Returns:

boolean Whether or not a reference to the table was found.
subqueryReferencesTarget
(String
The table name.
name
,
boolean
Whether or not the name is for a base table.
baseTable
)

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

Return whether or not this ResultSetNode contains a subquery with a reference to the specified target.

public void
updateBestPlanMap(short
Indicates whether we're adding, loading, or removing a best plan for the OptimizerImpl/Optimizable.
action
,
Object
Object to use as the map key when adding/looking up a plan. If it is an instance of OptimizerImpl then it corresponds to an outer query; otherwise it's some Optimizable above this Optimizable that could potentially reject plans chosen by the OptimizerImpl to which this Optimizable belongs.
planKey
)

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

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

When remembering "truly the best" access path for an Optimizable, we have to keep track of which OptimizerImpl the "truly the best" access is for.

pack-priv int

Returns:

The lock mode
updateTargetLockMode
()

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

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

Inherited from org.apache.derby.impl.sql.compile.FromTable:
assignCostEstimatecanBeOrderedcolumnsAreUpdatableconsiderSortAvoidancePathconvertAbsoluteToRelativeColumnPositioncursorTargetTableestimateCostfeasibleJoinStrategyfillInReferencedTableMapflattengetBaseTableNamegetBestAccessPathgetBestSortAvoidancePathgetCorrelationNamegetCostEstimategetCurrentAccessPathgetExposedNamegetLevelgetMergeTableIDgetNamegetNumColumnsReturnedgetOrigTableNamegetPropertiesgetResultColumnsForListgetSchemaDescriptorgetSchemaDescriptorgetScratchCostEstimategetTableDescriptorgetTableNamegetTableNumbergetUserSpecifiedJoinStrategyhashKeyColumnshasLargeObjectColumnshasTableNumberinitialCapacityisBaseTableisCoveringIndexisFlattenableJoinNodeisJoinColumnForRightOuterJoinisMaterializableisOneRowScanisTargetTablelegalJoinOrderloadFactorLOJ_reorderablemarkUpdatableByCursormaxCapacitymemoryUsageOKmodifyAccessPathneedsSpecialRCLBindingnextAccessPathoptimizeItoptimizeSubqueriespushOptPredicaterememberAsBestrememberJoinStrategyAsBestrememberSortAvoidancePathresetJoinStrategiessetCostEstimateCostsetHashKeyColumnssetMergeTableIDsetOrigTableNamesetPropertiessetTableNumberstartOptimizingsupportsMultipleInstantiationstellRowOrderingAboutConstantColumnstoStringtransformOuterJoinsuniqueJoinverifyProperties

Field Detail

childResultback to summary
pack-priv ResultSetNode childResult

ResultSetNode under the SingleChildResultSetNode

hasTrulyTheBestAccessPathback to summary
protected boolean hasTrulyTheBestAccessPath

Constructor Detail

SingleChildResultSetNodeback to summary
pack-priv SingleChildResultSetNode(ResultSetNode childResult, Properties tableProperties, ContextManager cm)

Method Detail

acceptChildrenback to summary
pack-priv void acceptChildren(Visitor v) throws StandardException

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

Accept the visitor for all visitable children of this node.

Parameters
v:Visitor

the visitor

Annotations
@Override
Exceptions
StandardException:
on error
addNewPredicateback to summary
pack-priv ResultSetNode addNewPredicate(Predicate predicate) throws StandardException

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

Add a new predicate to the list. This is useful when doing subquery transformations, when we build a new predicate with the left side of the subquery operator and the subquery's result column.

Parameters
predicate:Predicate

The predicate to add

Returns:ResultSetNode

ResultSetNode The new top of the tree.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
adjustForSortEliminationback to summary
pack-priv void adjustForSortElimination()

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

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.adjustForSortElimination.

Notify the underlying result set tree that the optimizer has chosen to "eliminate" a sort. Sort elimination can happen as part of preprocessing (see esp. SelectNode.preprocess(...)) or it can happen if the optimizer chooses an access path that inherently returns the rows in the correct order (also known as a "sort avoidance" plan). In either case we drop the sort and rely on the underlying result set tree to return its rows in the correct order. For most types of ResultSetNodes we automatically get the rows in the correct order if the sort was eliminated. One exception to this rule, though, is the case of an IndexRowToBaseRowNode, for which we have to disable bulk fetching on the underlying base table. Otherwise the index scan could return rows out of order if the base table is updated while the scan is "in progress" (i.e. while the result set is open). In order to account for this (and potentially other, similar issues in the future) this method exists to notify the result set node that it is expected to return rows in the correct order. The result set can then take necessary action to satsify this requirement--such as disabling bulk fetch in the case of IndexRowToBaseRowNode. All of that said, any ResultSetNodes for which we could potentially eliminate sorts should override this method accordingly. So we don't ever expect to get here.

Annotations
@Override
See Also
ResultSetNode#adjustForSortElimination
adjustForSortEliminationback to summary
pack-priv void adjustForSortElimination(RequiredRowOrdering rowOrdering) throws StandardException

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

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.adjustForSortElimination.

Same goal as adjustForSortElimination above, but this version takes a RequiredRowOrdering to allow nodes to adjust based on the ORDER BY clause, if needed.

Annotations
@Override
See Also
ResultSetNode#adjustForSortElimination
changeAccessPathback to summary
pack-priv ResultSetNode changeAccessPath() throws StandardException

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

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.changeAccessPath.

The optimizer's decision on the access path for a result set may require the generation of extra result sets. For example, if it chooses an index for a FromBaseTable, we need an IndexToBaseRowNode above the FromBaseTable (and the FromBaseTable has to change its column list to match the index. This method in the parent class does not generate any extra result sets. It may be overridden in child classes.

Returns:ResultSetNode

A ResultSetNode tree modified to do any extra processing for the chosen access path

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
ResultSetNode#changeAccessPath
decrementLevelback to summary
pack-priv void decrementLevel(int decrement)

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

Decrement (query block) level (0-based) for this FromTable. This is useful when flattening a subquery.

Parameters
decrement:int

The amount to decrement by.

Annotations
@Override
ensurePredicateListback to summary
pack-priv ResultSetNode ensurePredicateList(int numTables) throws StandardException

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

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

Parameters
numTables:int

The number of tables in the query.

Returns:ResultSetNode

ResultSetNode A RSN tree with a node which has a PredicateList on top.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
flattenableInFromSubqueryback to summary
pack-priv boolean flattenableInFromSubquery(FromList fromList)

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

Evaluate whether or not the subquery in a FromSubquery is flattenable. Currently, a FSqry is flattenable if all of the following are true: o Subquery is a SelectNode. o It contains no top level subqueries. (RESOLVE - we can relax this) o It does not contain a group by or having clause o It does not contain aggregates.

Parameters
fromList:FromList

The outer from list

Returns:boolean

boolean Whether or not the FromSubquery is flattenable.

Annotations
@Override
forUpdateback to summary
public boolean forUpdate()

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

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

Doc from org.apache.derby.iapi.sql.compile.Optimizable.forUpdate.

Return true if this is the target table of an update

Annotations
@Override
See Also
Optimizable#forUpdate
getChildResultback to summary
pack-priv ResultSetNode getChildResult()

Return the childResult from this node.

Returns:ResultSetNode

ResultSetNode The childResult from this node.

getFinalCostEstimateback to summary
pack-priv CostEstimate getFinalCostEstimate() throws StandardException

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

Get the final CostEstimate for this node.

Returns:CostEstimate

The final CostEstimate for this node, which is the final cost estimate for the child node.

Annotations
@Override
getFromTableByNameback to summary
pack-priv FromTable getFromTableByName(String name, String schemaName, boolean exactMatch) throws StandardException

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

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

Parameters
name:String

The specified name to search for as an exposed name.

schemaName:String

Schema name, if non-null.

exactMatch:boolean

Whether or not we need an exact match on specified schema and table names or match on table id.

Returns:FromTable

The FromTable, if any, with the exposed name.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
getTrulyTheBestAccessPathback to summary
public AccessPath getTrulyTheBestAccessPath()

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

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

Doc from org.apache.derby.iapi.sql.compile.Optimizable.getTrulyTheBestAccessPath.

Get the best access path overall for this Optimizable.

Annotations
@Override
See Also
Optimizable#getTrulyTheBestAccessPath
initAccessPathsback to summary
public void initAccessPaths(Optimizer optimizer)

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

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

Doc from org.apache.derby.iapi.sql.compile.Optimizable.initAccessPaths.

Init the access paths for this optimizable.

Parameters
optimizer:Optimizer

The optimizer being used.

Annotations
@Override
See Also
Optimizable#initAccessPaths
isNotExistsback to summary
pack-priv boolean isNotExists()

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

Return whether or not the underlying ResultSet tree is for a NOT EXISTS join.

Returns:boolean

Whether or not the underlying ResultSet tree is for a NOT EXISTS.

Annotations
@Override
isOneRowResultSetback to summary
pack-priv boolean isOneRowResultSet() throws StandardException

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

Return whether or not the underlying ResultSet tree will return a single row, at most. This is important for join nodes where we can save the extra next on the right side if we know that it will return at most 1 row.

Returns:boolean

Whether or not the underlying ResultSet tree will return a single row.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
isOrderedOnback to summary
pack-priv boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, List<FromBaseTable> fbtHolder) throws StandardException

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

Return whether or not the underlying ResultSet tree is ordered on the specified columns. RESOLVE - This method currently only considers the outermost table of the query block.

Parameters
crs:ColumnReference[]

The specified ColumnReference[]

permuteOrdering:boolean

Whether or not the order of the CRs in the array can be permuted

fbtHolder:List<FromBaseTable>

List that is to be filled with the FromBaseTable

Returns:boolean

Whether the underlying ResultSet tree is ordered on the specified column.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
modifyAccessPathsback to summary
pack-priv ResultSetNode modifyAccessPaths() throws StandardException

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

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.modifyAccessPaths.

Modify the access paths according to the decisions the optimizer made. This can include adding project/restrict nodes, index-to-base-row nodes, etc.

Returns:ResultSetNode

The modified query tree

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
ResultSetNode#modifyAccessPaths
optimizeback to summary
pack-priv ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicates, double outerRows) throws StandardException

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

Optimize this SingleChildResultSetNode.

Parameters
dataDictionary:DataDictionary

The DataDictionary to use for optimization

predicates:PredicateList

The PredicateList to optimize. This should be a join predicate.

outerRows:double

The number of outer joining rows

Returns:ResultSetNode

ResultSetNode The top of the optimized subtree

Annotations
@Override
Exceptions
StandardException:
Thrown on error
preprocessback to summary
pack-priv ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException

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

Put a ProjectRestrictNode on top of each FromTable in the FromList. 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 the ColumnReference. (The new PRN will have the original of the ResultColumnList and the ResultColumns from that list. The FromTable will get shallow copies of the ResultColumnList and its ResultColumns. ResultColumn.expression will remain at the FromTable, with the PRN getting a new VirtualColumnNode for each ResultColumn.expression.) We then project out the non-referenced columns. If there are no referenced columns, then the PRN's ResultColumnList will consist of a single ResultColumn whose expression is 1.

Parameters
numTables:int

Number of tables in the DML Statement

gbl:GroupByList

The group by list, if any

fromList:FromList

The from list, if any

Returns:ResultSetNode

The generated ProjectRestrictNode atop the original FromTable.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
printSubNodesback to summary
pack-priv void printSubNodes(int depth)

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

Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.

Parameters
depth:int

The depth of this node in the tree

Annotations
@Override
pullOptPredicatesback to summary
public void pullOptPredicates(OptimizablePredicateList optimizablePredicates) throws StandardException

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

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

Doc from org.apache.derby.iapi.sql.compile.Optimizable.pullOptPredicates.

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

Parameters
optimizablePredicates:OptimizablePredicateList

The list to put the pulled predicates in.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
Optimizable#pullOptPredicates
pushExpressionsback to summary
pack-priv void pushExpressions(PredicateList predicateList) throws StandardException

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

Push expressions down to the first ResultSetNode which can do expression evaluation and has the same referenced table map. RESOLVE - This means only pushing down single table expressions to DistinctNodes today. Once we have a better understanding of how the optimizer will work, we can push down join clauses.

Parameters
predicateList:PredicateList

The PredicateList.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
referencesSessionSchemaback to summary
public boolean referencesSessionSchema() throws StandardException

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

Return true if the node references SESSION schema tables (temporary or permanent)

Returns:boolean

true if references SESSION schema tables, else false

Annotations
@Override
Exceptions
StandardException:
Thrown on error
referencesTargetback to summary
pack-priv boolean referencesTarget(String name, boolean baseTable) throws StandardException

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

Search to see if a query references the specifed table name.

Parameters
name:String

Table name (String) to search for.

baseTable:boolean

Whether or not name is for a base table

Returns:boolean

true if found, else false

Annotations
@Override
Exceptions
StandardException:
Thrown on error
reflectionNeededForProjectionback to summary
protected boolean reflectionNeededForProjection()

Determine whether we need to do reflection in order to do the projection. Reflection is only needed if there is at least 1 column which is not simply selecting the source column.

Returns:boolean

Whether or not we need to do reflection in order to do the projection.

setChildResultback to summary
pack-priv void setChildResult(ResultSetNode childResult)

Set the childResult for this node.

Parameters
childResult:ResultSetNode

The new childResult for this node.

setLevelback to summary
pack-priv void setLevel(int level)

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

Set the (query block) level (0-based) for this FromTable.

Parameters
level:int

The query block level for this FromTable.

Annotations
@Override
subqueryReferencesTargetback to summary
pack-priv boolean subqueryReferencesTarget(String name, boolean baseTable) throws StandardException

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

Return whether or not this ResultSetNode contains a subquery with a reference to the specified target.

Parameters
name:String

The table name.

baseTable:boolean

Whether or not the name is for a base table.

Returns:boolean

boolean Whether or not a reference to the table was found.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
updateBestPlanMapback to summary
public void updateBestPlanMap(short action, Object planKey) throws StandardException

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

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

Doc from org.apache.derby.iapi.sql.compile.Optimizable.updateBestPlanMap.

When remembering "truly the best" access path for an Optimizable, we have to keep track of which OptimizerImpl the "truly the best" access is for. In most queries there will only be one OptimizerImpl in question, but in cases where there are nested subqueries, there will be one OptimizerImpl for every level of nesting, and each OptimizerImpl might have its own idea of what this Optimizable's "truly the best path" access path really is. In addition, there could be Optimizables above this Optimizable that might need to override the best path chosen during optimization. So whenever we save a "truly the best" path, we take note of which Optimizer/Optimizable told us to do so. Then as each level of subquery finishes optimization, the corresponding OptimizerImpl/Optimizable can load its preferred access path into this Optimizable's trulyTheBestAccessPath field and pass it up the tree, until eventually the outer-most OptimizerImpl can choose to either use the best path that it received from below (by calling "rememberAsBest()") or else use the path that it found to be "best" for itself. This method is what allows us to keep track of which OptimizerImpl or Optimizable saved which "best plan", and allows us to load the appropriate plans after each round of optimization.

Parameters
action:short

Indicates whether we're adding, loading, or removing a best plan for the OptimizerImpl/Optimizable.

planKey:Object

Object to use as the map key when adding/looking up a plan. If it is an instance of OptimizerImpl then it corresponds to an outer query; otherwise it's some Optimizable above this Optimizable that could potentially reject plans chosen by the OptimizerImpl to which this Optimizable belongs.

Annotations
@Override
See Also
Makes a call to add/load/remove a plan mapping for this node, and then makes the necessary call to recurse on this node's child, in order to ensure that we've handled the full plan all the way down this node's subtree.
updateTargetLockModeback to summary
pack-priv int updateTargetLockMode()

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

Get the lock mode for the target of an update statement (a delete or update). The update mode will always be row for CurrentOfNodes. It will be table if there is no where clause.

Returns:int

The lock mode

Annotations
@Override