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
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.derby.impl.sql.compile.ResultSetNode
ResultSetNode.QueryExpressionClauses
-
-
Field Summary
Fields Modifier and Type Field Description private TableName
baseTableName
private java.lang.String
cursorName
private FromBaseTable
dummyTargetTable
private TableName
exposedTableName
private ExecPreparedStatement
preStmt
private CostEstimate
singleScanCostEstimate
-
Fields inherited from class org.apache.derby.impl.sql.compile.FromTable
ADD_PLAN, bestAccessPath, bestCostEstimate, bestSortAvoidancePath, correlationName, corrTableName, currentAccessPath, hashKeyColumns, initialCapacity, level, LOAD_PLAN, loadFactor, maxCapacity, origTableName, REMOVE_PLAN, tableNumber, tableProperties, trulyTheBestAccessPath, userSpecifiedJoinStrategy
-
Fields inherited from class org.apache.derby.impl.sql.compile.QueryTreeNode
AUTOINCREMENT_CREATE_MODIFY, AUTOINCREMENT_CYCLE, AUTOINCREMENT_INC_INDEX, AUTOINCREMENT_IS_AUTOINCREMENT_INDEX, AUTOINCREMENT_START_INDEX
-
-
Constructor Summary
Constructors Constructor Description CurrentOfNode(java.lang.String correlationName, java.lang.String cursor, java.util.Properties tableProperties, ContextManager cm)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
acceptChildren(Visitor v)
Accept the visitor for all visitable children of this node.(package private) void
bindExpressions(FromList fromListParam)
Bind the expressions in this ResultSetNode.(package private) ResultSetNode
bindNonVTITables(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).CostEstimate
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) void
generate(ActivationClassBuilder acb, MethodBuilder mb)
Generation on a CurrentOfNode creates a scan on the cursor, CurrentOfResultSet.(package private) TableName
getBaseCursorTargetTableName()
(package private) java.lang.String
getCursorName()
(package private) ExecPreparedStatement
getCursorStatement()
Return the CursorNode associated with a positioned update/delete.(package private) 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.(package private) TableName
getExposedTableName()
(package private) ResultColumn
getMatchingColumn(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 CurrentOfNode
makeForMerge(java.lang.String cursorName, FromBaseTable dummyTargetTable, ContextManager cm)
Construct a dummy CurrentOfNode just for compiling the DELETE action of a MERGE statement.(package private) ResultSetNode
optimize(DataDictionary dataDictionary, PredicateList predicateList, double outerRows)
Optimize this CurrentOfNode.(package private) ResultSetNode
preprocess(int numTables, GroupByList gbl, FromList fromList)
Preprocess a CurrentOfNode.(package private) 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
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, verifyProperties
-
Methods inherited from class org.apache.derby.impl.sql.compile.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, verifySelectStarSubquery
-
Methods inherited from class org.apache.derby.impl.sql.compile.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, 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, getOptimizerTracer, getReferencedTableMap, getResultSetNumber, optimizerTracingIsOn
-
Methods inherited from interface org.apache.derby.iapi.sql.compile.Visitable
accept, addTag, taggedWith
-
-
-
-
Field Detail
-
cursorName
private java.lang.String cursorName
-
preStmt
private ExecPreparedStatement preStmt
-
exposedTableName
private TableName exposedTableName
-
baseTableName
private TableName baseTableName
-
singleScanCostEstimate
private CostEstimate singleScanCostEstimate
-
dummyTargetTable
private FromBaseTable dummyTargetTable
-
-
Constructor Detail
-
CurrentOfNode
CurrentOfNode(java.lang.String correlationName, java.lang.String cursor, java.util.Properties tableProperties, ContextManager cm)
-
-
Method Detail
-
makeForMerge
static CurrentOfNode makeForMerge(java.lang.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: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 interfaceOptimizable
- Overrides:
estimateCost
in 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:
Optimizable.estimateCost(org.apache.derby.iapi.sql.compile.OptimizablePredicateList, org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor, org.apache.derby.iapi.sql.compile.CostEstimate, org.apache.derby.iapi.sql.compile.Optimizer, org.apache.derby.iapi.sql.compile.RowOrdering)
-
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:
bindNonVTITables
in classResultSetNode
- Parameters:
dataDictionary
- The DataDictionary to use for bindingfromListParam
- FromList to use/append to.- Returns:
- ResultSetNode Returns this.
- Throws:
StandardException
- Thrown on error
-
bindExpressions
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 classResultSetNode
- Parameters:
fromListParam
- FromList to use/append to.
-
getMatchingColumn
ResultColumn getMatchingColumn(ColumnReference columnReference) throws StandardException
Try to find a ResultColumn in the table represented by this CurrentOfNode that matches the name in the given ColumnReference.- Overrides:
getMatchingColumn
in 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:
preprocess
in 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:
optimize
in 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
void generate(ActivationClassBuilder acb, MethodBuilder mb) throws 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 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:
printSubNodes
in classResultSetNode
- Parameters:
depth
- The depth of this node in the tree
-
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.
-
getExposedName
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 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:
updateTargetLockMode
in classResultSetNode
- Returns:
- The lock mode
- See Also:
TransactionController
-
getExposedTableName
TableName getExposedTableName()
-
getBaseCursorTargetTableName
TableName getBaseCursorTargetTableName()
-
getCursorName
java.lang.String getCursorName()
-
getCursorStatement
ExecPreparedStatement getCursorStatement()
Return the CursorNode associated with a positioned update/delete.- Returns:
- CursorNode The associated CursorNode.
-
acceptChildren
void acceptChildren(Visitor v) throws StandardException
Description copied from class:ResultSetNode
Accept the visitor for all visitable children of this node.- Overrides:
acceptChildren
in classFromTable
- Parameters:
v
- the visitor- Throws:
StandardException
- on error
-
-