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

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.ValueNode
          extended byorg.apache.derby.impl.sql.compile.TernaryOperatorNode
              extended byorg.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. constant or parameter LIKE pattern with prefix followed by optional wild card e.g. Cloudscape% CHAR(n), VARCHAR(n) where n < 255 >= prefix padded with '' to length n -- e.g. Cloudscape <= prefix appended with '?' -- e.g. Cloudscape? [ 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 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 '?' 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 'Cloudscape??' is not a valid String because '?' is not a valid character.

Author:
ames converted to TernaryOperatorNode by been

Field Summary
(package private)  boolean addedEquals
           
(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
clause, dataTypeServices, IN_HAVING_CLAUSE, IN_SELECT_LIST, IN_UNKNOWN_CLAUSE, IN_WHERE_CLAUSE, transformed
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset
 
Constructor Summary
LikeEscapeOperatorNode()
           
 
Method Summary
 void bindComparisonOperator()
          Bind this operator
 ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector)
          overrides BindOperatorNode.bindExpression because like has special requirements for parameter binding.
private  ValueNode castArgToNationalString(ValueNode vn, TypeCompiler vnTC, TypeId vnTypeId)
           
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)
           
 
Methods inherited from class org.apache.derby.impl.sql.compile.TernaryOperatorNode
accept, bindToBuiltIn, castArgToString, categorize, constantExpression, getLeftOperand, getReceiver, getRightOperand, init, isConstantExpression, locateBind, printSubNodes, remapColumnReferencesToExpressions, setClause, setLeftOperand, setRightOperand, substrBind, toString
 
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkReliability, checkReliability, checkTopPredicatesForEqualsConditions, copyFields, eliminateNots, genEqualsFalseTree, generate, generateFilter, genIsNullTree, genSQLJavaSQLTree, getClause, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getOrderableVariantType, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isParameterNode, isRelationalOperator, optimizableEqualityNode, putAndsOnTop, selectivity, setDescriptor, setTransformed, setType, updatableByCursor, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getSPSName, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, 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

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
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

castArgToNationalString

private ValueNode castArgToNationalString(ValueNode vn,
                                          TypeCompiler vnTC,
                                          TypeId vnTypeId)
                                   throws StandardException
Throws:
StandardException

finishBindExpr

private void finishBindExpr()
                     throws StandardException
Throws:
StandardException

bindComparisonOperator

public void bindComparisonOperator()
                            throws StandardException
Bind this operator

Returns:
Nothing
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)
                                            throws StandardException
Throws:
StandardException

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.