Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

public final Class LikeEscapeOperatorNode

extends TernaryOperatorNode
Class Inheritance
Imports
java.sql.Types, java.util.Arrays, .List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.Limits, .SQLState, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.types.DataTypeDescriptor, .Like, .StringDataValue, .TypeId

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 '\0' to length n -- e.g. Derby\0\0 <= 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 >= '\0' padded with '\0' 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

Modifier and TypeField and Description
pack-priv boolean
addedEquals

Fields of the class

pack-priv String
Inherited from org.apache.derby.impl.sql.compile.TernaryOperatorNode:
K_LIKEK_LOCATEK_SUBSTRINGK_TIMESTAMPADDK_TIMESTAMPDIFFK_TRIMkindleftInterfaceTypeleftOperandmethodNameoperatorreceiverreceiverInterfaceTyperesultInterfaceTyperightInterfaceTyperightOperandTernaryArgTypeTernaryMethodNamesTernaryOperatorsTernaryResultTypetrimType

Constructor Summary

AccessConstructor and Description
pack-priv
LikeEscapeOperatorNode(ValueNode
The left operand of the like: column, CharConstant or Parameter
receiver
,
ValueNode
The right operand of the like: the pattern
leftOperand
,
ValueNode
The optional escape clause, null if not present
rightOperand
,
ContextManager
The context manager
cm
)

Constructor for a LikeEscapeOperatorNode receiver like pattern [ escape escapeValue ]

Method Summary

Modifier and TypeMethod and Description
public void
bindComparisonOperator()

Bind this operator

pack-priv ValueNode

Returns:

The new top of the expression tree.
bindExpression
(FromList
The FROM list for the query this expression is in, for binding columns.
fromList
,
SubqueryList
The subquery list being built as we find SubqueryNodes
subqueryList
,
List<AggregateNode>
The aggregate list being built as we find AggregateNodes
aggregates
)

Overrides org.apache.derby.impl.sql.compile.TernaryOperatorNode.bindExpression.

implement binding for like expressions.

private void
pack-priv void
generateExpression(ExpressionClassBuilder
The ExpressionClassBuilder for the class we're generating
acb
,
MethodBuilder
The method the code to place the code
mb
)

Overrides org.apache.derby.impl.sql.compile.TernaryOperatorNode.generateExpression.

Do code generation for this binary operator.

pack-priv ValueNode

Returns:

The modified expression
preprocess
(int
Number of tables in the DML Statement
numTables
,
FromList
FromList from outer query block
outerFromList
,
SubqueryList
SubqueryList from outer query block
outerSubqueryList
,
PredicateList
PredicateList from outer query block
outerPredicateList
)

Overrides org.apache.derby.impl.sql.compile.TernaryOperatorNode.preprocess.

Preprocess an expression tree.

private ValueNode
setupOptimizeStringFromParameter(ValueNode parameterNode, ValueNode escapeNode, String methodName, int maxWidth)

Inherited from org.apache.derby.impl.sql.compile.TernaryOperatorNode:
acceptChildrenbindToBuiltIncastArgToStringcategorizeconstantExpressiongetLeftOperandgetReceivergetRightOperandisConstantExpressionisEquivalentisSameNodeKindlocateBindprintSubNodesremapColumnReferencesToExpressionssetLeftOperandsetRightOperandsubstrBindtoString

Field Detail

addedEqualsback to summary
pack-priv boolean addedEquals

Fields of the class

escapeback to summary
pack-priv String escape

Constructor Detail

LikeEscapeOperatorNodeback to summary
pack-priv LikeEscapeOperatorNode(ValueNode receiver, ValueNode leftOperand, ValueNode rightOperand, ContextManager cm)

Constructor for a LikeEscapeOperatorNode receiver like pattern [ escape escapeValue ]

Parameters
receiver:ValueNode

The left operand of the like: column, CharConstant or Parameter

leftOperand:ValueNode

The right operand of the like: the pattern

rightOperand:ValueNode

The optional escape clause, null if not present

cm:ContextManager

The context manager

Method Detail

bindComparisonOperatorback to summary
public void bindComparisonOperator() throws StandardException

Bind this operator

Exceptions
StandardException:
Thrown on error
bindExpressionback to summary
pack-priv ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException

Overrides org.apache.derby.impl.sql.compile.TernaryOperatorNode.bindExpression.

implement binding for like expressions.

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

Parameters
fromList:FromList

Doc from org.apache.derby.impl.sql.compile.TernaryOperatorNode.bindExpression.

The FROM list for the query this expression is in, for binding columns.

subqueryList:SubqueryList

Doc from org.apache.derby.impl.sql.compile.TernaryOperatorNode.bindExpression.

The subquery list being built as we find SubqueryNodes

aggregates:List<AggregateNode>

Doc from org.apache.derby.impl.sql.compile.TernaryOperatorNode.bindExpression.

The aggregate list being built as we find AggregateNodes

Returns:ValueNode

The new top of the expression tree.

Annotations
@Override
Exceptions
StandardException:
thrown on failure
finishBindExprback to summary
private void finishBindExpr() throws StandardException
generateExpressionback to summary
pack-priv void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException

Overrides org.apache.derby.impl.sql.compile.TernaryOperatorNode.generateExpression.

Do code generation for this binary operator. This code was copied from BinaryOperatorNode and stripped down

Parameters
acb:ExpressionClassBuilder

The ExpressionClassBuilder for the class we're generating

mb:MethodBuilder

The method the code to place the code

Annotations
@Override
Exceptions
StandardException:
Thrown on error
preprocessback to summary
pack-priv ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException

Overrides org.apache.derby.impl.sql.compile.TernaryOperatorNode.preprocess.

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.

Parameters
numTables:int

Number of tables in the DML Statement

outerFromList:FromList

FromList from outer query block

outerSubqueryList:SubqueryList

SubqueryList from outer query block

outerPredicateList:PredicateList

PredicateList from outer query block

Returns:ValueNode

The modified expression

Annotations
@Override
Exceptions
StandardException:
Thrown on error
setupOptimizeStringFromParameterback to summary
private ValueNode setupOptimizeStringFromParameter(ValueNode parameterNode, ValueNode escapeNode, String methodName, int maxWidth) throws StandardException