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

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.QueryTreeNodeVector
          extended byorg.apache.derby.impl.sql.compile.SubqueryList
All Implemented Interfaces:
Visitable

public class SubqueryList
extends QueryTreeNodeVector

A SubqueryList represents a list of subquerys within a specific clause (select, where or having) in a DML statement. It extends QueryTreeNodeVector.

Author:
Jerry Brenner

Field Summary
 
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
SubqueryList()
           
 
Method Summary
 Visitable accept(Visitor v)
          Accept a visitor, and call v.visit() on child nodes as necessary.
 void addElement(QueryTreeNode qt)
           
 void addSubqueryNode(SubqueryNode subqueryNode)
          Add a subquery to the list.
(package private)  void decrementLevel(int decrement)
          Decrement (query block) level (0-based) for all of the tables in this subquery list.
 void destructiveAppend(QueryTreeNodeVector qtnv)
           
 QueryTreeNode elementAt(int index)
           
(package private)  int indexOf(QueryTreeNode qt)
           
(package private)  void insertElementAt(QueryTreeNode qt, int index)
           
 void modifyAccessPaths()
          Modify the access paths for all subqueries in this list.
 void nondestructiveAppend(QueryTreeNodeVector qtnv)
           
 void optimize(DataDictionary dataDictionary, double outerRows)
          Optimize the subqueries in this list.
 void preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList)
          Preprocess a SubqueryList.
 void printSubNodes(int depth)
          Prints the sub-nodes of this object.
 boolean referencesSessionSchema()
          Return true if the node references SESSION schema tables (temporary or permanent)
 boolean referencesTarget(java.lang.String name, boolean baseTable)
          Search to see if a query references the specifed table name.
(package private)  java.lang.Object remove(int index)
           
(package private)  void removeAllElements()
           
(package private)  void removeElement(QueryTreeNode qt)
           
(package private)  void removeElementAt(int index)
           
(package private)  void setElementAt(QueryTreeNode qt, int index)
           
 void setPointOfAttachment(int pointOfAttachment)
          Set the point of attachment in all subqueries in this list.
 int size()
           
 java.lang.String toString()
          Format this list as a string We can simply iterate through the list.
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, 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, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, 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
 

Constructor Detail

SubqueryList

public SubqueryList()
Method Detail

printSubNodes

public void printSubNodes(int depth)
Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.

Overrides:
printSubNodes in class QueryTreeNode
Parameters:
depth - The depth of this node in the tree
Returns:
Nothing

addSubqueryNode

public void addSubqueryNode(SubqueryNode subqueryNode)
                     throws StandardException
Add a subquery to the list.

Parameters:
subqueryNode - A SubqueryNode to add to the list
Returns:
Nothing
Throws:
StandardException - Thrown on error

preprocess

public void preprocess(int numTables,
                       FromList outerFromList,
                       SubqueryList outerSubqueryList,
                       PredicateList outerPredicateList)
                throws StandardException
Preprocess a SubqueryList. For now, we just preprocess each SubqueryNode in the list.

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:
None.
Throws:
StandardException - Thrown on error

optimize

public void optimize(DataDictionary dataDictionary,
                     double outerRows)
              throws StandardException
Optimize the subqueries in this list.

Parameters:
dataDictionary - The data dictionary to use for optimization
outerRows - The optimizer's estimate of the number of times this subquery will be executed.
Returns:
Nothing
Throws:
StandardException - Thrown on error

modifyAccessPaths

public void modifyAccessPaths()
                       throws StandardException
Modify the access paths for all subqueries in this list.

Throws:
StandardException - Thrown on error
See Also:
ResultSetNode.modifyAccessPaths()

referencesTarget

public boolean referencesTarget(java.lang.String name,
                                boolean baseTable)
                         throws StandardException
Search to see if a query references the specifed table name.

Parameters:
name - Table name (String) to search for.
baseTable - Whether or not name is for a base table
Returns:
true if found, else false
Throws:
StandardException - Thrown on error

referencesSessionSchema

public boolean referencesSessionSchema()
                                throws StandardException
Return true if the node references SESSION schema tables (temporary or permanent)

Overrides:
referencesSessionSchema in class QueryTreeNode
Returns:
true if references SESSION schema tables, else false
Throws:
StandardException - Thrown on error

setPointOfAttachment

public void setPointOfAttachment(int pointOfAttachment)
                          throws StandardException
Set the point of attachment in all subqueries in this list.

Parameters:
pointOfAttachment - The point of attachment
Returns:
Nothing.
Throws:
StandardException - Thrown on error

decrementLevel

void decrementLevel(int decrement)
Decrement (query block) level (0-based) for all of the tables in this subquery list. This is useful when flattening a subquery.

Parameters:
decrement - The amount to decrement by.
Returns:
Nothing;

size

public final int size()

elementAt

public QueryTreeNode elementAt(int index)

addElement

public final void addElement(QueryTreeNode qt)

removeElementAt

final void removeElementAt(int index)

removeElement

final void removeElement(QueryTreeNode qt)

remove

final java.lang.Object remove(int index)

indexOf

final int indexOf(QueryTreeNode qt)

setElementAt

final void setElementAt(QueryTreeNode qt,
                        int index)

destructiveAppend

public void destructiveAppend(QueryTreeNodeVector qtnv)

nondestructiveAppend

public void nondestructiveAppend(QueryTreeNodeVector qtnv)

removeAllElements

final void removeAllElements()

insertElementAt

final void insertElementAt(QueryTreeNode qt,
                           int index)

toString

public java.lang.String toString()
Format this list as a string We can simply iterate through the list. Note each list member is a QueryTreeNode, and so should have its specialization of toString defined.

Overrides:
toString in class QueryTreeNode
Returns:
This list formatted as a String

accept

public Visitable accept(Visitor v)
                 throws StandardException
Accept a visitor, and call v.visit() on child nodes as necessary.

Specified by:
accept in interface Visitable
Overrides:
accept in class QueryTreeNode
Parameters:
v - the visitor
Throws:
StandardException - 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.