org.apache.derby.impl.sql.execute
Class DependentResultSet

java.lang.Object
  extended by org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
      extended by org.apache.derby.impl.sql.execute.NoPutResultSetImpl
          extended by org.apache.derby.impl.sql.execute.ScanResultSet
              extended by org.apache.derby.impl.sql.execute.DependentResultSet
All Implemented Interfaces:
CursorResultSet, NoPutResultSet, ResultSet, RowLocationRetRowSource, RowSource

 class DependentResultSet
extends ScanResultSet
implements CursorResultSet

DependentResultSet should be used by only ON DELETE CASCADE/ON DELETE SET NULL ref actions implementation to gather the rows from the dependent tables. Idea is to scan the foreign key index for the rows in the source table matelized temporary result set. Scanning of foreign key index gives us the rows that needs to be deleted on dependent tables. Using the row location we got from the index , base row is fetched.


Field Summary
(package private)  RowLocation baseRowLocation
           
 boolean coarserLock
           
protected  long conglomId
           
(package private)  boolean deferred
           
protected  boolean firstScan
           
(package private)  int[] fkColArray
           
 boolean forUpdate
           
(package private)  ConglomerateController heapCC
           
protected  DynamicCompiledOpenConglomInfo heapDcoci
           
protected  StaticCompiledOpenConglomInfo heapScoci
           
(package private)  DynamicCompiledOpenConglomInfo indexDcoci
           
 java.lang.String indexName
           
(package private)  IndexRow indexQualifierRow
           
(package private)  ExecRow indexRow
           
(package private)  ScanController indexSC
           
(package private)  StaticCompiledOpenConglomInfo indexScoci
           
 boolean isConstraint
           
protected  boolean isKeyed
           
(package private)  boolean isOpen
           
(package private)  int numFkColumns
           
 boolean oneRowScan
           
(package private)  java.lang.String parentResultSetId
           
protected  Qualifier[][] qualifiers
           
protected  GeneratedMethod resultRowAllocator
           
(package private)  RowLocation rowLocation
           
 int rowsPerRead
           
protected  long rowsThisScan
           
protected  boolean runTimeStatisticsOn
           
private  boolean sameStartStopPosition
           
(package private)  int sArrayIndex
           
protected  ScanController scanController
           
protected  boolean scanControllerOpened
           
private  java.util.Properties scanProperties
           
(package private)  ExecRow searchRow
           
(package private)  TemporaryRowHolderResultSet source
           
(package private)  int[] sourceOpened
           
(package private)  TemporaryRowHolderResultSet[] sourceResultSets
           
(package private)  TemporaryRowHolder[] sourceRowHolders
           
protected  GeneratedMethod startKeyGetter
           
protected  ExecIndexRow startPosition
           
 java.lang.String startPositionString
           
protected  int startSearchOperator
           
protected  GeneratedMethod stopKeyGetter
           
protected  ExecIndexRow stopPosition
           
 java.lang.String stopPositionString
           
protected  int stopSearchOperator
           
(package private)  java.util.Vector sVector
           
 java.lang.String tableName
           
(package private)  TransactionController tc
           
 java.lang.String userSuppliedOptimizerOverrides
           
 
Fields inherited from class org.apache.derby.impl.sql.execute.ScanResultSet
accessedCols, candidate, isolationLevel, lockMode
 
Fields inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
checkNullCols, clonedExecRow, cncLen, resultSetNumber, targetResultSet
 
Fields inherited from class org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
activation, beginTime, closeTime, compactRow, constructorTime, currentRow, endExecutionTime, finished, isTopResultSet, nextTime, numOpens, openTime, optimizerEstimatedCost, optimizerEstimatedRowCount, resultDescription, rowsFiltered, rowsSeen, startExecutionTime, subqueryTrackingArray
 
Fields inherited from interface org.apache.derby.iapi.sql.ResultSet
CURRENT_RESULTSET_ONLY, ENTIRE_RESULTSET_TREE, ISAFTERLAST, ISBEFOREFIRST, ISFIRST, ISLAST
 
Fields inherited from interface org.apache.derby.iapi.sql.execute.NoPutResultSet
ABSOLUTE, FIRST, LAST, NEXT, PREVIOUS, RELATIVE
 
