org.apache.derby.impl.sql.compile
Class IsNullNode

java.lang.Object
  extended by org.apache.derby.impl.sql.compile.QueryTreeNode
      extended by org.apache.derby.impl.sql.compile.ValueNode
          extended by org.apache.derby.impl.sql.compile.UnaryOperatorNode
              extended by org.apache.derby.impl.sql.compile.UnaryComparisonOperatorNode
                  extended by org.apache.derby.impl.sql.compile.IsNullNode
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
private  DataValueDescriptor nullValue
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.UnaryOperatorNode
methodName, operand, operator, receiverInterfaceType, resultInterfaceType, UnaryArgTypes, UnaryMethodNames, UnaryOperators, UnaryResultTypes, XMLPARSE_OP, XMLSERIALIZE_OP
 
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_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, isPrivilegeCollectionRequired
 
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
IsNullNode()
           
 
Method Summary
(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.
 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.
private  boolean isNotNullNode()
           
private  boolean isNullNode()
           
 boolean isRelationalOperator()
          Returns true if this ValueNode is a relational operator.
 boolean optimizableEqualityNode(Optimizable optTable, int columnNumber, boolean isNullOkay)
          Return true if the predicate represents an optimizable equality node.
 double selectivity(Optimizable optTable)
          IS NULL is like =, so should have the same selectivity
 void setNodeType(int nodeType)
          Set the node type for this node.
 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, init, init, isConstantExpression, isEquivalent, preprocess, printSubNodes, remapColumnReferencesToExpressions, setMethodName, setOperator, toString
 
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, copyFields, evaluateConstantExpressions, genEqualsFalseTree, generate, generateFilter, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, init, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isInListProbeNode, isParameterNode, isSameNodeType, 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, bindOffsetFetch, bindRowMultiSet, bindUserType, checkReliability, checkReliability, convertDefaultNode, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, foundString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, orReliability, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setRefActionInfo, stackPrint, 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
Constructor Detail

IsNullNode

public IsNullNode()
Method Detail

setNodeType

public void setNodeType(int nodeType)
Description copied from class: QueryTreeNode
Set the node type for this node.

Overrides:
setNodeType in class QueryTreeNode
Parameters:
nodeType - The node type.

getNegation

UnaryOperatorNode getNegation(ValueNode operand)
                        throws StandardException
Negate the comparison.

Specified by:
getNegation in class UnaryComparisonOperatorNode
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 class UnaryOperatorNode
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 interface RelationalOperator
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 interface RelationalOperator
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 interface RelationalOperator
Overrides:
getStartOperator in class UnaryComparisonOperatorNode
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 interface RelationalOperator
Overrides:
getStopOperator in class UnaryComparisonOperatorNode
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 interface RelationalOperator
Parameters:
mb - The method the generated code is to go into
optTable - 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 interface RelationalOperator
Parameters:
mb - The method the generated code is to go into
optTable - 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 interface RelationalOperator
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 interface RelationalOperator
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 interface RelationalOperator
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.

Specified by:
equalsComparisonWithConstantExpression in interface RelationalOperator
See Also:
RelationalOperator.equalsComparisonWithConstantExpression(org.apache.derby.iapi.sql.compile.Optimizable)

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 interface RelationalOperator
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

public java.lang.String getReceiverInterfaceName()
null operators are defined on DataValueDescriptor. Overrides method in UnaryOperatorNode for code generation purposes.

Overrides:
getReceiverInterfaceName in class UnaryOperatorNode

selectivity

public double selectivity(Optimizable optTable)
IS NULL is like =, so should have the same selectivity

Overrides:
selectivity in class ValueNode

isNullNode

private boolean isNullNode()

isNotNullNode

private boolean isNotNullNode()

isRelationalOperator

public 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 class ValueNode
See Also:
ValueNode.isRelationalOperator()

optimizableEqualityNode

public 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:
  1. the operator is an = or IS NULL operator
  2. one of the operands is a column specified by optTable/columnNumber
  3. Both operands are not the same column; i.e tab.col = tab.col
  4. 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 class ValueNode
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/columnNumber
isNullOkay - 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)

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.