Class IsNullNode
- java.lang.Object
-
- All Implemented Interfaces:
Visitable
,RelationalOperator
public final class IsNullNode extends UnaryComparisonOperatorNode implements RelationalOperator
This node represents either a unary IS NULL or IS NOT NULL comparison operator
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
notNull
Iftrue
, this node represents a NOT NULL node rather than a NULL node.private DataValueDescriptor
nullValue
-
Fields inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
K_BASE, K_XMLPARSE, K_XMLSERIALIZE, kind, methodName, operand, operator, receiverInterfaceType, resultInterfaceType, UnaryArgTypes, UnaryMethodNames, UnaryOperators, UnaryResultTypes
-
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_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
-
Fields inherited from interface org.apache.derby.impl.sql.compile.RelationalOperator
EQUALS_RELOP, GREATER_EQUALS_RELOP, GREATER_THAN_RELOP, IS_NOT_NULL_RELOP, IS_NULL_RELOP, LESS_EQUALS_RELOP, LESS_THAN_RELOP, NOT_EQUALS_RELOP
-
-
Constructor Summary
Constructors Constructor Description IsNullNode(ValueNode operand, boolean notNull, ContextManager cm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
bindParameter()
Bind a ?boolean
compareWithKnownConstant(Optimizable optTable, boolean considerParameters)
Return whether this operator compares the given Optimizable with a constant whose value is known at compile time.boolean
equalsComparisonWithConstantExpression(Optimizable optTable)
Return whether this operator is an equality comparison of the given optimizable with a constant expression.void
generateNegate(MethodBuilder mb, Optimizable optTable)
Generate an expression that evaluates to true if the result of the comparison should be negated.void
generateOperator(MethodBuilder mb, Optimizable optTable)
Generate the comparison operator for this RelationalOperator.DataValueDescriptor
getCompareValue(Optimizable optTable)
Return an Object representing the known value that this relational operator is comparing to a column in the given Optimizable.(package private) UnaryOperatorNode
getNegation(ValueNode operand)
Negate the comparison.int
getOperator()
Return the operator (as an int) for this RelationalOperator.(package private) java.lang.String
getReceiverInterfaceName()
null operators are defined on DataValueDescriptor.int
getStartOperator(Optimizable optTable)
Get the start operator for a scan (at the store level) for this RelationalOperator.int
getStopOperator(Optimizable optTable)
Get the stop operator for a scan (at the store level) for this RelationalOperator.RelationalOperator
getTransitiveSearchClause(ColumnReference otherCR)
Return a relational operator which matches the current one but with the passed in ColumnReference as the (left) operand.(package private) boolean
isNullNode()
(package private) boolean
isRelationalOperator()
Returns true if this ValueNode is a relational operator.(package private) boolean
optimizableEqualityNode(Optimizable optTable, int columnNumber, boolean isNullOkay)
Return true if the predicate represents an optimizable equality node.double
selectivity(Optimizable optTable)
The default selectivity for value nodes is 50%.private void
updateOperatorDetails()
boolean
usefulStartKey(Optimizable optTable)
Tell whether this relop is a useful start key for the given table.boolean
usefulStopKey(Optimizable optTable)
Tell whether this relop is a useful stop key for the given table.-
Methods inherited from class org.apache.derby.impl.sql.compile.UnaryComparisonOperatorNode
bindComparisonOperator, bindExpression, eliminateNots, generateAbsoluteColumnId, generateExpressionOperand, generateOrderedNulls, generateQualMethod, generateRelativeColumnId, getColumnOperand, getColumnOperand, getExpressionOperand, getOperand, getOrderableVariantType, isQualifier, orderedNulls, selfComparison
-
Methods inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
acceptChildren, addXmlOpMethodParams, bindOperand, categorize, constantExpression, generateExpression, getOperand, getOperatorString, getOrderableVariantType, getParameterOperand, isConstantExpression, isEquivalent, isSameNodeKind, preprocess, printSubNodes, remapColumnReferencesToExpressions, setMethodName, setOperator, toString
-
Methods inherited from class org.apache.derby.impl.sql.compile.OperatorNode
pushSqlXmlUtil
-
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, evaluateConstantExpressions, genEqualsFalseTree, generate, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isInListProbeNode, isParameterNode, putAndsOnTop, requiresTypeFromContext, 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, 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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.derby.impl.sql.compile.RelationalOperator
generateAbsoluteColumnId, generateExpressionOperand, generateOrderedNulls, generateQualMethod, generateRelativeColumnId, getColumnOperand, getColumnOperand, getExpressionOperand, getOperand, getOrderableVariantType, isQualifier, orderedNulls, selfComparison
-
-
-
-
Field Detail
-
nullValue
private DataValueDescriptor nullValue
-
notNull
private boolean notNull
Iftrue
, this node represents a NOT NULL node rather than a NULL node. Note that this state is mutable, cfgetNegation(org.apache.derby.impl.sql.compile.ValueNode)
.
-
-
Constructor Detail
-
IsNullNode
IsNullNode(ValueNode operand, boolean notNull, ContextManager cm) throws StandardException
- Throws:
StandardException
-
-
Method Detail
-
updateOperatorDetails
private void updateOperatorDetails()
-
getNegation
UnaryOperatorNode getNegation(ValueNode operand) throws StandardException
Negate the comparison.- Specified by:
getNegation
in classUnaryComparisonOperatorNode
- Parameters:
operand
- The operand of the operator- Returns:
- UnaryOperatorNode The negated expression
- Throws:
StandardException
- Thrown on error
-
bindParameter
void bindParameter() throws StandardException
Bind a ? parameter operand of the IS [NOT] NULL predicate.- Overrides:
bindParameter
in classUnaryOperatorNode
- Throws:
StandardException
- Thrown on error
-
usefulStartKey
public boolean usefulStartKey(Optimizable optTable)
Description copied from interface:RelationalOperator
Tell whether this relop is a useful start key for the given table. It has already been determined that the relop has a column from the given table on one side or the other.- Specified by:
usefulStartKey
in interfaceRelationalOperator
- Parameters:
optTable
- The Optimizable table for which we want to know whether this is a useful start key.- Returns:
- true if this is a useful start key
- See Also:
RelationalOperator.usefulStartKey(org.apache.derby.iapi.sql.compile.Optimizable)
-
usefulStopKey
public boolean usefulStopKey(Optimizable optTable)
Description copied from interface:RelationalOperator
Tell whether this relop is a useful stop key for the given table. It has already been determined that the relop has a column from the given table on one side or the other.- Specified by:
usefulStopKey
in interfaceRelationalOperator
- Parameters:
optTable
- The Optimizable table for which we want to know whether this is a useful stop key.- Returns:
- true if this is a useful stop key
- See Also:
RelationalOperator.usefulStopKey(org.apache.derby.iapi.sql.compile.Optimizable)
-
getStartOperator
public int getStartOperator(Optimizable optTable)
Description copied from interface:RelationalOperator
Get the start operator for a scan (at the store level) for this RelationalOperator.- Specified by:
getStartOperator
in interfaceRelationalOperator
- Overrides:
getStartOperator
in classUnaryComparisonOperatorNode
- Parameters:
optTable
- The optimizable table we're doing the scan on. This parameter is so we can tell which side of the operator the table's column is on.- Returns:
- Either ScanController.GT or ScanController.GE
- See Also:
RelationalOperator.getStartOperator(org.apache.derby.iapi.sql.compile.Optimizable)
-
getStopOperator
public int getStopOperator(Optimizable optTable)
Description copied from interface:RelationalOperator
Get the stop operator for a scan (at the store level) for this RelationalOperator.- Specified by:
getStopOperator
in interfaceRelationalOperator
- Overrides:
getStopOperator
in classUnaryComparisonOperatorNode
- Parameters:
optTable
- The optimizable table we're doing the scan on. This parameter is so we can tell which side of the operator the table's column is on.- Returns:
- Either ScanController.GT or ScanController.GE
- See Also:
RelationalOperator.getStopOperator(org.apache.derby.iapi.sql.compile.Optimizable)
-
generateOperator
public void generateOperator(MethodBuilder mb, Optimizable optTable)
Description copied from interface:RelationalOperator
Generate the comparison operator for this RelationalOperator. The operator can depend on which side of this operator the optimizable column is.- Specified by:
generateOperator
in interfaceRelationalOperator
- Parameters:
mb
- The method the generated code is to go intooptTable
- The optimizable table we're doing the scan on.- See Also:
RelationalOperator.generateOperator(org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.sql.compile.Optimizable)
-
generateNegate
public void generateNegate(MethodBuilder mb, Optimizable optTable)
Description copied from interface:RelationalOperator
Generate an expression that evaluates to true if the result of the comparison should be negated. For example, col > 1 generates a comparison operator of <= and a negation of true, while col < 1 generates a comparison operator of < and a negation of false.- Specified by:
generateNegate
in interfaceRelationalOperator
- Parameters:
mb
- The method the generated code is to go intooptTable
- The Optimizable table the Qualifier will qualify- See Also:
RelationalOperator.generateNegate(org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.sql.compile.Optimizable)
-
getOperator
public int getOperator()
Description copied from interface:RelationalOperator
Return the operator (as an int) for this RelationalOperator.- Specified by:
getOperator
in interfaceRelationalOperator
- Returns:
- int The operator for this RelationalOperator.
- See Also:
RelationalOperator.getOperator()
-
compareWithKnownConstant
public boolean compareWithKnownConstant(Optimizable optTable, boolean considerParameters)
Description copied from interface:RelationalOperator
Return whether this operator compares the given Optimizable with a constant whose value is known at compile time.- Specified by:
compareWithKnownConstant
in interfaceRelationalOperator
- See Also:
RelationalOperator.compareWithKnownConstant(org.apache.derby.iapi.sql.compile.Optimizable, boolean)
-
getCompareValue
public DataValueDescriptor getCompareValue(Optimizable optTable) throws StandardException
Description copied from interface:RelationalOperator
Return an Object representing the known value that this relational operator is comparing to a column in the given Optimizable.- Specified by:
getCompareValue
in interfaceRelationalOperator
- Throws:
StandardException
- Thrown on error- See Also:
RelationalOperator.getCompareValue(org.apache.derby.iapi.sql.compile.Optimizable)
-
equalsComparisonWithConstantExpression
public boolean equalsComparisonWithConstantExpression(Optimizable optTable)
Description copied from interface:RelationalOperator
Return whether this operator is an equality comparison of the given optimizable with a constant expression.
-
getTransitiveSearchClause
public RelationalOperator getTransitiveSearchClause(ColumnReference otherCR) throws StandardException
Description copied from interface:RelationalOperator
Return a relational operator which matches the current one but with the passed in ColumnReference as the (left) operand.- Specified by:
getTransitiveSearchClause
in interfaceRelationalOperator
- Parameters:
otherCR
- The ColumnReference for the new (left) operand.- Returns:
- A relational operator which matches the current one but with the passed in ColumnReference as the (left) operand.
- Throws:
StandardException
- thrown on error- See Also:
RelationalOperator.getTransitiveSearchClause(org.apache.derby.impl.sql.compile.ColumnReference)
-
getReceiverInterfaceName
java.lang.String getReceiverInterfaceName()
null operators are defined on DataValueDescriptor. Overrides method in UnaryOperatorNode for code generation purposes.- Overrides:
getReceiverInterfaceName
in classUnaryOperatorNode
-
selectivity
public double selectivity(Optimizable optTable)
Description copied from class:ValueNode
The default selectivity for value nodes is 50%. This is overridden in specific cases, such as the RelationalOperators.- Overrides:
selectivity
in classValueNode
-
isNullNode
boolean isNullNode()
-
isRelationalOperator
boolean isRelationalOperator()
Description copied from class:ValueNode
Returns true if this ValueNode is a relational operator. Relational Operators are <, <=, =, >, >=, <> as well as IS NULL and IS NOT NULL. This is the preferred way of figuring out if a ValueNode is relational or not.- Overrides:
isRelationalOperator
in classValueNode
- See Also:
ValueNode.isRelationalOperator()
-
optimizableEqualityNode
boolean optimizableEqualityNode(Optimizable optTable, int columnNumber, boolean isNullOkay)
Description copied from class:ValueNode
Return true if the predicate represents an optimizable equality node. an expression is considered to be an optimizable equality node if all the following conditions are met:- the operator is an = or IS NULL operator
- one of the operands is a column specified by optTable/columnNumber
- Both operands are not the same column; i.e tab.col = tab.col
- There are no implicit varchar comparisons of the operands; i.e either both operands are string like (varchar, char, longvarchar) or neither operand is string like
- Overrides:
optimizableEqualityNode
in classValueNode
- Parameters:
optTable
- the table being optimized. Column reference must be from this table.columnNumber
- the column number. One of the operands of this predicate must be the column number specified by optTable/columnNumberisNullOkay
- if set to true we also consider IS NULL predicates; otherwise consider only = predicates.- See Also:
ValueNode.optimizableEqualityNode(org.apache.derby.iapi.sql.compile.Optimizable, int, boolean)
-
-