Constructor Summary
DependentResultSet(long conglomId, StaticCompiledOpenConglomInfo scoci, Activation activation, GeneratedMethod resultRowAllocator, int resultSetNumber, GeneratedMethod startKeyGetter, int startSearchOperator, GeneratedMethod stopKeyGetter, int stopSearchOperator, boolean sameStartStopPosition, Qualifier[][] qualifiers, java.lang.String tableName, java.lang.String userSuppliedOptimizerOverrides, java.lang.String indexName, boolean isConstraint, boolean forUpdate, int colRefItem, int lockMode, boolean tableLocked, int isolationLevel, int rowsPerRead, boolean oneRowScan, double optimizerEstimatedRowCount, double optimizerEstimatedCost, java.lang.String parentResultSetId, long fkIndexConglomId, int fkColArrayItem, int rltItem)
           
 
Method Summary
private  void addNewSources()
           
(package private)  boolean canGetInstantaneousLocks()
          Can we get instantaneous locks when getting share row locks at READ COMMITTED.
 void close()
          Close the all the opens we did in this result set.
private  ExecRow fetchBaseRow()
          Fetch the base row corresponding to the current index row
private  ExecRow fetchIndexRow()
          Fetch a row from the index scan.
 void finish()
          Tells the system that there will be no more access to any database information via this result set; in particular, no more calls to open().
 ExecRow getCurrentRow()
          Returns the current row of the result set.
private  ExecRow getNextParentRow()
           
 ExecRow getNextRowCore()
          Return the requested values computed from the next row (if any) for which the restriction evaluates to true.
 RowLocation getRowLocation()
          Returns the row location of the current base table row of the cursor.
 java.util.Properties getScanProperties()
           
 long getTimeSpent(int type)
          Return the total amount of time spent in this ResultSet
 void openCore()
          open a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...
 ConglomerateController openHeapConglomerateController()
           
private  void openIndexScan(ExecRow searchRow)
           
private  ScanController openIndexScanController(ExecRow searchRow)
          Get a scan controller positioned using searchRow as the start/stop position.
private  java.lang.String printPosition(int searchOperator, ExecIndexRow positioner)
          Return a start or stop positioner as a String.
 java.lang.String printQualifiers()
          Return an array of Qualifiers as a String
 java.lang.String printStartPosition()
           
 java.lang.String printStopPosition()
           
private  void reopenIndexScanController(ExecRow searchRow)
           
private  void setupQualifierRow(ExecRow searchRow)
           
 
Methods inherited from class org.apache.derby.impl.sql.execute.ScanResultSet
getScanIsolationLevel, initIsolationLevel
 
Methods inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
clearCurrentRow, clearOrderableCache, closeRowSource, getCursorName, getNextRowFromRowSource, getResultDescription, getValidColumns, isForUpdate, markRowAsDeleted, needsRowLocation, needsToClone, positionScanAtRowLocation, printQualifiers, resultSetNumber, rowLocation, setCurrentRow, setNeedsRowLocation, setTargetResultSet, skipRow, skipScan, updateRow
 
Methods inherited from class org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
addWarning, attachStatementContext, checkCancellationFlag, checkRowPosition, cleanUp, dumpTimeStats, finishAndRTS, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCompactRow, getCurrentTimeMillis, getElapsedMillis, getEndExecutionTimestamp, getEstimatedRowCount, getExecuteTime, getExecutionFactory, getFirstRow, getLanguageConnectionContext, getLastRow, getNextRow, getPointOfAttachment, getPreviousRow, getRelativeRow, getRowNumber, getSubqueryTrackingArray, getTransactionController, getWarnings, isClosed, markAsTopResultSet, modifiedRowCount, open, recordConstructorTime, reopenCore, requiresRelocking, returnsRows, setAfterLastRow, setBeforeFirstRow, setCompactRow, setCompatRow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.derby.iapi.sql.ResultSet
checkRowPosition, cleanUp, clearCurrentRow, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCursorName, getEndExecutionTimestamp, getExecuteTime, getFirstRow, getLastRow, getNextRow, getPreviousRow, getRelativeRow, getResultDescription, getRowNumber, getSubqueryTrackingArray, getWarnings, isClosed, modifiedRowCount, open, returnsRows, setAfterLastRow, setBeforeFirstRow
 

Field Detail

heapCC

ConglomerateController heapCC

baseRowLocation

RowLocation baseRowLocation

indexRow

ExecRow indexRow

indexQualifierRow

IndexRow indexQualifierRow

indexSC

ScanController indexSC

indexScoci

StaticCompiledOpenConglomInfo indexScoci

indexDcoci

DynamicCompiledOpenConglomInfo indexDcoci

numFkColumns

int numFkColumns

isOpen

boolean isOpen

deferred

boolean deferred

source

TemporaryRowHolderResultSet source

tc

TransactionController tc

parentResultSetId

java.lang.String parentResultSetId

fkColArray

int[] fkColArray

rowLocation

RowLocation rowLocation

sourceRowHolders

TemporaryRowHolder[] sourceRowHolders

sourceResultSets

TemporaryRowHolderResultSet[] sourceResultSets

sourceOpened

int[] sourceOpened

sArrayIndex

int sArrayIndex

sVector

java.util.Vector sVector

scanController

protected ScanController scanController

scanControllerOpened

protected boolean scanControllerOpened

isKeyed

protected boolean isKeyed

firstScan

protected boolean firstScan

startPosition

protected ExecIndexRow startPosition

stopPosition

protected ExecIndexRow stopPosition

conglomId

protected long conglomId

heapDcoci

protected DynamicCompiledOpenConglomInfo heapDcoci

heapScoci

protected StaticCompiledOpenConglomInfo heapScoci

resultRowAllocator

protected GeneratedMethod resultRowAllocator

startKeyGetter

protected GeneratedMethod startKeyGetter

startSearchOperator

protected int startSearchOperator

stopKeyGetter

protected GeneratedMethod stopKeyGetter

stopSearchOperator

protected int stopSearchOperator

qualifiers

protected Qualifier[][] qualifiers

tableName

public java.lang.String tableName

userSuppliedOptimizerOverrides

public java.lang.String userSuppliedOptimizerOverrides

indexName

public java.lang.String indexName

runTimeStatisticsOn

protected boolean runTimeStatisticsOn

rowsPerRead

public int rowsPerRead

forUpdate

public boolean forUpdate

sameStartStopPosition

private boolean sameStartStopPosition

scanProperties

private java.util.Properties scanProperties

startPositionString

public java.lang.String startPositionString

stopPositionString

public java.lang.String stopPositionString

isConstraint

public boolean isConstraint

coarserLock

public boolean coarserLock

oneRowScan

public boolean oneRowScan

rowsThisScan

protected long rowsThisScan

searchRow

ExecRow searchRow
Constructor Detail

DependentResultSet

DependentResultSet(long conglomId,
                   StaticCompiledOpenConglomInfo scoci,
                   Activation activation,
                   GeneratedMethod resultRowAllocator,
                   int resultSetNumber,
                   GeneratedMethod startKeyGetter,
                   int startSearchOperator,
                   GeneratedMethod stopKeyGetter,
                   int stopSearchOperator,
                   boolean sameStartStopPosition,
                   Qualifier[][] qualifiers,
                   java.lang.String tableName,
                   java.lang.String userSuppliedOptimizerOverrides,
                   java.lang.String indexName,
                   boolean isConstraint,
                   boolean forUpdate,
                   int colRefItem,
                   int lockMode,
                   boolean tableLocked,
                   int isolationLevel,
                   int rowsPerRead,
                   boolean oneRowScan,
                   double optimizerEstimatedRowCount,
                   double optimizerEstimatedCost,
                   java.lang.String parentResultSetId,
                   long fkIndexConglomId,
                   int fkColArrayItem,
                   int rltItem)
             throws StandardException
Throws:
StandardException
Method Detail

openIndexScanController

private ScanController openIndexScanController(ExecRow searchRow)
                                        throws StandardException
Get a scan controller positioned using searchRow as the start/stop position. The assumption is that searchRow is of the same format as the index being opened.

Parameters:
searchRow - the row to match
Throws:
StandardException - on error

reopenIndexScanController

private void reopenIndexScanController(ExecRow searchRow)
                                throws StandardException
Throws:
StandardException

setupQualifierRow

private void setupQualifierRow(ExecRow searchRow)

openIndexScan

private void openIndexScan(ExecRow searchRow)
                    throws StandardException
