Top Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv Class OrNode

extends BinaryLogicalOperatorNode
Class Inheritance
Imports
java.util.List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager

Field Summary

Modifier and TypeField and Description
private boolean
Inherited from org.apache.derby.impl.sql.compile.BinaryLogicalOperatorNode:
shortCircuitValue

Constructor Summary

AccessConstructor and Description
pack-priv
OrNode(ValueNode
The left operand of the OR
leftOperand
,
ValueNode
The right operand of the OR
rightOperand
,
ContextManager
The context manager
cm
)

Constructor for an OrNode

Method Summary

Modifier and TypeMethod and Description
pack-priv ValueNode

Returns:

The new top of the expression tree.
bindExpression
(FromList
The query's FROM list
fromList
,
SubqueryList
The subquery list being built as we find SubqueryNodes
subqueryList
,
List<AggregateNode>
The aggregate list being built as we find AggregateNodes
aggregates
)

Overrides org.apache.derby.impl.sql.compile.BinaryLogicalOperatorNode.bindExpression.

Bind this logical operator.

pack-priv ValueNode

Returns:

The modified expression
changeToCNF
(boolean
Whether or not we are under a top level AndNode.
underTopAndNode
)

Overrides org.apache.derby.impl.sql.compile.ValueNode.changeToCNF.

Finish putting an expression into conjunctive normal form.

pack-priv ValueNode

Returns:

The modified expression
eliminateNots
(boolean
Whether or not we are under a NotNode.
underNotNode
)

Overrides org.apache.derby.impl.sql.compile.ValueNode.eliminateNots.

Eliminate NotNodes in the current query block.

pack-priv void
postBindFixup()

Do bind() by hand for an AndNode that was generated after bind(), eg by putAndsOnTop().

pack-priv ValueNode

Returns:

The modified expression
preprocess
(int
Number of tables in the DML Statement
numTables
,
FromList
FromList from outer query block
outerFromList
,
SubqueryList
SubqueryList from outer query block
outerSubqueryList
,
PredicateList
PredicateList from outer query block
outerPredicateList
)

Overrides org.apache.derby.impl.sql.compile.BinaryOperatorNode.preprocess.

Preprocess an expression tree.

pack-priv void
setFirstOr()

Mark this OrNode as the 1st OR in the OR chain.

pack-priv boolean

Returns:

Boolean which reflects validity of the tree.
verifyChangeToCNF
()

Overrides org.apache.derby.impl.sql.compile.ValueNode.verifyChangeToCNF.

Verify that changeToCNF() did its job correctly.

Inherited from org.apache.derby.impl.sql.compile.BinaryLogicalOperatorNode:
generateExpressionresolveLogicalBinaryOperatorverifyEliminateNots

Field Detail

firstOrback to summary
private boolean firstOr

Constructor Detail

OrNodeback to summary
pack-priv OrNode(ValueNode leftOperand, ValueNode rightOperand, ContextManager cm)

Constructor for an OrNode

Parameters
leftOperand:ValueNode

The left operand of the OR

rightOperand:ValueNode

The right operand of the OR

cm:ContextManager

The context manager

Method Detail

bindExpressionback to summary
pack-priv ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, List<AggregateNode> aggregates) throws StandardException

Overrides org.apache.derby.impl.sql.compile.BinaryLogicalOperatorNode.bindExpression.

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.

Parameters
fromList:FromList

The query's FROM list

subqueryList:SubqueryList

The subquery list being built as we find SubqueryNodes

aggregates:List<AggregateNode>

The aggregate list being built as we find AggregateNodes

Returns:ValueNode

The new top of the expression tree.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
changeToCNFback to summary
pack-priv ValueNode changeToCNF(boolean underTopAndNode) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ValueNode.changeToCNF.

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.

Parameters
underTopAndNode:boolean

Whether or not we are under a top level AndNode.

Returns:ValueNode

The modified expression

Annotations
@Override
Exceptions
StandardException:
Thrown on error
eliminateNotsback to summary
pack-priv ValueNode eliminateNots(boolean underNotNode) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ValueNode.eliminateNots.

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.

Parameters
underNotNode:boolean

Whether or not we are under a NotNode.

Returns:ValueNode

The modified expression

Annotations
@Override
Exceptions
StandardException:
Thrown on error
postBindFixupback to summary
pack-priv 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.)

Exceptions
StandardException:
Thrown on error
preprocessback to summary
pack-priv ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException

Overrides org.apache.derby.impl.sql.compile.BinaryOperatorNode.preprocess.

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.

Parameters
numTables:int

Number of tables in the DML Statement

outerFromList:FromList

FromList from outer query block

outerSubqueryList:SubqueryList

SubqueryList from outer query block

outerPredicateList:PredicateList

PredicateList from outer query block

Returns:ValueNode

The modified expression

Annotations
@Override
Exceptions
StandardException:
Thrown on error
setFirstOrback to summary
pack-priv 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

verifyChangeToCNFback to summary
pack-priv boolean verifyChangeToCNF()

Overrides org.apache.derby.impl.sql.compile.ValueNode.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

Returns:boolean

Boolean which reflects validity of the tree.

Annotations
@Override