Visitable
class SelectNode extends ResultSetNode
ResultSetNode.QueryExpressionClauses
Modifier and Type | Field | Description |
---|---|---|
private boolean |
bindTargetListOnly |
|
(package private) FromList |
fromList |
List of tables in the FROM clause of this SELECT
|
(package private) GroupByList |
groupByList |
List of result columns in GROUP BY clause
|
private java.util.List<AggregateNode> |
havingAggregates |
Aggregates in the HAVING clause.
|
(package private) ValueNode |
havingClause |
|
(package private) SubqueryList |
havingSubquerys |
|
private boolean |
isDistinct |
|
private int |
nestingLevel |
|
private boolean |
orderByAndDistinctMerged |
|
(package private) boolean |
orderByQuery |
|
(package private) ValueNode |
originalWhereClause |
|
(package private) boolean |
originalWhereClauseHadSubqueries |
|
(package private) OptimizerPlan |
overridingPlan |
Full plan for this SELECT as specified in an optimizer override
|
private FromList |
preJoinFL |
|
(package private) ResultSetNode.QueryExpressionClauses |
qec |
|
private java.util.List<AggregateNode> |
selectAggregates |
Aggregates in the SELECT list.
|
(package private) SubqueryList |
selectSubquerys |
|
(package private) FromTable |
targetTable |
|
private boolean |
wasGroupBy |
User specified a group by without aggregates and we turned
it into a select distinct
|
private java.util.List<AggregateNode> |
whereAggregates |
Aggregates in the WHERE clause.
|
(package private) ValueNode |
whereClause |
The ValueNode for the WHERE clause must represent a boolean
expression.
|
(package private) PredicateList |
wherePredicates |
|
(package private) SubqueryList |
whereSubquerys |
|
(package private) java.util.List<WindowFunctionNode> |
windowFuncCalls |
List of window function calls (e.g.
|
(package private) WindowList |
windows |
List of windows.
|
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
Constructor | Description |
---|---|
SelectNode(ResultColumnList selectList,
FromList fromList,
ValueNode whereClause,
GroupByList groupByList,
ValueNode havingClause,
WindowList windowDefinitionList,
OptimizerPlan overridingPlan,
ContextManager cm) |
Modifier and Type | Method | Description |
---|---|---|
(package private) void |
acceptChildren(Visitor v) |
Accept the visitor for all visitable children of this node.
|
private WindowList |
addInlinedWindowDefinition(WindowList wl,
WindowFunctionNode wfn) |
|
(package private) ResultSetNode |
addNewPredicate(Predicate predicate) |
Add a new predicate to the list.
|
(package private) void |
bindExpressions(FromList fromListParam) |
Bind the expressions in this SelectNode.
|
(package private) void |
bindExpressionsWithTables(FromList fromListParam) |
Bind the expressions in this ResultSetNode if it has tables.
|
(package private) ResultSetNode |
bindNonVTITables(DataDictionary dataDictionary,
FromList fromListParam) |
Bind the tables in this SelectNode.
|
(package private) void |
bindResultColumns(TableDescriptor targetTableDescriptor,
FromVTI targetVTI,
ResultColumnList targetColumnList,
DMLStatementNode statement,
FromList fromListParam) |
Bind the result columns for this ResultSetNode to a base table.
|
(package private) void |
bindResultColumns(FromList fromListParam) |
Bind the result columns of this ResultSetNode when there is no
base table to bind them to.
|
(package private) void |
bindTargetExpressions(FromList fromListParam) |
Bind the expressions in the target list.
|
(package private) void |
bindUntypedNullsToResultColumns(ResultColumnList bindingRCL) |
Bind any untyped null nodes to the types in the given ResultColumnList.
|
(package private) static void |
checkNoWindowFunctions(QueryTreeNode clause,
java.lang.String clauseName) |
|
(package private) void |
clearDistinct() |
|
(package private) void |
decrementLevel(int decrement) |
Decrement (query block) level (0-based) for
all of the tables in this ResultSet tree.
|
(package private) ResultSetNode |
ensurePredicateList(int numTables) |
Ensure that the top of the RSN tree has a PredicateList.
|
(package private) ColumnReference |
findColumnReferenceInResult(java.lang.String colName) |
Find colName in the result columns and return underlying columnReference.
|
(package private) boolean |
flattenableInFromSubquery(FromList fromList) |
Evaluate whether or not the subquery in a FromSubquery is flattenable.
|
(package private) ResultSetNode |
genProjectRestrict(int origFromListSize) |
Replace this SelectNode with a ProjectRestrictNode,
since it has served its purpose.
|
(package private) FromTable |
getCursorTargetTable() |
Assumes that isCursorUpdatable has been called, and that it
is only called for updatable cursors.
|
(package private) CostEstimate |
getFinalCostEstimate() |
Get the final CostEstimate for this SelectNode.
|
(package private) FromList |
getFromList() |
Return the fromList for this SelectNode.
|
(package private) FromTable |
getFromTableByName(java.lang.String name,
java.lang.String schemaName,
boolean exactMatch) |
Determine whether or not the specified name is an exposed name in
the current query block.
|
private Optimizer |
getOptimizer(OptimizableList optList,
OptimizablePredicateList predList,
DataDictionary dataDictionary,
RequiredRowOrdering requiredRowOrdering,
OptimizerPlan overridingPlan) |
Get an optimizer to use for this SelectNode.
|
(package private) SubqueryList |
getSelectSubquerys() |
Return the selectSubquerys for this SelectNode.
|
(package private) ValueNode |
getWhereClause() |
Return the whereClause for this SelectNode.
|
(package private) PredicateList |
getWherePredicates() |
Return the wherePredicates for this SelectNode.
|
(package private) SubqueryList |
getWhereSubquerys() |
Return the whereSubquerys for this SelectNode.
|
(package private) boolean |
hasAggregatesInSelectList() |
|
(package private) boolean |
hasDistinct() |
|
(package private) boolean |
hasOffsetFetchFirst() |
|
(package private) boolean |
hasWindows() |
Used by SubqueryNode to avoid flattening of a subquery if a window is
defined on it.
|
private boolean |
isOrderedResult(ResultColumnList resultColumns,
ResultSetNode newTopRSN,
boolean permuteOrdering) |
Is the result of this node an ordered result set.
|
(package private) boolean |
isUpdatableCursor(DataDictionary dd) |
Determine if this select is updatable or not, for a cursor.
|
(package private) void |
makeDistinct() |
|
(package private) ResultSetNode |
modifyAccessPaths() |
Modify the access paths according to the choices the optimizer made.
|
(package private) ResultSetNode |
modifyAccessPaths(PredicateList predList) |
Modify the access paths according to the decisions the optimizer
made.
|
private ValueNode |
normExpressions(ValueNode boolClause) |
Put the expression trees in conjunctive normal form
|
(package private) ResultSetNode |
optimize(DataDictionary dataDictionary,
PredicateList predicateList,
double outerRows) |
Optimize this SelectNode.
|
private void |
performTransitiveClosure(int numTables) |
Peform the various types of transitive closure on the where clause.
|
(package private) ResultSetNode |
preprocess(int numTables,
GroupByList gbl,
FromList fl) |
Put a ProjectRestrictNode on top of each FromTable in the FromList.
|
(package private) void |
printSubNodes(int depth) |
Prints the sub-nodes of this object.
|
(package private) void |
pushExpressionsIntoSelect(Predicate predicate) |
Push an expression into this SELECT (and possibly down into
one of the tables in the FROM list).
|
(package private) void |
pushOffsetFetchFirst(ValueNode offset,
ValueNode fetchFirst,
boolean hasJDBClimitClause) |
Push down the offset and fetch first parameters to this node.
|
(package private) void |
pushOrderByList(OrderByList orderByList) |
Push the order by list down from the cursor node
into its child result set so that the optimizer
has all of the information that it needs to
consider sort avoidance.
|
void |
pushQueryExpressionSuffix() |
Set up a new level for order by and fetch/offset clauses.
|
boolean |
referencesSessionSchema() |
Return true if the node references SESSION schema tables (temporary or permanent)
|
(package private) boolean |
referencesTarget(java.lang.String name,
boolean baseTable) |
Search to see if a query references the specifed table name.
|
(package private) void |
rejectParameters() |
Check for (and reject) ?
|
(package private) void |
replaceOrForbidDefaults(TableDescriptor ttd,
ResultColumnList tcl,
boolean allowDefaults) |
Replace any DEFAULTs with the associated tree for the default if
allowed, or flag (when inside top level set operator nodes).
|
(package private) boolean |
returnsAtMostOneRow() |
Return whether or not this ResultSet tree is guaranteed to return
at most 1 row based on heuristics.
|
(package private) java.lang.String |
statementToString() |
|
(package private) boolean |
subqueryReferencesTarget(java.lang.String name,
boolean baseTable) |
Return whether or not this ResultSetNode contains a subquery with a
reference to the specified target table.
|
java.lang.String |
toString() |
Convert this object to a String.
|
(package private) boolean |
uniqueSubquery(boolean additionalEQ) |
Determine whether or not this subquery,
the SelectNode is in a subquery, can be flattened
into the outer query block based on a uniqueness condition.
|
(package private) int |
updateTargetLockMode() |
Get the lock mode for the target of an update statement
(a delete or update).
|
(package private) void |
verifySelectStarSubquery(FromList outerFromList,
int subqueryType) |
Verify that a SELECT * is valid for this type of subquery.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
adjustForSortElimination, adjustForSortElimination, assignResultSetNumber, bindVTITables, changeAccessPath, columnTypesAndLengthsMatch, considerMaterialization, enhanceRCLForInsert, fillInReferencedTableMap, generateNormalizationResultSet, generateResultSet, genProjectRestrict, genProjectRestrictForReordering, getAllResultColumns, getCandidateFinalCostEstimate, getCostEstimate, getMatchingColumn, getNewCostEstimate, getOptimizer, getOptimizerImpl, getRCLForInsert, getReferencedTableMap, getResultColumns, getResultSetNumber, getScratchCostEstimate, isCursorTargetTable, isInsertSource, isNotExists, isOneRowResultSet, isOrderedOn, isPossibleDistinctScan, isStatementResultSet, LOJgetReferencedTables, makeResultDescription, makeResultDescriptors, markAsCursorTargetTable, markForDistinctScan, markStatementResultSet, notCursorTargetTable, notFlattenableJoin, numDistinctAggregates, parseDefault, performMaterialization, printQueryExpressionSuffixClauses, projectResultColumns, rejectXMLValues, renameGeneratedResultNames, setCandidateFinalCostEstimate, setCostEstimate, setCursorTargetTable, setInsertSource, setOptimizer, setReferencedTableMap, setResultColumns, setResultSetNumber, setResultToBooleanTrueNode, setScratchCostEstimate, setTableConstructorTypes
FromList fromList
FromTable targetTable
private java.util.List<AggregateNode> selectAggregates
private java.util.List<AggregateNode> whereAggregates
private java.util.List<AggregateNode> havingAggregates
ValueNode whereClause
ValueNode originalWhereClause
GroupByList groupByList
WindowList windows
OptimizerPlan overridingPlan
java.util.List<WindowFunctionNode> windowFuncCalls
private boolean wasGroupBy
boolean orderByQuery
PredicateList wherePredicates
SubqueryList selectSubquerys
SubqueryList whereSubquerys
SubqueryList havingSubquerys
private boolean bindTargetListOnly
private boolean isDistinct
private boolean orderByAndDistinctMerged
boolean originalWhereClauseHadSubqueries
private FromList preJoinFL
ValueNode havingClause
private int nestingLevel
SelectNode(ResultColumnList selectList, FromList fromList, ValueNode whereClause, GroupByList groupByList, ValueNode havingClause, WindowList windowDefinitionList, OptimizerPlan overridingPlan, ContextManager cm) throws StandardException
StandardException
private WindowList addInlinedWindowDefinition(WindowList wl, WindowFunctionNode wfn)
public java.lang.String toString()
toString
in class ResultSetNode
java.lang.String statementToString()
void makeDistinct()
void clearDistinct()
boolean hasDistinct()
void printSubNodes(int depth)
printSubNodes
in class ResultSetNode
depth
- The depth of this node in the treeFromList getFromList()
getFromList
in class ResultSetNode
ColumnReference findColumnReferenceInResult(java.lang.String colName) throws StandardException
colName
- Name of the columnStandardException
ValueNode getWhereClause()
PredicateList getWherePredicates()
SubqueryList getSelectSubquerys()
SubqueryList getWhereSubquerys()
ResultSetNode bindNonVTITables(DataDictionary dataDictionary, FromList fromListParam) throws StandardException
bindNonVTITables
in class ResultSetNode
dataDictionary
- The DataDictionary to use for bindingfromListParam
- FromList to use/append to.StandardException
- Thrown on errorvoid bindExpressions(FromList fromListParam) throws StandardException
bindExpressions
in class ResultSetNode
fromListParam
- FromList to use/append to.StandardException
- Thrown on errorvoid bindExpressionsWithTables(FromList fromListParam) throws StandardException
bindExpressionsWithTables
in class ResultSetNode
fromListParam
- FromList to use/append to.StandardException
- Thrown on errorvoid bindTargetExpressions(FromList fromListParam) throws StandardException
bindTargetExpressions
in class ResultSetNode
StandardException
- Thrown on errorvoid bindResultColumns(FromList fromListParam) throws StandardException
bindResultColumns
in class ResultSetNode
fromListParam
- FromList to use/append to.StandardException
- Thrown on errorvoid bindResultColumns(TableDescriptor targetTableDescriptor, FromVTI targetVTI, ResultColumnList targetColumnList, DMLStatementNode statement, FromList fromListParam) throws StandardException
bindResultColumns
in class ResultSetNode
targetTableDescriptor
- The TableDescriptor for the table being
updated or inserted intotargetColumnList
- 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
- Calling DMLStatementNode (Insert or Update)fromListParam
- FromList to use/append to.StandardException
- Thrown on errorvoid pushExpressionsIntoSelect(Predicate predicate) throws StandardException
predicate
- The predicate that we attempt to pushStandardException
- Thrown on errorvoid verifySelectStarSubquery(FromList outerFromList, int subqueryType) throws StandardException
verifySelectStarSubquery
in class ResultSetNode
outerFromList
- The FromList from the outer query block(s)subqueryType
- The subquery typeStandardException
- Thrown on errorFromTable getFromTableByName(java.lang.String name, java.lang.String schemaName, boolean exactMatch) throws StandardException
getFromTableByName
in class ResultSetNode
name
- The specified name to search for as an exposed name.schemaName
- Schema name, if non-null.exactMatch
- Whether or not we need an exact match on specified schema and table
names or match on table id.StandardException
- Thrown on errorvoid rejectParameters() throws StandardException
rejectParameters
in class ResultSetNode
StandardException
- Thrown if a ? parameter found
directly under a ResultColumnpublic void pushQueryExpressionSuffix()
ResultSetNode
ResultSetNode.QueryExpressionClauses
.
Overridden by implementors of pushOrderByNode, pushOffsetFetchFirst.pushQueryExpressionSuffix
in class ResultSetNode
void pushOrderByList(OrderByList orderByList)
pushOrderByList
in class ResultSetNode
orderByList
- The order by listvoid pushOffsetFetchFirst(ValueNode offset, ValueNode fetchFirst, boolean hasJDBClimitClause)
pushOffsetFetchFirst
in class ResultSetNode
offset
- the OFFSET, if anyfetchFirst
- the OFFSET FIRST, if anyhasJDBClimitClause
- true if the clauses were added by (and have the semantics of) a JDBC limit clauseResultSetNode preprocess(int numTables, GroupByList gbl, FromList fl) throws StandardException
preprocess
in class ResultSetNode
numTables
- The number of tables in the DML Statementgbl
- The outer group by list, if anyfl
- The from list, if anyStandardException
- Thrown on errorprivate void performTransitiveClosure(int numTables) throws StandardException
numTables
- The number of tables in the queryStandardException
- Thrown on errorprivate ValueNode normExpressions(ValueNode boolClause) throws StandardException
boolClause
- clause to normalizeStandardException
- Thrown on errorResultSetNode addNewPredicate(Predicate predicate) throws StandardException
addNewPredicate
in class ResultSetNode
predicate
- The predicate to addStandardException
- Thrown on errorboolean flattenableInFromSubquery(FromList fromList)
flattenableInFromSubquery
in class ResultSetNode
fromList
- The outer from listResultSetNode genProjectRestrict(int origFromListSize) throws StandardException
genProjectRestrict
in class ResultSetNode
origFromListSize
- The size of the original FROM list, before
generation of join tree.StandardException
- Thrown on errorprivate boolean isOrderedResult(ResultColumnList resultColumns, ResultSetNode newTopRSN, boolean permuteOrdering) throws StandardException
StandardException
- Thrown on errorResultSetNode ensurePredicateList(int numTables) throws StandardException
ensurePredicateList
in class ResultSetNode
numTables
- The number of tables in the query.StandardException
- Thrown on errorResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicateList, double outerRows) throws StandardException
optimize
in class ResultSetNode
dataDictionary
- The DataDictionary to use for optimizationpredicateList
- The predicate list to optimize againstouterRows
- The number of outer joining rowsStandardException
- Thrown on errorprivate Optimizer getOptimizer(OptimizableList optList, OptimizablePredicateList predList, DataDictionary dataDictionary, RequiredRowOrdering requiredRowOrdering, OptimizerPlan overridingPlan) throws StandardException
StandardException
- Thrown on errorResultSetNode modifyAccessPaths(PredicateList predList) throws StandardException
modifyAccessPaths
in class ResultSetNode
predList
- A list of optimizable predicates that should
be pushed to this ResultSetNode, as determined by optimizer.StandardException
- Thrown on errorResultSetNode modifyAccessPaths() throws StandardException
modifyAccessPaths
in class ResultSetNode
StandardException
- Thrown on errorCostEstimate getFinalCostEstimate() throws StandardException
getFinalCostEstimate
in class ResultSetNode
StandardException
boolean isUpdatableCursor(DataDictionary dd) throws StandardException
isUpdatableCursor
in class ResultSetNode
StandardException
- Thrown on errorFromTable getCursorTargetTable()
getCursorTargetTable
in class ResultSetNode
boolean referencesTarget(java.lang.String name, boolean baseTable) throws StandardException
referencesTarget
in class ResultSetNode
name
- Table name (String) to search for.baseTable
- Whether or not name is for a base tableStandardException
- Thrown on errorboolean subqueryReferencesTarget(java.lang.String name, boolean baseTable) throws StandardException
subqueryReferencesTarget
in class ResultSetNode
name
- The table name.baseTable
- Whether or not table is a base table.StandardException
- Thrown on errorvoid bindUntypedNullsToResultColumns(ResultColumnList bindingRCL) throws StandardException
bindUntypedNullsToResultColumns
in class ResultSetNode
bindingRCL
- The ResultColumnList with the types to bind to.StandardException
- Thrown on errorvoid decrementLevel(int decrement)
decrementLevel
in class ResultSetNode
decrement
- The amount to decrement by.boolean uniqueSubquery(boolean additionalEQ) throws StandardException
additionalEQ
- Whether or not the column returned
by this select, if it is a ColumnReference,
is in an equality comparison.StandardException
- Thrown on errorint updateTargetLockMode()
updateTargetLockMode
in class ResultSetNode
TransactionController
boolean returnsAtMostOneRow()
returnsAtMostOneRow
in class ResultSetNode
public boolean referencesSessionSchema() throws StandardException
referencesSessionSchema
in class QueryTreeNode
StandardException
- Thrown on errorvoid acceptChildren(Visitor v) throws StandardException
acceptChildren
in class ResultSetNode
v
- the visitorStandardException
- on errorboolean hasAggregatesInSelectList()
boolean hasWindows()
static void checkNoWindowFunctions(QueryTreeNode clause, java.lang.String clauseName) throws StandardException
StandardException
void replaceOrForbidDefaults(TableDescriptor ttd, ResultColumnList tcl, boolean allowDefaults) throws StandardException
replaceOrForbidDefaults
in class ResultSetNode
ttd
- The TableDescriptor for the target table.tcl
- The RCL for the target table.allowDefaults
- true if allowedStandardException
- Thrown on errorboolean hasOffsetFetchFirst()
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.