Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.impl.sql.compile
Class LikeEscapeOperatorNode  view LikeEscapeOperatorNode download LikeEscapeOperatorNode.java

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:
org.apache.derby.iapi.sql.compile.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.


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, org.apache.derby.iapi.sql.compile.TypeCompiler vnTC, org.apache.derby.iapi.types.TypeId vnTypeId)
           
private  void finishBindExpr()
           
 void generateExpression(ExpressionClassBuilder acb, org.apache.derby.iapi.services.compiler.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

bindExpression

public ValueNode bindExpression(FromList fromList,
                                SubqueryList subqueryList,
                                java.util.Vector aggregateVector)
                         throws org.apache.derby.iapi.error.StandardException
overrides BindOperatorNode.bindExpression because like has special requirements for parameter binding.

Overrides:
bindExpression in class TernaryOperatorNode

castArgToNationalString

private ValueNode castArgToNationalString(ValueNode vn,
                                          org.apache.derby.iapi.sql.compile.TypeCompiler vnTC,
                                          org.apache.derby.iapi.types.TypeId vnTypeId)
                                   throws org.apache.derby.iapi.error.StandardException

finishBindExpr

private void finishBindExpr()
                     throws org.apache.derby.iapi.error.StandardException

bindComparisonOperator

public void bindComparisonOperator()
                            throws org.apache.derby.iapi.error.StandardException
Bind this operator


preprocess

public ValueNode preprocess(int numTables,
                            FromList outerFromList,
                            SubqueryList outerSubqueryList,
                            PredicateList outerPredicateList)
                     throws org.apache.derby.iapi.error.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

generateExpression

public void generateExpression(ExpressionClassBuilder acb,
                               org.apache.derby.iapi.services.compiler.MethodBuilder mb)
                        throws org.apache.derby.iapi.error.StandardException
Do code generation for this binary operator. This code was copied from BinaryOperatorNode and stripped down

Overrides:
generateExpression in class TernaryOperatorNode

setupOptimizeStringFromParameter

private ValueNode setupOptimizeStringFromParameter(ValueNode parameterNode,
                                                   ValueNode escapeNode,
                                                   java.lang.String methodName)
                                            throws org.apache.derby.iapi.error.StandardException