org.apache.derby.impl.sql.compile
Class HasVariantValueNodeVisitor

java.lang.Object
  extended by org.apache.derby.impl.sql.compile.HasVariantValueNodeVisitor
All Implemented Interfaces:
Visitor

public 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.e

 insert 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
private  boolean hasVariant
           
private  boolean ignoreParameters
           
private  int variantType
           
 
Constructor Summary
HasVariantValueNodeVisitor()
          Construct a visitor
HasVariantValueNodeVisitor(int variantType, boolean ignoreParameters)
          Construct a visitor.
 
Method Summary
 boolean hasVariant()
          Indicate whether we found the node in question
 boolean skipChildren(Visitable node)
          Method that is called to indicate whether we should skip all nodes below this node for traversal.
 boolean stopTraversal()
          Stop traversal if we found the target node
 Visitable visit(Visitable node)
          If we have found the target node, we are done.
 boolean visitChildrenFirst(Visitable node)
          Method that is called to see if visit() should be called on the children of node before it is called on node itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hasVariant

private boolean hasVariant

variantType

private int variantType

ignoreParameters

private boolean ignoreParameters
Constructor Detail

HasVariantValueNodeVisitor

public HasVariantValueNodeVisitor()
Construct a visitor


HasVariantValueNodeVisitor

public 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 variant
ignoreParameters - 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:
visit in interface Visitor
Parameters:
node - the node to process
Returns:
me
Throws:
StandardException - on error

skipChildren

public boolean skipChildren(Visitable node)
Description copied from interface: Visitor
Method 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:
skipChildren in interface Visitor
Parameters:
node - the node to process
Returns:
true/false

visitChildrenFirst

public boolean visitChildrenFirst(Visitable node)
Description copied from interface: Visitor
Method that is called to see if visit() should be called on the children of node before it is called on node itself. If this method always returns true, the visitor will walk the tree bottom-up. If it always returns false, the tree is visited top-down.

Specified by:
visitChildrenFirst in interface Visitor
Parameters:
node - the top node of a sub-tree about to be visited
Returns:
true if node's children should be visited before node, false otherwise

stopTraversal

public boolean stopTraversal()
Stop traversal if we found the target node

Specified by:
stopTraversal in interface Visitor
Returns:
true/false

hasVariant

public boolean hasVariant()
Indicate whether we found the node in question

Returns:
true/false

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.