Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.impl.sql.compile
Class CurrentOfNode  view CurrentOfNode download CurrentOfNode.java

java.lang.Object
  extended byorg.apache.derby.impl.sql.compile.QueryTreeNode
      extended byorg.apache.derby.impl.sql.compile.ResultSetNode
          extended byorg.apache.derby.impl.sql.compile.FromTable
              extended byorg.apache.derby.impl.sql.compile.CurrentOfNode
All Implemented Interfaces:
org.apache.derby.iapi.sql.compile.Optimizable, org.apache.derby.iapi.sql.compile.Visitable

public final class CurrentOfNode
extends FromTable

The CurrentOf operator is used by positioned DELETE and UPDATE to get the current row and location for the target cursor. The bind() operations for positioned DELETE and UPDATE add a column to the select list under the statement for the row location accessible from this node. This node is placed in the from clause of the select generated for the delete or update operation. It acts much like a FromBaseTable, using the information about the target table of the cursor to provide information.


Field Summary
private  TableName baseTableName
           
private  java.lang.String cursorName
           
private  TableName exposedTableName
           
private  org.apache.derby.iapi.sql.execute.ExecPreparedStatement preStmt
           
private  org.apache.derby.iapi.sql.compile.CostEstimate singleScanCostEstimate
           
 
Fields inherited from class org.apache.derby.impl.sql.compile.FromTable
bestAccessPath, bestCostEstimate, bestSortAvoidancePath, correlationName, corrTableName, currentAccessPath, hashKeyColumns, initialCapacity, level, loadFactor, maxCapacity, tableNumber, tableProperties, trulyTheBestAccessPath, userSpecifiedJoinStrategy
 
Fields inherited from class org.apache.derby.impl.sql.compile.ResultSetNode
costEstimate, cursorTargetTable, insertSource, optimizer, referencedTableMap, resultColumns, resultSetNumber, scratchCostEstimate, statementResultSet
 
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
CurrentOfNode()
           
 
Method Summary
 void bindExpressions(FromList fromListParam)
          Bind the expressions in this ResultSetNode.
 ResultSetNode bindNonVTITables(org.apache.derby.iapi.sql.dictionary.DataDictionary dataDictionary, FromList fromListParam)
          Binding this FromTable means finding the prepared statement for the cursor and creating the result columns (the columns updatable on that cursor).
 org.apache.derby.iapi.sql.compile.CostEstimate estimateCost(org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList, org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd, org.apache.derby.iapi.sql.compile.CostEstimate outerCost, org.apache.derby.iapi.sql.compile.Optimizer optimizer, org.apache.derby.iapi.sql.compile.RowOrdering rowOrdering)
          Estimate the cost of scanning this Optimizable using the given predicate list with the given conglomerate.
 void generate(ActivationClassBuilder acb, org.apache.derby.iapi.services.compiler.MethodBuilder mb)
          Generation on a CurrentOfNode creates a scan on the cursor, CurrentOfResultSet.
 TableName getBaseCursorTargetTableName()
           
 java.lang.String getCursorName()
           
(package private)  org.apache.derby.iapi.sql.execute.ExecPreparedStatement getCursorStatement()
          Return the CursorNode associated with a positioned update/delete.
 java.lang.String getExposedName()
          Get the exposed name for this table, which is the name that can be used to refer to it in the rest of the query.
 TableName getExposedTableName()
           
 ResultColumn getMatchingColumn(ColumnReference columnReference)
          Try to find a ResultColumn in the table represented by this CurrentOfNode that matches the name in the given ColumnReference.
 void init(java.lang.Object cursor, java.lang.Object tableProperties)
          Initializer for a table in a FROM list.
 ResultSetNode optimize(org.apache.derby.iapi.sql.dictionary.DataDictionary dataDictionary, PredicateList predicateList, double outerRows)
          Optimize this CurrentOfNode.
 ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList)
          Preprocess a CurrentOfNode.
 void printSubNodes(int depth)
          Prints the sub-nodes of this object.
 java.lang.String toString()
          Convert this object to a String.
 int updateTargetLockMode()
          Get the lock mode for this table as the target of an update statement (a delete or update).
 
Methods inherited from class org.apache.derby.impl.sql.compile.FromTable
areAllColumnsProjected, assignCostEstimate, canBeOrdered, considerSortAvoidancePath, convertAbsoluteToRelativeColumnPosition, cursorTargetTable, decrementLevel, feasibleJoinStrategy, fillInReferencedTableMap, flatten, forUpdate, getBaseTableName, getBestAccessPath, getBestSortAvoidancePath, getCostEstimate, getCurrentAccessPath, getFromTableByName, getLevel, getName, getNumColumnsReturned, getProperties, getResultColumnsForList, getSchemaDescriptor, getSchemaDescriptor, getScratchCostEstimate, getTableDescriptor, getTableName, getTableNumber, getTrulyTheBestAccessPath, getUserSpecifiedJoinStrategy, hashKeyColumns, hasTableNumber, initAccessPaths, initialCapacity, isBaseTable, isCoveringIndex, isFlattenableJoinNode, isMaterializable, isOneRowScan, isTargetTable, legalJoinOrder, loadFactor, LOJ_reorderable, markUpdatableByCursor, maxCapacity, memoryUsageOK, modifyAccessPath, needsSpecialRCLBinding, nextAccessPath, optimizeIt, optimizeSubqueries, pullOptPredicates, pushExpressions, pushOptPredicate, rememberAsBest, rememberJoinStrategyAsBest, rememberSortAvoidancePath, resetJoinStrategies, setAllColumnsProjected, setCostEstimate, setHashKeyColumns, setLevel, setProperties, setTableNumber, startOptimizing, supportsMultipleInstantiations, tellRowOrderingAboutConstantColumns, transformOuterJoins, uniqueJoin, verifyProperties
 
Methods inherited from class org.apache.derby.impl.sql.compile.ResultSetNode
accept, addNewPredicate, assignResultSetNumber, bindExpressionsWithTables, bindResultColumns, bindResultColumns, bindTargetExpressions, bindUntypedNullsToResultColumns, bindVTITables, changeAccessPath, closeMethodArgument, columnTypesAndLengthsMatch, considerMaterialization, enhanceRCLForInsert, ensurePredicateList, flattenableInFromSubquery, generateNormalizationResultSet, generateResultSet, genNewRCForInsert, genNormalizeResultSetNode, genProjectRestrict, genProjectRestrict, genProjectRestrictForReordering, getAllResultColumns, getCostEstimate, getCursorTargetTable, getFinalCostEstimate, getFromList, getNewCostEstimate, getOptimizer, getReferencedTableMap, getResultColumns, getResultSetNumber, isNotExists, isOneRowResultSet, isOrderedOn, isPossibleDistinctScan, isUpdatableCursor, LOJgetReferencedTables, makeResultDescription, makeResultDescriptors, markAsCursorTargetTable, markForDistinctScan, markOrderingDependent, markStatementResultSet, modifyAccessPaths, notCursorTargetTable, notFlattenableJoin, numDistinctAggregates, parseDefault, performMaterialization, projectResultColumns, pushOrderByList, referencesTarget, rejectParameters, rejectXMLValues, renameGeneratedResultNames, replaceDefaults, returnsAtMostOneRow, setInsertSource, setReferencedTableMap, setResultColumns, setResultToBooleanTrueNode, setTableConstructorTypes, subqueryReferencesTarget, verifySelectStarSubquery
 
Methods inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
bind, convertDefaultNode, debugFlush, debugPrint, executeSchemaName, executeStatementName, formatNodeString, foundString, 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, makeTableName, needsSavepoint, nodeHeader, optimize, parseQueryText, printLabel, 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
 
Methods inherited from interface org.apache.derby.iapi.sql.compile.Optimizable
getDataDictionary, getReferencedTableMap, getResultSetNumber
 

Field Detail

cursorName

private java.lang.String cursorName

preStmt

private org.apache.derby.iapi.sql.execute.ExecPreparedStatement preStmt

exposedTableName

private TableName exposedTableName

baseTableName

private TableName baseTableName

singleScanCostEstimate

private org.apache.derby.iapi.sql.compile.CostEstimate singleScanCostEstimate
Constructor Detail

CurrentOfNode

public CurrentOfNode()
Method Detail

init

