|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.ResultSetNode
org.apache.derby.impl.sql.compile.SelectNode
A SelectNode represents the result set for any of the basic DML operations: SELECT, INSERT, UPDATE, and DELETE. (A RowResultSetNode will be used for an INSERT with a VALUES clause.) For INSERT - SELECT, any of the fields in a SelectNode can be used (the SelectNode represents the SELECT statement in the INSERT - SELECT). For UPDATE and DELETE, there will be one table in the fromList, and the groupByList fields 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.
Field Summary | |
private boolean |
bindTargetListOnly
|
(package private) FromList |
fromList
List of tables in the FROM clause of this SELECT |
private boolean |
generatedForGroupByClause
|
private boolean |
generatedForHavingClause
|
(package private) GroupByList |
groupByList
List of result columns in GROUP BY clause |
private boolean |
isDistinct
|
private boolean |
orderByAndDistinctMerged
|
(package private) OrderByList |
orderByList
|
(package private) boolean |
orderByQuery
|
(package private) ValueNode |
originalWhereClause
|
private FromList |
preJoinFL
|
(package private) java.util.Vector |
selectAggregates
|
(package private) SubqueryList |
selectSubquerys
|
(package private) FromTable |
targetTable
|
(package private) java.util.Vector |
whereAggregates
|
(package private) ValueNode |
whereClause
The ValueNode for the WHERE clause must represent a boolean expression. |
(package private) PredicateList |
wherePredicates
|
(package private) SubqueryList |
whereSubquerys
|
Fields inherited from class org.apache.derby.impl.sql.compile.ResultSetNode |
costEstimate, cursorTargetTable, insertSource, optimizer, referencedTableMap, resultColumns, resultSetNumber, scratchCostEstimate, statementResultSet |
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode |
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset |
Constructor Summary | |
SelectNode()
|
Method Summary | |
Visitable |
accept(Visitor v)
Accept a visitor, and call v.visit() on child nodes as necessary. |
ResultSetNode |
addNewPredicate(Predicate predicate)
Add a new predicate to the list. |
void |
bindExpressions(FromList fromListParam)
Bind the expressions in this SelectNode. |
void |
bindExpressionsWithTables(FromList fromListParam)
Bind the expressions in this ResultSetNode if it has tables. |
ResultSetNode |
bindNonVTITables(DataDictionary dataDictionary,
FromList fromListParam)
Bind the tables in this SelectNode. |
void |
bindResultColumns(FromList fromListParam)
Bind the result columns of this ResultSetNode when there is no base table to bind them to. |
void |
bindResultColumns(TableDescriptor targetTableDescriptor,
FromVTI targetVTI,
ResultColumnList targetColumnList,
DMLStatementNode statement,
FromList fromListParam)
Bind the result columns for this ResultSetNode to a base table. |
void |
bindTargetExpressions(FromList fromListParam)
Bind the expressions in the target list. |
void |
bindUntypedNullsToResultColumns(ResultColumnList bindingRCL)
Bind any untyped null nodes to the types in the given ResultColumnList. |
void |
clearDistinct()
|
(package private) void |
decrementLevel(int decrement)
Decrement (query block) level (0-based) for all of the tables in this ResultSet tree. |
ResultSetNode |
ensurePredicateList(int numTables)
Ensure that the top of the RSN tree has a PredicateList. |
boolean |
flattenableInFromSubquery(FromList fromList)
Evaluate whether or not the subquery in a FromSubquery is flattenable. |
ResultSetNode |
genProjectRestrict(int origFromListSize)
Replace this SelectNode with a ProjectRestrictNode, since it has served its purpose. |
java.util.Vector |
getAggregateVector(int clause)
Return the specified aggregate vector for this SelectNode. |
(package private) FromTable |
getCursorTargetTable()
Assumes that isCursorUpdatable has been called, and that it is only called for updatable cursors. |
FromList |
getFromList()
Return the fromList for this SelectNode. |
protected 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. |
boolean |
getGeneratedForGroupbyClause()
Return whether or not this SelectNode was generated for a GROUP BY clause. |
GroupByList |
getGroupByList()
Return the groupByList for this SelectNode. |
SubqueryList |
getSelectSubquerys()
Return the selectSubquerys for this SelectNode. |
ValueNode |
getWhereClause()
Return the whereClause for this SelectNode. |
PredicateList |
getWherePredicates()
Return the wherePredicates for this SelectNode. |
SubqueryList |
getWhereSubquerys()
Return the whereSubquerys for this SelectNode. |
(package private) boolean |
hasDistinct()
|
void |
init(java.lang.Object selectList,
java.lang.Object aggregateVector,
java.lang.Object fromList,
java.lang.Object whereClause,
java.lang.Object groupByList)
Initializer for a SelectNode. |
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. |
void |
makeDistinct()
|
void |
markAsForGroupByClause()
Mark this SelectNode as being generated for a GROUP BY clause. |
void |
markAsForHavingClause()
Mark this SelectNode as being generated for a HAVING clause. |
ResultSetNode |
modifyAccessPaths()
Modify the access paths according to the choices the optimizer made. |
private void |
normExpressions()
Put the expression trees in conjunctive normal form |
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. |
ResultSetNode |
preprocess(int numTables,
GroupByList gbl,
FromList fl)
Put a ProjectRestrictNode on top of each FromTable in the FromList. |
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 |
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. |
boolean |
referencesSessionSchema()
Return true if the node references SESSION schema tables (temporary or permanent) |
boolean |
referencesTarget(java.lang.String name,
boolean baseTable)
Search to see if a query references the specifed table name. |
void |
rejectParameters()
Check for (and reject) ? |
(package private) boolean |
returnsAtMostOneRow()
Return whether or not this ResultSet tree is guaranteed to return at most 1 row based on heuristics. |
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. |
int |
updateTargetLockMode()
Get the lock mode for the target of an update statement (a delete or update). |
void |
verifySelectStarSubquery(FromList outerFromList,
int subqueryType)
Verify that a SELECT * is valid for this type of subquery. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
FromList fromList
FromTable targetTable
java.util.Vector selectAggregates
java.util.Vector whereAggregates
ValueNode whereClause
ValueNode originalWhereClause
GroupByList groupByList
OrderByList orderByList
boolean orderByQuery
PredicateList wherePredicates
SubqueryList selectSubquerys
SubqueryList whereSubquerys
private boolean bindTargetListOnly
private boolean isDistinct
private boolean orderByAndDistinctMerged
private boolean generatedForGroupByClause
private boolean generatedForHavingClause
private FromList preJoinFL
Constructor Detail |
public SelectNode()
Method Detail |
public void init(java.lang.Object selectList, java.lang.Object aggregateVector, java.lang.Object fromList, java.lang.Object whereClause, java.lang.Object groupByList) throws StandardException
init
in class QueryTreeNode
selectList
- The result column list for the SELECT statementaggregateVector
- The aggregate vector for this SELECTfromList
- The FROM list for the SELECT statementwhereClause
- An expression representing the WHERE clause.
It must be a boolean expression, but this is
not checked until binding.groupByList
- The GROUP BY list, if any.
StandardException
- Thrown on errorpublic java.lang.String toString()
toString
in class ResultSetNode
public java.lang.String statementToString()
public void makeDistinct()
public void clearDistinct()
boolean hasDistinct()
public void markAsForGroupByClause()
public boolean getGeneratedForGroupbyClause()
public void markAsForHavingClause()
public void printSubNodes(int depth)
printSubNodes
in class ResultSetNode
depth
- The depth of this node in the tree
public FromList getFromList()
getFromList
in class ResultSetNode
public GroupByList getGroupByList()
public ValueNode getWhereClause()
public PredicateList getWherePredicates()
public SubqueryList getSelectSubquerys()
public java.util.Vector getAggregateVector(int clause)
clause
- Which clause to get the aggregate list for
public SubqueryList getWhereSubquerys()
public 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 errorpublic void bindExpressions(FromList fromListParam) throws StandardException
bindExpressions
in class ResultSetNode
fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorpublic void bindExpressionsWithTables(FromList fromListParam) throws StandardException
bindExpressionsWithTables
in class ResultSetNode
fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorpublic void bindTargetExpressions(FromList fromListParam) throws StandardException
bindTargetExpressions
in class ResultSetNode
StandardException
- Thrown on errorpublic void bindResultColumns(FromList fromListParam) throws StandardException
bindResultColumns
in class ResultSetNode
fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorpublic void 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 push
StandardException
- Thrown on errorpublic void verifySelectStarSubquery(FromList outerFromList, int subqueryType) throws StandardException
verifySelectStarSubquery
in class ResultSetNode
outerFromList
- The FromList from the outer query block(s)subqueryType
- The subquery type
StandardException
- Thrown on errorprotected FromTable 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 errorpublic void rejectParameters() throws StandardException
rejectParameters
in class ResultSetNode
StandardException
- Thrown if a ? parameter found
directly under a ResultColumnvoid pushOrderByList(OrderByList orderByList)
pushOrderByList
in class ResultSetNode
orderByList
- The order by list
public ResultSetNode 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 any
StandardException
- Thrown on errorprivate void performTransitiveClosure(int numTables) throws StandardException
numTables
- The number of tables in the query
StandardException
- Thrown on errorprivate void normExpressions() throws StandardException
StandardException
- Thrown on errorpublic ResultSetNode addNewPredicate(Predicate predicate) throws StandardException
addNewPredicate
in class ResultSetNode
predicate
- The predicate to add
StandardException
- Thrown on errorpublic boolean flattenableInFromSubquery(FromList fromList)
flattenableInFromSubquery
in class ResultSetNode
fromList
- The outer from list
public ResultSetNode 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 errorpublic ResultSetNode ensurePredicateList(int numTables) throws StandardException
ensurePredicateList
in class ResultSetNode
numTables
- The number of tables in the query.
StandardException
- Thrown on errorpublic ResultSetNode 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 rows
StandardException
- Thrown on errorpublic ResultSetNode modifyAccessPaths() throws StandardException
modifyAccessPaths
in class ResultSetNode
StandardException
- Thrown on errorboolean isUpdatableCursor(DataDictionary dd) throws StandardException
isUpdatableCursor
in class ResultSetNode
StandardException
- Thrown on errorFromTable getCursorTargetTable()
getCursorTargetTable
in class ResultSetNode
public 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 table
StandardException
- 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 errorpublic void 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 errorpublic int updateTargetLockMode()
updateTargetLockMode
in class ResultSetNode
TransactionController
boolean returnsAtMostOneRow()
returnsAtMostOneRow
in class ResultSetNode
public boolean referencesSessionSchema() throws StandardException
referencesSessionSchema
in class QueryTreeNode
StandardException
- Thrown on errorpublic Visitable accept(Visitor v) throws StandardException
accept
in interface Visitable
accept
in class ResultSetNode
v
- the visitor
StandardException
- on error
|
Built on Tue 2006-10-10 19:23:47+0200, from revision exported | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |