org.apache.derby.impl.sql.compile
Class ResultColumn

java.lang.Object
  extended by org.apache.derby.impl.sql.compile.QueryTreeNode
      extended by org.apache.derby.impl.sql.compile.ValueNode
          extended by org.apache.derby.impl.sql.compile.ResultColumn
All Implemented Interfaces:
java.lang.Comparable, Visitable, ResultColumnDescriptor
Direct Known Subclasses:
AllResultColumn

public class ResultColumn
extends ValueNode
implements ResultColumnDescriptor, java.lang.Comparable

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 org.apache.derby.impl.sql.compile.ValueNode
bindExpression, categorize, changeToCNF, checkIsBoolean, checkTopPredicatesForEqualsConditions, constantExpression, copyFields, eliminateNots, evaluateConstantExpressions, genEqualsFalseTree, generate, generateFilter, genIsNullTree, genSQLJavaSQLTree, getClone, getColumnName, getConstantValueAsObject, getDataValueFactory, getSourceResultColumn, getTablesReferenced, getTransformed, getTypeCompiler, getTypeId, init, isBinaryEqualsOperatorNode, isBooleanFalse, isBooleanTrue, isCloneable, isConstantExpression, isInListProbeNode, isParameterNode, isRelationalOperator, isSameNodeType, optimizableEqualityNode, putAndsOnTop, remapColumnReferencesToExpressions, requiresTypeFromContext, selectivity, setCollationInfo, setCollationInfo, setCollationUsingCompilationSchema, setCollationUsingCompilationSchema, setNullability, setTransformed, setType, setType, setType, verifyChangeToCNF, verifyEliminateNots, verifyPutAndsOnTop
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, bindOffsetFetch, bindRowMultiSet, bindUserType, checkReliability, checkReliability, convertDefaultNode, createTypeDependency, debugFlush, debugPrint, formatNodeString, foundString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, orReliability, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, stackPrint, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

java.lang.String name

exposedName

java.lang.String exposedName

tableName

java.lang.String tableName

sourceTableName

java.lang.String sourceTableName

sourceSchemaName

java.lang.String sourceSchemaName

expression

ValueNode expression

columnDescriptor

ColumnDescriptor columnDescriptor

isGenerated

boolean isGenerated

isGeneratedForUnmatchedColumnInInsert

boolean isGeneratedForUnmatchedColumnInInsert

isGroupingColumn

boolean isGroupingColumn

isReferenced

boolean isReferenced

isRedundant

boolean isRedundant

isNameGenerated

boolean isNameGenerated

updated

boolean updated

updatableByCursor

boolean updatableByCursor

defaultColumn

private boolean defaultColumn

wasDefault

private boolean wasDefault

autoincrementGenerated

boolean autoincrementGenerated

autoincrement

boolean autoincrement

resultSetNumber

private int resultSetNumber

reference

ColumnReference reference

virtualColumnId

private int virtualColumnId
Constructor Detail

ResultColumn

public ResultColumn()
Method Detail

init

public void init(java.lang.Object arg1,
                 java.lang.Object arg2)
          throws StandardException
Different types of initializer parameters indicate different types of initialization. Parameters may be:

- OR -

- OR -

- OR -

Overrides:
init in class QueryTreeNode
Throws:
StandardException - Thrown on error

isDefaultColumn

public boolean isDefaultColumn()
Returns TRUE if the ResultColumn is standing in for a DEFAULT keyword in an insert/update statement.


setDefaultColumn

public void setDefaultColumn(boolean value)

wasDefaultColumn

public boolean wasDefaultColumn()
Returns TRUE if the ResultColumn used to stand in for a DEFAULT keyword in an insert/update statement.


setWasDefaultColumn

public void setWasDefaultColumn(boolean value)

columnNameMatches

boolean columnNameMatches(java.lang.String columnName)
Return TRUE if this result column matches the provided column name. This function is used by ORDER BY column resolution. For the ORDER BY clause, Derby will prefer to match on the column's alias (exposedName), but will also successfully match on the underlying column name. Thus the following statements are treated equally: select name from person order by name; select name as person_name from person order by name; select name as person_name from person order by person_name; See DERBY-2351 for more discussion.


getSourceColumnName

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.


getName

public java.lang.String getName()
The following methods implement the ResultColumnDescriptor interface. See the Language Module Interface for details.

Specified by:
getName in interface ResultColumnDescriptor
Returns:
A String containing the name of the column.

getSchemaName

public java.lang.String getSchemaName()
                               throws StandardException
Description copied from class: ValueNode
This returns the user-supplied schema name of the column. At this class level, it simply returns null. But, the subclasses of ValueNode will overwrite this method to return the user-supplied schema name. When the value node is in a result column of a select list, the user can request metadata information. The result column won't have a column descriptor, so we return some default information through the expression. This lets expressions that are simply columns return all of the info, and others use this supertype's default values.

Overrides:
getSchemaName in class ValueNode
Returns:
the default schema name for an expression -- null
Throws:
StandardException

getTableName

public java.lang.String getTableName()
Description copied from class: ValueNode
This returns the user-supplied table name of the column. At this class level, it simply returns null. But, the subclasses of ValueNode will overwrite this method to return the user-supplied table name. When the value node is in a result column of a select list, the user can request metadata information. The result column won't have a column descriptor, so we return some default information through the expression. This lets expressions that are simply columns return all of the info, and others use this supertype's default values.

Overrides:
getTableName in class ValueNode
Returns:
the default table name for an expression -- null

getSourceTableName

public java.lang.String getSourceTableName()
Description copied from interface: ResultColumnDescriptor
Get the name of the underlying(base) table this column comes from, if any. Following example queries will all return T select a from t select b.a from t as b select t.a from t

Specified by:
getSourceTableName in interface ResultColumnDescriptor
Returns:
A String containing the name of the base table of the Column is in. If the column is not in a table (i.e. is a derived column), it returns NULL.
See Also:
ResultColumnDescriptor.getSourceTableName()

getSourceSchemaName

public java.lang.String getSourceSchemaName()
Description copied from interface: ResultColumnDescriptor
Get the name of the schema for the Column's base table, if any. Following example queries will all return APP (assuming user is in schema APP) select t.a from t select b.a from t as b select app.t.a from t

Specified by:
getSourceSchemaName in interface ResultColumnDescriptor
Returns:
The name of the schema of the Column's base table. If the column is not in a schema (i.e. is a derived column), it returns NULL.
See Also:
ResultColumnDescriptor.getSourceSchemaName()

clearTableName

public void clearTableName()
Clear the table name for the underlying ColumnReference. See UpdateNode.scrubResultColumns() for full explaination.


getType

public DataTypeDescriptor getType()
Description copied from interface: ResultColumnDescriptor
Returns a DataTypeDescriptor for the column. This DataTypeDescriptor will not represent an actual value, it will only represent the type that all values in the column will have.

Specified by:
getType in interface ResultColumnDescriptor
Returns:
A DataTypeDescriptor describing the type of the column.

getColumnPosition

public int getColumnPosition()
Description copied from interface: ResultColumnDescriptor
Get the position of the Column. NOTE - position is 1-based.

Specified by:
getColumnPosition in interface ResultColumnDescriptor
Returns:
An int containing the position of the Column within the table.

setExpression

public void setExpression(ValueNode expression)
Set the expression in this ResultColumn. This is useful in those cases where you don't know the expression in advance, like for INSERT statements with column lists, where the column list and SELECT or VALUES clause are parsed separately, and then have to be hooked up.

Parameters:
expression - The expression to be set in this ResultColumn

getExpression

public ValueNode getExpression()
Get the expression in this ResultColumn.

Returns:
ValueNode this.expression

setExpressionToNullNode

void setExpressionToNullNode()
                       throws StandardException
