Class IsNullNode
- All Implemented Interfaces:
Visitable
,RelationalOperator
This node represents either a unary
IS NULL or IS NOT NULL comparison operator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Iftrue
, this node represents a NOT NULL node rather than a NULL node.private DataValueDescriptor
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 -
Method Summary
Modifier and TypeMethodDescription(package private) void
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
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.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
Return the operator (as an int) for this RelationalOperator.(package private) String
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.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
(package private) boolean
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
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 Details
-
nullValue
-
notNull
private boolean notNullIftrue
, 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 Details
-
IsNullNode
IsNullNode(ValueNode operand, boolean notNull, ContextManager cm) throws StandardException - Throws:
StandardException
-
-
Method Details
-
updateOperatorDetails
private void updateOperatorDetails() -
getNegation
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
Bind a ? parameter operand of the IS [NOT] NULL predicate.- Overrides:
bindParameter
in classUnaryOperatorNode
- Throws:
StandardException
- Thrown on error
-
usefulStartKey
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:
-
usefulStopKey
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:
-
getStartOperator
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:
-
getStopOperator
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:
-
generateOperator
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:
-
generateNegate
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:
-
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:
-
compareWithKnownConstant
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:
-
getCompareValue
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:
-
equalsComparisonWithConstantExpression
Description copied from interface:RelationalOperator
Return whether this operator is an equality comparison of the given optimizable with a constant expression.- Specified by:
equalsComparisonWithConstantExpression
in interfaceRelationalOperator
- See Also:
-
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:
-
getReceiverInterfaceName
String getReceiverInterfaceName()null operators are defined on DataValueDescriptor. Overrides method in UnaryOperatorNode for code generation purposes.- Overrides:
getReceiverInterfaceName
in classUnaryOperatorNode
-
selectivity
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:
-
optimizableEqualityNode
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:
-