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  int addedColumnOffset
          If this sort key is added to the result column list then it is at result column position 1 + resultColumnList.size() - resultColumnList.getOrderBySelect() + addedColumnOffset If the sort key is already in the result column list then addedColumnOffset < 0.
private  boolean ascending
           
private  ValueNode expression
           
private  ResultColumn resultCol
           
 
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?
(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 expression)
          Initializer.
 boolean isAscending()
          Get the column order.
private static boolean isReferedColByNum(ValueNode expression)
           
 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.
private  void resolveAddedColumn(ResultSetNode target)
           
private  ResultColumn resolveColumnReference(ResultSetNode target, ColumnReference cr)
           
 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, init, isAtomic, isInstanceOf, isSessionSchema, isSessionSchema, makeConstantAction, makeResultDescription, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, printSubNodes, referencesSessionSchema, resolveTableToSynonym, 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

ascending

private boolean ascending

expression

private ValueNode expression

addedColumnOffset

private int addedColumnOffset
If this sort key is added to the result column list then it is at result column position 1 + resultColumnList.size() - resultColumnList.getOrderBySelect() + addedColumnOffset If the sort key is already in the result column list then addedColumnOffset < 0.

Constructor Detail

OrderByColumn

public OrderByColumn()
Method Detail

init

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

Overrides:
init in class QueryTreeNode
Parameters:
expression - Expression of this column

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

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

resolveAddedColumn

private void resolveAddedColumn(ResultSetNode target)

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

isReferedColByNum

private static boolean isReferedColByNum(ValueNode expression)
                                  throws StandardException
Throws:
StandardException

resolveColumnReference

private ResultColumn resolveColumnReference(ResultSetNode target,
                                            ColumnReference cr)
                                     throws StandardException
Throws:
StandardException

Built on Mon 2007-06-04 09:58:47+0400, from revision ???

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