|
|||||||||
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.ResultColumn
public class ResultColumn
A ResultColumn represents a result column in a SELECT, INSERT, or UPDATE statement. In a SELECT statement, the result column just represents an expression in a row being returned to the client. For INSERT and UPDATE statements, the result column represents an column in a stored table. So, a ResultColumn has to be bound differently depending on the type of statement it appears in.
The type of the ResultColumn can differ from its underlying expression, for example in certain joins the ResultColumn can be nullable even if its underlying column is not. In an INSERT or UPDATE the ResultColumn will represent the type of the column in the table, the type of the underlying expresion will be the type of the source of the value to be insert or updated. The method columnTypeAndLengthMatch() can be used to detect when normalization is required between the expression and the tyoe of ResultColumn. This class does not implement any type normalization (conversion), this is typically handled by a NormalizeResultSetNode.
Field Summary | |
---|---|
(package private) boolean |
autoincrement
|
(package private) boolean |
autoincrementGenerated
|
(package private) ColumnDescriptor |
columnDescriptor
|
private boolean |
defaultColumn
|
(package private) java.lang.String |
exposedName
|
(package private) ValueNode |
expression
|
(package private) boolean |
isGenerated
|
(package private) boolean |
isGeneratedForUnmatchedColumnInInsert
|
(package private) boolean |
isGroupingColumn
|
(package private) boolean |
isNameGenerated
|
(package private) boolean |
isRedundant
|
(package private) boolean |
isReferenced
|
(package private) java.lang.String |
name
|
(package private) ColumnReference |
reference
|
private int |
resultSetNumber
|
(package private) java.lang.String |
sourceSchemaName
|
(package private) java.lang.String |
sourceTableName
|
(package private) java.lang.String |
tableName
|
(package private) boolean |
updatableByCursor
|
(package private) boolean |
updated
|
private int |
virtualColumnId
|
private boolean |
wasDefault
|
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 | |
---|---|
ResultColumn()
|
Method Summary | |
---|---|
(package private) void |
acceptChildren(Visitor v)
Accept the visitor for all visitable children of this node. |
void |
adjustVirtualColumnId(int adjust)
Adjust the virtualColumnId for this ResultColumn by the specified amount |
ValueNode |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.Vector aggregateVector)
Bind this expression. |
void |
bindResultColumnByName(TableDescriptor tableDescriptor,
int columnId)
Bind this result column by its name and set the VirtualColumnId. |
(package private) void |
bindResultColumnByPosition(TableDescriptor tableDescriptor,
int columnId)
Bind this result column by ordinal position and set the VirtualColumnId. |
void |
bindResultColumnToExpression()
Bind the result column to the expression that lives under it. |
void |
checkStorableExpression()
This verifies that the expression is storable into the result column. |
void |
checkStorableExpression(ResultColumn toStore)
This verifies that the expression is storable into the result column. |
private void |
checkStorableExpression(ValueNode source)
|
void |
clearTableName()
Clear the table name for the underlying ColumnReference. |
(package private) ResultColumn |
cloneMe()
Make a copy of this ResultColumn in a new ResultColumn |
void |
collapseVirtualColumnIdGap(int removedColumnId)
Adjust this virtualColumnId to account for the removal of a column This routine is called when bind processing finds and removes duplicate columns in the result list which were pulled up due to their presence in the ORDER BY clause, but were later found to be duplicate. |
(package private) boolean |
columnNameMatches(java.lang.String columnName)
Return TRUE if this result column matches the provided column name. |
(package private) boolean |
columnTypeAndLengthMatch()
Check whether the column length and type of this result column match the expression under the columns. |
(package private) boolean |
columnTypeAndLengthMatch(ResultColumn otherColumn)
|
int |
compareTo(java.lang.Object other)
|
private DataValueDescriptor |
convertConstant(TypeId toTypeId,
int maxWidth,
DataValueDescriptor constantValue)
|
void |
disablePrivilegeCollection()
Triggers, constraints and views get executed with their definer's privileges and they can exist in the system only if their definers' still have all the privileges to creeate them. |
boolean |
foundInList(java.lang.String[] list)
Is this column in this array of strings? |
void |
generateExpression(ExpressionClassBuilder ecb,
MethodBuilder mb)
Do code generation for a result column. |
void |
generateHolder(ExpressionClassBuilder acb,
MethodBuilder mb)
Generate the code to create a column the same shape and size as this ResultColumn. |
BaseColumnNode |
getBaseColumnNode()
Get the source BaseColumnNode for this result column. |
int |
getColumnPosition()
Get the position of the Column. |
ValueNode |
getExpression()
Get the expression in this ResultColumn. |
int |
getMaximumColumnSize()
Get the maximum size of the column |
java.lang.String |
getName()
The following methods implement the ResultColumnDescriptor interface. |
protected int |
getOrderableVariantType()
Return the variant type for the underlying expression. |
ColumnReference |
getReference()
|
int |
getResultSetNumber()
Get the resultSetNumber for this ResultColumn. |
java.lang.String |
getSchemaName()
This returns the user-supplied schema name of the column. |
(package private) java.lang.String |
getSourceColumnName()
Returns the underlying source column name, if this ResultColumn is a simple direct reference to a table column, or NULL otherwise. |
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. |
(package private) ColumnDescriptor |
getTableColumnDescriptor()
If this ResultColumn is bound to a column in a table get the column descriptor for the column in the table. |
java.lang.String |
getTableName()
This returns the user-supplied table name of the column. |
TableName |
getTableNameObject()
|
int |
getTableNumber()
Search the tree beneath this ResultColumn until we find the number of the table to which this RC points, and return that table number. |
DataTypeDescriptor |
getType()
Returns a DataTypeDescriptor for the column. |
DataTypeDescriptor |
getTypeServices()
Get the DataTypeServices from this ValueNode. |
int |
getVirtualColumnId()
Get the virtualColumnId for this ResultColumn |
void |
guaranteeColumnName()
Generate a unique (across the entire statement) column name for unnamed ResultColumns |
boolean |
hasGenerationClause()
Return true if this result column represents a generated column. |
void |
init(java.lang.Object arg1,
java.lang.Object arg2)
Different types of initializer parameters indicate different types of initialization. |
boolean |
isAutoincrement()
Tell us if the column is an autoincrement column or not. |
boolean |
isAutoincrementGenerated()
Returns true if this result column is a placeholder for a generated autoincrement value. |
boolean |
isDefaultColumn()
Returns TRUE if the ResultColumn is standing in for a DEFAULT keyword in an insert/update statement. |
boolean |
isEquivalent(ValueNode o)
Tests if this node is equivalent to the specified ValueNode. |
boolean |
isGenerated()
Is this a generated column? |
boolean |
isGeneratedForUnmatchedColumnInInsert()
Is this columm generated for an unmatched column in an insert? |
boolean |
isGroupingColumn()
|
boolean |
isNameGenerated()
Is the name for this ResultColumn generated? |
boolean |
isRedundant()
Is this a redundant ResultColumn? |
boolean |
isReferenced()
Is this a referenced column? |
(package private) void |
markAllRCsInChainReferenced()
Mark this RC and all RCs in the underlying RC/VCN chain as referenced. |
void |
markAsGroupingColumn()
Mark this ResultColumn as a grouping column in the SELECT list |
void |
markGenerated()
Mark this a columm as a generated column |
void |
markGeneratedForUnmatchedColumnInInsert()
Mark this a columm as generated for an unmatched column in an insert |
(package private) void |
markUpdatableByCursor()
Mark this column as being updatable, so we can make sure it is in the "for update" list of a positioned update. |
(package private) void |
markUpdated()
Mark this column as being updated by an update statemment. |
ValueNode |
preprocess(int numTables,
FromList outerFromList,
SubqueryList outerSubqueryList,
PredicateList outerPredicateList)
Preprocess an expression tree. |
void |
printSubNodes(int depth)
Prints the sub-nodes of this object. |
(package private) void |
pullVirtualIsReferenced()
Mark this column as a referenced column if it is already marked as referenced or if any result column in its chain of virtual columns is marked as referenced. |
(package private) void |
rejectParameter()
Look for and reject ? |
void |
resetAutoincrementGenerated()
|
void |
setAutoincrement()
|
void |
setAutoincrementGenerated()
|
(package private) void |
setColumnDescriptor(TableDescriptor tableDescriptor,
ColumnDescriptor columnDescriptor)
Set the column descriptor for this result column. |
void |
setDefaultColumn(boolean value)
|
void |
setExpression(ValueNode expression)
Set the expression in this ResultColumn. |
(package private) void |
setExpressionToNullNode()
Set the expression to a null node of the correct type. |
void |
setName(java.lang.String name)
Set the name in this ResultColumn. |
void |
setNameGenerated(boolean value)
Set that this result column name is generated. |
void |
setRedundant()
Mark this ResultColumn as redundant. |
void |
setReferenced()
Mark this column as a referenced column. |
void |
setResultSetNumber(int resultSetNumber)
Set the resultSetNumber for this ResultColumn. |
void |
setSourceSchemaName(java.lang.String s)
Set the column source's schema name |
void |
setSourceTableName(java.lang.String t)
Set the column source's table name |
void |
setUnreferenced()
Mark this column as an unreferenced column. |
void |
setVirtualColumnId(int id)
Set the virtualColumnId for this ResultColumn |
void |
setWasDefaultColumn(boolean value)
|
java.lang.String |
toString()
Convert this object to a String. |
void |
typeUntypedNullExpression(ResultColumn bindingRC)
Change an untyped null to a typed null. |
boolean |
updatableByCursor()
Tell whether this column is updatable by a positioned update. |
(package private) boolean |
updated()
Tell whether this column is being updated. |
(package private) void |
verifyOrderable()
Verify that this RC is orderable. |
boolean |
wasDefaultColumn()
Returns TRUE if the ResultColumn used to stand in for a DEFAULT keyword in an insert/update statement. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
java.lang.String name
java.lang.String exposedName
java.lang.String tableName
java.lang.String sourceTableName
java.lang.String sourceSchemaName
ValueNode expression
ColumnDescriptor columnDescriptor
boolean isGenerated
boolean isGeneratedForUnmatchedColumnInInsert
boolean isGroupingColumn
boolean isReferenced
boolean isRedundant
boolean isNameGenerated
boolean updated
boolean updatableByCursor
private boolean defaultColumn
private boolean wasDefault
boolean autoincrementGenerated
boolean autoincrement
private int resultSetNumber
ColumnReference reference
private int virtualColumnId
Constructor Detail |
---|
public ResultColumn()
Method Detail |
---|
public void init(java.lang.Object arg1, java.lang.Object arg2) throws StandardException
- OR -
- OR -
- OR -
init
in class QueryTreeNode
StandardException
- Thrown on errorpublic boolean isDefaultColumn()
public void setDefaultColumn(boolean value)
public boolean wasDefaultColumn()
public void setWasDefaultColumn(boolean value)
boolean columnNameMatches(java.lang.String columnName)
java.lang.String getSourceColumnName()
public java.lang.String getName()
getName
in interface ResultColumnDescriptor
public java.lang.String getSchemaName() throws StandardException
ValueNode
getSchemaName
in class ValueNode
StandardException
public java.lang.String getTableName()
ValueNode
getTableName
in class ValueNode
public java.lang.String getSourceTableName()
ResultColumnDescriptor
getSourceTableName
in interface ResultColumnDescriptor
ResultColumnDescriptor.getSourceTableName()
public java.lang.String getSourceSchemaName()
ResultColumnDescriptor
getSourceSchemaName
in interface ResultColumnDescriptor
ResultColumnDescriptor.getSourceSchemaName()
public void clearTableName()
public DataTypeDescriptor getType()
ResultColumnDescriptor
getType
in interface ResultColumnDescriptor
public int getColumnPosition()
ResultColumnDescriptor
getColumnPosition
in interface ResultColumnDescriptor
public void setExpression(ValueNode expression)
expression
- The expression to be set in this ResultColumnpublic ValueNode getExpression()
void setExpressionToNullNode() throws StandardException
StandardException
- Thrown on errorpublic void setName(java.lang.String name)
name
- The name to set in this ResultColumnpublic boolean isNameGenerated()
public void setNameGenerated(boolean value)
public void setResultSetNumber(int resultSetNumber)
resultSetNumber
- The resultSetNumber.public int getResultSetNumber()
public void adjustVirtualColumnId(int adjust)
adjust
- The adjustment for the virtualColumnIdpublic void setVirtualColumnId(int id)
id
- The virtualColumnId for this ResultColumnpublic int getVirtualColumnId()
public void collapseVirtualColumnIdGap(int removedColumnId)
removedColumnId
- id of the column being removed.public void guaranteeColumnName() throws StandardException
StandardException
- Thrown on errorpublic 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 treepublic 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 errorvoid bindResultColumnByPosition(TableDescriptor tableDescriptor, int columnId) throws StandardException
tableDescriptor
- The descriptor for the table being
inserted intocolumnId
- The ordinal position of the column
in the table, starting at 1.
StandardException
- Thrown on errorpublic void bindResultColumnByName(TableDescriptor tableDescriptor, int columnId) throws StandardException
tableDescriptor
- The descriptor for the table being
updated or inserted intocolumnId
- The ordinal position of the column
in the table, starting at 1. (Used to
set the VirtualColumnId.)
StandardException
- Thrown on errorpublic void typeUntypedNullExpression(ResultColumn bindingRC) throws StandardException
StandardException
- Thrown on errorvoid setColumnDescriptor(TableDescriptor tableDescriptor, ColumnDescriptor columnDescriptor) throws StandardException
tableDescriptor
- The TableDescriptor for the table
being updated or inserted into.
This parameter is used only for
error reporting.columnDescriptor
- The ColumnDescriptor to set in
this ResultColumn.
StandardException
- tableNameMismatchpublic void bindResultColumnToExpression() throws StandardException
StandardException
- Thrown on errorpublic void setSourceTableName(java.lang.String t)
t
- The source table namepublic void setSourceSchemaName(java.lang.String s)
s
- The source schema namepublic ValueNode preprocess(int numTables, FromList outerFromList, SubqueryList outerSubqueryList, PredicateList outerPredicateList) throws StandardException
preprocess
in class ValueNode
numTables
- Number of tables in the DML StatementouterFromList
- FromList from outer query blockouterSubqueryList
- SubqueryList from outer query blockouterPredicateList
- PredicateList from outer query block
StandardException
- Thrown on errorpublic void checkStorableExpression(ResultColumn toStore) throws StandardException
StandardException
- thrown if types not suitable.private void checkStorableExpression(ValueNode source) throws StandardException
StandardException
public void checkStorableExpression() throws StandardException
StandardException
- thrown if types not suitable.public void generateExpression(ExpressionClassBuilder ecb, MethodBuilder mb) throws StandardException
generateExpression
in class ValueNode
ecb
- The ExpressionClassBuilder for the class we're generatingmb
- The method the expression will go into
StandardException
- Thrown on errorpublic void generateHolder(ExpressionClassBuilder acb, MethodBuilder mb) throws StandardException
StandardException
- thrown on failureboolean columnTypeAndLengthMatch() throws StandardException
StandardException
boolean columnTypeAndLengthMatch(ResultColumn otherColumn) throws StandardException
StandardException
public boolean isGenerated()
public boolean isGeneratedForUnmatchedColumnInInsert()
public void markGenerated()
public void markGeneratedForUnmatchedColumnInInsert()
public boolean isReferenced()
public void setReferenced()
void pullVirtualIsReferenced()
public void setUnreferenced()
void markAllRCsInChainReferenced()
public boolean isRedundant()
public void setRedundant()
public void markAsGroupingColumn()
void rejectParameter() throws StandardException
StandardException
- Thrown if a ?/-?/+? parameter was found
directly under this ResultColumn.public int compareTo(java.lang.Object other)
compareTo
in interface java.lang.Comparable
void markUpdated()
void markUpdatableByCursor()
boolean updated()
public boolean updatableByCursor()
updatableByCursor
in interface ResultColumnDescriptor
updatableByCursor
in class ValueNode
public void disablePrivilegeCollection()
QueryTreeNode
disablePrivilegeCollection
in class QueryTreeNode
QueryTreeNode.disablePrivilegeCollection()
ResultColumn cloneMe() throws StandardException
StandardException
- Thrown on errorpublic int getMaximumColumnSize()
public DataTypeDescriptor getTypeServices()
ValueNode
getTypeServices
in class ValueNode
protected int getOrderableVariantType() throws StandardException
getOrderableVariantType
in class ValueNode
StandardException
- thrown on errorvoid acceptChildren(Visitor v) throws StandardException
acceptChildren
in class QueryTreeNode
v
- the visitor
StandardException
- on errorpublic boolean foundInList(java.lang.String[] list)
list
- the array of column names to compare
void verifyOrderable() throws StandardException
StandardException
- Thrown on errorColumnDescriptor getTableColumnDescriptor()
public boolean isAutoincrementGenerated()
public void setAutoincrementGenerated()
public void resetAutoincrementGenerated()
public boolean isAutoincrement()
ResultColumnDescriptor
isAutoincrement
in interface ResultColumnDescriptor
public void setAutoincrement()
public boolean isGroupingColumn()
private DataValueDescriptor convertConstant(TypeId toTypeId, int maxWidth, DataValueDescriptor constantValue) throws StandardException
StandardException
- Thrown on errorpublic TableName getTableNameObject()
public ColumnReference getReference()
public BaseColumnNode getBaseColumnNode()
public int getTableNumber() throws StandardException
StandardException
public 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
public boolean hasGenerationClause()
hasGenerationClause
in interface ResultColumnDescriptor
|
Built on Thu 2012-03-29 21:53:33+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |