Class LikeEscapeOperatorNode

All Implemented Interfaces:
Visitable

public final class LikeEscapeOperatorNode extends TernaryOperatorNode
This node represents a like comparison operator (no escape) If the like pattern is a constant or a parameter then if possible the like is modified to include a >= and < operator. In some cases the like can be eliminated. By adding =, >= or < operators it may allow indexes to be used to greatly narrow the search range of the query, and allow optimizer to estimate number of rows to affected. constant or parameter LIKE pattern with prefix followed by optional wild card e.g. Derby% CHAR(n), VARCHAR(n) where n < 255 >= prefix padded with '' to length n -- e.g. Derby <= prefix appended with '￿' -- e.g. Derby￿ [ can eliminate LIKE if constant. ] CHAR(n), VARCHAR(n), LONG VARCHAR where n >= 255 >= prefix backed up one characer <= prefix appended with '￿' no elimination of like parameter like pattern starts with wild card e.g. %Derby CHAR(n), VARCHAR(n) where n <= 256 >= '' padded with '' to length n <= '￿' no elimination of like CHAR(n), VARCHAR(n), LONG VARCHAR where n > 256 >= NULL <= '￿' Note that the Unicode value '￿' is defined as not a character value and can be used by a program for any purpose. We use it to set an upper bound on a character range with a less than predicate. We only need a single '￿' appended because the string 'Derby￿￿' is not a valid String because '￿' is not a valid character.
  • Field Details

    • addedEquals

      boolean addedEquals
      Fields of the class
    • escape

      String escape
  • Constructor Details

    • LikeEscapeOperatorNode

      LikeEscapeOperatorNode(ValueNode receiver, ValueNode leftOperand, ValueNode rightOperand, ContextManager cm)
      Constructor for a LikeEscapeOperatorNode receiver like pattern [ escape escapeValue ]
      Parameters:
      receiver - The left operand of the like: column, CharConstant or Parameter
      leftOperand - The right operand of the like: the pattern
      rightOperand - The optional escape clause, null if not present
      cm - The context manager
  • Method Details

    • bindExpression

      ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException
      implement binding for like expressions.

      overrides BindOperatorNode.bindExpression because like has special requirements for parameter binding.

      Overrides:
      bindExpression in class TernaryOperatorNode
      Parameters:
      fromList - The FROM list for the query this expression is in, for binding columns.
      subqueryList - The subquery list being built as we find SubqueryNodes
      aggregates - The aggregate list being built as we find AggregateNodes
      Returns:
      The new top of the expression tree.
      Throws:
      StandardException - thrown on failure
    • finishBindExpr

      private void finishBindExpr() throws StandardException
      Throws:
      StandardException
    • bindComparisonOperator

      public void bindComparisonOperator() throws StandardException
      Bind this operator
      Throws:
      StandardException - Thrown on error
    • preprocess

      ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException
      Preprocess an expression tree. We do a number of transformations here (including subqueries, IN lists, LIKE and BETWEEN) plus subquery flattening. NOTE: This is done before the outer ResultSetNode is preprocessed.
      Overrides:
      preprocess in class TernaryOperatorNode
      Parameters:
      numTables - Number of tables in the DML Statement
      outerFromList - FromList from outer query block
      outerSubqueryList - SubqueryList from outer query block
      outerPredicateList - PredicateList from outer query block
      Returns:
      The modified expression
      Throws:
      StandardException - Thrown on error
    • generateExpression

      void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
      Do code generation for this binary operator. This code was copied from BinaryOperatorNode and stripped down
      Overrides:
      generateExpression in class TernaryOperatorNode
      Parameters:
      acb - The ExpressionClassBuilder for the class we're generating
      mb - The method the code to place the code
      Throws:
      StandardException - Thrown on error
    • setupOptimizeStringFromParameter

      private ValueNode setupOptimizeStringFromParameter(ValueNode parameterNode, ValueNode escapeNode, String methodName, int maxWidth) throws StandardException
      Throws:
      StandardException