Set the expression to a null node of the correct type.

Throws:
StandardException - Thrown on error

setName

public void setName(java.lang.String name)
Set the name in this ResultColumn. This is useful when you don't know the name at the time you create the ResultColumn, for example, in an insert-select statement, where you want the names of the result columns to match the table being inserted into, not the table they came from.

Parameters:
name - The name to set in this ResultColumn

isNameGenerated

public boolean isNameGenerated()
Is the name for this ResultColumn generated?


setNameGenerated

public void setNameGenerated(boolean value)
Set that this result column name is generated.


setResultSetNumber

public void setResultSetNumber(int resultSetNumber)
Set the resultSetNumber for this ResultColumn. This is the resultSetNumber for the ResultSet that we belong to. This is useful for generate() and necessary since we do not have a back pointer to the RSN.

Parameters:
resultSetNumber - The resultSetNumber.

getResultSetNumber

public int getResultSetNumber()
Get the resultSetNumber for this ResultColumn.

Returns:
int The resultSetNumber.

adjustVirtualColumnId

public void adjustVirtualColumnId(int adjust)
Adjust the virtualColumnId for this ResultColumn by the specified amount

Parameters:
adjust - The adjustment for the virtualColumnId

setVirtualColumnId

public void setVirtualColumnId(int id)
Set the virtualColumnId for this ResultColumn

Parameters:
id - The virtualColumnId for this ResultColumn

getVirtualColumnId

public int getVirtualColumnId()
Get the virtualColumnId for this ResultColumn

Returns:
virtualColumnId for this ResultColumn

collapseVirtualColumnIdGap

public 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. If this column is a virtual column, and if this column's virtual column id is greater than the column id which is being removed, then we must logically shift this column to the left by decrementing its virtual column id.

Parameters:
removedColumnId - id of the column being removed.

guaranteeColumnName

public void guaranteeColumnName()
                         throws StandardException
Generate a unique (across the entire statement) column name for unnamed ResultColumns

Throws:
StandardException - Thrown on error

toString

public java.lang.String toString()
Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Overrides:
toString in class ValueNode
Returns:
This object as a String

printSubNodes

public void printSubNodes(int depth)
Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.

Overrides:
printSubNodes in class QueryTreeNode
Parameters:
depth - The depth of this node in the tree

bindExpression

public ValueNode bindExpression(FromList fromList,
                                SubqueryList subqueryList,
                                java.util.Vector aggregateVector)
                         throws StandardException
Bind this expression. This means binding the sub-expressions. In this case, we figure out what the result type of this result column is when we call one of the bindResultColumn*() methods. The reason is that there are different ways of binding the result columns depending on the statement type, and this is a standard interface that does not take the statement type as a parameter.

Overrides:
bindExpression in class ValueNode
Parameters:
fromList - The FROM list for the query this expression is in, for binding columns.
subqueryList - The subquery list being built as we find SubqueryNodes
aggregateVector - The aggregate vector being built as we find AggregateNodes
Returns:
The new top of the expression tree.
Throws:
StandardException - Thrown on error

bindResultColumnByPosition

void bindResultColumnByPosition(TableDescriptor tableDescriptor,
                                int columnId)
                          throws StandardException
Bind this result column by ordinal position and set the VirtualColumnId. This is useful for INSERT statements like "insert into t values (1, 2, 3)", where the user did not specify a column list. If a columnDescriptor is not found for a given position, then the user has specified more values than the # of columns in the table and an exception is thrown. NOTE: We must set the VirtualColumnId here because INSERT does not construct the ResultColumnList in the usual way.

Parameters:
tableDescriptor - The descriptor for the table being inserted into
columnId - The ordinal position of the column in the table, starting at 1.
Throws:
StandardException - Thrown on error

bindResultColumnByName

public void bindResultColumnByName(TableDescriptor tableDescriptor,
                                   int columnId)
                            throws StandardException
