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

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.OrderedColumn
          extended byorg.apache.derby.impl.sql.compile.OrderByColumn
All Implemented Interfaces:
Visitable

public class OrderByColumn
extends OrderedColumn

An OrderByColumn is a column in the ORDER BY clause. An OrderByColumn can be ordered ascending or descending. We need to make sure that the named columns are columns in that query, and that positions are within range.

Author:
ames

Field Summary
private  boolean ascending
           
private  java.lang.String columnName
           
private  java.lang.String correlationName
           
private  ResultColumn resultCol
           
private  java.lang.String schemaName
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.OrderedColumn
columnPosition, UNMATCHEDPOSITION
 
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX, beginOffset, endOffset
 
Constructor Summary
OrderByColumn()
           
 
Method Summary
 void bindOrderByColumn(ResultSetNode target)
          Bind this column.
(package private)  boolean constantColumn(PredicateList whereClause)
          Is this OrderByColumn constant, according to the given predicate list?
 java.lang.String getColumnName()
          Get the name of this column
(package private)  ValueNode getNonRedundantExpression()
          Get the underlying expression, skipping over ResultColumns that are marked redundant.
(package private)  ResultColumn getResultColumn()
          Get the underlying ResultColumn.
 void init(java.lang.Object columnPosition)
          Initializer.
 void init(java.lang.Object columnName, java.lang.Object correlationName, java.lang.Object schemaName)
          Initializer.
 boolean isAscending()
          Get the column order.
 void pullUpOrderByColumn(ResultSetNode target)
          Pull up this orderby column if it doesn't appear in the resultset
(package private)  void remapColumnReferencesToExpressions()
          Remap all the column references under this OrderByColumn to their expressions.
(package private)  void resetToSourceRC()
          Order by columns now point to the PRN above the node of interest.
 void setDescending()
          Mark the column as descending order
 java.lang.String toString()
          Convert this object to a String.
 
Methods inherited from class org.apache.derby.impl.sql.compile.OrderedColumn
getColumnPosition, setColumnPosition
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
accept, bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, generate, generate, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContextManager, getCursorInfo, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getNodeFactory, getNodeType, getNullNode, getParameterTypes, getRowEstimate, getSchemaDescriptor, getSchemaDescriptor, getSPSName, getStatementType, getTableDescriptor, getTypeCompiler, init, init, init, init, init, init, init, init, init, init, init, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, printSubNodes, referencesSessionSchema, setBeginOffset, setContextManager, setEndOffset, setNodeType, setRefActionInfo, treePrint, treePrint, verifyClassExist
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

resultCol

private ResultColumn resultCol

columnName

private java.lang.String columnName

correlationName

private java.lang.String correlationName

schemaName

private java.lang.String schemaName

ascending

private boolean ascending
Constructor Detail

OrderByColumn

public OrderByColumn()
Method Detail

init

public void init(java.lang.Object columnName,
                 java.lang.Object correlationName,
                 java.lang.Object schemaName)
Initializer.

Overrides:
init in class QueryTreeNode
Parameters:
columnName - The name of the column being referenced
correlationName - The correlation name, if any

init

public void init(java.lang.Object columnPosition)
Initializer.

Overrides:
init in class QueryTreeNode
Parameters:
columnPosition - The position of the column being referenced

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 OrderedColumn
Returns:
This object as a String

getColumnName

public java.lang.String getColumnName()
Get the name of this column

Returns:
The name of this column

setDescending

public void setDescending()
Mark the column as descending order


isAscending

public boolean isAscending()
Get the column order. Overrides OrderedColumn.isAscending.

Overrides:
isAscending in class OrderedColumn
Returns:
true if ascending, false if descending

getResultColumn

ResultColumn getResultColumn()
Get the underlying ResultColumn.

Returns:
The underlying ResultColumn.

getNonRedundantExpression

ValueNode getNonRedundantExpression()
Get the underlying expression, skipping over ResultColumns that are marked redundant.


bindOrderByColumn

public void bindOrderByColumn(ResultSetNode target)
                       throws StandardException
Bind this column.

Parameters:
target - The result set being selected from
Throws:
StandardException - Thrown on error
StandardException - Thrown when column not found

pullUpOrderByColumn

public void pullUpOrderByColumn(ResultSetNode target)
                         throws StandardException
Pull up this orderby column if it doesn't appear in the resultset

Parameters:
target - The result set being selected from
Throws:
StandardException

resetToSourceRC

void resetToSourceRC()
Order by columns now point to the PRN above the node of interest. We need them to point to the RCL under that one. This is useful when combining sorts where we need to reorder the sorting columns.

Returns:
Nothing.

constantColumn

boolean constantColumn(PredicateList whereClause)
Is this OrderByColumn constant, according to the given predicate list? A constant column is one where all the column references it uses are compared equal to constants.


remapColumnReferencesToExpressions

void remapColumnReferencesToExpressions()
                                  throws StandardException
Remap all the column references under this OrderByColumn to their expressions.

Throws:
StandardException - Thrown on error


Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.