Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

pack-priv Class ResultColumn

extends ValueNode
implements ResultColumnDescriptor, Comparable<ResultColumn>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, org.apache.derby.iapi.sql.ResultColumnDescriptor
Known Direct Subclasses
org.apache.derby.impl.sql.compile.AllResultColumn
Imports
java.util.List, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.iapi.services.io.StoredFormatIds, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.ResultColumnDescriptor, org.apache.derby.iapi.sql.compile.Visitor, org.apache.derby.iapi.sql.dictionary.ColumnDescriptor, .TableDescriptor, org.apache.derby.iapi.store.access.Qualifier, org.apache.derby.iapi.types.DataTypeDescriptor, .DataValueDescriptor, .DataValueFactory, .StringDataValue, .TypeId, org.apache.derby.iapi.util.StringUtil

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 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.

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private ColumnDescriptor
private String
private ValueNode
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private ColumnReference
private String
private String
private String
private String
private boolean
private boolean
private boolean
private JoinNode
private int
private boolean
private int
private boolean
Inherited from org.apache.derby.impl.sql.compile.ValueNode:
transformed

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
ResultColumn(String
The name of the column, if any.
underlyingName
,
ValueNode
The expression this result column represents
expression
,
ContextManager
context manager
cm
)

pack-priv
ResultColumn(ColumnReference
A column reference node
cr
,
ValueNode
The expression this result column represents
expression
,
ContextManager
context manager
cm
)

pack-priv
ResultColumn(ColumnDescriptor
The column descriptor
cd
,
ValueNode
The expression this result column represents
expression
,
ContextManager
context manager
cm
)

