| java.lang.Object org.apache.derby.impl.sql.compile.QueryTreeNode org.apache.derby.impl.sql.compile.QueryTreeNodeVector org.apache.derby.impl.sql.compile.FromList
FromList | public class FromList extends QueryTreeNodeVector implements OptimizableList(Code) | | A FromList represents the list of tables in a FROM clause in a DML
statement. It extends QueryTreeNodeVector.
author: Jeff Lichtman |
Method Summary | |
public boolean | LOJ_reorderable(int numTables) | public Visitable | accept(Visitor v) Accept a visitor, and call v.visit()
on child nodes as necessary. | public void | addFromTable(FromTable fromTable) Add a table to the FROM list. | public ResultColumn | bindColumnReference(ColumnReference columnReference) Bind a column reference to one of the tables in this FromList. | public void | bindExpressions(FromList fromListParam) Bind the expressions in this FromList. | public void | bindResultColumns(FromList fromListParam) Bind the result columns of the ResultSetNodes in this FromList when there is no
base table to bind them to. | public void | bindTables(DataDictionary dataDictionary, FromList fromListParam) Bind the tables in this FromList. | public void | bindUntypedNullsToResultColumns(ResultColumnList bindingRCL) Bind any untyped null nodes to the types in the given ResultColumnList. | void | decrementLevel(int decrement) Decrement (query block) level (0-based) for
all of the tables in this from list. | public ResultColumnList | expandAll(TableName allTableName) Expand a "*" into the appropriate ResultColumnList. | public void | flattenFromTables(ResultColumnList rcl, PredicateList predicateList, SubqueryList sql, GroupByList gbl) Flatten all the FromTables that are flattenable.
RESOLVE - right now we just flatten FromSubqueries. | void | genExistsBaseTables(JBitSet referencedTableMap, FromList outerFromList, boolean isNotExists) Mark all of the FromBaseTables in the list as EXISTS FBTs. | protected FromTable | getFromTableByName(String name, String schemaName, boolean exactMatch) Determine whether or not the specified name is an exposed name in
the current query block.
Parameters: name - The specified name to search for as an exposed name. Parameters: schemaName - Schema name, if non-null. Parameters: exactMatch - Whether or not we need an exact match on specified schema and tablenames or match on table id. | public FromTable | getFromTableByResultColumn(ResultColumn rc) Get the FromTable from this list which has the specified ResultColumn in
its RCL.
Parameters: rc - The ResultColumn match on. | public Optimizable | getOptimizable(int index) | int[] | getTableNumbers() | public boolean | hasOuterJoins() Returns true if any Outer joins present. | boolean | hashJoinSpecified() Return whether or not the user specified a hash join for any of the
tables in this list. | public void | init(Object optimizeJoinOrder) | public void | init(Object optimizeJoinOrder, Object fromTable) | public void | initAccessPaths(Optimizer optimizer) | public boolean | legalJoinOrder(int numTablesInQuery) | public boolean | optimizeJoinOrder() | public void | preprocess(int numTables, GroupByList gbl, ValueNode predicateTree) Preprocess the query tree - this currently means:
o Generating a referenced table map for each ResultSetNode.
o Putting the WHERE and HAVING clauses in conjunctive normal form (CNF).
o Converting the WHERE and HAVING clauses into PredicateLists and
classifying them.
o Flatten those FromSubqueries which can be flattened.
o Ensuring that a ProjectRestrictNode is generated on top of every
FromBaseTable and generated in place of every FromSubquery which
could not be flattened. | public void | printSubNodes(int depth) Prints the sub-nodes of this object. | void | pushPredicates(PredicateList predicateList) Categorize and push the predicates that are pushable. | public void | reOrder(int[] joinOrder) | public boolean | referencesSessionSchema() | public boolean | referencesTarget(String name, boolean baseTable) Search to see if a query references the specifed table name. | public void | rejectParameters() Check for (and reject) all ? parameters directly under the ResultColumns. | boolean | returnsAtMostSingleRow(ResultColumnList rcl, ValueNode whereClause, PredicateList wherePredicates, DataDictionary dd) This method is used for both subquery flattening and distinct
elimination based on a uniqueness condition. | public void | setLevel(int level) Set the (query block) level (0-based) for the FromTables in this
FromList. | public void | setOptimizable(int index, Optimizable optimizable) | public void | setProperties(Properties props) Set the Properties list for this FromList. | public int | updateTargetLockMode() Get the lock mode for the target of an update statement
(a delete or update). | public boolean | useStatistics() | public void | verifyProperties(DataDictionary dDictionary) |
fixedJoinOrder | boolean fixedJoinOrder(Code) | | |
useStatistics | boolean useStatistics(Code) | | |
bindColumnReference | public ResultColumn bindColumnReference(ColumnReference columnReference) throws StandardException(Code) | | Bind a column reference to one of the tables in this FromList. The column name
must be unique within the tables in the FromList. An exception is thrown
if a column name is not unique.
NOTE: Callers are responsible for ordering the FromList by nesting level,
with tables at the deepest (current) nesting level first. We will try to
match against all FromTables at a given nesting level. If no match is
found at a nesting level, then we proceed to the next level. We stop
walking the list when the nesting level changes and we have found a match.
NOTE: If the ColumnReference is qualified, then we will stop the search
at the first nesting level where there is a match on the exposed table name.
For example, s (a, b, c), t (d, e, f)
select * from s where exists (select * from t s where s.c = a)
will not find a match for s.c, which is the expected ANSI behavior.
bindTables() must have already been called on this FromList before
calling this method.
Parameters: columnReference - The ColumnReference describing the column to bind ResultColumn The matching ResultColumn exception: StandardException - Thrown on error |
bindExpressions | public void bindExpressions(FromList fromListParam) throws StandardException(Code) | | Bind the expressions in this FromList. This means
binding the sub-expressions, as well as figuring out what the return
type is for each expression.
exception: StandardException - Thrown on error |
bindResultColumns | public void bindResultColumns(FromList fromListParam) throws StandardException(Code) | | Bind the result columns of the ResultSetNodes in this FromList when there is no
base table to bind them to. This is useful for SELECT statements,
where the result columns get their types from the expressions that
live under them.
Parameters: fromListParam - FromList to use/append to. exception: StandardException - Thrown on error |
bindTables | public void bindTables(DataDictionary dataDictionary, FromList fromListParam) throws StandardException(Code) | | Bind the tables in this FromList. This includes looking them up in
the DataDictionary, getting their TableDescriptors and assigning the
table numbers.
Parameters: dataDictionary - The DataDictionary to use for binding Parameters: fromListParam - FromList to use/append to. exception: StandardException - Thrown on error |
bindUntypedNullsToResultColumns | public void bindUntypedNullsToResultColumns(ResultColumnList bindingRCL) throws StandardException(Code) | | Bind any untyped null nodes to the types in the given ResultColumnList.
Parameters: bindingRCL - The ResultColumnList with the types to bind to. exception: StandardException - Thrown on error |
decrementLevel | void decrementLevel(int decrement)(Code) | | Decrement (query block) level (0-based) for
all of the tables in this from list.
This is useful when flattening a subquery.
Parameters: decrement - The amount to decrement by. |
expandAll | public ResultColumnList expandAll(TableName allTableName) throws StandardException(Code) | | Expand a "*" into the appropriate ResultColumnList. If the "*"
is unqualified it will expand into a list of all columns in all
of the base tables in the from list, otherwise it will expand
into a list of all of the columns in the base table that matches
the qualification.
Parameters: allTableName - The qualification on the "*" as a String. ResultColumnList representing expansion exception: StandardException - Thrown on error |
flattenFromTables | public void flattenFromTables(ResultColumnList rcl, PredicateList predicateList, SubqueryList sql, GroupByList gbl) throws StandardException(Code) | | Flatten all the FromTables that are flattenable.
RESOLVE - right now we just flatten FromSubqueries. We
should also flatten flattenable JoinNodes here.
Parameters: rcl - The RCL from the outer query Parameters: predicateList - The PredicateList from the outer query Parameters: sql - The SubqueryList from the outer query Parameters: gbl - The group by list, if any exception: StandardException - Thrown on error |
genExistsBaseTables | void genExistsBaseTables(JBitSet referencedTableMap, FromList outerFromList, boolean isNotExists) throws StandardException(Code) | | Mark all of the FromBaseTables in the list as EXISTS FBTs.
Each EBT has the same dependency list - those tables that are referenced
minus the tables in the from list.
Parameters: referencedTableMap - The referenced table map. Parameters: outerFromList - FromList from outer query block Parameters: isNotExists - Whether or not for NOT EXISTS exception: StandardException - Thrown on error |
getFromTableByName | protected FromTable getFromTableByName(String name, String schemaName, boolean exactMatch) throws StandardException(Code) | | Determine whether or not the specified name is an exposed name in
the current query block.
Parameters: name - The specified name to search for as an exposed name. Parameters: schemaName - Schema name, if non-null. Parameters: exactMatch - Whether or not we need an exact match on specified schema and tablenames or match on table id. The FromTable, if any, with the exposed name. exception: StandardException - Thrown on error |
getFromTableByResultColumn | public FromTable getFromTableByResultColumn(ResultColumn rc)(Code) | | Get the FromTable from this list which has the specified ResultColumn in
its RCL.
Parameters: rc - The ResultColumn match on. FromTable The matching FromTable. |
getTableNumbers | int[] getTableNumbers()(Code) | | |
hasOuterJoins | public boolean hasOuterJoins() throws StandardException(Code) | | Returns true if any Outer joins present. Used to set Nullability
True if has any outer joins. False otherwise. |
hashJoinSpecified | boolean hashJoinSpecified()(Code) | | Return whether or not the user specified a hash join for any of the
tables in this list.
Whether or not the user specified a hash join for any of the tables in this list. |
init | public void init(Object optimizeJoinOrder)(Code) | | Initializer for a FromList
|
preprocess | public void preprocess(int numTables, GroupByList gbl, ValueNode predicateTree) throws StandardException(Code) | | Preprocess the query tree - this currently means:
o Generating a referenced table map for each ResultSetNode.
o Putting the WHERE and HAVING clauses in conjunctive normal form (CNF).
o Converting the WHERE and HAVING clauses into PredicateLists and
classifying them.
o Flatten those FromSubqueries which can be flattened.
o Ensuring that a ProjectRestrictNode is generated on top of every
FromBaseTable and generated in place of every FromSubquery which
could not be flattened.
o Pushing single table predicates down to the new ProjectRestrictNodes.
Parameters: numTables - The number of tables in the DML Statement Parameters: gbl - The group by list, if any exception: StandardException - Thrown on error |
printSubNodes | public void printSubNodes(int depth)(Code) | | Prints the sub-nodes of this object. See QueryTreeNode.java for
how tree printing is supposed to work.
Parameters: depth - The depth of this node in the tree |
referencesSessionSchema | public boolean referencesSessionSchema() throws StandardException(Code) | | Return true if the node references SESSION schema tables (temporary or permanent)
true if references SESSION schema tables, else false exception: StandardException - Thrown on error |
referencesTarget | public boolean referencesTarget(String name, boolean baseTable) throws StandardException(Code) | | Search to see if a query references the specifed table name.
Parameters: name - Table name (String) to search for. Parameters: baseTable - Whether or not name is for a base table true if found, else false exception: StandardException - Thrown on error |
rejectParameters | public void rejectParameters() throws StandardException(Code) | | Check for (and reject) all ? parameters directly under the ResultColumns.
This is done for SELECT statements.
exception: StandardException - Thrown if a ? parameter founddirectly under a ResultColumn |
returnsAtMostSingleRow | boolean returnsAtMostSingleRow(ResultColumnList rcl, ValueNode whereClause, PredicateList wherePredicates, DataDictionary dd) throws StandardException(Code) | | This method is used for both subquery flattening and distinct
elimination based on a uniqueness condition. For subquery
flattening we want to make sure that the query block
will return at most 1 row. For distinct elimination we
want to make sure that the query block will not return
any duplicates.
This is true if every table in the from list is
(a base table and the set of columns from the table that
are in equality comparisons with expressions that do not include columns
from the same table is a superset of any unique index
on the table) or an EXISTS FBT. In addition, at least 1 of the tables
in the list has a set of columns in equality comparisons with expressions
that do not include column references from the same query block
is a superset of a unique index
on that table. (This ensures that the query block will onlyr
return a single row.)
This method is expected to be called after normalization and
after the from list has been preprocessed.
It can be called both before and after the predicates have
been pulled from the where clause.
The algorithm for this is as follows
If any table in the query block is not a base table, give up.
For each table in the query
Ignore exists table since they can only produce one row
create a matrix of tables and columns from the table (tableColMap)
(this is used to keep track of the join columns and constants
that can be used to figure out whether the rows from a join
or in a select list are distinct based on unique indexes)
create an array of columns from the table(eqOuterCol)
(this is used to determine that only one row will be returned
from a join)
if the current table is the table for the result columns
set the result columns in the eqOuterCol and tableColMap
(if these columns are a superset of a unique index and
all joining tables result in only one row, the
results will be distinct)
go through all the predicates and update tableColMap and
eqOuterCol with join columns and correlation variables,
parameters and constants
since setting constants, correlation variables and parameters,
reduces the number of columns required for uniqueness in a
multi-column index, they are set for all the tables (if the
table is not the result table, in this case only the column of the
result table is set)
join columns are just updated for the column in the row of the
joining table.
check if the marked columns in tableColMap are a superset of a unique
index
(This means that the join will only produce 1 row when joined
with 1 row of another table)
check that there is a least one table for which the columns in
eqOuterCol(i.e. constant values) are a superset of a unique index
(This quarantees that there will be only one row selected
from this table).
Once all tables have been evaluated, check that all the tables can be
joined by unique index or will have only one row
Parameters: rcl - If non-null, the RCL from the query block.If non-null for subqueries, then entry canbe considered as part of an = comparison. Parameters: whereClause - The WHERE clause to consider. Parameters: wherePredicates - The predicates that have already beenpulled from the WHERE clause. Parameters: dd - The DataDictionary to use. Whether or not query block will returnat most 1 row for a subquery, no duplicatesfor a distinct. exception: StandardException - Thrown on error |
setLevel | public void setLevel(int level)(Code) | | Set the (query block) level (0-based) for the FromTables in this
FromList.
Parameters: level - The query block level for this table. |
updateTargetLockMode | public int updateTargetLockMode()(Code) | | Get the lock mode for the target of an update statement
(a delete or update). The update mode will always be row for
CurrentOfNodes. It will be table if there is no where clause.
The lock mode |
Methods inherited from org.apache.derby.impl.sql.compile.QueryTreeNode | public Visitable accept(Visitor v) throws StandardException(Code)(Java Doc) public QueryTreeNode bind() throws StandardException(Code)(Java Doc) public DataValueDescriptor convertDefaultNode(DataTypeDescriptor typeDescriptor) throws StandardException(Code)(Java Doc) protected static void debugFlush()(Code)(Java Doc) public static void debugPrint(String outputString)(Code)(Java Doc) public void disablePrivilegeCollection()(Code)(Java Doc) public String executeSchemaName()(Code)(Java Doc) public String executeStatementName()(Code)(Java Doc) public static String formatNodeString(String nodeString, int depth)(Code)(Java Doc) public boolean foundString(String[] list, String search)(Code)(Java Doc) public GeneratedClass generate(ByteArray ignored) throws StandardException(Code)(Java Doc) protected void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException(Code)(Java Doc) void generateAuthorizeCheck(ActivationClassBuilder acb, MethodBuilder mb, int sqlOperation)(Code)(Java Doc) public int getBeginOffset()(Code)(Java Doc) final protected ClassFactory getClassFactory()(Code)(Java Doc) final protected CompilerContext getCompilerContext()(Code)(Java Doc) final public ContextManager getContextManager()(Code)(Java Doc) public Object getCursorInfo() throws StandardException(Code)(Java Doc) final public DataDictionary getDataDictionary()(Code)(Java Doc) final public DependencyManager getDependencyManager()(Code)(Java Doc) public int getEndOffset()(Code)(Java Doc) final public ExecutionFactory getExecutionFactory()(Code)(Java Doc) final public GenericConstantActionFactory getGenericConstantActionFactory()(Code)(Java Doc) protected int getIntProperty(String value, String key) throws StandardException(Code)(Java Doc) final protected LanguageConnectionContext getLanguageConnectionContext()(Code)(Java Doc) final public NodeFactory getNodeFactory()(Code)(Java Doc) protected int getNodeType()(Code)(Java Doc) public ConstantNode getNullNode(TypeId typeId, ContextManager cm) throws StandardException(Code)(Java Doc) public DataTypeDescriptor[] getParameterTypes() throws StandardException(Code)(Java Doc) public long getRowEstimate()(Code)(Java Doc) public String getSPSName()(Code)(Java Doc) final SchemaDescriptor getSchemaDescriptor(String schemaName) throws StandardException(Code)(Java Doc) final SchemaDescriptor getSchemaDescriptor(String schemaName, boolean raiseError) throws StandardException(Code)(Java Doc) protected int getStatementType()(Code)(Java Doc) final protected TableDescriptor getTableDescriptor(String tableName, SchemaDescriptor schema) throws StandardException(Code)(Java Doc) final protected TypeCompiler getTypeCompiler(TypeId typeId)(Code)(Java Doc) public void init(Object arg1) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13) throws StandardException(Code)(Java Doc) public void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14) throws StandardException(Code)(Java Doc) public boolean isAtomic() throws StandardException(Code)(Java Doc) protected boolean isInstanceOf(int nodeType)(Code)(Java Doc) public boolean isPrivilegeCollectionRequired()(Code)(Java Doc) final boolean isSessionSchema(SchemaDescriptor sd)(Code)(Java Doc) final boolean isSessionSchema(String schemaName)(Code)(Java Doc) public ConstantAction makeConstantAction() throws StandardException(Code)(Java Doc) public ResultDescription makeResultDescription() throws StandardException(Code)(Java Doc) public TableName makeTableName(String schemaName, String flatName) throws StandardException(Code)(Java Doc) public boolean needsSavepoint()(Code)(Java Doc) protected String nodeHeader()(Code)(Java Doc) public QueryTreeNode optimize() throws StandardException(Code)(Java Doc) public static QueryTreeNode parseQueryText(CompilerContext compilerContext, String queryText, Object[] paramDefaults, LanguageConnectionContext lcc) throws StandardException(Code)(Java Doc) public void printLabel(int depth, String label)(Code)(Java Doc) public void printSubNodes(int depth)(Code)(Java Doc) public boolean referencesSessionSchema() throws StandardException(Code)(Java Doc) public TableName resolveTableToSynonym(TableName tabName) throws StandardException(Code)(Java Doc) public void setBeginOffset(int beginOffset)(Code)(Java Doc) public void setContextManager(ContextManager cm)(Code)(Java Doc) public void setEndOffset(int endOffset)(Code)(Java Doc) public void setNodeType(int nodeType)(Code)(Java Doc) public void setRefActionInfo(long fkIndexConglomId, int[] fkColArray, String parentResultSetId, boolean dependentScan)(Code)(Java Doc) public String toString()(Code)(Java Doc) public void treePrint()(Code)(Java Doc) public void treePrint(int depth)(Code)(Java Doc) String verifyClassExist(String javaClassName, boolean convertCase) throws StandardException(Code)(Java Doc)
|
|
|