Class HasVariantValueNodeVisitor
- java.lang.Object
-
- org.apache.derby.impl.sql.compile.HasVariantValueNodeVisitor
-
- All Implemented Interfaces:
Visitor
class HasVariantValueNodeVisitor extends java.lang.Object implements Visitor
Find out if we have a value node with variant type less than what the caller desires, anywhere below us. Stop traversal as soon as we find one. This is used in two places: one to check the values clause of an insert statement; i.einsert into
values (?, 1, foobar()); If all the expressions in the values clause are QUERY_INVARIANT (and an exception is made for parameters) then we can cache the results in the RowResultNode. This is useful when we have a prepared insert statement which is repeatedly executed.
The second place where this is used is to check if a subquery can be materialized or not.
- See Also:
Qualifier
-
-
Field Summary
Fields Modifier and Type Field Description private booleanhasVariantprivate booleanignoreParametersprivate intvariantType
-
Constructor Summary
Constructors Constructor Description HasVariantValueNodeVisitor()Construct a visitorHasVariantValueNodeVisitor(int variantType, boolean ignoreParameters)Construct a visitor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleanhasVariant()Indicate whether we found the node in questionbooleanskipChildren(Visitable node)Method that is called to indicate whether we should skip all nodes below this node for traversal.booleanstopTraversal()Stop traversal if we found the target nodeVisitablevisit(Visitable node)If we have found the target node, we are done.booleanvisitChildrenFirst(Visitable node)Method that is called to see ifvisit()should be called on the children ofnodebefore it is called onnodeitself.
-
-
-
Constructor Detail
-
HasVariantValueNodeVisitor
HasVariantValueNodeVisitor()
Construct a visitor
-
HasVariantValueNodeVisitor
HasVariantValueNodeVisitor(int variantType, boolean ignoreParameters)Construct a visitor. Pass in the variant type. We look for nodes that are less than or equal to this variant type. E.g., if the variantType is Qualifier.SCAN_VARIANT, then any node that is either VARIANT or SCAN_VARIANT will cause the visitor to consider it variant.- Parameters:
variantType- the type of variance we consider variantignoreParameters- should I ignore parameter nodes?
-
-
Method Detail
-
visit
public Visitable visit(Visitable node) throws StandardException
If we have found the target node, we are done.- Specified by:
visitin interfaceVisitor- Parameters:
node- the node to process- Returns:
- me
- Throws:
StandardException- on error
-
skipChildren
public boolean skipChildren(Visitable node)
Description copied from interface:VisitorMethod that is called to indicate whether we should skip all nodes below this node for traversal. Useful if we want to effectively ignore/prune all branches under a particular node.Differs from stopTraversal() in that it only affects subtrees, rather than the entire traversal.
- Specified by:
skipChildrenin interfaceVisitor- Parameters:
node- the node to process- Returns:
- true/false
-
visitChildrenFirst
public boolean visitChildrenFirst(Visitable node)
Description copied from interface:VisitorMethod that is called to see ifvisit()should be called on the children ofnodebefore it is called onnodeitself. If this method always returnstrue, the visitor will walk the tree bottom-up. If it always returnsfalse, the tree is visited top-down.- Specified by:
visitChildrenFirstin interfaceVisitor- Parameters:
node- the top node of a sub-tree about to be visited- Returns:
trueifnode's children should be visited beforenode,falseotherwise
-
stopTraversal
public boolean stopTraversal()
Stop traversal if we found the target node- Specified by:
stopTraversalin interfaceVisitor- Returns:
- true/false
-
hasVariant
boolean hasVariant()
Indicate whether we found the node in question- Returns:
- true/false
-
-