|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.ValueNode
org.apache.derby.impl.sql.compile.ColumnReference
public class ColumnReference
A ColumnReference represents a column in the query tree. The parser generates a ColumnReference for each column reference. A column refercence could be a column in a base table, a column in a view (which could expand into a complex expression), or a column in a subquery in the FROM clause.
Nested Class Summary | |
---|---|
private class |
ColumnReference.RemapInfo
Helper class to keep track of remap data when a ColumnReference is remapped multiple times. |
Field Summary | |
---|---|
(package private) java.lang.String |
columnName
|
private int |
columnNumber
|
private int |
columnNumberBeforeFlattening
|
private int |
nestingLevel
|
(package private) int |
origColumnNumber
|
private java.lang.String |
origName
|
(package private) ResultColumn |
origSource
|
(package private) int |
origTableNumber
|
private java.util.ArrayList |
remaps
|
private boolean |
replacesAggregate
|
private boolean |
replacesWindowFunctionCall
|
private boolean |
scoped
|
private ResultColumn |
source
|
private int |
sourceLevel
|
(package private) TableName |
tableName
|
private int |
tableNumber
|
private int |
tableNumberBeforeFlattening
|
Fields inherited from class org.apache.derby.impl.sql.compile.ValueNode |
---|
transformed |
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode |
---|
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, isPrivilegeCollectionRequired |
Constructor Summary | |
---|---|
ColumnReference()
|
Method Summary | |
---|---|
ValueNode |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.Vector aggregateVector)
Bind this expression. |
boolean |
categorize(JBitSet referencedTabs,
boolean simplePredsOnly)
Categorize this predicate. |
boolean |
constantExpression(PredicateList whereClause)
Return whether or not this expression tree represents a constant value. |
void |
copyFields(ColumnReference oldCR)
Copy all of the "appropriate fields" for a shallow copy. |
void |
generateExpression(ExpressionClassBuilder acb,
MethodBuilder mb)
ColumnReference's are to the current row in the system. |
ValueNode |
getClone()
Return a clone of this node. |
java.lang.String |
getColumnName()
Get the name of this column |
int |
getColumnNumber()
Get the column number for this ColumnReference. |
(package private) boolean |
getCorrelated()
Return whether or not this CR is correlated. |
boolean |
getGeneratedToReplaceAggregate()
Determine whether or not this node was generated to replace an aggregate in the user's SELECT. |
boolean |
getGeneratedToReplaceWindowFunctionCall()
Determine whether or not this node was generated to replace a window function call in the user's SELECT. |
private int |
getNestingLevel()
Get the nesting level for this CR. |
protected int |
getOrderableVariantType()
Return the variant type for the underlying expression. |
java.lang.String |
getSchemaName()
Get the user-supplied schema name of this column. |
ResultColumn |
getSource()
Get the source this columnReference |
(package private) int |
getSourceLevel()
Get the source level for this CR. |
ResultColumn |
getSourceResultColumn()
Get the source for this ValueNode. |
protected ResultSetNode |
getSourceResultSet(int[] colNum)
Find the source result set for this ColumnReference and return it. |
java.lang.String |
getSourceSchemaName()
Get the name of the schema for the Column's base table, if any. |
java.lang.String |
getSourceTableName()
Get the name of the underlying(base) table this column comes from, if any. |
java.lang.String |
getSQLColumnName()
Get the column name for purposes of error messages or debugging. |
java.lang.String |
getTableName()
Get the user-supplied table name of this column. |
TableName |
getTableNameNode()
Return the table name as the node it is. |
int |
getTableNumber()
Get the table number for this ColumnReference. |
(package private) void |
getTablesReferenced(JBitSet refs)
Update the table map to reflect the source of this CR. |
DataTypeDescriptor |
getTypeServices()
The type of a ColumnReference is the type of its source unless the source is null then it is the type that has been set on this node. |
protected boolean |
hasBeenRemapped()
Returns true if this ColumnReference has been remapped; false otherwise. |
void |
init(java.lang.Object columnName,
java.lang.Object tableName)
Initializer. |
void |
init(java.lang.Object columnName,
java.lang.Object tableName,
java.lang.Object tokBeginOffset,
java.lang.Object tokEndOffset)
Initializer. |
boolean |
isCloneable()
Return whether or not this expression tree is cloneable. |
protected boolean |
isEquivalent(ValueNode o)
Tests if this node is equivalent to the specified ValueNode. |
protected boolean |
isScoped()
Return whether or not this ColumnReference is scoped. |
protected void |
markAsScoped()
Mark this column reference as "scoped", which means that it was created (as a clone of another ColumnReference) to serve as the left or right operand of a scoped predicate. |
void |
markGeneratedToReplaceAggregate()
Mark this node as being generated to replace an aggregate. |
void |
markGeneratedToReplaceWindowFunctionCall()
Mark this node as being generated to replace a window function call. |
(package private) boolean |
pointsToColumnReference()
Return whether or not the source of this ColumnReference is itself a ColumnReference. |
void |
printSubNodes(int depth)
Prints the sub-nodes of this object. |
ValueNode |
putAndsOnTop()
Do the 1st step in putting an expression into conjunctive normal form. |
void |
remapColumnReferences()
Remap all of the ColumnReferences in this expression tree to point to the ResultColumn that is 1 level under their current source ResultColumn. |
ValueNode |
remapColumnReferencesToExpressions()
Remap all ColumnReferences in this tree to be clones of the underlying expression. |
void |
setColumnNumber(int colNum)
Set the column number for this ColumnReference. |
(package private) void |
setNestingLevel(int nestingLevel)
Set the nesting level for this CR. |
void |
setSource(ResultColumn source)
Set the source this columnReference |
(package private) void |
setSourceLevel(int sourceLevel)
Set the source level for this CR. |
void |
setTableNameNode(TableName tableName)
|
void |
setTableNumber(int tableNumber)
Set this ColumnReference to refer to the given table number. |
java.lang.String |
toString()
Convert this object to a String. |
void |
unRemapColumnReferences()
|
boolean |
updatableByCursor()
Is the column wirtable by the cursor or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
java.lang.String columnName
TableName tableName
private int tableNumber
private int columnNumber
private ResultColumn source
ResultColumn origSource
private java.lang.String origName
int origTableNumber
int origColumnNumber
private int tableNumberBeforeFlattening
private int columnNumberBeforeFlattening
private boolean replacesAggregate
private boolean replacesWindowFunctionCall
private int nestingLevel
private int sourceLevel
private boolean scoped
private java.util.ArrayList remaps
Constructor Detail |
---|
public ColumnReference()
Method Detail |
---|
public void init(java.lang.Object columnName, java.lang.Object tableName, java.lang.Object tokBeginOffset, java.lang.Object tokEndOffset)
init
in class QueryTreeNode
columnName
- The name of the column being referencedtableName
- The qualification for the columntokBeginOffset
- begin position of token for the column name
identifier from parser.tokEndOffset
- end position of token for the column name
identifier from parser.public void init(java.lang.Object columnName, java.lang.Object tableName)
init
in class QueryTreeNode
columnName
- The name of the column being referencedtableName
- The qualification for the columnpublic java.lang.String toString()
toString
in class ValueNode
public void printSubNodes(int depth)
printSubNodes
in class QueryTreeNode
depth
- The depth of this node in the treeboolean getCorrelated()
void setNestingLevel(int nestingLevel)
nestingLevel
- The Nesting level at which the CR appears.private int getNestingLevel()
void setSourceLevel(int sourceLevel)
sourceLevel
- The Nesting level of the source of the CR.int getSourceLevel()
public void markGeneratedToReplaceAggregate()
public void markGeneratedToReplaceWindowFunctionCall()
public boolean getGeneratedToReplaceAggregate()
public boolean getGeneratedToReplaceWindowFunctionCall()
public ValueNode getClone() throws StandardException
getClone
in class ValueNode
StandardException
- Thrown on errorpublic void copyFields(ColumnReference oldCR) throws StandardException
oldCR
- The ColumnReference to copy from.
StandardException
- Thrown on errorpublic ValueNode bindExpression(FromList fromList, SubqueryList subqueryList, java.util.Vector aggregateVector) throws StandardException
bindExpression
in class ValueNode
fromList
- The FROM list for the query this
expression is in, for binding columns.subqueryList
- The subquery list being built as we find SubqueryNodesaggregateVector
- The aggregate vector being built as we find AggregateNodes
StandardException
- Thrown on errorpublic java.lang.String getSQLColumnName()
public java.lang.String getColumnName()
getColumnName
in class ValueNode
public int getTableNumber()
public void setTableNumber(int tableNumber)
tableNumber
- The table number this ColumnReference will refer topublic java.lang.String getTableName()
getTableName
in class ValueNode
public java.lang.String getSourceTableName()
public java.lang.String getSourceSchemaName() throws StandardException
StandardException
public boolean updatableByCursor()
updatableByCursor
in class ValueNode
public TableName getTableNameNode()
public void setTableNameNode(TableName tableName)
public int getColumnNumber()
public void setColumnNumber(int colNum)
colNum
- The new column number.public ResultColumn getSource()
public void setSource(ResultColumn source)
source
- The source of this columnReferencepublic ValueNode putAndsOnTop() throws StandardException
putAndsOnTop
in class ValueNode
StandardException
- Thrown on errorpublic boolean categorize(JBitSet referencedTabs, boolean simplePredsOnly)
categorize
in class ValueNode
referencedTabs
- JBitSet with bit map of referenced FromTablessimplePredsOnly
- Whether or not to consider method
calls, field references and conditional nodes
when building bit map
public void remapColumnReferences()
public void unRemapColumnReferences()
protected boolean hasBeenRemapped()
public ResultColumn getSourceResultColumn()
ValueNode
getSourceResultColumn
in class ValueNode
public ValueNode remapColumnReferencesToExpressions() throws StandardException
remapColumnReferencesToExpressions
in class ValueNode
StandardException
- Thrown on errorvoid getTablesReferenced(JBitSet refs)
refs
- The table map.public boolean isCloneable()
isCloneable
in class ValueNode
public boolean constantExpression(PredicateList whereClause)
ValueNode
constantExpression
in class ValueNode
ValueNode.constantExpression(org.apache.derby.impl.sql.compile.PredicateList)
public void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
generateExpression
in class ValueNode
acb
- The ExpressionClassBuilder for the class being builtmb
- The method the expression will go into
StandardException
- Thrown on errorpublic java.lang.String getSchemaName()
getSchemaName
in class ValueNode
protected int getOrderableVariantType()
getOrderableVariantType
in class ValueNode
boolean pointsToColumnReference()
public DataTypeDescriptor getTypeServices()
getTypeServices
in class ValueNode
protected ResultSetNode getSourceResultSet(int[] colNum) throws StandardException
colNum
- Place to store the position of the column
to which this ColumnReference points (position is w.r.t
the source result set).
StandardException
protected boolean isEquivalent(ValueNode o) throws StandardException
ValueNode
This method provides basic expression matching facility for the derived class of ValueNode and it is used by the language layer to compare the node structural form of the two expressions for equivalence at bind phase.
Note that it is not comparing the actual row values at runtime to produce a result; hence, when comparing SQL NULLs, they are considered to be equivalent and not unknown.
One usage case of this method in this context is to compare the select column expression against the group by expression to check if they are equivalent. e.g.:
SELECT c1+c2 FROM t1 GROUP BY c1+c2
In general, node equivalence is determined by the derived class of ValueNode. But they generally abide to the rules below:
isEquivalent
in class ValueNode
o
- the node to compare this ValueNode against.
true
if the two nodes are equivalent,
false
otherwise.
StandardException
protected void markAsScoped()
protected boolean isScoped()
|
Built on Thu 2010-12-23 20:49:13+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |