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

pack-priv Class ValueNodeList

extends QueryTreeNodeVector<ValueNode>
Class Inheritance
Imports
java.util.List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.loader.ClassFactory, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.compile.TypeCompiler, org.apache.derby.iapi.store.access.Qualifier, org.apache.derby.iapi.types.DataTypeDescriptor, .DataValueDescriptor, .StringDataValue, .TypeId, org.apache.derby.iapi.util.JBitSet

A ValueNodeList represents a list of ValueNodes within a specific predicate e.g. IN list, NOT IN list or BETWEEN in a DML statement.

Field Summary

Inherited from org.apache.derby.impl.sql.compile.QueryTreeNodeVector:
eltClass

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addValueNode(ValueNode
A ValueNode to add to the list
valueNode
)

Add a ValueNode to the list.

pack-priv boolean

Returns:

Whether or not all of the entries in the list have the same type precendence as the specified value.
allSamePrecendence
(int
The specified precedence.
precedence
)

Return whether or not all of the entries in the list have the same type precendence as the specified value.

pack-priv void
bindExpression(FromList
The FROM list for the query this expression is in, for binding columns.
fromList
,
SubqueryList
The subquery list being built as we find SubqueryNodes
subqueryList
,
List<AggregateNode>
The aggregate list being built as we find AggregateNodes
aggregates
)

Bind this expression.

pack-priv boolean

Returns:

boolean Whether or not source.expression is a ColumnReference or a VirtualColumnNode.
categorize
(JBitSet
JBitSet with bit map of referenced FromTables
referencedTabs
,
boolean
Whether or not to consider method calls, field references and conditional nodes when building bit map
simplePredsOnly
)

Categorize this predicate.

pack-priv void
comparable(ValueNode
The left side of the expression
leftOperand
)

Determine whether or not the leftOperand is comparable() with all of the elements in the list.

pack-priv void
compatible(ValueNode
Check for compatibility against this parameter's type
leftOperand
)

Make sure that passed ValueNode's type is compatible with the non-parameter elements in the ValueNodeList.

pack-priv boolean
pack-priv boolean

Returns:

boolean Whether or not the list contains all ConstantNodes
containsAllConstantNodes
()

Does this list contain all ConstantNodes?

pack-priv boolean

Returns:

boolean Whether or not the list contains all ParameterNodes
containsAllParameterNodes
()

Does this list contain all ParameterNodes?

pack-priv boolean

Returns:

boolean True if every node in this list is either a constant node or parameter node.
containsOnlyConstantAndParamNodes
()

Does this list *only* contain constant and/or parameter nodes?

pack-priv boolean

Returns:

boolean Whether or not the list contains a ParameterNode
containsParameterNode
()

Does this list contain a ParameterNode?

pack-priv void
eliminateNots(boolean
whether or not we are under a NotNode
underNotNode
)

Eliminate NotNodes in all the nodes in this list.

pack-priv void
genSQLJavaSQLTrees()

Generate a SQL->Java->SQL conversion tree any node in the list which is not a system built-in type.

pack-priv DataTypeDescriptor

Returns:

DataTypeServices The dominant DataTypeServices.
getDominantTypeServices
()

Get the dominant DataTypeServices from the elements in the list.

protected int

Returns:

The variant type for the underlying expression.
getOrderableVariantType
()

Return the variant type for the underlying expression.

pack-priv DataTypeDescriptor

Returns:

DataTypeServices The first non-null DataTypeServices.
getTypeServices
()

Get the first non-null DataTypeServices from the elements in the list.

pack-priv boolean

Returns:

Whether or not this expression tree represents a constant expression.
isConstantExpression
()

Return whether or not this expression tree represents a constant expression.

pack-priv boolean

Returns:

true if the two lists contain equivalent elements, or false otherwise
isEquivalent
(ValueNodeList
the other list
other
)

Check if all the elements in this list are equivalent to the elements in another list.

pack-priv boolean

Returns:

boolean Whether or not any of the elements in the list are nullable.
isNullable
()

Determine whether or not any of the elements in the list are nullable.

pack-priv void
preprocess(int
Number of tables in the DML Statement
numTables
,
FromList
FromList from outer query block
outerFromList
,
SubqueryList
SubqueryList from outer query block
outerSubqueryList
,
PredicateList
PredicateList from outer query block
outerPredicateList
)

Preprocess a ValueNodeList.

pack-priv ValueNodeList

Returns:

ValueNodeList The remapped expression tree.
remapColumnReferencesToExpressions
()

Remap all ColumnReferences in this tree to be clones of the underlying expression.

pack-priv void
setParameterDescriptor(DataTypeDescriptor
The DataTypeServices to set for the parameters
descriptor
)

