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

pack-priv abstract Class TableOperatorNode

extends FromTable
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.compile.JoinNode, org.apache.derby.impl.sql.compile.SetOperatorNode
Imports
java.util.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.CostEstimate, .Optimizable, .Optimizer, .OptimizerFactory, .RequiredRowOrdering, .Visitor, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.dictionary.DataDictionary, .TableDescriptor, org.apache.derby.iapi.util.JBitSet

A TableOperatorNode represents a relational operator like UNION, INTERSECT, JOIN, etc. that takes two tables as parameters and returns a table. The parameters it takes are represented as ResultSetNodes. Currently, all known table operators are binary operators, so there are no subclasses of this node type called "BinaryTableOperatorNode" and "UnaryTableOperatorNode".

Field Summary

Modifier and TypeField and Description
private boolean
pack-priv Optimizer
pack-priv ResultSetNode
private boolean
pack-priv Optimizer
pack-priv ResultSetNode
Inherited from org.apache.derby.impl.sql.compile.FromTable:
ADD_PLANbestAccessPathbestCostEstimatebestSortAvoidancePathcorrelationNamecorrTableNamecurrentAccessPathhashKeyColumnsinitialCapacitylevelLOAD_PLANloadFactormaxCapacityorigTableNameREMOVE_PLANtableNumbertablePropertiestrulyTheBestAccessPathuserSpecifiedJoinStrategy

Constructor Summary

AccessConstructor and Description
pack-priv
TableOperatorNode(ResultSetNode
The ResultSetNode on the left side of this node
leftResultSet
,
ResultSetNode
The ResultSetNode on the right side of this node
rightResultSet
,
Properties
Properties list associated with the table
tableProperties
,
ContextManager
The context manager
cm
)

Constructor for a TableOperatorNode.

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 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 void
bindExpressions(FromList
FromList to use/append to.
fromListParam
)

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

Bind the expressions under this TableOperatorNode.

pack-priv void
bindExpressionsWithTables(FromList
FromList to use/append to.
fromListParam
)

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

Bind the expressions in this ResultSetNode if it has tables.

pack-priv ResultSetNode

Returns:

ResultSetNode Returns this.
bindNonVTITables
(DataDictionary
The DataDictionary to use for binding
dataDictionary
,
FromList
FromList to use/append to.
fromListParam
)

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

Bind the non VTI tables in this TableOperatorNode.

pack-priv void
bindResultColumns(FromList
FromList to use/append to.
fromListParam
)

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

Bind the result columns of this ResultSetNode when there is no base table to bind them to.

