001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.compile.QuantifiedBinaryOperatorNode
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.compile;
023:
024: import org.apache.derby.iapi.sql.dictionary.DataDictionary;
025:
026: import org.apache.derby.iapi.error.StandardException;
027:
028: import org.apache.derby.iapi.services.sanity.SanityManager;
029:
030: import org.apache.derby.iapi.util.JBitSet;
031:
032: import java.util.Vector;
033:
034: /**
035: * A QuantifiedBinaryOperatorNode represents a binary quantified predicate
036: * that is used with a subquery, such as IN, NOT IN, < ALL, etc. Quantified
037: * predicates all return Boolean values. All quantified operators will be
038: * removed from the tree by the time we get to code generation - they will
039: * be replaced by other constructs that can be compiled. For example,
040: * an IN node may be converted to a type of join.
041: *
042: * @author Jeff Lichtman
043: */
044:
045: public class QuantifiedBinaryOperatorNode extends BinaryOperatorNode {
046: int operator;
047:
048: public final static int IN = 1;
049: public final static int NOT_IN = 2;
050: public final static int EQ_ANY = 3;
051: public final static int EQ_ALL = 4;
052: public final static int NE_ANY = 5;
053: public final static int NE_ALL = 6;
054: public final static int GT_ANY = 7;
055: public final static int GT_ALL = 8;
056: public final static int GE_ANY = 9;
057: public final static int GE_ALL = 10;
058: public final static int LT_ANY = 11;
059: public final static int LT_ALL = 12;
060: public final static int LE_ANY = 13;
061: public final static int LE_ALL = 14;
062:
063: ValueNode leftOperand;
064: SubqueryNode rightOperand;
065:
066: /**
067: * Prints the sub-nodes of this object. See QueryTreeNode.java for
068: * how tree printing is supposed to work.
069: *
070: * @param depth The depth of this node in the tree
071: */
072:
073: public void printSubNodes(int depth) {
074: if (SanityManager.DEBUG) {
075: super .printSubNodes(depth);
076:
077: if (leftOperand != null) {
078: printLabel(depth, "leftOperand: ");
079: leftOperand.treePrint(depth + 1);
080: }
081:
082: if (rightOperand != null) {
083: printLabel(depth, "rightOperand: ");
084: rightOperand.treePrint(depth + 1);
085: }
086: }
087: }
088:
089: /**
090: * Bind this expression. This means binding the sub-expressions,
091: * as well as figuring out what the return type is for this expression.
092: *
093: * @param fromList The FROM list for the query this
094: * expression is in, for binding columns.
095: * @param subqueryList The subquery list being built as we find SubqueryNodes
096: * @param aggregateVector The aggregate vector being built as we find AggregateNodes
097: *
098: * @return The new top of the expression tree.
099: *
100: * @exception StandardException Thrown on error
101: */
102:
103: public ValueNode bindExpression(FromList fromList,
104: SubqueryList subqueryList, Vector aggregateVector)
105: throws StandardException {
106: leftOperand = leftOperand.bindExpression(fromList,
107: subqueryList, aggregateVector);
108: rightOperand = (SubqueryNode) rightOperand.bindExpression(
109: fromList, subqueryList, aggregateVector);
110:
111: /* RESOLVE: Need to bind this node */
112: /* RESOLVE - set the subqueryOperator in the SubqueryNode */
113:
114: return this;
115: }
116: }
|