Set the descriptor for every ParameterNode in the list.

pack-priv void
sortInAscendingOrder(DataValueDescriptor
In case of type not exactly matching, the judging type.
judgeODV
)

Sort the entries in the list in ascending order.

Inherited from org.apache.derby.impl.sql.compile.QueryTreeNodeVector:
acceptChildrenaddElementdestructiveAppendelementAtindexOfinsertElementAtiteratornondestructiveAppendprintSubNodesremoveAllElementsremoveElementremoveElementAtsetElementAtsize

Constructor Detail

ValueNodeListback to summary
pack-priv ValueNodeList(ContextManager cm)

Method Detail

addValueNodeback to summary
pack-priv void addValueNode(ValueNode valueNode) throws StandardException

Add a ValueNode to the list.

Parameters
valueNode:ValueNode

A ValueNode to add to the list

Exceptions
StandardException:
Thrown on error
allSamePrecendenceback to summary
pack-priv boolean allSamePrecendence(int precedence)

Return whether or not all of the entries in the list have the same type precendence as the specified value.

Parameters
precedence:int

The specified precedence.

Returns:boolean

Whether or not all of the entries in the list have the same type precendence as the specified value.

bindExpressionback to summary
pack-priv void bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException

Bind this expression. This means binding the sub-expressions, as well as figuring out what the return type is for this expression.

Parameters
fromList:FromList

The FROM list for the query this expression is in, for binding columns.

subqueryList:SubqueryList

The subquery list being built as we find SubqueryNodes

aggregates:List<AggregateNode>

The aggregate list being built as we find AggregateNodes

Exceptions
StandardException:
Thrown on error
categorizeback to summary
pack-priv boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly) throws StandardException

Categorize this predicate. Initially, this means building a bit map of the referenced tables for each predicate. If the source of this ColumnReference (at the next underlying level) is not a ColumnReference or a VirtualColumnNode then this predicate will not be pushed down. For example, in: select * from (select 1 from s) a (x) where x = 1 we will not push down x = 1.

Note

It would be easy to handle the case of a constant, but if the inner SELECT returns an arbitrary expression, then we would have to copy that tree into the pushed predicate, and that tree could contain subqueries and method calls. RESOLVE - revisit this issue once we have views.

Parameters
referencedTabs:JBitSet

JBitSet with bit map of referenced FromTables

simplePredsOnly:boolean

Whether or not to consider method calls, field references and conditional nodes when building bit map

Returns:boolean

boolean Whether or not source.expression is a ColumnReference or a VirtualColumnNode.

Exceptions
StandardException:
Thrown on error
comparableback to summary
pack-priv void comparable(ValueNode leftOperand) throws StandardException

Determine whether or not the leftOperand is comparable() with all of the elements in the list. Throw an exception if any of them are not comparable.

Parameters
leftOperand:ValueNode

The left side of the expression

Exceptions
StandardException:
Thrown on error
compatibleback to summary
pack-priv void compatible(ValueNode leftOperand) throws StandardException

Make sure that passed ValueNode's type is compatible with the non-parameter elements in the ValueNodeList.

Parameters
leftOperand:ValueNode

Check for compatibility against this parameter's type

constantExpressionback to summary
pack-priv boolean constantExpression(PredicateList whereClause)
See Also
ValueNode#constantExpression
containsAllConstantNodesback to summary
pack-priv boolean containsAllConstantNodes()

Does this list contain all ConstantNodes?

Returns:boolean

boolean Whether or not the list contains all ConstantNodes

containsAllParameterNodesback to summary
pack-priv boolean containsAllParameterNodes()

Does this list contain all ParameterNodes?

Returns:boolean

boolean Whether or not the list contains all ParameterNodes

containsOnlyConstantAndParamNodesback to summary
pack-priv boolean containsOnlyConstantAndParamNodes()

Does this list *only* contain constant and/or parameter nodes?

Returns:boolean

boolean True if every node in this list is either a constant node or parameter node.

containsParameterNodeback to summary
pack-priv boolean containsParameterNode()

Does this list contain a ParameterNode?

Returns:boolean

boolean Whether or not the list contains a ParameterNode

eliminateNotsback to summary
pack-priv void eliminateNots(boolean underNotNode) throws StandardException

Eliminate NotNodes in all the nodes in this list.

Parameters
underNotNode:boolean

whether or not we are under a NotNode

See Also
ValueNode#eliminateNots(boolean)
genSQLJavaSQLTreesback to summary
pack-priv void genSQLJavaSQLTrees() throws StandardException

Generate a SQL->Java->SQL conversion tree any node in the list which is not a system built-in type. This is useful when doing comparisons, built-in functions, etc. on java types which have a direct mapping to system built-in types.

