Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv abstract Class SetOperatorNode

extends TableOperatorNode
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.sql.compile.UnionNode, org.apache.derby.impl.sql.compile.IntersectOrExceptNode
Imports
java.util.HashMap, .Properties, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.CostEstimate, .Optimizable, .OptimizablePredicate, .OptimizablePredicateList, org.apache.derby.iapi.sql.dictionary.TableDescriptor, org.apache.derby.iapi.types.DataTypeDescriptor, org.apache.derby.iapi.util.JBitSet

A SetOperatorNode represents a UNION, INTERSECT, or EXCEPT in a DML statement. Binding and optimization preprocessing is the same for all of these operations, so they share bind methods in this abstract class. The class contains a boolean telling whether the operation should eliminate duplicate rows.

Field Summary

Modifier and TypeField and Description
pack-priv boolean
all

Tells whether to eliminate duplicate rows.

private PredicateList
private HashMap<Predicate, Predicate>
private PredicateList
pack-priv ResultSetNode.QueryExpressionClauses
private PredicateList
private HashMap<Predicate, Predicate>
Inherited from org.apache.derby.impl.sql.compile.TableOperatorNode:
leftOptimizerleftResultSetrightOptimizerrightResultSet

Constructor Summary

AccessConstructor 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.

Method Summary

Modifier and TypeMethod and Description
public void
bindExpressions(FromList
FromList to use/append to.
fromList
)

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.bindExpressions.

Bind the expressions under this TableOperatorNode.

pack-priv void
bindResultColumns(FromList
FromList to use/append to.
fromListParam
)

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.bindResultColumns.

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.apache.derby.impl.sql.compile.TableOperatorNode.bindResultColumns.

Bind the result columns for this ResultSetNode to a base table.

pack-priv void
bindTargetExpressions(FromList fromListParam)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.bindTargetExpressions.

Bind the expressions in the target list.

pack-priv void
bindUntypedNullsToResultColumns(ResultColumnList
The ResultColumnList with the types to bind to
rcl
)

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.bindUntypedNullsToResultColumns.

Bind the result columns of a table constructor to the types in the given ResultColumnList.

private void
buildRCL()

Build the RCL for this node.

pack-priv ResultSetNode

Returns:

ResultSetNode A RSN tree with a node which has a PredicateList on top.
ensurePredicateList
(int
The number of tables in the query.
numTables
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.ensurePredicateList.

Ensure that the top of the RSN tree has a PredicateList.

pack-priv boolean

Returns:

boolean Whether or not the FromSubquery is flattenable.
flattenableInFromSubquery
(FromList
The outer from list
fromList
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.flattenableInFromSubquery.

Evaluate whether or not the subquery in a FromSubquery is flattenable.

pack-priv FromTable

Returns:

The FromTable, if any, with the exposed name.
getFromTableByName
(String
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.apache.derby.impl.sql.compile.TableOperatorNode.getFromTableByName.

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

Returns:

the operator name: "UNION", "INTERSECT", or "EXCEPT"
getOperatorName
()

pack-priv int

Returns:

The number of new types found in the RowResultSetNode
getParamColumnTypes
(DataTypeDescriptor[]
The 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.
hasUnPushedPredicates
()

It's possible that we tried to push predicates to this node's children but failed to do so.

public Optimizable
modifyAccessPath(JBitSet outerTables, PredicateList predList)

pack-priv boolean

Returns:

Whether or not to materialize this ResultSet tree. would return valid results.
performMaterialization
(JBitSet outerTables)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.performMaterialization.

Return whether or not to materialize this ResultSet tree.

pack-priv ResultSetNode

Returns:

The preprocessed ResultSetNode that can be optimized
preprocess
(int
Number of tables in the DML Statement
numTables
,
GroupByList
The group by list, if any
gbl
,
FromList
The from list, if any
fromList
)

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.preprocess.

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.apache.derby.impl.sql.compile.TableOperatorNode.printSubNodes.

Prints the sub-nodes of this object.

public void
pullOptPredicates(OptimizablePredicateList
The list to put the pulled predicates in.
optimizablePredicates
)

Overrides org.apache.derby.impl.sql.compile.FromTable.pullOptPredicates.

Implements org.apache.derby.iapi.sql.compile.Optimizable.pullOptPredicates.

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.apache.derby.impl.sql.compile.ResultSetNode.pushOffsetFetchFirst.

Push down the offset and fetch first parameters, if any, to this node.

public boolean
pushOptPredicate(OptimizablePredicate
OptimizablePredicate to push down.
optimizablePredicate
)

Overrides org.apache.derby.impl.sql.compile.FromTable.pushOptPredicate.

Implements org.apache.derby.iapi.sql.compile.Optimizable.pushOptPredicate.

Push an OptimizablePredicate down, if this node accepts it.

pack-priv void
pushOrderByList(OrderByList
The order by list
orderByList
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.pushOrderByList.

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.apache.derby.impl.sql.compile.ResultSetNode.pushQueryExpressionSuffix.

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.apache.derby.impl.sql.compile.ResultSetNode.replaceOrForbidDefaults.

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.apache.derby.impl.sql.compile.ResultSetNode.setResultToBooleanTrueNode.

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 String
toString
()

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.toString.

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.apache.derby.impl.sql.compile.ResultSetNode.verifySelectStarSubquery.

Verify that a SELECT * is valid for this type of subquery.

Inherited from org.apache.derby.impl.sql.compile.TableOperatorNode:
acceptChildrenadjustForSortEliminationadjustForSortEliminationbindExpressionsWithTablesbindNonVTITablesbindVTITablesdecrementLevelgetExposedNamegetLeftmostResultSetgetLeftResultSetgetRightResultSetmodifyAccessPathmodifyAccessPathsneedsSpecialRCLBindingoptimizeoptimizeSourceprojectResultColumnsreferencesSessionSchemareferencesTargetrejectParameterssetLeftmostResultSetsetLevelsetNestedInParenssetReferencedColumnsupdateBestPlanMapverifyProperties

Field Detail

allback to summary
pack-priv boolean all

Tells whether to eliminate duplicate rows. all == TRUE means do not eliminate duplicates, all == FALSE means eliminate duplicates.

leftOptPredicatesback to summary
private PredicateList leftOptPredicates
leftScopedPredsback to summary
private HashMap<Predicate, Predicate> leftScopedPreds
pushedPredicatesback to summary
private PredicateList pushedPredicates
qecback to summary
pack-priv ResultSetNode.QueryExpressionClauses qec
rightOptPredicatesback to summary
private PredicateList rightOptPredicates
rightScopedPredsback to summary
private HashMap<Predicate, Predicate> rightScopedPreds

Constructor Detail

SetOperatorNodeback to summary
pack-priv SetOperatorNode(ResultSetNode leftResult, ResultSetNode rightResult, boolean all, Properties tableProperties, ContextManager cm) throws StandardException

Constructor for a SetOperatorNode.

Parameters
leftResult:ResultSetNode

The ResultSetNode on the left side of this union

rightResult:ResultSetNode

The ResultSetNode on the right side of this union

all:boolean

Whether or not this is an ALL.

tableProperties:Properties

Properties list associated with the table

cm:ContextManager

The context manager

Exceptions
StandardException:
Thrown on error

Method Detail

bindExpressionsback to summary
public void bindExpressions(FromList fromList) throws StandardException

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.bindExpressions.

Doc from org.apache.derby.impl.sql.compile.TableOperatorNode.bindExpressions.

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.

Parameters
fromList:FromList

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.bindExpressions.

FromList to use/append to.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindResultColumnsback to summary
pack-priv void bindResultColumns(FromList fromListParam) throws StandardException

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.bindResultColumns.

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

FromList to use/append to.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindResultColumnsback to summary
pack-priv void bindResultColumns(TableDescriptor targetTableDescriptor, FromVTI targetVTI, ResultColumnList targetColumnList, DMLStatementNode statement, FromList fromListParam) throws StandardException

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.bindResultColumns.

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:TableDescriptor

The TableDescriptor for the table being updated or inserted into

targetColumnList: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.

statement:DMLStatementNode

Calling DMLStatementNode (Insert or Update)

fromListParam:FromList

FromList to use/append to.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindTargetExpressionsback to summary
pack-priv void bindTargetExpressions(FromList fromListParam) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.bindTargetExpressions.

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.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
bindUntypedNullsToResultColumnsback to summary
pack-priv void bindUntypedNullsToResultColumns(ResultColumnList rcl) throws StandardException

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.bindUntypedNullsToResultColumns.

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.

Parameters
rcl:ResultColumnList

The ResultColumnList with the types to bind to

Annotations
@Override
Exceptions
StandardException:
Thrown on error.
buildRCLback 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.

Exceptions
StandardException:
Thrown on error
ensurePredicateListback to summary
pack-priv ResultSetNode ensurePredicateList(int numTables) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.ensurePredicateList.

Ensure that the top of the RSN tree has a PredicateList.

Parameters
numTables:int

The number of tables in the query.

Returns:ResultSetNode

ResultSetNode A RSN tree with a node which has a PredicateList on top.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
flattenableInFromSubqueryback to summary
pack-priv boolean flattenableInFromSubquery(FromList fromList)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.flattenableInFromSubquery.

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:FromList

The outer from list

Returns:boolean

boolean Whether or not the FromSubquery is flattenable.

Annotations
@Override
getFromTableByNameback to summary
pack-priv FromTable getFromTableByName(String name, String schemaName, boolean exactMatch) throws StandardException

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.getFromTableByName.

Determine whether or not the specified name is an exposed name in the current query block.

Parameters
name:String

The specified name to search for as an exposed name.

schemaName:String

Schema name, if non-null.

exactMatch:boolean

Whether or not we need an exact match on specified schema and table names or match on table id.

Returns:FromTable

The FromTable, if any, with the exposed name.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
getLeftOptPredicateListback 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.

getOperatorNameback to summary
pack-priv abstract String getOperatorName()
Returns:String

the operator name: "UNION", "INTERSECT", or "EXCEPT"

getParamColumnTypesback 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.

Parameters
types:DataTypeDescriptor[]

The array of types to fill in

rrsn:RowResultSetNode

The RowResultSetNode from which to take the param types

Returns:int

The number of new types found in the RowResultSetNode

getRightOptPredicateListback 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.

hasUnPushedPredicatesback 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).

Returns:boolean

True if this SetOperatorNode has unpushed predicates; false otherwise.

modifyAccessPathback to summary
public Optimizable modifyAccessPath(JBitSet outerTables, PredicateList predList) throws StandardException
Exceptions
StandardException:
Thrown on error
See Also
Optimizable#modifyAccessPath
performMaterializationback to summary
pack-priv boolean performMaterialization(JBitSet outerTables) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.performMaterialization.

Return whether or not to materialize this ResultSet tree.

Returns:boolean

Whether or not to materialize this ResultSet tree. would return valid results.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
preprocessback to summary
pack-priv ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.preprocess.

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:int

Number of tables in the DML Statement

gbl:GroupByList

The group by list, if any

fromList:FromList

The from list, if any

Returns:ResultSetNode

The preprocessed ResultSetNode that can be optimized

Annotations
@Override
Exceptions
StandardException:
Thrown on error
printSubNodesback to summary
pack-priv void printSubNodes(int depth)

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.printSubNodes.

Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.

Parameters
depth:int

The depth of this node in the tree

Annotations
@Override
pullOptPredicatesback to summary
public void pullOptPredicates(OptimizablePredicateList optimizablePredicates) throws StandardException

Overrides org.apache.derby.impl.sql.compile.FromTable.pullOptPredicates.

Implements org.apache.derby.iapi.sql.compile.Optimizable.pullOptPredicates.

Doc from org.apache.derby.iapi.sql.compile.Optimizable.pullOptPredicates.

Pull all the OptimizablePredicates from this Optimizable and put them in the given OptimizablePredicateList.

Parameters
optimizablePredicates:OptimizablePredicateList

The list to put the pulled predicates in.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
Optimizable#pullOptPredicates
pushOffsetFetchFirstback to summary
pack-priv void pushOffsetFetchFirst(ValueNode offset, ValueNode fetchFirst, boolean hasJDBClimitClause)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.pushOffsetFetchFirst.

Push down the offset and fetch first parameters, if any, to this node.

Parameters
offset:ValueNode

the OFFSET, if any

fetchFirst:ValueNode

the OFFSET FIRST, if any

hasJDBClimitClause:boolean

true if the clauses were added by (and have the semantics of) a JDBC limit clause

Annotations
@Override
pushOptPredicateback to summary
public boolean pushOptPredicate(OptimizablePredicate optimizablePredicate) throws StandardException

Overrides org.apache.derby.impl.sql.compile.FromTable.pushOptPredicate.

Implements org.apache.derby.iapi.sql.compile.Optimizable.pushOptPredicate.

Doc from org.apache.derby.iapi.sql.compile.Optimizable.pushOptPredicate.

Push an OptimizablePredicate down, if this node accepts it.

Parameters
optimizablePredicate:OptimizablePredicate

OptimizablePredicate to push down.

Returns:boolean

Whether or not the predicate was pushed down.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
Take a predicate and push it down to both the left AND right result sets. Return "true" if we successfully pushed it to both sides, and "false" otherwise. The assumption is that if we return "true", the caller will take the predicate and remove it from its own list of predicates to evaluate; if we return false, then the predicate will be evaluated at the level of the caller. So returning "false" means that the left and right result sets for this node will be fully returned, and then the predicate will be evaluated against the set-operator of those result sets (as of DERBY-805, the only set-operator calling this method is UnionNode). If we can push the predicate down to both children, though, we can evaluate it closer to store, which means that each child result set returns only the correctly qualified rows, and thus the calling set operator will have a smaller result set on which to operate, which can boost performance. That said, if we can't push the predicate to _both_ sides, we don't push it at all. The reason is that if we push to one side but not to the other, we would have to ask the question of whether we should return "true" (meaning that the predicate would be removed from the caller's list and thus would _not_ be evaluated at the set-operator level) or "false" (meaning that the caller would keep the predicate and evaluate it at the set-operator level). Depending on the query in question, both answers could end up returning incorrect results. For example, if we push it to the right but not to the left, then leave it in the caller's list, the optimizer for the caller might decide to use the predicate to do a hash join with some outer result set (if the predicate is an equijoin predicate). That would result in materialization of the calling node and of its children--but since we pushed a predicate that depends on the outer table down into the right child, materialization of the right child will only return the rows that join with the _first_ row of the outer result set, which is wrong. If, on the other hand, we push the predicate to one side and then tell the caller to remove it from its list, the side to which we did _not_ push the predicate could return rows that aren't qualified. Then, since the caller removed the predicate from its list, it (the caller) will not evaluate the predicate on its own result set--and thus we can end up returning rows that we weren't supposed to return. So all of that said, only push (and return "true") if we think we can push the predicate to both sides.
pushOrderByListback to summary
pack-priv void pushOrderByList(OrderByList orderByList)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.pushOrderByList.

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:OrderByList

The order by list

Annotations
@Override
pushQueryExpressionSuffixback to summary
public void pushQueryExpressionSuffix()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.pushQueryExpressionSuffix.

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.pushQueryExpressionSuffix.

Set up a new level for order by and fetch/offset clauses. See Javadoc for ResultSetNode.QueryExpressionClauses. Overridden by implementors of pushOrderByNode, pushOffsetFetchFirst.

Annotations
@Override
replaceOrForbidDefaultsback to summary
pack-priv void replaceOrForbidDefaults(TableDescriptor ttd, ResultColumnList tcl, boolean allowDefaults) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.replaceOrForbidDefaults.

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.replaceOrForbidDefaults.

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.

Parameters
ttd:TableDescriptor

The TableDescriptor for the target table.

tcl:ResultColumnList

The RCL for the target table.

allowDefaults:boolean

true if allowed

Annotations
@Override
Exceptions
StandardException:
Thrown on error
setParamColumnTypesback 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.

Parameters
types:DataTypeDescriptor[]

An array of types containing the proper type for each ? parameter, by ordinal position.

rrsn:RowResultSetNode

A RowResultSetNode that could contain ? parameters whose types need to be set.

Exceptions
StandardException:
Thrown on error
setResultToBooleanTrueNodeback to summary
pack-priv ResultSetNode setResultToBooleanTrueNode(boolean onlyConvertAlls) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.setResultToBooleanTrueNode.

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.

Parameters
onlyConvertAlls:boolean

Boolean, whether or not to just convert *'s

Returns:ResultSetNode

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.setResultToBooleanTrueNode.

ResultSetNode whose resultColumn was transformed; defaults to "this" here, but can be overridden by subclasses.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
toStringback to summary
public String toString()

Overrides org.apache.derby.impl.sql.compile.TableOperatorNode.toString.

Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Returns:String

This object as a String

Annotations
@Override
verifySelectStarSubqueryback to summary
pack-priv void verifySelectStarSubquery(FromList outerFromList, int subqueryType) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.verifySelectStarSubquery.

Verify that a SELECT * is valid for this type of subquery.

Parameters
outerFromList:FromList

The FromList from the outer query block(s)

subqueryType:int

The subquery type

Annotations
@Override
Exceptions
StandardException:
Thrown on error