| java.lang.Object org.apache.derby.impl.sql.compile.QueryTreeNode org.apache.derby.impl.sql.compile.ResultSetNode
All known Subclasses: org.apache.derby.impl.sql.compile.SelectNode, org.apache.derby.impl.sql.compile.MaterializeSubqueryNode, org.apache.derby.impl.sql.compile.FromTable,
ResultSetNode | abstract public class ResultSetNode extends QueryTreeNode (Code) | | 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.
author: Jeff Lichtman |
Method Summary | |
public JBitSet | LOJgetReferencedTables(int numTables) | public Visitable | accept(Visitor v) Accept a visitor, and call v.visit()
on child nodes as necessary. | public ResultSetNode | addNewPredicate(Predicate predicate) Add a new predicate to the list. | public void | assignResultSetNumber() Assign the next resultSetNumber to the resultSetNumber in this ResultSetNode. | public void | bindExpressions(FromList fromListParam) Bind the expressions in this ResultSetNode. | public void | bindExpressionsWithTables(FromList fromListParam) Bind the expressions in this ResultSetNode if it has tables. | public ResultSetNode | bindNonVTITables(DataDictionary dataDictionary, FromList fromListParam) Bind the non VTI tables in this ResultSetNode. | public void | bindResultColumns(FromList fromListParam) Bind the result columns of this ResultSetNode when there is no
base table to bind them to. | public void | bindResultColumns(TableDescriptor targetTableDescriptor, FromVTI targetVTI, ResultColumnList targetColumnList, DMLStatementNode statement, FromList fromListParam) 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 - The TableDescriptor for the table beingupdated or inserted into Parameters: targetColumnList - For INSERT statements, the userdoes not have to supply columnnames (for example, "insert into tvalues (1,2,3)". | public void | bindTargetExpressions(FromList fromListParam) Bind the expressions in the target list. | public void | bindUntypedNullsToResultColumns(ResultColumnList rcl) Bind untyped nulls to the types in the given ResultColumnList.
This is used for binding the nulls in row constructors and
table constructors. | public ResultSetNode | bindVTITables(FromList fromListParam) Bind the VTI tables in this ResultSetNode. | public ResultSetNode | changeAccessPath() The optimizer's decision on the access path for a result set
may require the generation of extra result sets. | boolean | columnTypesAndLengthsMatch() | public ResultSetNode | considerMaterialization(JBitSet outerTables) | abstract void | decrementLevel(int decrement) Decrement (query block) level (0-based) for
all of the tables in this ResultSet tree. | public void | disablePrivilegeCollection() | public ResultSetNode | enhanceRCLForInsert(int numTargetColumns, int[] colMap, DataDictionary dataDictionary, TableDescriptor targetTD, FromVTI targetVTI) This ResultSet is the source for an Insert. | public ResultSetNode | ensurePredicateList(int numTables) Ensure that the top of the RSN tree has a PredicateList.
Parameters: numTables - The number of tables in the query. | public void | fillInReferencedTableMap(JBitSet passedMap) Fill the referencedTableMap with this ResultSetNode. | public boolean | flattenableInFromSubquery(FromList fromList) Evaluate whether or not the subquery in a FromSubquery is flattenable. | ResultColumn | genNewRCForInsert(TableDescriptor targetTD, FromVTI targetVTI, int columnNumber, DataDictionary dataDictionary) Generate the RC/expression for an unspecified column in an insert. | public NormalizeResultSetNode | genNormalizeResultSetNode(ResultSetNode normalizeChild, boolean forUpdate) Put a NormalizeResultSetNode on top of the specified ResultSetNode.
ColumnReferences must continue to point to the same ResultColumn, so
that ResultColumn must percolate up to the new PRN. | public ResultSetNode | genProjectRestrict() Put a ProjectRestrictNode on top of this ResultSetNode.
ColumnReferences must continue to point to the same ResultColumn, so
that ResultColumn must percolate up to the new PRN. | protected ResultSetNode | genProjectRestrict(int numTables) 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. | ResultSetNode | genProjectRestrictForReordering() Get a parent ProjectRestrictNode above us. | public void | generateNormalizationResultSet(ActivationClassBuilder acb, MethodBuilder mb, int resultSetNumber, ResultDescription resultDescription) Generate the code for a NormalizeResultSet. | public void | generateResultSet(ExpressionClassBuilder acb, MethodBuilder mb) General logic shared by Core compilation and by the Replication Filter
compiler. | public ResultColumnList | getAllResultColumns(TableName allTableName) Expand "*" into a ResultColumnList with all of the columns
in the table's result list. | public CostEstimate | getCostEstimate() Get the CostEstimate for this ResultSetNode. | FromTable | getCursorTargetTable() return the target table of an updatable cursor result set. | public CostEstimate | getFinalCostEstimate() Get the final CostEstimate for this ResultSetNode. | public FromList | getFromList() Get the FromList. | protected FromTable | getFromTableByName(String name, String schemaName, boolean exactMatch) Determine whether or not the specified name is an exposed name in
the current query block.
Parameters: name - The specified name to search for as an exposed name. Parameters: schemaName - Schema name, if non-null. Parameters: exactMatch - Whether or not we need an exact match on specified schema and tablenames or match on table id. | public 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. | protected OptimizerImpl | getOptimizerImpl() Get the optimizer for this result set. | public JBitSet | getReferencedTableMap() | public ResultColumnList | getResultColumns() | public int | getResultSetNumber() Get the resultSetNumber in this ResultSetNode. | public boolean | isNotExists() Return whether or not the underlying ResultSet tree is for a NOT EXISTS
join. | public boolean | isOneRowResultSet() Return whether or not the underlying ResultSet tree will return
a single row, at most. | boolean | isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, Vector fbtVector) Return whether or not the underlying ResultSet tree
is ordered on the specified columns. | boolean | isPossibleDistinctScan(Set distinctColumns) Is it possible to do a distinct scan on this ResultSet tree. | boolean | isUpdatableCursor(DataDictionary dd) Determine if this result set is updatable or not, for a cursor
(i.e., is it a cursor-updatable select). | public ResultDescription | makeResultDescription() Make a ResultDescription for use in a ResultSet. | ResultColumnDescriptor[] | makeResultDescriptors(ExecutionContext ec) | public boolean | markAsCursorTargetTable() Mark this ResultSetNode as the target table of an updatable
cursor. | void | markForDistinctScan() Mark the underlying scan as a distinct scan. | void | markOrderingDependent() Notify the underlying result set tree that the result is
ordering dependent. | public 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. | public ResultSetNode | modifyAccessPaths() Modify the access paths according to the decisions the optimizer
made. | public ResultSetNode | modifyAccessPaths(PredicateList predList) Modify the access paths according to the decisions the optimizer
made. | void | notCursorTargetTable() Mark this ResultSetNode as *not* the target table of an updatable
cursor. | void | notFlattenableJoin() Mark this node and its children as not being a flattenable join. | final protected static int | numDistinctAggregates(Vector aggregateVector) Count the number of distinct aggregates in the list. | public ResultSetNode | optimize(DataDictionary dataDictionary, PredicateList predicates, double outerRows) Optimize a ResultSetNode. | public ValueNode | parseDefault(String defaultText) Parse a default and turn it into a query tree. | public boolean | performMaterialization(JBitSet outerTables) Return whether or not to materialize this ResultSet tree. | public ResultSetNode | preprocess(int numTables, GroupByList gbl, FromList fromList) Preprocess a ResultSetNode - this currently means:
o Generating a referenced table map for each ResultSetNode.
o Putting the WHERE and HAVING clauses in conjunctive normal form (CNF).
o Converting the WHERE and HAVING clauses into PredicateLists and
classifying them.
o Ensuring that a ProjectRestrictNode is generated on top of every
FromBaseTable and generated in place of every FromSubquery. | public void | printSubNodes(int depth) Prints the sub-nodes of this object. | void | projectResultColumns() Find the unreferenced result columns and project them out. | 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. | public boolean | referencesTarget(String name, boolean baseTable) Search to see if a query references the specifed table name. | public void | rejectParameters() Check for (and reject) ? parameters directly under the ResultColumns. | public void | rejectXMLValues() Check for (and reject) XML values directly under the ResultColumns.
This is done for SELECT/VALUES statements. | public void | renameGeneratedResultNames() Rename generated result column names as '1', '2' etc... | void | replaceDefaults(TableDescriptor ttd, ResultColumnList tcl) Replace any DEFAULTs with the associated tree for the default. | boolean | returnsAtMostOneRow() Return whether or not this ResultSet tree is guaranteed to return
at most 1 row based on heuristics. | public void | setInsertSource() Remember that this node is the source result set for an INSERT. | public void | setReferencedTableMap(JBitSet newRTM) | public void | setResultColumns(ResultColumnList newRCL) | public void | setResultToBooleanTrueNode(boolean onlyConvertAlls) Set the result column for the subquery to a boolean true,
Useful for transformations such as
changing:
where exists (select ... | void | setTableConstructorTypes(ResultColumnList typeColumns) Set the type of each parameter in the result column list for this table constructor. | boolean | subqueryReferencesTarget(String name, boolean baseTable) Return whether or not this ResultSetNode contains a subquery with a
reference to the specified target.
Parameters: name - The table name. | public String | toString() Convert this object to a String. | public int | updateTargetLockMode() Get the lock mode for the target of an update statement
(a delete or update). | public void | verifySelectStarSubquery(FromList outerFromList, int subqueryType) Verify that a SELECT * is valid for this type of subquery. |
cursorTargetTable | boolean cursorTargetTable(Code) | | |
insertSource | boolean insertSource(Code) | | |
resultSetNumber | int resultSetNumber(Code) | | |
statementResultSet | boolean statementResultSet(Code) | | |
addNewPredicate | public ResultSetNode addNewPredicate(Predicate predicate) throws StandardException(Code) | | Add a new predicate to the list. This is useful when doing subquery
transformations, when we build a new predicate with the left side of
the subquery operator and the subquery's result column.
Parameters: predicate - The predicate to add ResultSetNode The new top of the tree. exception: StandardException - Thrown on error |
assignResultSetNumber | public void assignResultSetNumber() throws StandardException(Code) | | Assign the next resultSetNumber to the resultSetNumber in this ResultSetNode.
Expected to be done during generate().
exception: StandardException - Thrown on error |
bindExpressions | public void bindExpressions(FromList fromListParam) throws StandardException(Code) | | Bind the expressions in this ResultSetNode. This means binding the
sub-expressions, as well as figuring out what the return type is for
each expression.
Parameters: fromListParam - FromList to use/append to. exception: StandardException - Thrown on error |
bindExpressionsWithTables | public void bindExpressionsWithTables(FromList fromListParam) throws StandardException(Code) | | 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 to use/append to. exception: StandardException - Thrown on error |
bindNonVTITables | public ResultSetNode bindNonVTITables(DataDictionary dataDictionary, FromList fromListParam) throws StandardException(Code) | | Bind the non VTI tables in this ResultSetNode. This includes getting their
descriptors from the data dictionary and numbering them.
Parameters: dataDictionary - The DataDictionary to use for binding Parameters: fromListParam - FromList to use/append to. ResultSetNode exception: StandardException - Thrown on error |
bindResultColumns | public void bindResultColumns(FromList fromListParam) throws StandardException(Code) | | 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 to use/append to. exception: StandardException - Thrown on error |
bindResultColumns | public void bindResultColumns(TableDescriptor targetTableDescriptor, FromVTI targetVTI, ResultColumnList targetColumnList, DMLStatementNode statement, FromList fromListParam) throws StandardException(Code) | | 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 - The TableDescriptor for the table beingupdated or inserted into Parameters: targetColumnList - For INSERT statements, the userdoes not have to supply columnnames (for example, "insert into tvalues (1,2,3)". When thisparameter is null, it means thatthe user did not supply columnnames, and so the binding shouldbe done based on order. When itis not null, it means do the bindingby name, not position. Parameters: statement - Calling DMLStatementNode (Insert or Update) Parameters: fromListParam - FromList to use/append to. exception: StandardException - Thrown on error |
bindTargetExpressions | public void bindTargetExpressions(FromList fromListParam) throws StandardException(Code) | | Bind the expressions in the target list. This means binding the
sub-expressions, as well as figuring out what the return type is
for each expression. This is useful for EXISTS subqueries, where we
need to validate the target list before blowing it away and replacing
it with a SELECT true.
exception: StandardException - Thrown on error |
bindUntypedNullsToResultColumns | public void bindUntypedNullsToResultColumns(ResultColumnList rcl) throws StandardException(Code) | | Bind untyped nulls to the types in the given ResultColumnList.
This is used for binding the nulls in row constructors and
table constructors. In all other cases (as of the time of
this writing), we do nothing.
Parameters: rcl - The ResultColumnList with the types to bind nulls to exception: StandardException - Thrown on error |
bindVTITables | public ResultSetNode bindVTITables(FromList fromListParam) throws StandardException(Code) | | Bind the VTI tables in this ResultSetNode. This includes getting their
descriptors from the data dictionary and numbering them.
Parameters: fromListParam - FromList to use/append to. ResultSetNode exception: StandardException - Thrown on error |
changeAccessPath | public ResultSetNode changeAccessPath() throws StandardException(Code) | | The optimizer's decision on the access path for a result set
may require the generation of extra result sets. For example,
if it chooses an index for a FromBaseTable, we need an IndexToBaseRowNode
above the FromBaseTable (and the FromBaseTable has to change its
column list to match the index.
This method in the parent class does not generate any extra result sets.
It may be overridden in child classes.
A ResultSetNode tree modified to do any extra processing forthe chosen access path exception: StandardException - Thrown on error |
considerMaterialization | public ResultSetNode considerMaterialization(JBitSet outerTables) throws StandardException(Code) | | Consider materialization for this ResultSet tree if it is valid and cost effective
(It is not valid if incorrect results would be returned.)
Top of the new/same ResultSet tree. exception: StandardException - Thrown on error |
decrementLevel | abstract void decrementLevel(int decrement)(Code) | | Decrement (query block) level (0-based) for
all of the tables in this ResultSet tree.
This is useful when flattening a subquery.
Parameters: decrement - The amount to decrement by. |
enhanceRCLForInsert | public ResultSetNode enhanceRCLForInsert(int numTargetColumns, int[] colMap, DataDictionary dataDictionary, TableDescriptor targetTD, FromVTI targetVTI) throws StandardException(Code) | | This ResultSet is the source for an Insert. The target RCL
is in a different order and/or a superset of this RCL. In most cases
we will reorder and/or add defaults to the current RCL so that is
matches the target RCL. Those RSNs whose generate() method does
not handle projects will insert a PRN, with a new RCL which matches
the target RCL, above the current RSN.
NOTE - The new or enhanced RCL will be fully bound.
Parameters: numTargetColumns - # of columns in target RCL Parameters: colMap - int array representation of correspondence betweenRCLs - colmap[i] = -1 -> missing in current RCLcolmap[i] = j -> targetRCL(i) <-> thisRCL(j+1) Parameters: dataDictionary - DataDictionary to use Parameters: targetTD - TableDescriptor for target if the target is not a VTI, null if a VTI Parameters: targetVTI - Target description if it is a VTI, null if not a VTI ResultSetNode The new top of the tree exception: StandardException - Thrown on error |
ensurePredicateList | public ResultSetNode ensurePredicateList(int numTables) throws StandardException(Code) | | Ensure that the top of the RSN tree has a PredicateList.
Parameters: numTables - The number of tables in the query. ResultSetNode A RSN tree with a node which has a PredicateList on top. exception: StandardException - Thrown on error |
fillInReferencedTableMap | public void fillInReferencedTableMap(JBitSet passedMap)(Code) | | Fill the referencedTableMap with this ResultSetNode.
Parameters: passedMap - The table map to fill in. |
flattenableInFromSubquery | public boolean flattenableInFromSubquery(FromList fromList)(Code) | | Evaluate whether or not the subquery in a FromSubquery is flattenable.
Currently, a FSqry is flattenable if all of the following are true:
o Subquery is a SelectNode. (ie, not a RowResultSetNode or a UnionNode)
o It contains no top level subqueries. (RESOLVE - we can relax this)
o It does not contain a group by or having clause
o It does not contain aggregates.
Parameters: fromList - The outer from list boolean Whether or not the FromSubquery is flattenable. |
genNewRCForInsert | ResultColumn genNewRCForInsert(TableDescriptor targetTD, FromVTI targetVTI, int columnNumber, DataDictionary dataDictionary) throws StandardException(Code) | | Generate the RC/expression for an unspecified column in an insert.
Use the default if one exists.
Parameters: targetTD - Target TableDescriptor if the target is not a VTI, null if a VTI. Parameters: targetVTI - Target description if it is a VTI, null if not a VTI Parameters: columnNumber - The column number Parameters: dataDictionary - The DataDictionary The RC/expression for the unspecified column. exception: StandardException - Thrown on error |
genNormalizeResultSetNode | public NormalizeResultSetNode genNormalizeResultSetNode(ResultSetNode normalizeChild, boolean forUpdate) throws StandardException(Code) | | Put a NormalizeResultSetNode on top of the specified ResultSetNode.
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 NRSN 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.)
This is useful for UNIONs, where we want to generate a DistinctNode above
the UnionNode to eliminate the duplicates, because the type going into the
sort has to agree with what the sort expects.
(insert into t1 (smallintcol) values 1 union all values 2;
Parameters: normalizeChild - Child result set for new NRSN. Parameters: forUpdate - If the normalize result set is being used as achild for an update statement, then this is true. The generated NormalizeResultSetNode atop the original UnionNode. exception: StandardException - Thrown on error See Also: NormalizeResultSetNode.init |
genProjectRestrict | public ResultSetNode genProjectRestrict() throws StandardException(Code) | | Put a ProjectRestrictNode on top of this ResultSetNode.
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.)
This is useful for UNIONs, where we want to generate a DistinctNode above
the UnionNode to eliminate the duplicates, because DistinctNodes expect
their immediate child to be a PRN.
The generated ProjectRestrictNode atop the original ResultSetNode. exception: StandardException - Thrown on error |
genProjectRestrict | protected ResultSetNode genProjectRestrict(int numTables) throws StandardException(Code) | | 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 - Number of tables in the DML Statement The generated ProjectRestrictNode atop the original FromTable. exception: StandardException - Thrown on error |
genProjectRestrictForReordering | ResultSetNode genProjectRestrictForReordering() throws StandardException(Code) | | Get a parent ProjectRestrictNode above us.
This is useful when we need to preserve the
user specified column order when reordering the
columns in the distinct when we combine
an order by with a distinct.
A parent ProjectRestrictNode to do column reordering exception: StandardException - Thrown on error |
generateNormalizationResultSet | public void generateNormalizationResultSet(ActivationClassBuilder acb, MethodBuilder mb, int resultSetNumber, ResultDescription resultDescription) throws StandardException(Code) | | Generate the code for a NormalizeResultSet.
The call must push two items before calling this method
- pushGetResultSetFactoryExpression
- the expression to normalize
Parameters: acb - The ActivationClassBuilder Parameters: mb - The method to put the generated code in Parameters: resultSetNumber - The result set number for the NRS Parameters: resultDescription - The ERD for the ResultSet exception: StandardException - Thrown on error |
generateResultSet | public void generateResultSet(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException(Code) | | General logic shared by Core compilation and by the Replication Filter
compiler. A couple ResultSets (the ones used by PREPARE SELECT FILTER)
implement this method.
Parameters: acb - The ExpressionClassBuilder for the class being built Parameters: mb - The method the expression will go into exception: StandardException - Thrown on error |
getAllResultColumns | public ResultColumnList getAllResultColumns(TableName allTableName) throws StandardException(Code) | | Expand "*" into a ResultColumnList with all of the columns
in the table's result list.
Parameters: allTableName - The qualifier on the "*" ResultColumnList The expanded list exception: StandardException - Thrown on error |
getCostEstimate | public CostEstimate getCostEstimate()(Code) | | Get the CostEstimate for this ResultSetNode.
The CostEstimate for this ResultSetNode. |
getCursorTargetTable | FromTable getCursorTargetTable()(Code) | | return the target table of an updatable cursor result set.
since this is not updatable, just return null.
|
getFinalCostEstimate | public CostEstimate getFinalCostEstimate() throws StandardException(Code) | | Get the final CostEstimate for this ResultSetNode.
The final CostEstimate for this ResultSetNode. |
getFromList | public FromList getFromList() throws StandardException(Code) | | Get the FromList. Create and return an empty FromList. (Subclasses
which actuall have FromLists will override this.) This is useful because
there is a FromList parameter to bindExpressions() which is used as
the common FromList to bind against, allowing us to support
correlation columns under unions in subqueries.
FromList exception: StandardException - Thrown on error |
getFromTableByName | protected FromTable getFromTableByName(String name, String schemaName, boolean exactMatch) throws StandardException(Code) | | Determine whether or not the specified name is an exposed name in
the current query block.
Parameters: name - The specified name to search for as an exposed name. Parameters: schemaName - Schema name, if non-null. Parameters: exactMatch - Whether or not we need an exact match on specified schema and tablenames or match on table id. The FromTable, if any, with the exposed name. exception: StandardException - Thrown on error |
getMatchingColumn | public ResultColumn getMatchingColumn(ColumnReference columnReference) throws StandardException(Code) | | Try to find a ResultColumn in the table represented by this FromTable
that matches the name in the given ColumnReference.
Parameters: columnReference - The columnReference whose name we're lookingfor in the given table. A ResultColumn whose expression is the ColumnNodethat matches the ColumnReference.Returns null if there is no match. exception: StandardException - Thrown on error |
getOptimizerImpl | protected OptimizerImpl getOptimizerImpl()(Code) | | Get the optimizer for this result set.
If this.optimizer has has already been created by thegetOptimizer() method above, then return it; otherwise,return null. |
getReferencedTableMap | public JBitSet getReferencedTableMap()(Code) | | Get the referencedTableMap for this ResultSetNode
JBitSet Referenced table map for this ResultSetNode |
getResultColumns | public ResultColumnList getResultColumns()(Code) | | Get the resultColumns for this ResultSetNode
ResultColumnList for this ResultSetNode |
getResultSetNumber | public int getResultSetNumber()(Code) | | Get the resultSetNumber in this ResultSetNode. Expected to be set during
generate().
int The resultSetNumber. |
isNotExists | public boolean isNotExists()(Code) | | Return whether or not the underlying ResultSet tree is for a NOT EXISTS
join.
Whether or not the underlying ResultSet tree if for NOT EXISTS. |
isOneRowResultSet | public boolean isOneRowResultSet() throws StandardException(Code) | | Return whether or not the underlying ResultSet tree will return
a single row, at most.
This is important for join nodes where we can save the extra next
on the right side if we know that it will return at most 1 row.
Whether or not the underlying ResultSet tree will return a single row. exception: StandardException - Thrown on error |
isOrderedOn | boolean isOrderedOn(ColumnReference[] crs, boolean permuteOrdering, Vector fbtVector) throws StandardException(Code) | | Return whether or not the underlying ResultSet tree
is ordered on the specified columns.
RESOLVE - This method currently only considers the outermost table
of the query block.
Parameters: crs - The specified ColumnReference[] Parameters: permuteOrdering - Whether or not the order of the CRs in the array can be permuted Parameters: fbtVector - Vector that is to be filled with the FromBaseTable Whether the underlying ResultSet treeis ordered on the specified column. exception: StandardException - Thrown on error |
isPossibleDistinctScan | boolean isPossibleDistinctScan(Set distinctColumns)(Code) | | Is it possible to do a distinct scan on this ResultSet tree.
(See SelectNode for the criteria.)
Parameters: distinctColumns - the set of distinct columns Whether or not it is possible to do a distinct scan on this ResultSet tree. |
isUpdatableCursor | boolean isUpdatableCursor(DataDictionary dd) throws StandardException(Code) | | Determine if this result set is updatable or not, for a cursor
(i.e., is it a cursor-updatable select). This returns false
and we expect selectnode to refine it for further checking.
exception: StandardException - Thrown on error |
makeResultDescription | public ResultDescription makeResultDescription()(Code) | | Make a ResultDescription for use in a ResultSet.
This is useful when generating/executing a NormalizeResultSet, since
it can appear anywhere in the tree.
A ResultDescription for this ResultSetNode. |
markAsCursorTargetTable | public boolean markAsCursorTargetTable()(Code) | | Mark this ResultSetNode as the target table of an updatable
cursor. Most types of ResultSetNode can't be target tables.
true if the target table supports positioned updates. |
markForDistinctScan | void markForDistinctScan()(Code) | | Mark the underlying scan as a distinct scan.
|
markOrderingDependent | void markOrderingDependent()(Code) | | Notify the underlying result set tree that the result is
ordering dependent. (For example, no bulk fetch on an index
if under an IndexRowToBaseRow.)
|
markStatementResultSet | public void markStatementResultSet()(Code) | | 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.
|
modifyAccessPaths | public ResultSetNode modifyAccessPaths() throws StandardException(Code) | | Modify the access paths according to the decisions the optimizer
made. This can include adding project/restrict nodes,
index-to-base-row nodes, etc.
The modified query tree exception: StandardException - Thrown on error |
modifyAccessPaths | public ResultSetNode modifyAccessPaths(PredicateList predList) throws StandardException(Code) | | Modify the access paths according to the decisions the optimizer
made. This can include adding project/restrict nodes,
index-to-base-row nodes, etc.
Parameters: predList - A list of optimizable predicates that shouldbe pushed to this ResultSetNode, as determined by optimizer. The modified query tree exception: StandardException - Thrown on error |
notCursorTargetTable | void notCursorTargetTable()(Code) | | Mark this ResultSetNode as *not* the target table of an updatable
cursor.
|
notFlattenableJoin | void notFlattenableJoin()(Code) | | Mark this node and its children as not being a flattenable join.
|
numDistinctAggregates | final protected static int numDistinctAggregates(Vector aggregateVector)(Code) | | Count the number of distinct aggregates in the list.
By 'distinct' we mean aggregates of the form:
SELECT MAX(DISTINCT x) FROM T<\I><\UL>
number of aggregates |
optimize | public ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicates, double outerRows) throws StandardException(Code) | | Optimize a ResultSetNode. This means choosing the best access
path for each table under the ResultSetNode, among other things.
The only RSNs that need to implement their own optimize() are a
SelectNode and those RSNs that can appear above a SelectNode in the
query tree. Currently, a ProjectRestrictNode is the only RSN that
can appear above a SelectNode.
Parameters: dataDictionary - The DataDictionary to use for optimization Parameters: predicates - The PredicateList to apply. Parameters: outerRows - The number of outer joining rows ResultSetNode The top of the optimized query tree exception: StandardException - Thrown on error |
performMaterialization | public boolean performMaterialization(JBitSet outerTables) throws StandardException(Code) | | Return whether or not to materialize this ResultSet tree.
Whether or not to materialize this ResultSet tree.would return valid results. exception: StandardException - Thrown on error |
preprocess | public ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException(Code) | | Preprocess a ResultSetNode - this currently means:
o Generating a referenced table map for each ResultSetNode.
o Putting the WHERE and HAVING clauses in conjunctive normal form (CNF).
o Converting the WHERE and HAVING clauses into PredicateLists and
classifying them.
o Ensuring that a ProjectRestrictNode is generated on top of every
FromBaseTable and generated in place of every FromSubquery.
o Pushing single table predicates down to the new ProjectRestrictNodes.
Parameters: numTables - The number of tables in the DML Statement Parameters: gbl - The group by list, if any Parameters: fromList - The from list, if any ResultSetNode at top of preprocessed tree. exception: StandardException - Thrown on error |
printSubNodes | public void printSubNodes(int depth)(Code) | | Prints the sub-nodes of this object. See QueryTreeNode.java for
how tree printing is supposed to work.
Parameters: depth - The depth of this node in the tree |
projectResultColumns | void projectResultColumns() throws StandardException(Code) | | Find the unreferenced result columns and project them out.
|
pushOrderByList | void pushOrderByList(OrderByList orderByList)(Code) | | 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.
Parameters: orderByList - The order by list |
referencesTarget | public boolean referencesTarget(String name, boolean baseTable) throws StandardException(Code) | | Search to see if a query references the specifed table name.
Parameters: name - Table name (String) to search for. Parameters: baseTable - Whether or not name is for a base table true if found, else false exception: StandardException - Thrown on error |
rejectParameters | public void rejectParameters() throws StandardException(Code) | | Check for (and reject) ? parameters directly under the ResultColumns.
This is done for SELECT statements.
exception: StandardException - Thrown if a ? parameter founddirectly under a ResultColumn |
rejectXMLValues | public void rejectXMLValues() throws StandardException(Code) | | Check for (and reject) XML values directly under the ResultColumns.
This is done for SELECT/VALUES statements. We reject values
in this case because JDBC does not define an XML type/binding
and thus there's no standard way to pass such a type back
to a JDBC application.
exception: StandardException - Thrown if an XML value founddirectly under a ResultColumn |
renameGeneratedResultNames | public void renameGeneratedResultNames() throws StandardException(Code) | | Rename generated result column names as '1', '2' etc... These will be the result
column names seen by JDBC clients.
|
returnsAtMostOneRow | boolean returnsAtMostOneRow()(Code) | | Return whether or not this ResultSet tree is guaranteed to return
at most 1 row based on heuristics. (A RowResultSetNode and a
SELECT with a non-grouped aggregate will return at most 1 row.)
Whether or not this ResultSet tree is guaranteed to returnat most 1 row based on heuristics. |
setInsertSource | public void setInsertSource()(Code) | | Remember that this node is the source result set for an INSERT.
|
setReferencedTableMap | public void setReferencedTableMap(JBitSet newRTM)(Code) | | Set the referencedTableMap in this ResultSetNode
Parameters: newRTM - The new referencedTableMap for this ResultSetNode |
setResultColumns | public void setResultColumns(ResultColumnList newRCL)(Code) | | Set the resultColumns in this ResultSetNode
Parameters: newRCL - The new ResultColumnList for this ResultSetNode |
setResultToBooleanTrueNode | public void setResultToBooleanTrueNode(boolean onlyConvertAlls) throws StandardException(Code) | | Set the result column for the subquery to a boolean true,
Useful for transformations such as
changing:
where exists (select ... from ...)
to:
where (select true from ...)
NOTE: No transformation is performed if the ResultColumn.expression is
already the correct boolean constant.
Parameters: onlyConvertAlls - Boolean, whether or not to just convert *'s exception: StandardException - Thrown on error |
setTableConstructorTypes | void setTableConstructorTypes(ResultColumnList typeColumns) throws StandardException(Code) | | Set the type of each parameter in the result column list for this table constructor.
Parameters: typeColumns - The ResultColumnList containing the desired resulttypes. exception: StandardException - Thrown on error |
subqueryReferencesTarget | boolean subqueryReferencesTarget(String name, boolean baseTable) throws StandardException(Code) | | Return whether or not this ResultSetNode contains a subquery with a
reference to the specified target.
Parameters: name - The table name. boolean Whether or not a reference to the table was found. exception: StandardException - Thrown on error |
toString | public String toString()(Code) | | Convert this object to a String. See comments in QueryTreeNode.java
for how this should be done for tree printing.
This object as a String |
updateTargetLockMode | public int updateTargetLockMode()(Code) | | Get the lock mode for the target of an update statement
(a delete or update). The update mode will always be row for
CurrentOfNodes. It will be table if there is no where clause.
See Also: TransactionController The lock mode |
verifySelectStarSubquery | public void verifySelectStarSubquery(FromList outerFromList, int subqueryType) throws StandardException(Code) | | Verify that a SELECT * is valid for this type of subquery.
Parameters: outerFromList - The FromList from the outer query block(s) Parameters: subqueryType - The subquery type exception: StandardException - Thrown on error |
Methods inherited from org.apache.derby.impl.sql.compile.QueryTreeNode | public Visitable accept(Visitor v) throws StandardException(Code)(Java Doc) public QueryTreeNode bind() throws StandardException(Code)(Java Doc) public DataValueDescriptor convertDefaultNode(DataTypeDescriptor typeDescriptor) throws StandardException(Code)(Java Doc) protected static void debugFlush()(Code)(Java Doc) public static void debugPrint(String outputString)(Code)(Java Doc) public void disablePrivilegeCollection()(Code)(Java Doc) public String executeSchemaName()(Code)(Java Doc) public String executeStatementName()(Code)(Java Doc) public static String formatNodeString(String nodeString, int depth)(Code)(Java Doc) public boolean foundString(String[] list, String search)(Code)(Java Doc) public GeneratedClass generate(ByteArray ignored) throws StandardException(Code)(Java Doc) protected void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException(Code)(Java Doc) void generateAuthorizeCheck(ActivationClassBuilder acb, MethodBuilder mb, int sqlOperation)(Code)(Java Doc) public int getBeginOffset()(Code)(Java Doc) final protected ClassFactory getClassFactory()(Code)(Java Doc) final protected CompilerContext getCompilerContext()(Code)(Java Doc) final public ContextManager getContextManager()(Code)(Java Doc) public Object getCursorInfo() throws StandardException(Code)(Java Doc) final public DataDictionary getDataDictionary()(Code)(Java Doc) final public DependencyManager getDependencyManager()(Code)(Java Doc) public int getEndOffset()(Code)(Java Doc) final public ExecutionFactory getExecutionFactory()(Code)(Java Doc) final public GenericConstantActionFactory getGenericConstantActionFactory()(Code)(Java Doc) protected int getIntProperty(String value, String key) throws StandardException(Code)(Java Doc) final protected LanguageConnectionContext getLanguageConnectionContext()(Code)(Java Doc) final public NodeFactory getNodeFactory()(Code)(Java Doc) protected int getNodeType()(Code)(Java Doc) public ConstantNode getNullNode(TypeId typeId, ContextManager cm) throws StandardException(Code)(Java Doc) public DataTypeDescriptor[] getParameterTypes() throws StandardException(Code)(Java Doc) public long getRowEstimate()(Code)(Java Doc) public String getSPSName()(Code)(Java Doc) final SchemaDescriptor getSchemaDescriptor(String schemaName) throws StandardException(Code)(Java Doc) final SchemaDescriptor getSchemaDescriptor(String schemaName, boolean raiseError) throws StandardException(Code)(Java Doc) protected int getStatementType()(Code)(Java Doc) final protected TableDescriptor getTableDescriptor(String tableName, SchemaDescriptor schema) throws StandardException(Code)(Java Doc) final protected TypeCompiler getTypeCompiler(TypeId typeId)(Code)(Java Doc) public void init(Object arg1) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14) throws StandardException(Code)(Java Doc) public boolean isAtomic() throws StandardException(Code)(Java Doc) protected boolean isInstanceOf(int nodeType)(Code)(Java Doc) public boolean isPrivilegeCollectionRequired()(Code)(Java Doc) final boolean isSessionSchema(SchemaDescriptor sd)(Code)(Java Doc) final boolean isSessionSchema(String schemaName)(Code)(Java Doc) public ConstantAction makeConstantAction() throws StandardException(Code)(Java Doc) public ResultDescription makeResultDescription() throws StandardException(Code)(Java Doc) public TableName makeTableName(String schemaName, String flatName) throws StandardException(Code)(Java Doc) public boolean needsSavepoint()(Code)(Java Doc) protected String nodeHeader()(Code)(Java Doc) public QueryTreeNode optimize() throws StandardException(Code)(Java Doc) public static QueryTreeNode parseQueryText(CompilerContext compilerContext, String queryText, Object[] paramDefaults, LanguageConnectionContext lcc) throws StandardException(Code)(Java Doc) public void printLabel(int depth, String label)(Code)(Java Doc) public void printSubNodes(int depth)(Code)(Java Doc) public boolean referencesSessionSchema() throws StandardException(Code)(Java Doc) public TableName resolveTableToSynonym(TableName tabName) throws StandardException(Code)(Java Doc) public void setBeginOffset(int beginOffset)(Code)(Java Doc) public void setContextManager(ContextManager cm)(Code)(Java Doc) public void setEndOffset(int endOffset)(Code)(Java Doc) public void setNodeType(int nodeType)(Code)(Java Doc) public void setRefActionInfo(long fkIndexConglomId, int[] fkColArray, String parentResultSetId, boolean dependentScan)(Code)(Java Doc) public String toString()(Code)(Java Doc) public void treePrint()(Code)(Java Doc) public void treePrint(int depth)(Code)(Java Doc) String verifyClassExist(String javaClassName, boolean convertCase) throws StandardException(Code)(Java Doc)
|
|
|