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 booleannotNullIftrue, this node represents a NOT NULL node rather than a NULL node.private DataValueDescriptornullValue-
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) voidbindParameter()Bind a ?booleancompareWithKnownConstant(Optimizable optTable, boolean considerParameters)Return whether this operator compares the given Optimizable with a constant whose value is known at compile time.booleanequalsComparisonWithConstantExpression(Optimizable optTable)Return whether this operator is an equality comparison of the given optimizable with a constant expression.voidgenerateNegate(MethodBuilder mb, Optimizable optTable)Generate an expression that evaluates to true if the result of the comparison should be negated.voidgenerateOperator(MethodBuilder mb, Optimizable optTable)Generate the comparison operator for this RelationalOperator.DataValueDescriptorgetCompareValue(Optimizable optTable)Return an Object representing the known value that this relational operator is comparing to a column in the given Optimizable.(package private) UnaryOperatorNodegetNegation(ValueNode operand)Negate the comparison.intgetOperator()Return the operator (as an int) for this RelationalOperator.(package private) java.lang.StringgetReceiverInterfaceName()null operators are defined on DataValueDescriptor.intgetStartOperator(Optimizable optTable)Get the start operator for a scan (at the store level) for this RelationalOperator.intgetStopOperator(Optimizable optTable)Get the stop operator for a scan (at the store level) for this RelationalOperator.RelationalOperatorgetTransitiveSearchClause(ColumnReference otherCR)Return a relational operator which matches the current one but with the passed in ColumnReference as the (left) operand.(package private) booleanisNullNode()(package private) booleanisRelationalOperator()Returns true if this ValueNode is a relational operator.(package private) booleanoptimizableEqualityNode(Optimizable optTable, int columnNumber, boolean isNullOkay)Return true if the predicate represents an optimizable equality node.doubleselectivity(Optimizable optTable)The default selectivity for value nodes is 50%.private voidupdateOperatorDetails()booleanusefulStartKey(Optimizable optTable)Tell whether this relop is a useful start key for the given table.booleanusefulStopKey(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:
getNegationin classUnaryComparisonOperatorNode- Parameters:
operand- The operand of the operator- Returns:
- UnaryOperatorNode The negated expression
- Throws:
StandardException- Thrown on error
-
bindParameter
void bindParameter() throws StandardExceptionBind a ? parameter operand of the IS [NOT] NULL predicate.- Overrides:
bindParameterin classUnaryOperatorNode- Throws:
StandardException- Thrown on error
-
usefulStartKey
public boolean usefulStartKey(Optimizable optTable)
Description copied from interface:RelationalOperatorTell 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:
usefulStartKeyin 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:RelationalOperatorTell 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:
usefulStopKeyin 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:RelationalOperatorGet the start operator for a scan (at the store level) for this RelationalOperator.- Specified by:
getStartOperatorin interfaceRelationalOperator- Overrides:
getStartOperatorin 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:RelationalOperatorGet the stop operator for a scan (at the store level) for this RelationalOperator.- Specified by:
getStopOperatorin interfaceRelationalOperator- Overrides:
getStopOperatorin 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:RelationalOperatorGenerate the comparison operator for this RelationalOperator. The operator can depend on which side of this operator the optimizable column is.- Specified by:
generateOperatorin 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:RelationalOperatorGenerate 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:
generateNegatein 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:RelationalOperatorReturn the operator (as an int) for this RelationalOperator.- Specified by:
getOperatorin interfaceRelationalOperator- Returns:
- int The operator for this RelationalOperator.
- See Also:
RelationalOperator.getOperator()
-
compareWithKnownConstant
public boolean compareWithKnownConstant(Optimizable optTable, boolean considerParameters)
Description copied from interface:RelationalOperatorReturn whether this operator compares the given Optimizable with a constant whose value is known at compile time.- Specified by:
compareWithKnownConstantin 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:RelationalOperatorReturn an Object representing the known value that this relational operator is comparing to a column in the given Optimizable.- Specified by:
getCompareValuein 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:RelationalOperatorReturn 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:RelationalOperatorReturn a relational operator which matches the current one but with the passed in ColumnReference as the (left) operand.- Specified by:
getTransitiveSearchClausein 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:
getReceiverInterfaceNamein classUnaryOperatorNode
-
selectivity
public double selectivity(Optimizable optTable)
Description copied from class:ValueNodeThe default selectivity for value nodes is 50%. This is overridden in specific cases, such as the RelationalOperators.- Overrides:
selectivityin classValueNode
-
isNullNode
boolean isNullNode()
-
isRelationalOperator
boolean isRelationalOperator()
Description copied from class:ValueNodeReturns 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:
isRelationalOperatorin classValueNode- See Also:
ValueNode.isRelationalOperator()
-
optimizableEqualityNode
boolean optimizableEqualityNode(Optimizable optTable, int columnNumber, boolean isNullOkay)
Description copied from class:ValueNodeReturn 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:
optimizableEqualityNodein 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)
-
-