public void init(java.lang.Object cursor,
                 java.lang.Object tableProperties)
Description copied from class: FromTable
Initializer for a table in a FROM list.

Overrides:
init in class FromTable

estimateCost

public org.apache.derby.iapi.sql.compile.CostEstimate estimateCost(org.apache.derby.iapi.sql.compile.OptimizablePredicateList predList,
                                                                   org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor cd,
                                                                   org.apache.derby.iapi.sql.compile.CostEstimate outerCost,
                                                                   org.apache.derby.iapi.sql.compile.Optimizer optimizer,
                                                                   org.apache.derby.iapi.sql.compile.RowOrdering rowOrdering)
                                                            throws org.apache.derby.iapi.error.StandardException
Description copied from interface: org.apache.derby.iapi.sql.compile.Optimizable
Estimate the cost of scanning this Optimizable using the given predicate list with the given conglomerate. It is assumed that the predicate list has already been classified. This cost estimate is just for one scan, not for the life of the query.

Specified by:
estimateCost in interface org.apache.derby.iapi.sql.compile.Optimizable
Overrides:
estimateCost in class FromTable

bindNonVTITables

public ResultSetNode bindNonVTITables(org.apache.derby.iapi.sql.dictionary.DataDictionary dataDictionary,
                                      FromList fromListParam)
                               throws org.apache.derby.iapi.error.StandardException
Binding this FromTable means finding the prepared statement for the cursor and creating the result columns (the columns updatable on that cursor). We expect someone else to verify that the target table of the positioned update or delete is the table under this cursor.

Overrides:
bindNonVTITables in class ResultSetNode

bindExpressions

public void bindExpressions(FromList fromListParam)
Bind the expressions in this ResultSetNode. This means binding the sub-expressions, as well as figuring out what the return type is for each expression.

Overrides:
bindExpressions in class ResultSetNode

getMatchingColumn

public ResultColumn getMatchingColumn(ColumnReference columnReference)
                               throws org.apache.derby.iapi.error.StandardException
Try to find a ResultColumn in the table represented by this CurrentOfNode that matches the name in the given ColumnReference.

Overrides:
getMatchingColumn in class ResultSetNode

preprocess

public ResultSetNode preprocess(int numTables,
                                GroupByList gbl,
                                FromList fromList)
                         throws org.apache.derby.iapi.error.StandardException
Preprocess a CurrentOfNode. For a CurrentOfNode, this simply means allocating a referenced table map to avoid downstream NullPointerExceptions. NOTE: There are no bits set in the referenced table map.

Overrides:
preprocess in class ResultSetNode

optimize

public ResultSetNode optimize(org.apache.derby.iapi.sql.dictionary.DataDictionary dataDictionary,
                              PredicateList predicateList,
                              double outerRows)
                       throws org.apache.derby.iapi.error.StandardException
Optimize this CurrentOfNode. Nothing to do.

Overrides:
optimize in class ResultSetNode

generate

public void generate(ActivationClassBuilder acb,
                     org.apache.derby.iapi.services.compiler.MethodBuilder mb)
              throws org.apache.derby.iapi.error.StandardException
Generation on a CurrentOfNode creates a scan on the cursor, CurrentOfResultSet.

This routine will generate and return a call of the form:


                ResultSetFactory.getCurrentOfResultSet(cursorName)
           

Overrides:
generate in class QueryTreeNode

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 ResultSetNode

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 FromTable

getExposedName

public java.lang.String getExposedName()
Description copied from class: FromTable
Get the exposed name for this table, which is the name that can be used to refer to it in the rest of the query.

Overrides:
getExposedName in class FromTable

getExposedTableName

public TableName getExposedTableName()

getBaseCursorTargetTableName

public TableName getBaseCursorTargetTableName()

getCursorName

public java.lang.String getCursorName()

getCursorStatement

org.apache.derby.iapi.sql.execute.ExecPreparedStatement getCursorStatement()
Return the CursorNode associated with a positioned update/delete.


updateTargetLockMode

public int updateTargetLockMode()
Get the lock mode for this table as the target of an update statement (a delete or update). This is implemented only for base tables and CurrentOfNodes.

Overrides:
updateTargetLockMode in class ResultSetNode