Class HasVariantValueNodeVisitor

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

class HasVariantValueNodeVisitor extends 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:
  • Field Details

    • hasVariant

      private boolean hasVariant
    • variantType

      private int variantType
    • ignoreParameters

      private boolean ignoreParameters
  • Constructor Details

    • 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 variant
      ignoreParameters - should I ignore parameter nodes?
  • Method Details

    • 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

      boolean hasVariant()
      Indicate whether we found the node in question
      Returns:
      true/false