pack-priv void
bindResultColumns(TableDescriptor
The TableDescriptor for the table being updated or inserted into
targetTableDescriptor
,
FromVTI targetVTI, ResultColumnList
For INSERT statements, the user does not have to supply column names (for example, "insert into t values (1,2,3)". When this parameter is null, it means that the user did not supply column names, and so the binding should be done based on order. When it is not null, it means do the binding by name, not position.
targetColumnList
,
DMLStatementNode
Calling DMLStatementNode (Insert or Update)
statement
,
FromList
FromList to use/append to.
fromListParam
)

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

Bind the result columns for this ResultSetNode to a base table.

pack-priv void
bindUntypedNullsToResultColumns(ResultColumnList
The ResultColumnList with the types to bind nulls to
rcl
)

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

DERBY-4365 Bind untyped nulls to the types in the given ResultColumnList.

pack-priv ResultSetNode

Returns:

ResultSetNode Returns this.
bindVTITables
(FromList
FromList to use/append to.
fromListParam
)

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

Bind the VTI tables in this TableOperatorNode.

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 all of the tables in this ResultSet tree.

pack-priv String

Returns:

The exposed name for this table.
getExposedName
()

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

Return the exposed name for this table, which is the name that can be used to refer to this table in the rest of the query.

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.

pack-priv ResultSetNode
pack-priv ResultSetNode

Returns:

ResultSetNode The leftResultSet from this node.
getLeftResultSet
()

Get the leftResultSet from this node.

pack-priv ResultSetNode

Returns:

ResultSetNode The rightResultSet from this node.
getRightResultSet
()

Get the rightResultSet from this node.

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.

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 boolean
needsSpecialRCLBinding()

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

apparently something special needs to be done for me....

pack-priv ResultSetNode

Returns:

ResultSetNode The top of the optimized query tree
optimize
(DataDictionary
The DataDictionary to use for optimization
dataDictionary
,
PredicateList
The PredicateList to apply.
predicateList
,
double
The number of outer joining rows
outerRows
)

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

Optimize a TableOperatorNode.

protected ResultSetNode
optimizeSource(Optimizer optimizer, ResultSetNode sourceResultSet, PredicateList predList, CostEstimate outerCost)

Optimize a source result set to this table operator.

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.

pack-priv void
projectResultColumns()

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

Find the unreferenced result columns and project them out.

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.

pack-priv void
pack-priv void
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 void
setNestedInParens(boolean
Whether or not this node is nested in parens.
nestedInParens
)

Mark whether or not this node is nested in parens.

pack-priv void
setReferencedColumns()

Set the referenced columns in the column list if it may not be correct.

public String

Returns:

This object as a String
toString
()

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

Convert this object to a String.

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.

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.FromTable:
assignCostEstimatecanBeOrderedcolumnsAreUpdatableconsiderSortAvoidancePathconvertAbsoluteToRelativeColumnPositioncursorTargetTableestimateCostfeasibleJoinStrategyfillInReferencedTableMapflattenforUpdategetBaseTableNamegetBestAccessPathgetBestSortAvoidancePathgetCorrelationNamegetCostEstimategetCurrentAccessPathgetFinalCostEstimategetLevelgetMergeTableIDgetNamegetNumColumnsReturnedgetOrigTableNamegetPropertiesgetResultColumnsForListgetSchemaDescriptorgetSchemaDescriptorgetScratchCostEstimategetTableDescriptorgetTableNamegetTableNumbergetTrulyTheBestAccessPathgetUserSpecifiedJoinStrategyhashKeyColumnshasLargeObjectColumnshasTableNumberinitAccessPathsinitialCapacityisBaseTableisCoveringIndexisFlattenableJoinNodeisJoinColumnForRightOuterJoinisMaterializableisOneRowScanisTargetTablelegalJoinOrderloadFactorLOJ_reorderablemarkUpdatableByCursormaxCapacitymemoryUsageOKnextAccessPathoptimizeItoptimizeSubqueriespullOptPredicatespushExpressionspushOptPredicaterememberAsBestrememberJoinStrategyAsBestrememberSortAvoidancePathresetJoinStrategiessetCostEstimateCostsetHashKeyColumnssetMergeTableIDsetOrigTableNamesetPropertiessetTableNumberstartOptimizingsupportsMultipleInstantiationstellRowOrderingAboutConstantColumnstransformOuterJoinsuniqueJoin

Field Detail

leftModifyAccessPathsDoneback to summary
private boolean leftModifyAccessPathsDone
leftOptimizerback to summary
pack-priv Optimizer leftOptimizer
leftResultSetback to summary
pack-priv ResultSetNode leftResultSet
rightModifyAccessPathsDoneback to summary
private boolean rightModifyAccessPathsDone
rightOptimizerback to summary
pack-priv Optimizer rightOptimizer
rightResultSetback to summary
pack-priv ResultSetNode rightResultSet

Constructor Detail

TableOperatorNodeback to summary
pack-priv TableOperatorNode(ResultSetNode leftResultSet, ResultSetNode rightResultSet, Properties tableProperties, ContextManager cm) throws StandardException

Constructor for a TableOperatorNode.

Parameters
leftResultSet:ResultSetNode

The ResultSetNode on the left side of this node

rightResultSet:ResultSetNode

The ResultSetNode on the right side of this node

tableProperties:Properties

Properties list associated with the table

cm:ContextManager

The context manager

Exceptions
StandardException:
Thrown on error

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
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
bindExpressionsback to summary
pack-priv void bindExpressions(FromList fromListParam) throws StandardException

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

Bind the expressions under this TableOperatorNode. This means binding the sub-expressions, as well as figuring out what the return type is for each expression.

Parameters
fromListParam:FromList

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

FromList to use/append to.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindExpressionsWithTablesback to summary
pack-priv void bindExpressionsWithTables(FromList fromListParam) throws StandardException

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

Bind the expressions in this ResultSetNode if it has tables. This means binding the sub-expressions, as well as figuring out what the return type is for each expression.

Parameters
fromListParam:FromList

FromList to use/append to.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindNonVTITablesback to summary
pack-priv ResultSetNode bindNonVTITables(DataDictionary dataDictionary, FromList fromListParam) throws StandardException

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

Bind the non VTI tables in this TableOperatorNode. This means getting their TableDescriptors from the DataDictionary. We will build an unbound RCL for this node. This RCL must be "bound by hand" after the underlying left and right RCLs are bound.

Parameters
dataDictionary:DataDictionary

The DataDictionary to use for binding

fromListParam:FromList

FromList to use/append to.

Returns:ResultSetNode

ResultSetNode Returns this.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindResultColumnsback to summary
pack-priv void bindResultColumns(FromList fromListParam) throws StandardException

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

Bind the result columns of this ResultSetNode when there is no base table to bind them to. This is useful for SELECT statements, where the result columns get their types from the expressions that live under them.

Parameters
fromListParam:FromList

FromList to use/append to.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindResultColumnsback to summary
pack-priv void bindResultColumns(TableDescriptor targetTableDescriptor, FromVTI targetVTI, ResultColumnList targetColumnList, DMLStatementNode statement, FromList fromListParam) throws StandardException

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

Bind the result columns for this ResultSetNode to a base table. This is useful for INSERT and UPDATE statements, where the result columns get their types from the table being updated or inserted into. If a result column list is specified, then the verification that the result column list does not contain any duplicates will be done when binding them by name.

Parameters
targetTableDescriptor:TableDescriptor

The TableDescriptor for the table being updated or inserted into

targetColumnList:ResultColumnList

For INSERT statements, the user does not have to supply column names (for example, "insert into t values (1,2,3)". When this parameter is null, it means that the user did not supply column names, and so the binding should be done based on order. When it is not null, it means do the binding by name, not position.

statement:DMLStatementNode

Calling DMLStatementNode (Insert or Update)

fromListParam:FromList

FromList to use/append to.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindUntypedNullsToResultColumnsback to summary
pack-priv void bindUntypedNullsToResultColumns(ResultColumnList rcl) throws StandardException

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

DERBY-4365 Bind untyped nulls to the types in the given ResultColumnList. This is used for binding the nulls in row constructors and table constructors.

Parameters
rcl:ResultColumnList

The ResultColumnList with the types to bind nulls to

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindVTITablesback to summary
pack-priv ResultSetNode bindVTITables(FromList fromListParam) throws StandardException

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

Bind the VTI tables in this TableOperatorNode. This means getting their TableDescriptors from the DataDictionary. We will build an unbound RCL for this node. This RCL must be "bound by hand" after the underlying left and right RCLs are bound.

Parameters
fromListParam:FromList

FromList to use/append to.

Returns:ResultSetNode

ResultSetNode Returns this.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
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 all of the tables in this ResultSet tree. This is useful when flattening a subquery.

Parameters
decrement:int

The amount to decrement by.

Annotations
@Override
getExposedNameback to summary
pack-priv String getExposedName()

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

Return the exposed name for this table, which is the name that can be used to refer to this table in the rest of the query.

Returns:String

The exposed name for this table.

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
getLeftmostResultSetback to summary
pack-priv ResultSetNode getLeftmostResultSet()
getLeftResultSetback to summary
pack-priv ResultSetNode getLeftResultSet()

Get the leftResultSet from this node.

Returns:ResultSetNode

ResultSetNode The leftResultSet from this node.

getRightResultSetback to summary
pack-priv ResultSetNode getRightResultSet()

Get the rightResultSet from this node.

Returns:ResultSetNode

ResultSetNode The rightResultSet from this node.

modifyAccessPathback to summary
public Optimizable modifyAccessPath(JBitSet outerTables) throws StandardException

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

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

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

Modify the access path for this Optimizable, as necessary. This includes things like adding a result set to translate from index rows to base rows

Parameters
outerTables:JBitSet

Bit map of the tables that are outer to this one in the join order.

Returns:Optimizable

The (potentially new) Optimizable at the top of the tree.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
Optimizable#modifyAccessPath
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
needsSpecialRCLBindingback to summary
pack-priv boolean needsSpecialRCLBinding()

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

apparently something special needs to be done for me....

Annotations
@Override
optimizeback to summary
pack-priv ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicateList, double outerRows) throws StandardException

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

Optimize a TableOperatorNode.

Parameters
dataDictionary:DataDictionary

The DataDictionary to use for optimization

predicateList:PredicateList

The PredicateList to apply.

outerRows:double

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

The number of outer joining rows

Returns:ResultSetNode

ResultSetNode The top of the optimized query tree

Annotations
@Override
Exceptions
StandardException:
Thrown on error
optimizeSourceback to summary
protected ResultSetNode optimizeSource(Optimizer optimizer, ResultSetNode sourceResultSet, PredicateList predList, CostEstimate outerCost) throws StandardException

Optimize a source result set to this table operator.

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
projectResultColumnsback to summary
pack-priv void projectResultColumns() throws StandardException

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

Find the unreferenced result columns and project them out. This is used in pre-processing joins that are not flattened into the where clause.

Annotations
@Override
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
rejectParametersback to summary
pack-priv void rejectParameters() throws StandardException

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

Check for (and reject) ? parameters directly under the ResultColumns. This is done for SELECT statements. For TableOperatorNodes, we simply pass the check through to the left and right children.

Annotations
@Override
Exceptions
StandardException:
Thrown if a ? parameter found directly under a ResultColumn
setLeftmostResultSetback to summary
pack-priv void setLeftmostResultSet(ResultSetNode newLeftResultSet)
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
setNestedInParensback to summary
pack-priv void setNestedInParens(boolean nestedInParens)

Mark whether or not this node is nested in parens. (Useful to parser since some trees get created left deep and others right deep.) The resulting state of this cal was never used so its field was removed to save runtimespace for this node. Further cleanup can be done including parser changes if this call is really nor required.

Parameters
nestedInParens:boolean

Whether or not this node is nested in parens.

setReferencedColumnsback to summary
pack-priv void setReferencedColumns()

Set the referenced columns in the column list if it may not be correct.

toStringback to summary
public String toString()

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

Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Returns:String

This object as a String

Annotations
@Override
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 the plan mapping for this node, and then makes the necessary call to recurse on this node's left and right child, in order to ensure that we've handled the full plan all the way down this node's subtree.
verifyPropertiesback to summary
public void verifyProperties(DataDictionary dDictionary) throws StandardException

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

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

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

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

Parameters
dDictionary:DataDictionary

The DataDictionary to use.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
Optimizable#verifyProperties