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

java.lang.Object
  extended by org.apache.derby.impl.sql.compile.QueryTreeNode
      extended by org.apache.derby.impl.sql.compile.ValueNode
          extended by org.apache.derby.impl.sql.compile.TernaryOperatorNode
              extended by org.apache.derby.impl.sql.compile.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 Summary
(package private)  boolean addedEquals
          Fields of the class
(package private)  java.lang.String escape
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.TernaryOperatorNode
leftInterfaceType, leftOperand, LIKE, LOCATE, methodName, operator, operatorType, receiver, receiverInterfaceType, resultInterfaceType, rightInterfaceType, rightOperand, SUBSTRING, TernaryArgType, TernaryMethodNames, TernaryOperators, TernaryResultType, TIMESTAMPADD, TIMESTAMPDIFF, TRIM, trimType
 
Fields inherited from class org.apache.derby.impl.sql.compile.ValueNode
transformed
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, isPrivilegeCollectionRequired
 
Constructor Summary
LikeEscapeOperatorNode()
           
 
Method Summary
 void bindComparisonOperator()
          Bind this operator
 ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector)
          implement binding for like expressions.
private  void finishBindExpr()
           
 void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
          Do code generation for this binary operator.
 void init(java.lang.Object receiver, java.lang.Object leftOperand, java.lang.Object rightOperand)
          Initializer for a LikeEscapeOperatorNode receiver like pattern [ escape escapeValue ]
 ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList)
          Preprocess an expression tree.
private  ValueNode setupOptimizeStringFromParameter(ValueNode parameterNode, ValueNode escapeNode, java.lang.String methodName, int maxWidth)
           
 
Methods inherited from class org.apache.derby.impl.sql.compile.TernaryOperatorNode
acceptChildren, bindToBuiltIn, castArgToString, categorize, constantExpression, getLeftOperand, getReceiver, getRightOperand, init, isConstantExpression, isEquivalent, locateBind, printSubNodes, remapColumnReferencesToExpressions, setLeftOperand, setRightOperand, substrBind, toString
 
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, eliminateNots, evaluateConstantExpressions, genEqualsFalseTree, generate, generateFilter, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getOrderableVariantType, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isInListProbeNode, isParameterNode, isRelationalOperator, isSameNodeType, optimizableEqualityNode, putAndsOnTop, requiresTypeFromContext, selectivity, setCollationInfo, setCollationInfo, setCollationUsingCompilationSchema, setCollationUsingCompilationSchema, setNullability, setTransformed, setType, setType, setType, updatableByCursor, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, bindOffsetFetch, bindRowMultiSet, bindUserType, checkReliability, checkReliability, convertDefaultNode, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, foundString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, orReliability, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, stackPrint, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

addedEquals

boolean addedEquals
Fields of the class


escape

java.lang.String escape
Constructor Detail

LikeEscapeOperatorNode

public LikeEscapeOperatorNode()
Method Detail

init

public void init(java.lang.Object receiver,
                 java.lang.Object leftOperand,
                 java.lang.Object rightOperand)
Initializer for a LikeEscapeOperatorNode receiver like pattern [ escape escapeValue ]

Overrides:
init in class QueryTreeNode
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

bindExpression

public ValueNode bindExpression(FromList fromList,
                                SubqueryList subqueryList,
                                java.util.Vector aggregateVector)
                         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
aggregateVector - The aggregate vector 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

public 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

public 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,
                                                   java.lang.String methodName,
                                                   int maxWidth)
                                            throws StandardException
Throws:
StandardException

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.