Exceptions
StandardException:
Thrown on error
getDominantTypeServicesback to summary
pack-priv DataTypeDescriptor getDominantTypeServices() throws StandardException

Get the dominant DataTypeServices from the elements in the list. This method will also set the correct collation information on the dominant DataTypeService if we are dealing with character string datatypes. Algorithm for determining collation information This method will check if it is dealing with character string datatypes. If yes, then it will check if all the character string datatypes have the same collation derivation and collation type associated with them. If not, then the resultant DTD from this method will have collation derivation of NONE. If yes, then the resultant DTD from this method will have the same collation derivation and collation type as all the character string datatypes. Note that this method calls DTD.getDominantType and that method returns the dominant type of the 2 DTDs involved in this method. That method sets the collation info on the dominant type following the algorithm mentioned in the comments of

Returns:DataTypeDescriptor

DataTypeServices The dominant DataTypeServices.

Exceptions
StandardException:
Thrown on error
See Also
With that algorithm, if one DTD has collation derivation of NONE and the other DTD has collation derivation of IMPLICIT, then the return DTD from DTD.getDominantType will have collation derivation of IMPLICIT. That is not the correct algorithm for aggregate operators. SQL standards says that if EVERY type has implicit derivation AND is of the same type, then the collation of the resultant will be of that type with derivation IMPLICIT. To provide this behavior for aggregate operator, we basically ignore the collation type and derivation picked by DataTypeDescriptor.getDominantType. Instead we let getDominantTypeServices use the simple algorithm listed at the top of this method's comments to determine the collation type and derivation for this ValueNodeList object.
getOrderableVariantTypeback to summary
protected int getOrderableVariantType() throws StandardException

Return the variant type for the underlying expression. The variant type can be: VARIANT - variant within a scan (method calls and non-static field access) SCAN_INVARIANT - invariant within a scan (column references from outer tables) QUERY_INVARIANT - invariant within the life of a query CONSTANT - constant

Returns:int

The variant type for the underlying expression.

Exceptions
StandardException:
thrown on error
getTypeServicesback to summary
pack-priv DataTypeDescriptor getTypeServices() throws StandardException

Get the first non-null DataTypeServices from the elements in the list.

Returns:DataTypeDescriptor

DataTypeServices The first non-null DataTypeServices.

Exceptions
StandardException:
Thrown on error
isConstantExpressionback to summary
pack-priv boolean isConstantExpression()

Return whether or not this expression tree represents a constant expression.

Returns:boolean

Whether or not this expression tree represents a constant expression.

isEquivalentback to summary
pack-priv boolean isEquivalent(ValueNodeList other) throws StandardException

Check if all the elements in this list are equivalent to the elements in another list. The two lists must have the same size, and the equivalent nodes must appear in the same order in both lists, for the two lists to be equivalent.

Parameters
other:ValueNodeList

the other list

Returns:boolean

true if the two lists contain equivalent elements, or false otherwise

Exceptions
StandardException:
thrown on error
See Also
ValueNode#isEquivalent(ValueNode)
isNullableback to summary
pack-priv boolean isNullable() throws StandardException

Determine whether or not any of the elements in the list are nullable.

Returns:boolean

boolean Whether or not any of the elements in the list are nullable.

preprocessback to summary
pack-priv void preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException

Preprocess a ValueNodeList. For now, we just preprocess each ValueNode in the list.

Parameters
numTables:int

Number of tables in the DML Statement

outerFromList:FromList

FromList from outer query block

outerSubqueryList:SubqueryList

SubqueryList from outer query block

outerPredicateList:PredicateList

PredicateList from outer query block

Exceptions
StandardException:
Thrown on error
remapColumnReferencesToExpressionsback to summary
pack-priv ValueNodeList remapColumnReferencesToExpressions() throws StandardException

Remap all ColumnReferences in this tree to be clones of the underlying expression.

Returns:ValueNodeList

ValueNodeList The remapped expression tree.

Exceptions
StandardException:
Thrown on error
setParameterDescriptorback to summary
pack-priv void setParameterDescriptor(DataTypeDescriptor descriptor) throws StandardException

Set the descriptor for every ParameterNode in the list.

Parameters
descriptor:DataTypeDescriptor

The DataTypeServices to set for the parameters

Exceptions
StandardException:
Thrown on error
sortInAscendingOrderback to summary
pack-priv void sortInAscendingOrder(DataValueDescriptor judgeODV) throws StandardException

Sort the entries in the list in ascending order. (All values are assumed to be constants.)

Parameters
judgeODV:DataValueDescriptor

In case of type not exactly matching, the judging type.

Exceptions
StandardException:
Thrown on error