pack-priv
ResultColumn(DataTypeDescriptor
The type of the column
dtd
,
ValueNode
The expression this result column represents
expression
,
ContextManager
context manager
cm
)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
acceptChildren(Visitor
the visitor
v
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.acceptChildren.

Accept the visitor for all visitable children of this node.

pack-priv void
adjustVirtualColumnId(int
The adjustment for the virtualColumnId
adjust
)

Adjust the virtualColumnId for this ResultColumn by the specified amount

pack-priv ResultColumn

Returns:

The new top of the expression tree.
bindExpression
(FromList
The FROM list for the query this expression is in, for binding columns.
fromList
,
SubqueryList
The subquery list being built as we find SubqueryNodes
subqueryList
,
List<AggregateNode>
The aggregate list being built as we find AggregateNodes
aggregates
)

Overrides org.apache.derby.impl.sql.compile.ValueNode.bindExpression.

Bind this expression.

pack-priv void
bindResultColumnByName(TableDescriptor
The descriptor for the table being updated or inserted into
tableDescriptor
,
int
The ordinal position of the column in the table, starting at 1. (Used to set the VirtualColumnId.)
columnId
)

Bind this result column by its name and set the VirtualColumnId.

pack-priv void
bindResultColumnByPosition(TableDescriptor
The descriptor for the table being inserted into
tableDescriptor
,
int
The ordinal position of the column in the table, starting at 1.
columnId
)

Bind this result column by ordinal position and set the VirtualColumnId.

pack-priv void
bindResultColumnToExpression()

Bind the result column to the expression that lives under it.

pack-priv void
checkStorableExpression(ResultColumn toStore)

This verifies that the expression is storable into the result column.

private void
pack-priv void
checkStorableExpression()

This verifies that the expression is storable into the result column.

pack-priv void
clearTableName()

Clear the table name for the underlying ColumnReference.

pack-priv ResultColumn

Returns:

A new ResultColumn with the same contents as this one
cloneMe
()

Make a copy of this ResultColumn in a new ResultColumn

pack-priv void
collapseVirtualColumnIdGap(int
id of the column being removed.
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.

pack-priv boolean
columnNameMatches(String columnName)

Return TRUE if this result column matches the provided column name.

pack-priv boolean

Returns:

true means the column matches its expressions, false means it doesn't match.
columnTypeAndLengthMatch
()

Check whether the column length and type of this result column match the expression under the columns.

pack-priv boolean
public int
compareTo(ResultColumn
the object to be compared.
other
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

private DataValueDescriptor
convertConstant(TypeId toTypeId, int maxWidth, DataValueDescriptor constantValue)

pack-priv void
generateExpression(ExpressionClassBuilder
The ExpressionClassBuilder for the class we're generating
ecb
,
MethodBuilder
The method the expression will go into
mb
)

Overrides org.apache.derby.impl.sql.compile.ValueNode.generateExpression.

Do code generation for a result column.

pack-priv BaseColumnNode

Returns:

a BaseColumnNode, or null if a BaseColumnNode cannot be found
getBaseColumnNode
()

Get the source BaseColumnNode for this result column.

pack-priv ColumnDescriptor
getColumnDescriptor()

Get the column descriptor

public int
pack-priv ValueNode

Returns:

ValueNode this.expression
getExpression
()

Get the expression in this ResultColumn.

pack-priv 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.

pack-priv int

Returns:

the max size
getMaximumColumnSize
()

Get the maximum size of the column

public String
getName()

Implements org.apache.derby.iapi.sql.ResultColumnDescriptor.getName.

The following methods implement the ResultColumnDescriptor interface.

protected int

Returns:

The variant type for the underlying expression.
getOrderableVariantType
()

Overrides org.apache.derby.impl.sql.compile.ValueNode.getOrderableVariantType.

Return the variant type for the underlying expression.

public ColumnReference
public int

Returns:

int The resultSetNumber.
getResultSetNumber
()

Get the resultSetNumber for this ResultColumn.

pack-priv String
getSchemaName()

Overrides org.apache.derby.impl.sql.compile.ValueNode.getSchemaName.

This returns the user-supplied schema name of the column.

pack-priv String
getSourceColumnName()

Returns the underlying source column name, if this ResultColumn is a simple direct reference to a table column, or NULL otherwise.

public String
getSourceSchemaName()

Implements org.apache.derby.iapi.sql.ResultColumnDescriptor.getSourceSchemaName.

Get the name of the schema for the Column's base table, if any.

public String
getSourceTableName()

Implements org.apache.derby.iapi.sql.ResultColumnDescriptor.getSourceTableName.

Get the name of the underlying(base) table this column comes from, if any.

pack-priv ColumnDescriptor
getTableColumnDescriptor()

If this ResultColumn is bound to a column in a table get the column descriptor for the column in the table.

pack-priv String
getTableName()

Overrides org.apache.derby.impl.sql.compile.ValueNode.getTableName.

This returns the user-supplied table name of the column.

public TableName
pack-priv int

Returns:

The number of the table to which this ResultColumn points, or -1 if we can't determine that from where we are.
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.

public DataTypeDescriptor
getType()

Implements org.apache.derby.iapi.sql.ResultColumnDescriptor.getType.

Returns a DataTypeDescriptor for the column.

public DataTypeDescriptor
getTypeServices()

Overrides org.apache.derby.impl.sql.compile.ValueNode.getTypeServices.

Get the DataTypeServices from this ValueNode.

pack-priv String
getUnderlyingOrAliasName()

Get non-null column name.

pack-priv int

Returns:

virtualColumnId for this ResultColumn
getVirtualColumnId
()

Get the virtualColumnId for this ResultColumn

pack-priv void
guaranteeColumnName()

Generate a unique (across the entire statement) column name for unnamed ResultColumns

public boolean
hasGenerationClause()

Implements org.apache.derby.iapi.sql.ResultColumnDescriptor.hasGenerationClause.

Return true if this result column represents a generated column.

public boolean
isAutoincrement()

Implements org.apache.derby.iapi.sql.ResultColumnDescriptor.isAutoincrement.

Tell us if the column is an autoincrement column or not.

pack-priv boolean
isAutoincrementGenerated()

Returns true if this result column is a placeholder for a generated autoincrement value.

pack-priv boolean
isDefaultColumn()

Returns TRUE if the ResultColumn is standing in for a DEFAULT keyword in an insert/update statement.

pack-priv boolean
isEquivalent(ValueNode
the node to compare this ValueNode against.
o
)

Implements abstract org.apache.derby.impl.sql.compile.ValueNode.isEquivalent.

Tests if this node is equivalent to the specified ValueNode.

pack-priv boolean

Returns:

Boolean - whether or not this column is a generated column.
isGenerated
()

Is this a generated column?

pack-priv boolean

Returns:

Boolean - whether or not this columm was generated for an unmatched column in an insert.
isGeneratedForUnmatchedColumnInInsert
()

Is this columm generated for an unmatched column in an insert?

public boolean
pack-priv boolean
isNameGenerated()

Is the name for this ResultColumn generated?

pack-priv boolean

Returns:

Boolean - whether or not this RC is redundant.
isRedundant
()

Is this a redundant ResultColumn?

pack-priv boolean

Returns:

Boolean - whether or not this column is a referenced column.
isReferenced
()

Is this a referenced column?

pack-priv boolean
isRightOuterJoinUsingClause()

Returns TRUE if the ResultColumn is join column for a RIGHT OUTER JOIN with USING/NATURAL.

pack-priv boolean

Returns:

true if this result column is updatable.
isUpdatable
()

Returns true if this column is updatable.

pack-priv void
markAllRCsInChainReferenced()

Mark this RC and all RCs in the underlying RC/VCN chain as referenced.

pack-priv void
markAsGroupingColumn()

Mark this ResultColumn as a grouping column in the SELECT list

pack-priv void
markGenerated()

Mark this a columm as a generated column

pack-priv void
markGeneratedForUnmatchedColumnInInsert()

Mark this a columm as generated for an unmatched column in an insert

pack-priv void
markUpdatableByCursor()

Mark this column as being updatable, so we can make sure it is in the "for update" list of a positioned update.

pack-priv void
markUpdated()

Mark this column as being updated by an update statement.

pack-priv ResultColumn

Returns:

The modified expression
preprocess
(int
Number of tables in the DML Statement
numTables
,
FromList
FromList from outer query block
outerFromList
,
SubqueryList
SubqueryList from outer query block
outerSubqueryList
,
PredicateList
PredicateList from outer query block
outerPredicateList
)

Overrides org.apache.derby.impl.sql.compile.ValueNode.preprocess.

Preprocess an expression tree.

pack-priv void
printSubNodes(int
The depth of this node in the tree
depth
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.printSubNodes.

Prints the sub-nodes of this object.

pack-priv 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.

pack-priv void
rejectParameter()

Look for and reject ?/-?/+?

pack-priv void
pack-priv void
pack-priv void
pack-priv void
setColumnDescriptor(TableDescriptor
The TableDescriptor for the table being updated or inserted into. This parameter is used only for error reporting.
tableDescriptor
,
ColumnDescriptor
The ColumnDescriptor to set in this ResultColumn.
columnDescriptor
)

Set the column descriptor for this result column.

pack-priv void
setDefaultColumn(boolean value)

pack-priv void
setExpression(ValueNode
The expression to be set in this ResultColumn
expression
)

Set the expression in this ResultColumn.

pack-priv void
setExpressionToNullNode()

Set the expression to a null node of the correct type.

pack-priv void
setJoinResultset(JoinNode
- The ResultColumn belongs to this 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.

pack-priv void
setName(String
The name to set in this ResultColumn
name
)

Set the name in this ResultColumn.

pack-priv void
setNameGenerated(boolean value)

Set that this result column name is generated.

pack-priv void
setRedundant()

Mark this ResultColumn as redundant.

pack-priv void
setReferenced()

Mark this column as a referenced column.

pack-priv void
setResultSetNumber(int
The resultSetNumber.
resultSetNumber
)

Set the resultSetNumber for this ResultColumn.

pack-priv void
setRightOuterJoinUsingClause(boolean
True/False
value
)

Will be set to TRUE if this ResultColumn is join column for a RIGHT OUTER JOIN with USING/NATURAL.

pack-priv void
setSourceSchemaName(String
The source schema name
s
)

Set the column source's schema name

pack-priv void
setSourceTableName(String
The source table name
t
)

Set the column source's table name

private void
pack-priv void
setUnreferenced()

Mark this column as an unreferenced column.

pack-priv void
setVirtualColumnId(int
The virtualColumnId for this ResultColumn
id
)

Set the virtualColumnId for this ResultColumn

pack-priv void
setWasDefaultColumn(boolean value)

public String

Returns:

This object as a String
toString
()

Overrides org.apache.derby.impl.sql.compile.ValueNode.toString.

Convert this object to a String.

pack-priv void
typeUntypedNullExpression(ResultColumn bindingRC)

Change an untyped null to a typed null.

public boolean

Returns:

true means this column is updatable
updatableByCursor
()

Overrides org.apache.derby.impl.sql.compile.ValueNode.updatableByCursor.

Implements org.apache.derby.iapi.sql.ResultColumnDescriptor.updatableByCursor.

Tell whether this column is updatable by a positioned update.

pack-priv boolean

Returns:

true means this column is being updated.
updated
()

Tell whether this column is being updated.

pack-priv void
verifyOrderable()

Verify that this RC is orderable.

pack-priv boolean
wasDefaultColumn()

Returns TRUE if the ResultColumn used to stand in for a DEFAULT keyword in an insert/update statement.

Inherited from org.apache.derby.impl.sql.compile.ValueNode:
bindExpressioncategorizechangeToCNFcheckIsBooleancheckTopPredicatesForEqualsConditionsconstantExpressioncopyFieldseliminateNotsevaluateConstantExpressionsgenEqualsFalseTreegenerategenIsNullTreegenSQLJavaSQLTreegetClonegetColumnNamegetConstantValueAsObjectgetDataValueFactorygetSourceResultColumngetTablesReferencedgetTransformedgetTypeCompilergetTypeIdisBinaryEqualsOperatorNodeisBooleanFalseisBooleanTrueisCloneableisConstantExpressionisInListProbeNodeisParameterNodeisRelationalOperatorisSameNodeKindoptimizableEqualityNodeputAndsOnTopremapColumnReferencesToExpressionsrequiresTypeFromContextselectivitysetCollationInfosetCollationInfosetCollationUsingCompilationSchemasetCollationUsingCompilationSchemasetNullabilitysetTransformedsetTypesetTypesetTypeverifyChangeToCNFverifyEliminateNotsverifyPutAndsOnTop