Class LikeEscapeOperatorNode
java.lang.Object
org.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.ValueNode
org.apache.derby.impl.sql.compile.OperatorNode
org.apache.derby.impl.sql.compile.TernaryOperatorNode
org.apache.derby.impl.sql.compile.LikeEscapeOperatorNode
- All Implemented Interfaces:
Visitable
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
FieldsModifier and TypeFieldDescription(package private) booleanFields of the class(package private) StringFields inherited from class TernaryOperatorNode
K_LIKE, K_LOCATE, K_SUBSTRING, K_TIMESTAMPADD, K_TIMESTAMPDIFF, K_TRIM, kind, leftInterfaceType, leftOperand, methodName, operator, receiver, receiverInterfaceType, resultInterfaceType, rightInterfaceType, rightOperand, TernaryArgType, TernaryMethodNames, TernaryOperators, TernaryResultType, trimTypeFields inherited from class ValueNode
transformedFields inherited from class QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX -
Constructor Summary
ConstructorsConstructorDescriptionLikeEscapeOperatorNode(ValueNode receiver, ValueNode leftOperand, ValueNode rightOperand, ContextManager cm) Constructor for a LikeEscapeOperatorNode receiver like pattern [ escape escapeValue ] -
Method Summary
Modifier and TypeMethodDescriptionvoidBind this operator(package private) ValueNodebindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) implement binding for like expressions.private void(package private) voidDo code generation for this binary operator.(package private) ValueNodepreprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) Preprocess an expression tree.private ValueNodesetupOptimizeStringFromParameter(ValueNode parameterNode, ValueNode escapeNode, String methodName, int maxWidth) Methods inherited from class TernaryOperatorNode
acceptChildren, bindToBuiltIn, castArgToString, categorize, constantExpression, getLeftOperand, getReceiver, getRightOperand, isConstantExpression, isEquivalent, isSameNodeKind, locateBind, printSubNodes, remapColumnReferencesToExpressions, setLeftOperand, setRightOperand, substrBind, toStringMethods inherited from class OperatorNode
pushSqlXmlUtilMethods inherited from class ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, eliminateNots, evaluateConstantExpressions, genEqualsFalseTree, generate, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getOrderableVariantType, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isInListProbeNode, isParameterNode, isRelationalOperator, optimizableEqualityNode, putAndsOnTop, requiresTypeFromContext, selectivity, setCollationInfo, setCollationInfo, setCollationUsingCompilationSchema, setCollationUsingCompilationSchema, setNullability, setTransformed, setType, setType, setType, updatableByCursor, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTopMethods inherited from class QueryTreeNode
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
-
Field Details
-
addedEquals
boolean addedEqualsFields 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 ParameterleftOperand- The right operand of the like: the patternrightOperand- The optional escape clause, null if not presentcm- 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:
bindExpressionin classTernaryOperatorNode- Parameters:
fromList- The FROM list for the query this expression is in, for binding columns.subqueryList- The subquery list being built as we find SubqueryNodesaggregates- The aggregate list being built as we find AggregateNodes- Returns:
- The new top of the expression tree.
- Throws:
StandardException- thrown on failure
-
finishBindExpr
- Throws:
StandardException
-
bindComparisonOperator
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:
preprocessin classTernaryOperatorNode- Parameters:
numTables- Number of tables in the DML StatementouterFromList- FromList from outer query blockouterSubqueryList- SubqueryList from outer query blockouterPredicateList- PredicateList from outer query block- Returns:
- The modified expression
- Throws:
StandardException- Thrown on error
-
generateExpression
Do code generation for this binary operator. This code was copied from BinaryOperatorNode and stripped down- Overrides:
generateExpressionin classTernaryOperatorNode- Parameters:
acb- The ExpressionClassBuilder for the class we're generatingmb- 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
-