|
||||||||||
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
A ResultSetNode represents a result set, that is, a set of rows. It is analogous to a ResultSet in the LanguageModuleExternalInterface. In fact, code generation for a a ResultSetNode will create a "new" call to a constructor for a ResultSet.
Field Summary | |
(package private) CostEstimate |
costEstimate
|
(package private) boolean |
cursorTargetTable
|
(package private) boolean |
insertSource
|
(package private) Optimizer |
optimizer
|
(package private) JBitSet |
referencedTableMap
|
(package private) ResultColumnList |
resultColumns
|
(package private) int |
resultSetNumber
|
(package private) CostEstimate |
scratchCostEstimate
|
(package private) boolean |
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 | |
ResultSetNode()
|
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 |
assignResultSetNumber()
Assign the next resultSetNumber to the resultSetNumber in this ResultSetNode. |
void |
bindExpressions(FromList fromListParam)
Bind the expressions in this ResultSetNode. |
void |
bindExpressionsWithTables(FromList fromListParam)
Bind the expressions in this ResultSetNode if it has tables. |
ResultSetNode |
bindNonVTITables(DataDictionary dataDictionary,
FromList fromListParam)
Bind the non VTI tables in this ResultSetNode. |
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 rcl)
Bind untyped nulls to the types in the given ResultColumnList. |
ResultSetNode |
bindVTITables(FromList fromListParam)
Bind the VTI tables in this ResultSetNode. |
ResultSetNode |
changeAccessPath()
The optimizer's decision on the access path for a result set may require the generation of extra result sets. |
(package private) void |
closeMethodArgument(ExpressionClassBuilder acb,
MethodBuilder mb)
This utility method is used by result set nodes that can be statement nodes to determine what their final argument is; if they are the statement result set, and there is a current date/time request, then a method will have been generated. |
(package private) boolean |
columnTypesAndLengthsMatch()
|
ResultSetNode |
considerMaterialization(JBitSet outerTables)
Consider materialization for this ResultSet tree if it is valid and cost effective (It is not valid if incorrect results would be returned.) |
(package private) abstract void |
decrementLevel(int decrement)
Decrement (query block) level (0-based) for all of the tables in this ResultSet tree. |
ResultSetNode |
enhanceRCLForInsert(int numTargetColumns,
int[] colMap,
DataDictionary dataDictionary,
TableDescriptor targetTD,
FromVTI targetVTI)
This ResultSet is the source for an Insert. |
ResultSetNode |
ensurePredicateList(int numTables)
Ensure that the top of the RSN tree has a PredicateList. |
void |
fillInReferencedTableMap(JBitSet passedMap)
Fill the referencedTableMap with this ResultSetNode. |
boolean |
flattenableInFromSubquery(FromList fromList)
Evaluate whether or not the subquery in a FromSubquery is flattenable. |
void |
generateNormalizationResultSet(ActivationClassBuilder acb,
MethodBuilder mb,
int resultSetNumber,
ResultDescription resultDescription)
Generate the code for a NormalizeResultSet. |
void |
generateResultSet(ExpressionClassBuilder acb,
MethodBuilder mb)
General logic shared by Core compilation and by the Replication Filter compiler. |
(package private) ResultColumn |
genNewRCForInsert(TableDescriptor targetTD,
FromVTI targetVTI,
int columnNumber,
DataDictionary dataDictionary)
Generate the RC/expression for an unspecified column in an insert. |
NormalizeResultSetNode |
genNormalizeResultSetNode(ResultSetNode normalizeChild,
boolean forUpdate)
Put a NormalizeResultSetNode on top of the specified ResultSetNode. |
ResultSetNode |
genProjectRestrict()
Put a ProjectRestrictNode on top of this ResultSetNode. |
protected ResultSetNode |
genProjectRestrict(int numTables)
Put a ProjectRestrictNode on top of each FromTable in the FromList. |
(package private) ResultSetNode |
genProjectRestrictForReordering()
Get a parent ProjectRestrictNode above us. |
ResultColumnList |
getAllResultColumns(TableName allTableName)
Expand "*" into a ResultColumnList with all of the columns in the table's result list. |
CostEstimate |
getCostEstimate()
Get the CostEstimate for this ResultSetNode. |
(package private) FromTable |
getCursorTargetTable()
return the target table of an updatable cursor result set. |
CostEstimate |
getFinalCostEstimate()
Get the final CostEstimate for this ResultSetNode. |
FromList |
getFromList()
Get the FromList. |
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. |
ResultColumn |
getMatchingColumn(ColumnReference columnReference)
Try to find a ResultColumn in the table represented by this FromTable that matches the name in the given ColumnReference. |
protected CostEstimate |
getNewCostEstimate()
Get a cost estimate to use for this ResultSetNode. |
protected Optimizer |
getOptimizer(OptimizableList optList,
OptimizablePredicateList predList,
DataDictionary dataDictionary,
RequiredRowOrdering requiredRowOrdering)
Get an optimizer to use for this ResultSetNode. |
JBitSet |
getReferencedTableMap()
Get the referencedTableMap for this ResultSetNode |
ResultColumnList |
getResultColumns()
Get the resultColumns for this ResultSetNode |
int |
getResultSetNumber()
Get the resultSetNumber in this ResultSetNode. |
boolean |
isNotExists()
Return whether or not the underlying ResultSet tree is for a NOT EXISTS join. |
boolean |
isOneRowResultSet()
Return whether or not the underlying ResultSet tree will return a single row, at most. |
(package private) boolean |
isOrderedOn(ColumnReference[] crs,
boolean permuteOrdering,
java.util.Vector fbtVector)
Return whether or not the underlying ResultSet tree is ordered on the specified columns. |
(package private) boolean |
isPossibleDistinctScan()
Is it possible to do a distinct scan on this ResultSet tree. |
(package private) boolean |
isUpdatableCursor(DataDictionary dd)
Determine if this result set is updatable or not, for a cursor (i.e., is it a cursor-updatable select). |
JBitSet |
LOJgetReferencedTables(int numTables)
|
ResultDescription |
makeResultDescription()
Make a ResultDescription for use in a ResultSet. |
(package private) ResultColumnDescriptor[] |
makeResultDescriptors(ExecutionContext ec)
|
boolean |
markAsCursorTargetTable()
Mark this ResultSetNode as the target table of an updatable cursor. |
(package private) void |
markForDistinctScan()
Mark the underlying scan as a distinct scan. |
(package private) void |
markOrderingDependent()
Notify the underlying result set tree that the result is ordering dependent. |
void |
markStatementResultSet()
This method is overridden to allow a resultset node to know if it is the one controlling the statement -- i.e., it is the outermost result set node for the statement. |
ResultSetNode |
modifyAccessPaths()
Modify the access paths according to the decisions the optimizer made. |
(package private) void |
notCursorTargetTable()
Mark this ResultSetNode as *not* the target table of an updatable cursor. |
(package private) void |
notFlattenableJoin()
Mark this node and its children as not being a flattenable join. |
protected static int |
numDistinctAggregates(java.util.Vector aggregateVector)
Count the number of distinct aggregates in the list. |
ResultSetNode |
optimize(DataDictionary dataDictionary,
PredicateList predicates,
double outerRows)
Optimize a ResultSetNode. |
ValueNode |
parseDefault(java.lang.String defaultText)
Parse a default and turn it into a query tree. |
boolean |
performMaterialization(JBitSet outerTables)
Return whether or not to materialize this ResultSet tree. |
ResultSetNode |
preprocess(int numTables,
GroupByList gbl,
FromList fromList)
Preprocess a ResultSetNode - this currently means: o Generating a referenced table map for each ResultSetNode. |
void |
printSubNodes(int depth)
Prints the sub-nodes of this object. |
(package private) void |
projectResultColumns()
Find the unreferenced result columns and project them out. |
(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 |
referencesTarget(java.lang.String name,
boolean baseTable)
Search to see if a query references the specifed table name. |
void |
rejectParameters()
Check for (and reject) ? |
void |
rejectXMLValues()
Check for (and reject) XML values directly under the ResultColumns. |
void |
renameGeneratedResultNames()
Rename generated result column names as '1', '2' etc... |
(package private) void |
replaceDefaults(TableDescriptor ttd,
ResultColumnList tcl)
Replace any DEFAULTs with the associated tree for the default. |
(package private) boolean |
returnsAtMostOneRow()
Return whether or not this ResultSet tree is guaranteed to return at most 1 row based on heuristics. |
void |
setInsertSource()
Remember that this node is the source result set for an INSERT. |
void |
setReferencedTableMap(JBitSet newRTM)
Set the referencedTableMap in this ResultSetNode |
void |
setResultColumns(ResultColumnList newRCL)
Set the resultColumns in this ResultSetNode |
void |
setResultToBooleanTrueNode(boolean onlyConvertAlls)
Set the result column for the subquery to a boolean true, Useful for transformations such as changing: where exists (select ... from ...) |
(package private) void |
setTableConstructorTypes(ResultColumnList typeColumns)
Set the type of each parameter in the result column list for this table constructor. |
(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. |
java.lang.String |
toString()
Convert this object to a String. |
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 |
int resultSetNumber
JBitSet referencedTableMap
ResultColumnList resultColumns
boolean statementResultSet
boolean cursorTargetTable
boolean insertSource
CostEstimate costEstimate
CostEstimate scratchCostEstimate
Optimizer optimizer
Constructor Detail |
public ResultSetNode()
Method Detail |
public java.lang.String toString()
toString
in class QueryTreeNode
public void printSubNodes(int depth)
printSubNodes
in class QueryTreeNode
depth
- The depth of this node in the tree
public int getResultSetNumber()
public CostEstimate getCostEstimate()
public CostEstimate getFinalCostEstimate()
public void assignResultSetNumber() throws StandardException
StandardException
- Thrown on errorpublic ResultSetNode bindNonVTITables(DataDictionary dataDictionary, FromList fromListParam) throws StandardException
dataDictionary
- The DataDictionary to use for bindingfromListParam
- FromList to use/append to.
StandardException
- Thrown on errorpublic ResultSetNode bindVTITables(FromList fromListParam) throws StandardException
fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorpublic void bindExpressions(FromList fromListParam) throws StandardException
fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorpublic void bindExpressionsWithTables(FromList fromListParam) throws StandardException
fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorpublic void bindTargetExpressions(FromList fromListParam) throws StandardException
StandardException
- Thrown on errorvoid setTableConstructorTypes(ResultColumnList typeColumns) throws StandardException
typeColumns
- The ResultColumnList containing the desired result
types.
StandardException
- Thrown on errorpublic void setInsertSource()
public void verifySelectStarSubquery(FromList outerFromList, int subqueryType) throws StandardException
outerFromList
- The FromList from the outer query block(s)subqueryType
- The subquery type
StandardException
- Thrown on errorpublic ResultColumnList getAllResultColumns(TableName allTableName) throws StandardException
allTableName
- The qualifier on the "*"
StandardException
- Thrown on errorpublic ResultColumn getMatchingColumn(ColumnReference columnReference) throws StandardException
columnReference
- The columnReference whose name we're looking
for in the given table.
StandardException
- Thrown on errorpublic void setResultToBooleanTrueNode(boolean onlyConvertAlls) throws StandardException
onlyConvertAlls
- Boolean, whether or not to just convert *'s
StandardException
- Thrown on errorpublic FromList getFromList() throws StandardException
StandardException
- Thrown on errorpublic void bindResultColumns(FromList fromListParam) throws StandardException
fromListParam
- FromList to use/append to.
StandardException
- Thrown on errorpublic void bindResultColumns(TableDescriptor targetTableDescriptor, FromVTI targetVTI, ResultColumnList targetColumnList, DMLStatementNode statement, FromList fromListParam) throws StandardException
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 errorpublic void bindUntypedNullsToResultColumns(ResultColumnList rcl) throws StandardException
rcl
- The ResultColumnList with the types to bind nulls to
StandardException
- Thrown on errorpublic ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException
numTables
- The number of tables in the DML Statementgbl
- The group by list, if anyfromList
- The from list, if any
StandardException
- Thrown on errorvoid projectResultColumns() throws StandardException
StandardException
public ResultSetNode ensurePredicateList(int numTables) throws StandardException
numTables
- The number of tables in the query.
StandardException
- Thrown on errorpublic ResultSetNode addNewPredicate(Predicate predicate) throws StandardException
predicate
- The predicate to add
StandardException
- Thrown on errorpublic boolean flattenableInFromSubquery(FromList fromList)
fromList
- The outer from list
ResultSetNode genProjectRestrictForReordering() throws StandardException
StandardException
- Thrown on errorpublic ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicates, double outerRows) throws StandardException
dataDictionary
- The DataDictionary to use for optimizationouterRows
- The number of outer joining rows
StandardException
- Thrown on errorpublic ResultSetNode modifyAccessPaths() throws StandardException
StandardException
- Thrown on errorResultColumnDescriptor[] makeResultDescriptors(ExecutionContext ec)
boolean columnTypesAndLengthsMatch() throws StandardException
StandardException
public void setResultColumns(ResultColumnList newRCL)
public ResultColumnList getResultColumns()
public void setReferencedTableMap(JBitSet newRTM)
newRTM
- The new referencedTableMap for this ResultSetNode
public JBitSet getReferencedTableMap()
public void fillInReferencedTableMap(JBitSet passedMap)
passedMap
- The table map to fill in.
public void rejectParameters() throws StandardException
StandardException
- Thrown if a ? parameter found
directly under a ResultColumnpublic void rejectXMLValues() throws StandardException
StandardException
- Thrown if an XML value found
directly under a ResultColumnpublic void renameGeneratedResultNames() throws StandardException
StandardException
public void markStatementResultSet()
void closeMethodArgument(ExpressionClassBuilder acb, MethodBuilder mb)
public ResultSetNode enhanceRCLForInsert(int numTargetColumns, int[] colMap, DataDictionary dataDictionary, TableDescriptor targetTD, FromVTI targetVTI) throws StandardException
numTargetColumns
- # of columns in target RCLdataDictionary
- DataDictionary to usetargetTD
- TableDescriptor for target if the target is not a VTI, null if a VTItargetVTI
- Target description if it is a VTI, null if not a VTI
StandardException
- Thrown on errorResultColumn genNewRCForInsert(TableDescriptor targetTD, FromVTI targetVTI, int columnNumber, DataDictionary dataDictionary) throws StandardException
targetTD
- Target TableDescriptor if the target is not a VTI, null if a VTI.targetVTI
- Target description if it is a VTI, null if not a VTIcolumnNumber
- The column numberdataDictionary
- The DataDictionary
StandardException
- Thrown on errorpublic ValueNode parseDefault(java.lang.String defaultText) throws StandardException
defaultText
- Text of Default.
StandardException
- Thrown on failurepublic ResultDescription makeResultDescription()
makeResultDescription
in class QueryTreeNode
boolean isUpdatableCursor(DataDictionary dd) throws StandardException
StandardException
- Thrown on errorFromTable getCursorTargetTable()
public boolean markAsCursorTargetTable()
void notCursorTargetTable()
public ResultSetNode genProjectRestrict() throws StandardException
StandardException
- Thrown on errorprotected ResultSetNode genProjectRestrict(int numTables) throws StandardException
numTables
- Number of tables in the DML Statement
StandardException
- Thrown on errorpublic NormalizeResultSetNode genNormalizeResultSetNode(ResultSetNode normalizeChild, boolean forUpdate) throws StandardException
normalizeChild
- Child result set for new NRSN.forUpdate
- If the normalize result set is being used as a
child for an update statement, then this is true.
StandardException
- Thrown on errorNormalizeResultSetNode.init(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)
public void generateNormalizationResultSet(ActivationClassBuilder acb, MethodBuilder mb, int resultSetNumber, ResultDescription resultDescription) throws StandardException
acb
- The ActivationClassBuildermb
- The method to put the generated code inresultSetNumber
- The result set number for the NRSresultDescription
- The ERD for the ResultSet
StandardException
- Thrown on errorpublic ResultSetNode changeAccessPath() throws StandardException
StandardException
- Thrown on errorpublic boolean referencesTarget(java.lang.String name, boolean baseTable) throws StandardException
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
name
- The table name.
StandardException
- Thrown on errorpublic boolean isOneRowResultSet() throws StandardException
StandardException
- Thrown on errorpublic boolean isNotExists()
protected Optimizer getOptimizer(OptimizableList optList, OptimizablePredicateList predList, DataDictionary dataDictionary, RequiredRowOrdering requiredRowOrdering) throws StandardException
StandardException
- Thrown on errorprotected CostEstimate getNewCostEstimate() throws StandardException
StandardException
- Thrown on errorpublic Visitable accept(Visitor v) throws StandardException
accept
in interface Visitable
accept
in class QueryTreeNode
v
- the visitor
StandardException
- on errorpublic ResultSetNode considerMaterialization(JBitSet outerTables) throws StandardException
StandardException
- Thrown on errorpublic boolean performMaterialization(JBitSet outerTables) throws StandardException
StandardException
- Thrown on errorprotected FromTable getFromTableByName(java.lang.String name, java.lang.String schemaName, boolean exactMatch) throws StandardException
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 errorabstract void decrementLevel(int decrement)
decrement
- The amount to decrement by.
void pushOrderByList(OrderByList orderByList)
orderByList
- The order by list
public void generateResultSet(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
StandardException
- Thrown on errorpublic int updateTargetLockMode()
TransactionController
void notFlattenableJoin()
boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, java.util.Vector fbtVector) throws StandardException
crs
- The specified ColumnReference[]permuteOrdering
- Whether or not the order of the CRs in the array can be permutedfbtVector
- Vector that is to be filled with the FromBaseTable
StandardException
- Thrown on errorboolean returnsAtMostOneRow()
void replaceDefaults(TableDescriptor ttd, ResultColumnList tcl) throws StandardException
ttd
- The TableDescriptor for the target table.tcl
- The RCL for the target table.
StandardException
- Thrown on errorboolean isPossibleDistinctScan()
void markForDistinctScan()
void markOrderingDependent()
protected static final int numDistinctAggregates(java.util.Vector aggregateVector)
public JBitSet LOJgetReferencedTables(int numTables) throws StandardException
StandardException
|
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 |