| Modifier and Type | Field and Description |
|---|---|
| pack-priv boolean | all
Tells whether to eliminate duplicate rows. |
| private PredicateList | |
| private HashMap | |
| private PredicateList | |
| pack-priv ResultSetNode. | |
| private PredicateList | |
| private HashMap |
| Access | Constructor and Description |
|---|---|
| pack-priv | SetOperatorNode(ResultSetNode
The ResultSetNode on the left side of this union leftResult, ResultSetNode The ResultSetNode on the right side of this union rightResult, boolean Whether or not this is an ALL. all, Properties Properties list associated with the table tableProperties, ContextManager The context manager cm)Constructor for a SetOperatorNode. |
| Modifier and Type | Method and Description |
|---|---|
| public void | bindExpressions(FromList
FromList to use/append to. fromList)Overrides org. Bind the expressions under this TableOperatorNode. |
| pack-priv void | bindResultColumns(FromList
FromList to use/append to. fromListParam)Overrides org. Bind the result columns of this ResultSetNode when there is no base table to bind them to. |
| pack-priv void | bindResultColumns(TableDescriptor
The TableDescriptor for the table being
updated or inserted into targetTableDescriptor, FromVTI targetVTI, ResultColumnList For INSERT statements, the user
does not have to supply column
names (for example, "insert into t
values (1,2,3)". When this
parameter is null, it means that
the user did not supply column
names, and so the binding should
be done based on order. When it
is not null, it means do the binding
by name, not position. targetColumnList, DMLStatementNode Calling DMLStatementNode (Insert or Update) statement, FromList FromList to use/append to. fromListParam)Overrides org. Bind the result columns for this ResultSetNode to a base table. |
| pack-priv void | bindTargetExpressions(FromList fromListParam)
Overrides org. Bind the expressions in the target list. |
| pack-priv void | bindUntypedNullsToResultColumns(ResultColumnList
The ResultColumnList with the types to bind to rcl)Overrides org. Bind the result columns of a table constructor to the types in the given ResultColumnList. |
| private void | |
| pack-priv ResultSetNode | Returns: ResultSetNode A RSN tree with a node which has a PredicateList on top.The number of tables in the query. numTables)Overrides org. Ensure that the top of the RSN tree has a PredicateList. |
| pack-priv boolean | Returns: boolean Whether or not the FromSubquery is flattenable.The outer from list fromList)Overrides org. Evaluate whether or not the subquery in a FromSubquery is flattenable. |
| pack-priv FromTable | Returns: The FromTable, if any, with the exposed name.The specified name to search for as an exposed name. name, String Schema name, if non-null. schemaName, boolean Whether or not we need an exact match on specified schema and table
names or match on table id. exactMatch)Overrides org. Determine whether or not the specified name is an exposed name in the current query block. |
| pack-priv PredicateList | getLeftOptPredicateList()
Retrieve the list of optimizable predicates that are targeted for the left child. |
| pack-priv abstract String | |
| pack-priv int | Returns: The number of new types found in the RowResultSetNodeThe array of types to fill in types, RowResultSetNode The RowResultSetNode from which to take the param types rrsn)Get the parameter types from the given RowResultSetNode into the given array of types. |
| pack-priv PredicateList | getRightOptPredicateList()
Retrieve the list of optimizable predicates that are targeted for the right child. |
| protected boolean | Returns: True if this SetOperatorNode has unpushed predicates; false otherwise.It's possible that we tried to push predicates to this node's children but failed to do so. |
| public Optimizable | |
| pack-priv boolean | Returns: Whether or not to materialize this ResultSet tree. would return valid results.Overrides org. Return whether or not to materialize this ResultSet tree. |
| pack-priv ResultSetNode | Returns: The preprocessed ResultSetNode that can be optimizedNumber of tables in the DML Statement numTables, GroupByList The group by list, if any gbl, FromList The from list, if any fromList)Overrides org. Put a ProjectRestrictNode on top of each FromTable in the FromList. |
| pack-priv void | printSubNodes(int
The depth of this node in the tree depth)Overrides org. Prints the sub-nodes of this object. |
| public void | pullOptPredicates(OptimizablePredicateList
The list to put the pulled predicates
in. optimizablePredicates)Overrides org. Implements org. Pull all the OptimizablePredicates from this Optimizable and put them in the given OptimizablePredicateList. |
| pack-priv void | pushOffsetFetchFirst(ValueNode
the OFFSET, if any offset, ValueNode the OFFSET FIRST, if any fetchFirst, boolean true if the clauses were added by (and have the semantics of) a JDBC limit clause hasJDBClimitClause)Overrides org. Push down the offset and fetch first parameters, if any, to this node. |
| public boolean | pushOptPredicate(OptimizablePredicate
OptimizablePredicate to push down. optimizablePredicate)Overrides org. Implements org. Push an OptimizablePredicate down, if this node accepts it. |
| pack-priv void | pushOrderByList(OrderByList
The order by list orderByList)Overrides org. 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 void | pushQueryExpressionSuffix()
Overrides org. Set up a new level for order by and fetch/offset clauses. |
| pack-priv void | replaceOrForbidDefaults(TableDescriptor
The TableDescriptor for the target table. ttd, ResultColumnList The RCL for the target table. tcl, boolean true if allowed allowDefaults)Overrides org. Replace any DEFAULTs with the associated tree for the default if allowed, or flag (when inside top level set operator nodes). |
| pack-priv void | setParamColumnTypes(DataTypeDescriptor[]
An array of types containing the proper type for each
? parameter, by ordinal position. types, RowResultSetNode A RowResultSetNode that could contain ? parameters whose
types need to be set. rrsn)Set the type of each ? |
| pack-priv ResultSetNode | setResultToBooleanTrueNode(boolean
Boolean, whether or not to just convert *'s onlyConvertAlls)Overrides org. Set the result column for the subquery to a boolean true, Useful for transformations such as changing: where exists (select ... |
| public String | Returns: This object as a StringOverrides org. Convert this object to a String. |
| pack-priv void | verifySelectStarSubquery(FromList
The FromList from the outer query block(s) outerFromList, int The subquery type subqueryType)Overrides org. Verify that a SELECT * is valid for this type of subquery. |
| all | back to summary |
|---|---|
| pack-priv boolean all Tells whether to eliminate duplicate rows. all == TRUE means do not eliminate duplicates, all == FALSE means eliminate duplicates. | |
| leftOptPredicates | back to summary |
|---|---|
| private PredicateList leftOptPredicates | |
| leftScopedPreds | back to summary |
|---|---|
| private HashMap<Predicate, Predicate> leftScopedPreds | |
| pushedPredicates | back to summary |
|---|---|
| private PredicateList pushedPredicates | |
| qec | back to summary |
|---|---|
| pack-priv ResultSetNode. | |
| rightOptPredicates | back to summary |
|---|---|
| private PredicateList rightOptPredicates | |
| rightScopedPreds | back to summary |
|---|---|
| private HashMap<Predicate, Predicate> rightScopedPreds | |
| SetOperatorNode | back to summary |
|---|---|
| pack-priv SetOperatorNode(ResultSetNode leftResult, ResultSetNode rightResult, boolean all, Properties tableProperties, ContextManager cm) throws StandardException Constructor for a SetOperatorNode.
| |
| bindExpressions | back to summary |
|---|---|
| public void bindExpressions(FromList fromList) throws StandardException Overrides org. Doc from org. Bind the expressions under this TableOperatorNode. This means binding the sub-expressions, as well as figuring out what the return type is for each expression.
| |
| bindResultColumns | back to summary |
|---|---|
| pack-priv void bindResultColumns(FromList fromListParam) throws StandardException Overrides org. 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.
| |
| bindResultColumns | back to summary |
|---|---|
| pack-priv void bindResultColumns(TableDescriptor targetTableDescriptor, FromVTI targetVTI, ResultColumnList targetColumnList, DMLStatementNode statement, FromList fromListParam) throws StandardException Overrides org. 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.
| |
| bindTargetExpressions | back to summary |
|---|---|
| pack-priv void bindTargetExpressions(FromList fromListParam) throws StandardException Overrides org. 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.
| |
| bindUntypedNullsToResultColumns | back to summary |
|---|---|
| pack-priv void bindUntypedNullsToResultColumns(ResultColumnList rcl) throws StandardException Overrides org. Bind the result columns of a table constructor to the types in the given ResultColumnList. Use when inserting from a table constructor, and there are nulls in the values clauses.
| |
| buildRCL | back to summary |
|---|---|
| private void buildRCL() throws StandardException Build the RCL for this node. We propagate the RCL up from the left child to form this node's RCL.
| |
| ensurePredicateList | back to summary |
|---|---|
| pack-priv ResultSetNode ensurePredicateList(int numTables) throws StandardException Overrides org. Ensure that the top of the RSN tree has a PredicateList.
| |
| flattenableInFromSubquery | back to summary |
|---|---|
| pack-priv boolean flattenableInFromSubquery(FromList fromList) Overrides org. 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. | |
| getFromTableByName | back to summary |
|---|---|
| pack-priv FromTable getFromTableByName(String name, String schemaName, boolean exactMatch) throws StandardException Overrides org. Determine whether or not the specified name is an exposed name in the current query block.
| |
| getLeftOptPredicateList | back to summary |
|---|---|
| pack-priv PredicateList getLeftOptPredicateList() throws StandardException Retrieve the list of optimizable predicates that are targeted for the left child. Create a new (empty) list if the list is null. | |
| getOperatorName | back to summary |
|---|---|
pack-priv abstract String getOperatorName()
| |
| getParamColumnTypes | back to summary |
|---|---|
| pack-priv int getParamColumnTypes(DataTypeDescriptor[] types, RowResultSetNode rrsn) throws StandardException Get the parameter types from the given RowResultSetNode into the given array of types. If an array position is already filled in, don't clobber it.
| |
| getRightOptPredicateList | back to summary |
|---|---|
| pack-priv PredicateList getRightOptPredicateList() throws StandardException Retrieve the list of optimizable predicates that are targeted for the right child. Create a new (empty) list if the list is null. | |
| hasUnPushedPredicates | back to summary |
|---|---|
| protected boolean hasUnPushedPredicates() It's possible that we tried to push predicates to this node's children but failed to do so. This can happen if this node's children both satisfy the criteria for pushing a predicate (namely, they reference base tables) but the children's children do not (see modifyAccessPaths() above for an example of how that can happen). So this method determines whether or not this particular SetOperatorNode has predicates which were *not* successfully pushed to both of its children (note: this currently only applies to UnionNodes).
| |
| modifyAccessPath | back to summary |
|---|---|
public Optimizable modifyAccessPath(JBitSet outerTables, PredicateList predList) throws StandardException
| |
| performMaterialization | back to summary |
|---|---|
| pack-priv boolean performMaterialization(JBitSet outerTables) throws StandardException Overrides org. Return whether or not to materialize this ResultSet tree.
| |
| preprocess | back to summary |
|---|---|
| pack-priv ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException Overrides org. 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.
| |
| printSubNodes | back to summary |
|---|---|
| pack-priv void printSubNodes(int depth) Overrides org. Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.
| |
| pullOptPredicates | back to summary |
|---|---|
| public void pullOptPredicates(OptimizablePredicateList optimizablePredicates) throws StandardException Overrides org. Implements org. Doc from org. Pull all the OptimizablePredicates from this Optimizable and put them in the given OptimizablePredicateList.
| |
| pushOffsetFetchFirst | back to summary |
|---|---|
| pack-priv void pushOffsetFetchFirst(ValueNode offset, ValueNode fetchFirst, boolean hasJDBClimitClause) Overrides org. Push down the offset and fetch first parameters, if any, to this node. | |
| pushOrderByList | back to summary |
|---|---|
| pack-priv void pushOrderByList(OrderByList orderByList) Overrides org. 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.
| |
| pushQueryExpressionSuffix | back to summary |
|---|---|
| public void pushQueryExpressionSuffix() Overrides org. Doc from org. Set up a new level for order by and fetch/offset clauses.
See Javadoc for
| |
| replaceOrForbidDefaults | back to summary |
|---|---|
| pack-priv void replaceOrForbidDefaults(TableDescriptor ttd, ResultColumnList tcl, boolean allowDefaults) throws StandardException Overrides org. Doc from org. Replace any DEFAULTs with the associated tree for the default if allowed, or flag (when inside top level set operator nodes). Subqueries are checked for illegal DEFAULTs elsewhere.
| |
| setParamColumnTypes | back to summary |
|---|---|
| pack-priv void setParamColumnTypes(DataTypeDescriptor[] types, RowResultSetNode rrsn) throws StandardException Set the type of each ? parameter in the given RowResultSetNode according to its ordinal position in the given array of types.
| |
| setResultToBooleanTrueNode | back to summary |
|---|---|
| pack-priv ResultSetNode setResultToBooleanTrueNode(boolean onlyConvertAlls) throws StandardException Overrides org. 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. This method is used during binding of EXISTS predicates to map a subquery's result column list into a single TRUE node. For SELECT and VALUES subqueries this transformation is pretty straightforward. But for set operators (ex. INTERSECT) we have to do some extra work. To see why, assume we have the following query: select * from ( values 'BAD' ) as T where exists ((values 1) intersect (values 2)) If we treated the INTERSECT in this query the same way that we treat SELECT/VALUES subqueries then the above query would get transformed into: select * from ( values 'BAD' ) as T where ((values TRUE) intersect (values TRUE)) Since both children of the INTERSECT would then have the same value, the result of set operation would be a single value (TRUE), which means the WHERE clause would evaluate to TRUE and thus the query would return one row with value 'BAD'. That would be wrong. To avoid this problem, we internally wrap this SetOperatorNode inside a "SELECT *" subquery and then we change the new SelectNode's result column list (as opposed to *this* nodes' result column list) to a singe boolean true node: select * from ( values 'BAD' ) as T where SELECT TRUE FROM ((values 1) intersect (values 2)) In this case the left and right children of the INTERSECT retain their values, which ensures that the result of the intersect operation will be correct. Since (1 intersect 2) is an empty result set, the internally generated SELECT node will return zero rows, which in turn means the WHERE predicate will return NULL (an empty result set from a SubqueryNode is treated as NULL at execution time; see impl/sql/execute/AnyResultSet). Since NULL is not the same as TRUE the query will correctly return zero rows. DERBY-2370.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing. | |
| verifySelectStarSubquery | back to summary |
|---|---|
| pack-priv void verifySelectStarSubquery(FromList outerFromList, int subqueryType) throws StandardException Overrides org. Verify that a SELECT * is valid for this type of subquery.
| |