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

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.ValueNode
          extended byorg.apache.derby.impl.sql.compile.BinaryOperatorNode
              extended byorg.apache.derby.impl.sql.compile.BinaryLogicalOperatorNode
                  extended byorg.apache.derby.impl.sql.compile.OrNode
All Implemented Interfaces:
Visitable

public class OrNode
extends BinaryLogicalOperatorNode


Field Summary
private  boolean firstOr
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.BinaryLogicalOperatorNode
shortCircuitValue
 
Fields inherited from class org.apache.derby.impl.sql.compile.BinaryOperatorNode
AND, BinaryArgTypes, BinaryMethodNames, BinaryOperators, BinaryResultTypes, CONCATENATE, DIVIDE, EQ, GE, GT, LE, leftInterfaceType, leftOperand, LIKE, LT, methodName, MINUS, NE, operator, operatorType, OR, PLUS, receiver, resultInterfaceType, rightInterfaceType, rightOperand, TIMES, XMLEXISTS_OP
 
Fields inherited from class org.apache.derby.impl.sql.compile.ValueNode
clause, dataTypeServices, IN_HAVING_CLAUSE, IN_SELECT_LIST, IN_UNKNOWN_CLAUSE, IN_WHERE_CLAUSE, transformed
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset
 
Constructor Summary
OrNode()
           
 
Method Summary
 ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector)
          Bind this logical operator.
 ValueNode changeToCNF(boolean underTopAndNode)
          Finish putting an expression into conjunctive normal form.
(package private)  ValueNode eliminateNots(boolean underNotNode)
          Eliminate NotNodes in the current query block.
 void init(java.lang.Object leftOperand, java.lang.Object rightOperand)
          Initializer for an OrNode
(package private)  void postBindFixup()
          Do bind() by hand for an AndNode that was generated after bind(), eg by putAndsOnTop().
 ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList)
          Preprocess an expression tree.
(package private)  void setFirstOr()
          Mark this OrNode as the 1st OR in the OR chain.
 boolean verifyChangeToCNF()
          Verify that changeToCNF() did its job correctly.
 
Methods inherited from class org.apache.derby.impl.sql.compile.BinaryLogicalOperatorNode
generateExpression, init, resolveLogicalBinaryOperator, verifyEliminateNots
 
Methods inherited from class org.apache.derby.impl.sql.compile.BinaryOperatorNode
accept, bindXMLExists, categorize, constantExpression, genSQLJavaSQLTree, getLeftOperand, getOrderableVariantType, getReceiverInterfaceName, getRightOperand, init, init, initializeResultField, isConstantExpression, printSubNodes, remapColumnReferencesToExpressions, setClause, setLeftOperand, setLeftRightInterfaceType, setMethodName, setOperator, setRightOperand, swapOperands, toString
 
Methods inherited from class org.apache.derby.impl.sql.compile.ValueNode
bindExpression, checkIsBoolean, checkReliability, checkReliability, checkTopPredicatesForEqualsConditions, copyFields, genEqualsFalseTree, generate, generateFilter, genIsNullTree, getClause, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSchemaName, getSourceResultColumn, getTableName, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, getTypeServices, init, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isParameterNode, isRelationalOperator, optimizableEqualityNode, putAndsOnTop, selectivity, setDescriptor, setTransformed, setType, updatableByCursor, verifyPutAndsOnTop
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getSPSName, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

firstOr

private boolean firstOr
Constructor Detail

OrNode

public OrNode()
Method Detail

init

public void init(java.lang.Object leftOperand,
                 java.lang.Object rightOperand)
Initializer for an OrNode

Overrides:
init in class QueryTreeNode
Parameters:
leftOperand - The left operand of the OR
rightOperand - The right operand of the OR

setFirstOr

void setFirstOr()
Mark this OrNode as the 1st OR in the OR chain. We will consider converting the chain to an IN list during preprocess() if all entries are of the form: ColumnReference = expression

Returns:
Nothing.

bindExpression

public ValueNode bindExpression(FromList fromList,
                                SubqueryList subqueryList,
                                java.util.Vector aggregateVector)
                         throws StandardException
Bind this logical operator. All that has to be done for binding a logical operator is to bind the operands, check that both operands are BooleanDataValue, and set the result type to BooleanDataValue.

Overrides:
bindExpression in class BinaryLogicalOperatorNode
Parameters:
fromList - The query's FROM list
subqueryList - The subquery list being built as we find SubqueryNodes
aggregateVector - The aggregate vector being built as we find AggregateNodes
Returns:
The new top of the expression tree.
Throws:
StandardException - Thrown on error

preprocess

public ValueNode preprocess(int numTables,
                            FromList outerFromList,
                            SubqueryList outerSubqueryList,
                            PredicateList outerPredicateList)
                     throws StandardException
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.

Overrides:
preprocess in class BinaryOperatorNode
Parameters:
numTables - Number of tables in the DML Statement
outerFromList - FromList from outer query block
outerSubqueryList - SubqueryList from outer query block
outerPredicateList - PredicateList from outer query block
Returns:
The modified expression
Throws:
StandardException - Thrown on error

eliminateNots

ValueNode eliminateNots(boolean underNotNode)
                  throws StandardException
Eliminate NotNodes in the current query block. We traverse the tree, inverting ANDs and ORs and eliminating NOTs as we go. We stop at ComparisonOperators and boolean expressions. We invert ComparisonOperators and replace boolean expressions with boolean expression = false. NOTE: Since we do not recurse under ComparisonOperators, there still could be NotNodes left in the tree.

Overrides:
eliminateNots in class ValueNode
Parameters:
underNotNode - Whether or not we are under a NotNode.
Returns:
The modified expression
Throws:
StandardException - Thrown on error

changeToCNF

public ValueNode changeToCNF(boolean underTopAndNode)
                      throws StandardException
Finish putting an expression into conjunctive normal form. An expression tree in conjunctive normal form meets the following criteria: o If the expression tree is not null, the top level will be a chain of AndNodes terminating in a true BooleanConstantNode. o The left child of an AndNode will never be an AndNode. o Any right-linked chain that includes an AndNode will be entirely composed of AndNodes terminated by a true BooleanConstantNode. o The left child of an OrNode will never be an OrNode. o Any right-linked chain that includes an OrNode will be entirely composed of OrNodes terminated by a false BooleanConstantNode. o ValueNodes other than AndNodes and OrNodes are considered leaf nodes for purposes of expression normalization. In other words, we won't do any normalization under those nodes. In addition, we track whether or not we are under a top level AndNode. SubqueryNodes need to know this for subquery flattening.

Overrides:
changeToCNF in class ValueNode
Parameters:
underTopAndNode - Whether or not we are under a top level AndNode.
Returns:
The modified expression
Throws:
StandardException - Thrown on error

verifyChangeToCNF

public boolean verifyChangeToCNF()
Verify that changeToCNF() did its job correctly. Verify that: o AndNode - rightOperand is not instanceof OrNode leftOperand is not instanceof AndNode o OrNode - rightOperand is not instanceof AndNode leftOperand is not instanceof OrNode

Overrides:
verifyChangeToCNF in class ValueNode
Returns:
Boolean which reflects validity of the tree.

postBindFixup

void postBindFixup()
             throws StandardException
Do bind() by hand for an AndNode that was generated after bind(), eg by putAndsOnTop(). (Set the data type and nullability info.)

Returns:
None.
Throws:
StandardException - Thrown on error

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.