Bind this result column by its name and set the VirtualColumnId. This is useful for update statements, and for INSERT statements like "insert into t (a, b, c) values (1, 2, 3)" where the user specified a column list. An exception is thrown when a columnDescriptor cannot be found for a given name. (There is no column with that name.) NOTE: We must set the VirtualColumnId here because INSERT does not construct the ResultColumnList in the usual way.

Parameters:
tableDescriptor - The descriptor for the table being updated or inserted into
columnId - The ordinal position of the column in the table, starting at 1. (Used to set the VirtualColumnId.)
Throws:
StandardException - Thrown on error

typeUntypedNullExpression

public void typeUntypedNullExpression(ResultColumn bindingRC)
                               throws StandardException
Change an untyped null to a typed null.

Throws:
StandardException - Thrown on error

setColumnDescriptor

void setColumnDescriptor(TableDescriptor tableDescriptor,
                         ColumnDescriptor columnDescriptor)
                   throws StandardException
Set the column descriptor for this result column. It also gets the data type services from the column descriptor and stores it in this result column: this is redundant, but we have to store the result type here for SELECT statements, and it is more orthogonal if the type can be found here regardless of what type of statement it is.

Parameters:
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.
Throws:
StandardException - tableNameMismatch

bindResultColumnToExpression

public void bindResultColumnToExpression()
                                  throws StandardException
Bind the result column to the expression that lives under it. All this does is copy the datatype information to this node. This is useful for SELECT statements, where the result type of each column is the type of the column's expression.

Throws:
StandardException - Thrown on error

setSourceTableName

public void setSourceTableName(java.lang.String t)
Set the column source's table name

Parameters:
t - The source table name

setSourceSchemaName

public void setSourceSchemaName(java.lang.String s)
Set the column source's schema name

Parameters:
s - The source schema name

preprocess

public ValueNode preprocess(int numTables,
                            FromList outerFromList,
                            SubqueryList outerSubqueryList,
                            PredicateList outerPredicateList)
                     throws StandardException
Preprocess an expression tree. We do a number of transformations here (including subqueries, IN lists, LIKE and BETWEEN) plus subquery flattening. NOTE: This is done before the outer ResultSetNode is preprocessed.

Overrides:
preprocess in class ValueNode
Parameters:
numTables - Number of tables in the DML Statement
outerFromList - FromList from outer query block
outerSubqueryList - SubqueryList from outer query block
outerPredicateList - PredicateList from outer query block
Returns:
The modified expression
Throws:
StandardException - Thrown on error

checkStorableExpression

public void checkStorableExpression(ResultColumn toStore)
                             throws StandardException
This verifies that the expression is storable into the result column. It checks versus the given ResultColumn. This method should not be called until the result column and expression both have a valid type, i.e. after they are bound appropriately. Its use is for statements like insert, that need to verify if a given value can be stored into a column.

Throws:
StandardException - thrown if types not suitable.

checkStorableExpression

private void checkStorableExpression(ValueNode source)
                              throws StandardException
Throws:
StandardException

checkStorableExpression

public void checkStorableExpression()
                             throws StandardException
This verifies that the expression is storable into the result column. It checks versus the expression under this ResultColumn. This method should not be called until the result column and expression both have a valid type, i.e. after they are bound appropriately. Its use is for statements like update, that need to verify if a given value can be stored into a column.

Throws:
StandardException - thrown if types not suitable.

generateExpression

public void generateExpression(ExpressionClassBuilder ecb,
                               MethodBuilder mb)
                        throws StandardException
Do code generation for a result column. This consists of doing the code generation for the underlying expression.

Overrides:
generateExpression in class ValueNode
Parameters:
ecb - The ExpressionClassBuilder for the class we're generating
mb - The method the expression will go into
Throws:
StandardException - Thrown on error

generateHolder

public void generateHolder(ExpressionClassBuilder acb,
                           MethodBuilder mb)
                    throws StandardException
Generate the code to create a column the same shape and size as this ResultColumn. Used in ResultColumnList.generateHolder().

Throws:
StandardException - thrown on failure

columnTypeAndLengthMatch

boolean columnTypeAndLengthMatch()
                           throws StandardException
Check whether the column length and type of this result column match the expression under the columns. This is useful for INSERT and UPDATE statements. For SELECT statements this method should always return true. There is no need to call this for a DELETE statement.

Returns:
true means the column matches its expressions, false means it doesn't match.
Throws:
StandardException

columnTypeAndLengthMatch

boolean columnTypeAndLengthMatch(ResultColumn otherColumn)
                           throws StandardException
Throws:
StandardException

isGenerated

public boolean isGenerated()
Is this a generated column?

Returns:
Boolean - whether or not this column is a generated column.

isGeneratedForUnmatchedColumnInInsert

public boolean isGeneratedForUnmatchedColumnInInsert()
Is this columm generated for an unmatched column in an insert?

Returns:
Boolean - whether or not this columm was generated for an unmatched column in an insert.

markGenerated

public void markGenerated()
Mark this a columm as a generated column


markGeneratedForUnmatchedColumnInInsert

public void markGeneratedForUnmatchedColumnInInsert()
Mark this a columm as generated for an unmatched column in an insert


isReferenced

public boolean isReferenced()
Is this a referenced column?

Returns:
Boolean - whether or not this column is a referenced column.

setReferenced

public void setReferenced()
Mark this column as a referenced column.


pullVirtualIsReferenced

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.


setUnreferenced

public void setUnreferenced()
Mark this column as an unreferenced column.


markAllRCsInChainReferenced

void markAllRCsInChainReferenced()
Mark this RC and all RCs in the underlying RC/VCN chain as referenced.


isRedundant

public boolean isRedundant()
Is this a redundant ResultColumn?

Returns:
Boolean - whether or not this RC is redundant.

setRedundant

public void setRedundant()
Mark this ResultColumn as redundant.


markAsGroupingColumn

public void markAsGroupingColumn()
Mark this ResultColumn as a grouping column in the SELECT list


rejectParameter

void rejectParameter()
               throws StandardException
Look for and reject ?/-?/+? parameter under this ResultColumn. This is called for SELECT statements.

Throws:
StandardException - Thrown if a ?/-?/+? parameter was found directly under this ResultColumn.

compareTo

public int compareTo(java.lang.Object other)
Specified by:
compareTo in interface java.lang.Comparable

markUpdated

void markUpdated()
Mark this column as being updated by an update statemment.


markUpdatableByCursor

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


updated

boolean updated()
Tell whether this column is being updated.

Returns:
true means this column is being updated.

updatableByCursor

public boolean updatableByCursor()
Tell whether this column is updatable by a positioned update.

Specified by:
updatableByCursor in interface ResultColumnDescriptor
Overrides:
updatableByCursor in class ValueNode
Returns:
true means this column is updatable

disablePrivilegeCollection

public void disablePrivilegeCollection()
Description copied from class: QueryTreeNode
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. Based on this, any time a trigger/view/constraint is executing, we do not need to waste time in checking if the definer still has the right set of privileges. At compile time, we wil make sure that we do not collect the privilege requirement for objects accessed with definer privileges by calling the following method.

Overrides:
disablePrivilegeCollection in class QueryTreeNode
See Also:
QueryTreeNode.disablePrivilegeCollection()

cloneMe

ResultColumn cloneMe()
               throws StandardException
Make a copy of this ResultColumn in a new ResultColumn

Returns:
A new ResultColumn with the same contents as this one
Throws:
StandardException - Thrown on error

getMaximumColumnSize

public int getMaximumColumnSize()
Get the maximum size of the column

Returns:
the max size

getTypeServices

public DataTypeDescriptor getTypeServices()
Description copied from class: ValueNode
Get the DataTypeServices from this ValueNode.

Overrides:
getTypeServices in class ValueNode
Returns:
The DataTypeServices from this ValueNode. This may be null if the node isn't bound yet.

getOrderableVariantType

protected int getOrderableVariantType()
                               throws StandardException
Return the variant type for the underlying expression. The variant type can be: VARIANT - variant within a scan (method calls and non-static field access) SCAN_INVARIANT - invariant within a scan (column references from outer tables) QUERY_INVARIANT - invariant within the life of a query CONSTANT - constant

Overrides:
getOrderableVariantType in class ValueNode
Returns:
The variant type for the underlying expression.
Throws:
StandardException - thrown on error

acceptChildren

void acceptChildren(Visitor v)
              throws StandardException
Accept the visitor for all visitable children of this node.

Overrides:
acceptChildren in class QueryTreeNode
Parameters:
v - the visitor
Throws:
StandardException - on error

foundInList

public boolean foundInList(java.lang.String[] list)
Is this column in this array of strings?

Parameters:
list - the array of column names to compare
Returns:
true/false

verifyOrderable

void verifyOrderable()
               throws StandardException
Verify that this RC is orderable.

Throws:
StandardException - Thrown on error

getTableColumnDescriptor

ColumnDescriptor getTableColumnDescriptor()
If this ResultColumn is bound to a column in a table get the column descriptor for the column in the table. Otherwise return null.


isAutoincrementGenerated

public boolean isAutoincrementGenerated()
Returns true if this result column is a placeholder for a generated autoincrement value.


setAutoincrementGenerated

public void setAutoincrementGenerated()

resetAutoincrementGenerated

public void resetAutoincrementGenerated()

isAutoincrement

public boolean isAutoincrement()
Description copied from interface: ResultColumnDescriptor
Tell us if the column is an autoincrement column or not.

Specified by:
isAutoincrement in interface ResultColumnDescriptor
Returns:
TRUE, if the column is a base column of a table and is an autoincrement column.

setAutoincrement

public void setAutoincrement()

isGroupingColumn

public boolean isGroupingColumn()

convertConstant

private DataValueDescriptor convertConstant(TypeId toTypeId,
                                            int maxWidth,
                                            DataValueDescriptor constantValue)
                                     throws StandardException
Throws:
StandardException - Thrown on error

getTableNameObject

public TableName getTableNameObject()

getReference

public ColumnReference getReference()

getBaseColumnNode

public BaseColumnNode getBaseColumnNode()
Get the source BaseColumnNode for this result column. The BaseColumnNode cannot be found unless the ResultColumn is bound and is a simple reference to a column in a BaseFromTable.

Returns:
a BaseColumnNode, or null if a BaseColumnNode cannot be found

getTableNumber

public int getTableNumber()
                   throws StandardException
Search the tree beneath this ResultColumn until we find the number of the table to which this RC points, and return that table number. If we can't determine which table this RC is for, then return -1. There are two places we can find the table number: 1) if our expression is a ColumnReference, then we can get the target table number from the ColumnReference and that's it; 2) if expression is a VirtualColumnNode, then if the VirtualColumnNode points to a FromBaseTable, we can get that FBT's table number; otherwise, we walk the VirtualColumnNode-ResultColumn chain and do a recursive search.

Returns:
The number of the table to which this ResultColumn points, or -1 if we can't determine that from where we are.
Throws:
StandardException

isEquivalent

public boolean isEquivalent(ValueNode o)
                     throws StandardException
Description copied from class: ValueNode
Tests if this node is equivalent to the specified ValueNode. Two ValueNodes are considered equivalent if they will evaluate to the same value during query execution.

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:

Specified by:
isEquivalent in class ValueNode
Parameters:
o - the node to compare this ValueNode against.
Returns:
true if the two nodes are equivalent, false otherwise.
Throws:
StandardException

hasGenerationClause

public boolean hasGenerationClause()
Return true if this result column represents a generated column.

Specified by:
hasGenerationClause in interface ResultColumnDescriptor

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.