class ResultColumn extends ValueNode implements ResultColumnDescriptor, java.lang.Comparable<ResultColumn>
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 expression 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 type of ResultColumn. This class does not implement any type normalization (conversion), this is typically handled by a NormalizeResultSetNode.
Modifier and Type | Field and Description |
---|---|
private boolean |
_autoincrement |
private boolean |
_autoincrementGenerated |
private ColumnDescriptor |
_columnDescriptor |
private java.lang.String |
_derivedColumnName |
private ValueNode |
_expression |
private boolean |
_isGenerated |
private boolean |
_isGeneratedForUnmatchedColumnInInsert |
private boolean |
_isGroupingColumn |
private boolean |
_isNameGenerated |
private boolean |
_isRedundant |
private boolean |
_isReferenced |
private ColumnReference |
_reference |
private java.lang.String |
_sourceSchemaName |
private java.lang.String |
_underlyingName |
private java.lang.String |
_unqualifiedSourceTableName |
private java.lang.String |
_unqualifiedTableName |
private boolean |
_updatableByCursor |
private boolean |
_updated |
private boolean |
defaultColumn |
private JoinNode |
joinResultSet |
private int |
resultSetNumber |
private boolean |
rightOuterJoinUsingClause |
private int |
virtualColumnId |
private boolean |
wasDefault |
transformed
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
Constructor and Description |
---|
ResultColumn(ColumnDescriptor cd,
ValueNode expression,
ContextManager cm) |
ResultColumn(ColumnReference cr,
ValueNode expression,
ContextManager cm) |
ResultColumn(ContextManager cm) |
ResultColumn(DataTypeDescriptor dtd,
ValueNode expression,
ContextManager cm) |
ResultColumn(java.lang.String underlyingName,
ValueNode expression,
ContextManager cm) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
acceptChildren(Visitor v)
Accept the visitor for all visitable children of this node.
|
(package private) void |
adjustVirtualColumnId(int adjust)
Adjust the virtualColumnId for this ResultColumn by the specified amount
|
(package private) ResultColumn |
bindExpression(FromList fromList,
SubqueryList subqueryList,
java.util.List<AggregateNode> aggregates)
Bind this expression.
|
(package private) 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.
|
(package private) void |
bindResultColumnToExpression()
Bind the result column to the expression that lives under it.
|
(package private) void |
checkStorableExpression()
This verifies that the expression is storable into the result column.
|
(package private) void |
checkStorableExpression(ResultColumn toStore)
This verifies that the expression is storable into the result column.
|
private void |
checkStorableExpression(ValueNode source) |
(package private) void |
clearTableName()
Clear the table name for the underlying ColumnReference.
|
(package private) ResultColumn |
cloneMe()
Make a copy of this ResultColumn in a new ResultColumn
|
(package private) 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(ResultColumn other) |
private DataValueDescriptor |
convertConstant(TypeId toTypeId,
int maxWidth,
DataValueDescriptor constantValue) |
(package private) void |
generateExpression(ExpressionClassBuilder ecb,
MethodBuilder mb)
Do code generation for a result column.
|
(package private) BaseColumnNode |
getBaseColumnNode()
Get the source BaseColumnNode for this result column.
|
(package private) ColumnDescriptor |
getColumnDescriptor()
Get the column descriptor
|
int |
getColumnPosition()
Get the position of the Column.
|
(package private) ValueNode |
getExpression()
Get the expression in this ResultColumn.
|
(package private) JoinNode |
getJoinResultSet()
Returns a non-null value if the ResultColumn represents the join
column which is part of the SELECT list of a RIGHT OUTER JOIN with
USING/NATURAL. eg
select c from t1 right join t2 using (c)
The join column we are talking about is column c as in "select c"
The return value of following method will show the association of this
result column to the join resultset created for the RIGHT OUTER JOIN
with USING/NATURAL.
|
(package private) 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.
|
(package private) 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.
|
(package private) java.lang.String |
getTableName()
This returns the user-supplied table name of the column.
|
TableName |
getTableNameObject() |
(package private) 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.
|
(package private) java.lang.String |
getUnderlyingOrAliasName()
Get non-null column name.
|
(package private) int |
getVirtualColumnId()
Get the virtualColumnId for this ResultColumn
|
(package private) 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.
|
boolean |
isAutoincrement()
Tell us if the column is an autoincrement column or not.
|
(package private) boolean |
isAutoincrementGenerated()
Returns true if this result column is a placeholder for a generated
autoincrement value.
|
(package private) boolean |
isDefaultColumn()
Returns TRUE if the ResultColumn is standing in for a DEFAULT keyword in
an insert/update statement.
|
(package private) boolean |
isEquivalent(ValueNode o)
Tests if this node is equivalent to the specified ValueNode.
|
(package private) boolean |
isGenerated()
Is this a generated column?
|
(package private) boolean |
isGeneratedForUnmatchedColumnInInsert()
Is this columm generated for an unmatched column in an insert?
|
boolean |
isGroupingColumn() |
(package private) boolean |
isNameGenerated()
Is the name for this ResultColumn generated?
|
(package private) boolean |
isRedundant()
Is this a redundant ResultColumn?
|
(package private) boolean |
isReferenced()
Is this a referenced column?
|
(package private) boolean |
isRightOuterJoinUsingClause()
Returns TRUE if the ResultColumn is join column for a RIGHT OUTER
JOIN with USING/NATURAL.
|
(package private) boolean |
isUpdatable()
Returns true if this column is updatable.
|
(package private) void |
markAllRCsInChainReferenced()
Mark this RC and all RCs in the underlying
RC/VCN chain as referenced.
|
(package private) void |
markAsGroupingColumn()
Mark this ResultColumn as a grouping column in the SELECT list
|
(package private) void |
markGenerated()
Mark this a columm as a generated column
|
(package private) 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 statement.
|
(package private) ResultColumn |
preprocess(int numTables,
FromList outerFromList,
SubqueryList outerSubqueryList,
PredicateList outerPredicateList)
Preprocess an expression tree.
|
(package private) 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 ?
|
(package private) void |
resetAutoincrementGenerated() |
(package private) void |
setAutoincrement() |
(package private) void |
setAutoincrementGenerated() |
(package private) void |
setColumnDescriptor(TableDescriptor tableDescriptor,
ColumnDescriptor columnDescriptor)
Set the column descriptor for this result column.
|
(package private) void |
setDefaultColumn(boolean value) |
(package private) 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.
|
(package private) void |
setJoinResultset(JoinNode resultSet)
This method gets called during the bind phase of a ResultColumn if it
is determined that the ResultColumn represents the join column which
is part of the SELECT list of a RIGHT OUTER JOIN with
USING/NATURAL. eg
select c from t1 right join t2 using (c)
This case is talking about column c as in "select c"
|
(package private) void |
setName(java.lang.String name)
Set the name in this ResultColumn.
|
(package private) void |
setNameGenerated(boolean value)
Set that this result column name is generated.
|
(package private) void |
setRedundant()
Mark this ResultColumn as redundant.
|
(package private) void |
setReferenced()
Mark this column as a referenced column.
|
(package private) void |
setResultSetNumber(int resultSetNumber)
Set the resultSetNumber for this ResultColumn.
|
(package private) void |
setRightOuterJoinUsingClause(boolean value)
Will be set to TRUE if this ResultColumn is join column for a
RIGHT OUTER JOIN with USING/NATURAL.
|
(package private) void |
setSourceSchemaName(java.lang.String s)
Set the column source's schema name
|
(package private) void |
setSourceTableName(java.lang.String t)
Set the column source's table name
|
private void |
setTypeExpressionAndDefault(ValueNode expression) |
(package private) void |
setUnreferenced()
Mark this column as an unreferenced column.
|
(package private) void |
setVirtualColumnId(int id)
Set the virtualColumnId for this ResultColumn
|
(package private) void |
setWasDefaultColumn(boolean value) |
java.lang.String |
toString()
Convert this object to a String.
|
(package private) 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.
|
(package private) boolean |
wasDefaultColumn()
Returns TRUE if the ResultColumn used to stand in for a DEFAULT keyword in
an insert/update statement.
|
bindExpression, categorize, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, constantExpression, copyFields, eliminateNots, evaluateConstantExpressions, genEqualsFalseTree, generate, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSourceResultColumn, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isConstantExpression, isInListProbeNode, isParameterNode, isRelationalOperator, isSameNodeKind, optimizableEqualityNode, putAndsOnTop, remapColumnReferencesToExpressions, requiresTypeFromContext, selectivity, setCollationInfo, setCollationInfo, setCollationUsingCompilationSchema, setCollationUsingCompilationSchema, setNullability, setTransformed, setType, setType, setType, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExist
private java.lang.String _underlyingName
private java.lang.String _derivedColumnName
private java.lang.String _unqualifiedTableName
private java.lang.String _unqualifiedSourceTableName
private java.lang.String _sourceSchemaName
private ValueNode _expression
private ColumnDescriptor _columnDescriptor
private boolean _isGenerated
private boolean _isGeneratedForUnmatchedColumnInInsert
private boolean _isGroupingColumn
private boolean _isReferenced
private boolean _isRedundant
private boolean _isNameGenerated
private boolean _updated
private boolean _updatableByCursor
private boolean defaultColumn
private boolean wasDefault
private boolean rightOuterJoinUsingClause
private JoinNode joinResultSet
private boolean _autoincrementGenerated
private boolean _autoincrement
private int resultSetNumber
private ColumnReference _reference
private int virtualColumnId
ResultColumn(ContextManager cm)
ResultColumn(java.lang.String underlyingName, ValueNode expression, ContextManager cm) throws StandardException
underlyingName
- The name of the column, if any.expression
- The expression this result column representscm
- context managerStandardException
ResultColumn(ColumnReference cr, ValueNode expression, ContextManager cm) throws StandardException
cr
- A column reference nodeexpression
- The expression this result column representscm
- context managerStandardException
ResultColumn(ColumnDescriptor cd, ValueNode expression, ContextManager cm) throws StandardException
cd
- The column descriptorexpression
- The expression this result column representscm
- context managerStandardException
ResultColumn(DataTypeDescriptor dtd, ValueNode expression, ContextManager cm) throws StandardException
dtd
- The type of the columnexpression
- The expression this result column representscm
- context managerStandardException
private void setTypeExpressionAndDefault(ValueNode expression)
boolean isRightOuterJoinUsingClause()
void setRightOuterJoinUsingClause(boolean value)
value
- True/FalseJoinNode getJoinResultSet()
void setJoinResultset(JoinNode resultSet)
resultSet
- - The ResultColumn belongs to this JoinNodeboolean isDefaultColumn()
void setDefaultColumn(boolean value)
boolean wasDefaultColumn()
void setWasDefaultColumn(boolean value)
boolean columnNameMatches(java.lang.String columnName)
java.lang.String getUnderlyingOrAliasName()
boolean isUpdatable()
java.lang.String getSourceColumnName()
public java.lang.String getName()
getName
in interface ResultColumnDescriptor
java.lang.String getSchemaName() throws StandardException
ValueNode
getSchemaName
in class ValueNode
StandardException
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()
void clearTableName()
public DataTypeDescriptor getType()
ResultColumnDescriptor
getType
in interface ResultColumnDescriptor
public int getColumnPosition()
ResultColumnDescriptor
getColumnPosition
in interface ResultColumnDescriptor
void setExpression(ValueNode expression)
expression
- The expression to be set in this ResultColumnValueNode getExpression()
void setExpressionToNullNode() throws StandardException
StandardException
- Thrown on errorvoid setName(java.lang.String name)
name
- The name to set in this ResultColumnboolean isNameGenerated()
void setNameGenerated(boolean value)
void setResultSetNumber(int resultSetNumber)
resultSetNumber
- The resultSetNumber.public int getResultSetNumber()
void adjustVirtualColumnId(int adjust)
adjust
- The adjustment for the virtualColumnIdvoid setVirtualColumnId(int id)
id
- The virtualColumnId for this ResultColumnint getVirtualColumnId()
void collapseVirtualColumnIdGap(int removedColumnId)
removedColumnId
- id of the column being removed.void guaranteeColumnName() throws StandardException
StandardException
- Thrown on errorpublic java.lang.String toString()
void printSubNodes(int depth)
printSubNodes
in class QueryTreeNode
depth
- The depth of this node in the treeResultColumn bindExpression(FromList fromList, SubqueryList subqueryList, java.util.List<AggregateNode> aggregates) 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 SubqueryNodesaggregates
- The aggregate list being built as we find AggregateNodesStandardException
- 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 errorvoid 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 errorvoid 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
- tableNameMismatchvoid bindResultColumnToExpression() throws StandardException
StandardException
- Thrown on errorvoid setSourceTableName(java.lang.String t)
t
- The source table namevoid setSourceSchemaName(java.lang.String s)
s
- The source schema nameResultColumn 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 blockStandardException
- Thrown on errorvoid checkStorableExpression(ResultColumn toStore) throws StandardException
StandardException
- thrown if types not suitable.private void checkStorableExpression(ValueNode source) throws StandardException
StandardException
void checkStorableExpression() throws StandardException
StandardException
- thrown if types not suitable.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 intoStandardException
- Thrown on errorboolean columnTypeAndLengthMatch() throws StandardException
StandardException
boolean columnTypeAndLengthMatch(ResultColumn otherColumn) throws StandardException
StandardException
boolean isGenerated()
boolean isGeneratedForUnmatchedColumnInInsert()
void markGenerated()
void markGeneratedForUnmatchedColumnInInsert()
boolean isReferenced()
void setReferenced()
void pullVirtualIsReferenced()
void setUnreferenced()
void markAllRCsInChainReferenced()
boolean isRedundant()
void setRedundant()
void markAsGroupingColumn()
void rejectParameter() throws StandardException
StandardException
- Thrown if a ?/-?/+? parameter was found
directly under this ResultColumn.public int compareTo(ResultColumn other)
compareTo
in interface java.lang.Comparable<ResultColumn>
void markUpdated()
void markUpdatableByCursor()
boolean updated()
public boolean updatableByCursor()
updatableByCursor
in interface ResultColumnDescriptor
updatableByCursor
in class ValueNode
ResultColumn cloneMe() throws StandardException
StandardException
- Thrown on errorint 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 visitorStandardException
- on errorvoid verifyOrderable() throws StandardException
StandardException
- Thrown on errorColumnDescriptor getTableColumnDescriptor()
boolean isAutoincrementGenerated()
void setAutoincrementGenerated()
void resetAutoincrementGenerated()
public boolean isAutoincrement()
ResultColumnDescriptor
isAutoincrement
in interface ResultColumnDescriptor
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()
ColumnDescriptor getColumnDescriptor()
BaseColumnNode getBaseColumnNode()
int getTableNumber() throws StandardException
StandardException
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
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.