Top Description Fields Constructors Methods
org.apache.derby.impl.sql.compile

public final Class CurrentOfNode

extends FromTable
Class Inheritance
Imports
java.util.Properties, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.ClassName, .SQLState, org.apache.derby.iapi.services.classfile.VMOpcode, org.apache.derby.iapi.services.compiler.MethodBuilder, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.Activation, org.apache.derby.iapi.sql.compile.CostEstimate, .Optimizable, .OptimizablePredicateList, .Optimizer, .RowOrdering, .Visitor, org.apache.derby.iapi.sql.dictionary.ColumnDescriptor, .ColumnDescriptorList, .ConglomerateDescriptor, .DataDictionary, .SchemaDescriptor, .TableDescriptor, org.apache.derby.iapi.sql.execute.ExecCursorTableReference, .ExecPreparedStatement, org.apache.derby.iapi.store.access.TransactionController, org.apache.derby.iapi.util.JBitSet

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

Modifier and TypeField and Description
private TableName
private String
private FromBaseTable
private TableName
private ExecPreparedStatement
private CostEstimate
Inherited from org.apache.derby.impl.sql.compile.FromTable:
ADD_PLANbestAccessPathbestCostEstimatebestSortAvoidancePathcorrelationNamecorrTableNamecurrentAccessPathhashKeyColumnsinitialCapacitylevelLOAD_PLANloadFactormaxCapacityorigTableNameREMOVE_PLANtableNumbertablePropertiestrulyTheBestAccessPathuserSpecifiedJoinStrategy

Constructor Summary

AccessConstructor and Description
pack-priv
CurrentOfNode(String correlationName, String cursor, Properties tableProperties, ContextManager cm)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
acceptChildren(Visitor
the visitor
v
)

Overrides org.apache.derby.impl.sql.compile.FromTable.acceptChildren.

Accept the visitor for all visitable children of this node.

pack-priv void
bindExpressions(FromList
FromList to use/append to.
fromListParam
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.bindExpressions.

Bind the expressions in this ResultSetNode.

pack-priv ResultSetNode

Returns:

ResultSetNode Returns this.
bindNonVTITables
(DataDictionary
The DataDictionary to use for binding
dataDictionary
,
FromList
FromList to use/append to.
fromListParam
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.bindNonVTITables.

Binding this FromTable means finding the prepared statement for the cursor and creating the result columns (the columns updatable on that cursor).

public CostEstimate
estimateCost(OptimizablePredicateList
The predicate list to optimize against
predList
,
ConglomerateDescriptor
The conglomerate descriptor to get the cost of
cd
,
CostEstimate
The estimated cost of the part of the plan outer to this optimizable.
outerCost
,
Optimizer
The optimizer to use to help estimate the cost
optimizer
,
RowOrdering
The row ordering for all the tables in the join order, including this one.
rowOrdering
)

Overrides org.apache.derby.impl.sql.compile.FromTable.estimateCost.

Implements org.apache.derby.iapi.sql.compile.Optimizable.estimateCost.

Estimate the cost of scanning this Optimizable using the given predicate list with the given conglomerate.

pack-priv void
generate(ActivationClassBuilder
The ActivationClassBuilder for the class being built
acb
,
MethodBuilder
The execute() method to be built
mb
)

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.generate.

Generation on a CurrentOfNode creates a scan on the cursor, CurrentOfResultSet.</verbatim>

pack-priv TableName
pack-priv String
pack-priv ExecPreparedStatement

Returns:

CursorNode The associated CursorNode.
getCursorStatement
()

Return the CursorNode associated with a positioned update/delete.

pack-priv String
getExposedName()

Overrides org.apache.derby.impl.sql.compile.FromTable.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.

pack-priv TableName
pack-priv ResultColumn

Returns:

A ResultColumn whose expression is the ColumnNode that matches the ColumnReference. Returns null if there is no match.
getMatchingColumn
(ColumnReference
The columnReference whose name we're looking for in the given table.
columnReference
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.getMatchingColumn.

Try to find a ResultColumn in the table represented by this CurrentOfNode that matches the name in the given ColumnReference.

pack-priv static CurrentOfNode
makeForMerge(String cursorName, FromBaseTable dummyTargetTable, ContextManager cm)

Construct a dummy CurrentOfNode just for compiling the DELETE action of a MERGE statement.

pack-priv ResultSetNode

Returns:

ResultSetNode The top of the optimized subtree.
optimize
(DataDictionary
The DataDictionary to use for optimization
dataDictionary
,
PredicateList
The PredicateList to optimize. This should be a single-table predicate with the table the same as the table in this FromTable.
predicateList
,
double
The number of outer joining rows
outerRows
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.optimize.

Optimize this CurrentOfNode.

pack-priv ResultSetNode

Returns:

ResultSetNode at top of preprocessed tree.
preprocess
(int
The number of tables in the DML Statement
numTables
,
GroupByList
The group by list, if any
gbl
,
FromList
The from list, if any
fromList
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.preprocess.

Preprocess a CurrentOfNode.

pack-priv void
printSubNodes(int
The depth of this node in the tree
depth
)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.printSubNodes.

Prints the sub-nodes of this object.

public String

Returns:

This object as a String
toString
()

Overrides org.apache.derby.impl.sql.compile.FromTable.toString.

Convert this object to a String.

public int

Returns:

The lock mode
updateTargetLockMode
()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.updateTargetLockMode.

Get the lock mode for this table as the target of an update statement (a delete or update).

Inherited from org.apache.derby.impl.sql.compile.FromTable:
assignCostEstimatecanBeOrderedcolumnsAreUpdatableconsiderSortAvoidancePathconvertAbsoluteToRelativeColumnPositioncursorTargetTabledecrementLevelfeasibleJoinStrategyfillInReferencedTableMapflattenforUpdategetBaseTableNamegetBestAccessPathgetBestSortAvoidancePathgetCorrelationNamegetCostEstimategetCurrentAccessPathgetFinalCostEstimategetFromTableByNamegetLevelgetMergeTableIDgetNamegetNumColumnsReturnedgetOrigTableNamegetPropertiesgetResultColumnsForListgetSchemaDescriptorgetSchemaDescriptorgetScratchCostEstimategetTableDescriptorgetTableNamegetTableNumbergetTrulyTheBestAccessPathgetUserSpecifiedJoinStrategyhashKeyColumnshasLargeObjectColumnshasTableNumberinitAccessPathsinitialCapacityisBaseTableisCoveringIndexisFlattenableJoinNodeisJoinColumnForRightOuterJoinisMaterializableisOneRowScanisTargetTablelegalJoinOrderloadFactorLOJ_reorderablemarkUpdatableByCursormaxCapacitymemoryUsageOKmodifyAccessPathneedsSpecialRCLBindingnextAccessPathoptimizeItoptimizeSubqueriespullOptPredicatespushExpressionspushOptPredicaterememberAsBestrememberJoinStrategyAsBestrememberSortAvoidancePathresetJoinStrategiessetCostEstimateCostsetHashKeyColumnssetLevelsetMergeTableIDsetOrigTableNamesetPropertiessetTableNumberstartOptimizingsupportsMultipleInstantiationstellRowOrderingAboutConstantColumnstransformOuterJoinsuniqueJoinupdateBestPlanMapverifyProperties

Field Detail

baseTableNameback to summary
private TableName baseTableName
cursorNameback to summary
private String cursorName
dummyTargetTableback to summary
private FromBaseTable dummyTargetTable
exposedTableNameback to summary
private TableName exposedTableName
preStmtback to summary
private ExecPreparedStatement preStmt
singleScanCostEstimateback to summary
private CostEstimate singleScanCostEstimate

Constructor Detail

CurrentOfNodeback to summary
pack-priv CurrentOfNode(String correlationName, String cursor, Properties tableProperties, ContextManager cm)

Method Detail

acceptChildrenback to summary
pack-priv void acceptChildren(Visitor v) throws StandardException

Overrides org.apache.derby.impl.sql.compile.FromTable.acceptChildren.

Doc from org.apache.derby.impl.sql.compile.ResultSetNode.acceptChildren.

Accept the visitor for all visitable children of this node.

Parameters
v:Visitor

the visitor

Annotations
@Override
Exceptions
StandardException:
on error
bindExpressionsback to summary
pack-priv void bindExpressions(FromList fromListParam)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.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.

Parameters
fromListParam:FromList

FromList to use/append to.

Annotations
@Override
bindNonVTITablesback to summary
pack-priv ResultSetNode bindNonVTITables(DataDictionary dataDictionary, FromList fromListParam) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.bindNonVTITables.

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.

Parameters
dataDictionary:DataDictionary

The DataDictionary to use for binding

fromListParam:FromList

FromList to use/append to.

Returns:ResultSetNode

ResultSetNode Returns this.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
estimateCostback to summary
public CostEstimate estimateCost(OptimizablePredicateList predList, ConglomerateDescriptor cd, CostEstimate outerCost, Optimizer optimizer, RowOrdering rowOrdering) throws StandardException

Overrides org.apache.derby.impl.sql.compile.FromTable.estimateCost.

Implements org.apache.derby.iapi.sql.compile.Optimizable.estimateCost.

Doc from org.apache.derby.iapi.sql.compile.Optimizable.estimateCost.

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.

Parameters
predList:OptimizablePredicateList

The predicate list to optimize against

cd:ConglomerateDescriptor

The conglomerate descriptor to get the cost of

outerCost:CostEstimate

The estimated cost of the part of the plan outer to this optimizable.

optimizer:Optimizer

The optimizer to use to help estimate the cost

rowOrdering:RowOrdering

The row ordering for all the tables in the join order, including this one.

Returns:CostEstimate

The estimated cost of doing the scan

Annotations
@Override
Exceptions
StandardException:
Thrown on error
See Also
Optimizable#estimateCost
generateback to summary
pack-priv void generate(ActivationClassBuilder acb, MethodBuilder mb) throws StandardException

Overrides org.apache.derby.impl.sql.compile.QueryTreeNode.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)
	   
Parameters
acb:ActivationClassBuilder

The ActivationClassBuilder for the class being built

mb:MethodBuilder

The execute() method to be built

Annotations
@Override
Exceptions
StandardException:
Thrown on error
getBaseCursorTargetTableNameback to summary
pack-priv TableName getBaseCursorTargetTableName()
getCursorNameback to summary
pack-priv String getCursorName()
getCursorStatementback to summary
pack-priv ExecPreparedStatement getCursorStatement()

Return the CursorNode associated with a positioned update/delete.

Returns:ExecPreparedStatement

CursorNode The associated CursorNode.

getExposedNameback to summary
pack-priv String getExposedName()

Overrides org.apache.derby.impl.sql.compile.FromTable.getExposedName.

Doc from org.apache.derby.impl.sql.compile.FromTable.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.

Returns:String

The exposed name of this table.

Annotations
@Override
getExposedTableNameback to summary
pack-priv TableName getExposedTableName()
getMatchingColumnback to summary
pack-priv ResultColumn getMatchingColumn(ColumnReference columnReference) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.getMatchingColumn.

Try to find a ResultColumn in the table represented by this CurrentOfNode that matches the name in the given ColumnReference.

Parameters
columnReference:ColumnReference

The columnReference whose name we're looking for in the given table.

Returns:ResultColumn

A ResultColumn whose expression is the ColumnNode that matches the ColumnReference. Returns null if there is no match.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
makeForMergeback to summary
pack-priv static CurrentOfNode makeForMerge(String cursorName, FromBaseTable dummyTargetTable, ContextManager cm)

Construct a dummy CurrentOfNode just for compiling the DELETE action of a MERGE statement.

optimizeback to summary
pack-priv ResultSetNode optimize(DataDictionary dataDictionary, PredicateList predicateList, double outerRows) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.optimize.

Optimize this CurrentOfNode. Nothing to do.

Parameters
dataDictionary:DataDictionary

The DataDictionary to use for optimization

predicateList:PredicateList

The PredicateList to optimize. This should be a single-table predicate with the table the same as the table in this FromTable.

outerRows:double

The number of outer joining rows

Returns:ResultSetNode

ResultSetNode The top of the optimized subtree.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
preprocessback to summary
pack-priv ResultSetNode preprocess(int numTables, GroupByList gbl, FromList fromList) throws StandardException

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.preprocess.

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.

Parameters
numTables:int

The number of tables in the DML Statement

gbl:GroupByList

The group by list, if any

fromList:FromList

The from list, if any

Returns:ResultSetNode

ResultSetNode at top of preprocessed tree.

Annotations
@Override
Exceptions
StandardException:
Thrown on error
printSubNodesback to summary
pack-priv void printSubNodes(int depth)

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.printSubNodes.

Prints the sub-nodes of this object. See QueryTreeNode.java for how tree printing is supposed to work.

Parameters
depth:int

The depth of this node in the tree

Annotations
@Override
toStringback to summary
public String toString()

Overrides org.apache.derby.impl.sql.compile.FromTable.toString.

Convert this object to a String. See comments in QueryTreeNode.java for how this should be done for tree printing.

Returns:String

This object as a String

Annotations
@Override
updateTargetLockModeback to summary
public int updateTargetLockMode()

Overrides org.apache.derby.impl.sql.compile.ResultSetNode.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.

Returns:int

The lock mode

Annotations
@Override
See Also
TransactionController