Class CurrentOfNode
java.lang.Object
org.apache.derby.impl.sql.compile.QueryTreeNode
org.apache.derby.impl.sql.compile.ResultSetNode
org.apache.derby.impl.sql.compile.FromTable
org.apache.derby.impl.sql.compile.CurrentOfNode
- All Implemented Interfaces:
Optimizable, Visitable
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class ResultSetNode
ResultSetNode.QueryExpressionClauses -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TableNameprivate Stringprivate FromBaseTableprivate TableNameprivate ExecPreparedStatementprivate CostEstimateFields inherited from class FromTable
ADD_PLAN, bestAccessPath, bestCostEstimate, bestSortAvoidancePath, correlationName, corrTableName, currentAccessPath, hashKeyColumns, initialCapacity, level, LOAD_PLAN, loadFactor, maxCapacity, origTableName, REMOVE_PLAN, tableNumber, tableProperties, trulyTheBestAccessPath, userSpecifiedJoinStrategyFields inherited from class QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX -
Constructor Summary
ConstructorsConstructorDescriptionCurrentOfNode(String correlationName, String cursor, Properties tableProperties, ContextManager cm) -
Method Summary
Modifier and TypeMethodDescription(package private) voidAccept the visitor for all visitable children of this node.(package private) voidbindExpressions(FromList fromListParam) Bind the expressions in this ResultSetNode.(package private) ResultSetNodebindNonVTITables(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).estimateCost(OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, RowOrdering rowOrdering) Estimate the cost of scanning this Optimizable using the given predicate list with the given conglomerate.(package private) voidgenerate(ActivationClassBuilder acb, MethodBuilder mb) Generation on a CurrentOfNode creates a scan on the cursor, CurrentOfResultSet.(package private) TableName(package private) String(package private) ExecPreparedStatementReturn the CursorNode associated with a positioned update/delete.(package private) StringGet the exposed name for this table, which is the name that can be used to refer to it in the rest of the query.(package private) TableName(package private) ResultColumngetMatchingColumn(ColumnReference columnReference) Try to find a ResultColumn in the table represented by this CurrentOfNode that matches the name in the given ColumnReference.(package private) static CurrentOfNodemakeForMerge(String cursorName, FromBaseTable dummyTargetTable, ContextManager cm) Construct a dummy CurrentOfNode just for compiling the DELETE action of a MERGE statement.(package private) ResultSetNodeoptimize(DataDictionary dataDictionary, PredicateList predicateList, double outerRows) Optimize this CurrentOfNode.(package private) ResultSetNodepreprocess(int numTables, GroupByList gbl, FromList fromList) Preprocess a CurrentOfNode.(package private) voidprintSubNodes(int depth) Prints the sub-nodes of this object.toString()Convert this object to a String.intGet the lock mode for this table as the target of an update statement (a delete or update).Methods inherited from class FromTable
assignCostEstimate, canBeOrdered, columnsAreUpdatable, considerSortAvoidancePath, convertAbsoluteToRelativeColumnPosition, cursorTargetTable, decrementLevel, feasibleJoinStrategy, fillInReferencedTableMap, flatten, forUpdate, getBaseTableName, getBestAccessPath, getBestSortAvoidancePath, getCorrelationName, getCostEstimate, getCurrentAccessPath, getFinalCostEstimate, getFromTableByName, getLevel, getMergeTableID, getName, getNumColumnsReturned, getOrigTableName, getProperties, getResultColumnsForList, getSchemaDescriptor, getSchemaDescriptor, getScratchCostEstimate, getTableDescriptor, getTableName, getTableNumber, getTrulyTheBestAccessPath, getUserSpecifiedJoinStrategy, hashKeyColumns, hasLargeObjectColumns, hasTableNumber, initAccessPaths, initialCapacity, isBaseTable, isCoveringIndex, isFlattenableJoinNode, isJoinColumnForRightOuterJoin, isMaterializable, isOneRowScan, isTargetTable, legalJoinOrder, loadFactor, LOJ_reorderable, markUpdatableByCursor, maxCapacity, memoryUsageOK, modifyAccessPath, needsSpecialRCLBinding, nextAccessPath, optimizeIt, optimizeSubqueries, pullOptPredicates, pushExpressions, pushOptPredicate, rememberAsBest, rememberJoinStrategyAsBest, rememberSortAvoidancePath, resetJoinStrategies, setCostEstimateCost, setHashKeyColumns, setLevel, setMergeTableID, setOrigTableName, setProperties, setTableNumber, startOptimizing, supportsMultipleInstantiations, tellRowOrderingAboutConstantColumns, transformOuterJoins, uniqueJoin, updateBestPlanMap, verifyPropertiesMethods inherited from class ResultSetNode
addNewPredicate, adjustForSortElimination, adjustForSortElimination, assignResultSetNumber, bindExpressionsWithTables, bindResultColumns, bindResultColumns, bindTargetExpressions, bindUntypedNullsToResultColumns, bindVTITables, changeAccessPath, columnTypesAndLengthsMatch, considerMaterialization, enhanceRCLForInsert, ensurePredicateList, flattenableInFromSubquery, generateNormalizationResultSet, generateResultSet, genProjectRestrict, genProjectRestrict, genProjectRestrictForReordering, getAllResultColumns, getCandidateFinalCostEstimate, getCostEstimate, getCursorTargetTable, getFromList, getNewCostEstimate, getOptimizer, getOptimizerImpl, getRCLForInsert, getReferencedTableMap, getResultColumns, getResultSetNumber, getScratchCostEstimate, isCursorTargetTable, isInsertSource, isNotExists, isOneRowResultSet, isOrderedOn, isPossibleDistinctScan, isStatementResultSet, isUpdatableCursor, LOJgetReferencedTables, makeResultDescription, makeResultDescriptors, markAsCursorTargetTable, markForDistinctScan, markStatementResultSet, modifyAccessPaths, modifyAccessPaths, notCursorTargetTable, notFlattenableJoin, numDistinctAggregates, parseDefault, performMaterialization, printQueryExpressionSuffixClauses, projectResultColumns, pushOffsetFetchFirst, pushOrderByList, pushQueryExpressionSuffix, referencesTarget, rejectParameters, rejectXMLValues, renameGeneratedResultNames, replaceOrForbidDefaults, returnsAtMostOneRow, setCandidateFinalCostEstimate, setCostEstimate, setCursorTargetTable, setInsertSource, setOptimizer, setReferencedTableMap, setResultColumns, setResultSetNumber, setResultToBooleanTrueNode, setScratchCostEstimate, setTableConstructorTypes, subqueryReferencesTarget, verifySelectStarSubqueryMethods inherited from class QueryTreeNode
accept, addTag, addUDTUsagePriv, addUDTUsagePriv, bindOffsetFetch, bindRowMultiSet, bindUserCatalogType, bindUserType, checkReliability, checkReliability, convertDefaultNode, copyTagsFrom, createTypeDependency, debugFlush, debugPrint, disablePrivilegeCollection, formatNodeString, generateAuthorizeCheck, getBeginOffset, getClassFactory, getCompilerContext, getContext, getContextManager, getDataDictionary, getDependencyManager, getEndOffset, getExecutionFactory, getGenericConstantActionFactory, getIntProperty, getLanguageConnectionContext, getLongProperty, getNullNode, getOffsetOrderedNodes, getOptimizerFactory, getOptimizerTracer, getParameterTypes, getSchemaDescriptor, getSchemaDescriptor, getStatementType, getTableDescriptor, getTypeCompiler, getUDTDesc, isAtomic, isPrivilegeCollectionRequired, isSessionSchema, isSessionSchema, makeConstantAction, makeTableName, makeTableName, nodeHeader, optimizerTracingIsOn, orReliability, parseSearchCondition, parseStatement, printLabel, referencesSessionSchema, resolveTableToSynonym, setBeginOffset, setEndOffset, setRefActionInfo, stackPrint, taggedWith, treePrint, treePrint, verifyClassExistMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Optimizable
getDataDictionary, getOptimizerTracer, getReferencedTableMap, getResultSetNumber, optimizerTracingIsOnMethods inherited from interface Visitable
accept, addTag, taggedWith
-
Field Details
-
cursorName
-
preStmt
-
exposedTableName
-
baseTableName
-
singleScanCostEstimate
-
dummyTargetTable
-
-
Constructor Details
-
CurrentOfNode
CurrentOfNode(String correlationName, String cursor, Properties tableProperties, ContextManager cm)
-
-
Method Details
-
makeForMerge
static CurrentOfNode makeForMerge(String cursorName, FromBaseTable dummyTargetTable, ContextManager cm) Construct a dummy CurrentOfNode just for compiling the DELETE action of a MERGE statement.
-
estimateCost
public CostEstimate estimateCost(OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, RowOrdering rowOrdering) throws StandardException Description copied from interface:OptimizableEstimate 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:
estimateCostin interfaceOptimizable- Overrides:
estimateCostin classFromTable- Parameters:
predList- The predicate list to optimize againstcd- The conglomerate descriptor to get the cost ofouterCost- The estimated cost of the part of the plan outer to this optimizable.optimizer- The optimizer to use to help estimate the costrowOrdering- The row ordering for all the tables in the join order, including this one.- Returns:
- The estimated cost of doing the scan
- Throws:
StandardException- Thrown on error- See Also:
-
bindNonVTITables
ResultSetNode bindNonVTITables(DataDictionary dataDictionary, FromList fromListParam) throws 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:
bindNonVTITablesin classResultSetNode- Parameters:
dataDictionary- The DataDictionary to use for bindingfromListParam- FromList to use/append to.- Returns:
- ResultSetNode Returns this.
- Throws:
StandardException- Thrown on error
-
bindExpressions
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:
bindExpressionsin classResultSetNode- Parameters:
fromListParam- FromList to use/append to.
-
getMatchingColumn
Try to find a ResultColumn in the table represented by this CurrentOfNode that matches the name in the given ColumnReference.- Overrides:
getMatchingColumnin classResultSetNode- Parameters:
columnReference- The columnReference whose name we're looking for in the given table.- Returns:
- A ResultColumn whose expression is the ColumnNode that matches the ColumnReference. Returns null if there is no match.
- Throws:
StandardException- Thrown on error
-
preprocess
ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws 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:
preprocessin classResultSetNode- Parameters:
numTables- The number of tables in the DML Statementgbl- The group by list, if anyfromList- The from list, if any- Returns:
- ResultSetNode at top of preprocessed tree.
- Throws:
StandardException- Thrown on error
-
optimize
ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicateList, double outerRows) throws StandardException Optimize this CurrentOfNode. Nothing to do.- Overrides:
optimizein classResultSetNode- Parameters:
dataDictionary- The DataDictionary to use for optimizationpredicateList- The PredicateList to optimize. This should be a single-table predicate with the table the same as the table in this FromTable.outerRows- The number of outer joining rows- Returns:
- ResultSetNode The top of the optimized subtree.
- Throws:
StandardException- Thrown on error
-
generate
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:
generatein classQueryTreeNode- Parameters:
acb- The ActivationClassBuilder for the class being builtmb- The execute() method to be built- Throws:
StandardException- Thrown on error
-
printSubNodes
void printSubNodes(int depth) Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.- Overrides:
printSubNodesin classResultSetNode- Parameters:
depth- The depth of this node in the tree
-
toString
-
getExposedName
String getExposedName()Description copied from class:FromTableGet 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:
getExposedNamein classFromTable- Returns:
- The exposed name of this table.
-
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:
updateTargetLockModein classResultSetNode- Returns:
- The lock mode
- See Also:
-
getExposedTableName
TableName getExposedTableName() -
getBaseCursorTargetTableName
TableName getBaseCursorTargetTableName() -
getCursorName
String getCursorName() -
getCursorStatement
ExecPreparedStatement getCursorStatement()Return the CursorNode associated with a positioned update/delete.- Returns:
- CursorNode The associated CursorNode.
-
acceptChildren
Description copied from class:ResultSetNodeAccept the visitor for all visitable children of this node.- Overrides:
acceptChildrenin classFromTable- Parameters:
v- the visitor- Throws:
StandardException- on error
-