Throws:
StandardException

fetchIndexRow

private ExecRow fetchIndexRow()
                       throws StandardException
Fetch a row from the index scan.

Returns:
The row or null. Note that the next call to fetch will replace the columns in the returned row.
Throws:
StandardException - Ooops

fetchBaseRow

private ExecRow fetchBaseRow()
                      throws StandardException
Fetch the base row corresponding to the current index row

Returns:
The base row row or null.
Throws:
StandardException - Ooops

getNextRowCore

public ExecRow getNextRowCore()
                       throws StandardException
Description copied from interface: NoPutResultSet
Return the requested values computed from the next row (if any) for which the restriction evaluates to true.

restriction and projection parameters are evaluated for each row.

Specified by:
getNextRowCore in interface NoPutResultSet
Specified by:
getNextRowCore in class BasicNoPutResultSetImpl
Returns:
the next row in the result
Throws:
StandardException - thrown if cursor finished.
See Also:
NoPutResultSet.getNextRowCore()

getNextParentRow

private ExecRow getNextParentRow()
                          throws StandardException
Throws:
StandardException

openHeapConglomerateController

public ConglomerateController openHeapConglomerateController()
                                                      throws StandardException
Throws:
StandardException

close

public void close()
           throws StandardException
Close the all the opens we did in this result set.

Specified by:
close in interface ResultSet
Overrides:
close in class ScanResultSet
Throws:
StandardException - if an error occurs

finish

public void finish()
            throws StandardException
Description copied from interface: ResultSet
Tells the system that there will be no more access to any database information via this result set; in particular, no more calls to open(). Will close the result set if it is not already closed.

Specified by:
finish in interface ResultSet
Overrides:
finish in class BasicNoPutResultSetImpl
Throws:
StandardException - on error

openCore

public void openCore()
              throws StandardException
Description copied from interface: NoPutResultSet
open a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...

openCore() can only be called on a closed result set. see reopenCore if you want to reuse an open result set.

For NoPutResultSet open() must only be called on the top ResultSet. Opening of NoPutResultSet's below the top result set are implemented by calling openCore.

Specified by:
openCore in interface NoPutResultSet
Throws:
StandardException - thrown if cursor finished.

addNewSources

private void addNewSources()

canGetInstantaneousLocks

boolean canGetInstantaneousLocks()
Can we get instantaneous locks when getting share row locks at READ COMMITTED.

Specified by:
canGetInstantaneousLocks in class ScanResultSet

getTimeSpent

public long getTimeSpent(int type)
Description copied from interface: ResultSet
Return the total amount of time spent in this ResultSet

Specified by:
getTimeSpent in interface ResultSet
Parameters:
type - CURRENT_RESULTSET_ONLY - time spent only in this ResultSet ENTIRE_RESULTSET_TREE - time spent in this ResultSet and below.
Returns:
long The total amount of time spent (in milliseconds).

getRowLocation

public RowLocation getRowLocation()
                           throws StandardException
Description copied from interface: CursorResultSet
Returns the row location of the current base table row of the cursor. If this cursor's row is composed of multiple base tables' rows, i.e. due to a join, then a null is returned.

Specified by:
getRowLocation in interface CursorResultSet
Returns:
the row location of the current cursor row.
Throws:
StandardException - thrown on failure to get location from storage engine

getCurrentRow

public ExecRow getCurrentRow()
                      throws StandardException
Description copied from interface: CursorResultSet
Returns the current row of the result set. REMIND: eventually, this will only return the current row for result sets that need to return it; either some field in the activation or a parameter in the constructor will be used to signal that this needs to function. This will let us limit the number of live objects we are holding on to.

Specified by:
getCurrentRow in interface CursorResultSet
Returns:
the last row returned by getNextRow. null if closed.
Throws:
StandardException - thrown on failure.

getScanProperties

public java.util.Properties getScanProperties()

printStartPosition

public java.lang.String printStartPosition()

printStopPosition

public java.lang.String printStopPosition()

printPosition

private java.lang.String printPosition(int searchOperator,
                                       ExecIndexRow positioner)
Return a start or stop positioner as a String. If we already generated the information, then use that. Otherwise, invoke the activation to get it.


printQualifiers

public java.lang.String printQualifiers()
Return an array of Qualifiers as a String


Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.