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

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.OnceResultSet
All Implemented Interfaces:
NoPutResultSet, ResultSet, RowLocationRetRowSource, RowSource

public class OnceResultSet
extends NoPutResultSetImpl

Takes an expression subquery's result set and verifies that only a single scalar value is being returned. NOTE: A row with a single column containing null will be returned from getNextRow() if the underlying subquery ResultSet is empty.


Field Summary
private  int cardinalityCheck
           
static int DO_CARDINALITY_CHECK
           
private  GeneratedMethod emptyRowFun
           
static int NO_CARDINALITY_CHECK
           
 int pointOfAttachment
           
private  ExecRow rowWithNulls
           
 NoPutResultSet source
           
private  StatementContext statementContext
           
 int subqueryNumber
           
static int UNIQUE_CARDINALITY_CHECK
           
 
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, isOpen, isTopResultSet, nextTime, numOpens, openTime, optimizerEstimatedCost, optimizerEstimatedRowCount, resultDescription, rowsFiltered, rowsSeen, startExecutionTime, subqueryTrackingArray
 
Fields inherited from interface org.apache.derby.iapi.sql.execute.NoPutResultSet
ABSOLUTE, FIRST, LAST, NEXT, PREVIOUS, RELATIVE
 
Fields inherited from interface org.apache.derby.iapi.sql.ResultSet
CURRENT_RESULTSET_ONLY, ENTIRE_RESULTSET_TREE, ISAFTERLAST, ISBEFOREFIRST, ISFIRST, ISLAST
 
Constructor Summary
OnceResultSet(NoPutResultSet s, Activation a, GeneratedMethod emptyRowFun, int cardinalityCheck, int resultSetNumber, int subqueryNumber, int pointOfAttachment, double optimizerEstimatedRowCount, double optimizerEstimatedCost)
           
 
Method Summary
 void close()
          If the result set has been opened, close the open scan.
 ExecRow getNextRowCore()
          Return the requested value computed from the next row.
 int getPointOfAttachment()
          Return the point of attachment for this subquery.
 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...
 void reopenCore()
          reopen a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...
 
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, finish, finishAndRTS, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCompactRow, getCurrentTimeMillis, getElapsedMillis, getEndExecutionTimestamp, getEstimatedRowCount, getExecuteTime, getExecutionFactory, getFirstRow, getLanguageConnectionContext, getLastRow, getNextRow, getPreviousRow, getRelativeRow, getRowNumber, getScanIsolationLevel, getSubqueryTrackingArray, getTransactionController, getWarnings, isClosed, markAsTopResultSet, modifiedRowCount, open, recordConstructorTime, requiresRelocking, returnsRows, setAfterLastRow, setBeforeFirstRow, setCompactRow, setCompatRow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DO_CARDINALITY_CHECK

public static final int DO_CARDINALITY_CHECK
See Also:
Constant Field Values

NO_CARDINALITY_CHECK

public static final int NO_CARDINALITY_CHECK
See Also:
Constant Field Values

UNIQUE_CARDINALITY_CHECK

public static final int UNIQUE_CARDINALITY_CHECK
See Also:
Constant Field Values

rowWithNulls

private ExecRow rowWithNulls

statementContext

private StatementContext statementContext

source

public NoPutResultSet source

emptyRowFun

private GeneratedMethod emptyRowFun

cardinalityCheck

private int cardinalityCheck

subqueryNumber

public int subqueryNumber

pointOfAttachment

public int pointOfAttachment
Constructor Detail

OnceResultSet

public OnceResultSet(NoPutResultSet s,
                     Activation a,
                     GeneratedMethod emptyRowFun,
                     int cardinalityCheck,
                     int resultSetNumber,
                     int subqueryNumber,
                     int pointOfAttachment,
                     double optimizerEstimatedRowCount,
                     double optimizerEstimatedCost)
Method Detail

openCore

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

Throws:
StandardException - thrown if cursor finished.

reopenCore

public void reopenCore()
                throws StandardException
reopen a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...

Specified by:
reopenCore in interface NoPutResultSet
Overrides:
reopenCore in class BasicNoPutResultSetImpl
Throws:
StandardException - thrown if cursor finished.
See Also:
NoPutResultSet.openCore()

getNextRowCore

public ExecRow getNextRowCore()
                       throws StandardException
Return the requested value computed from the next row.

Specified by:
getNextRowCore in interface NoPutResultSet
Specified by:
getNextRowCore in class BasicNoPutResultSetImpl
Returns:
the next row in the result
Throws:
StandardException - thrown on failure. StandardException ScalarSubqueryCardinalityViolation Thrown if scalar subquery returns more than 1 row.
See Also:
NoPutResultSet.getNextRowCore()

close

public void close()
           throws StandardException
If the result set has been opened, close the open scan.

Specified by:
close in interface ResultSet
Overrides:
close in class NoPutResultSetImpl
Throws:
StandardException - thrown on error

getPointOfAttachment

public int getPointOfAttachment()
Description copied from interface: NoPutResultSet
Return the point of attachment for this subquery. (Only meaningful for Any and Once ResultSets, which can and will only be at the top of a ResultSet for a subquery.)

Specified by:
getPointOfAttachment in interface NoPutResultSet
Overrides:
getPointOfAttachment in class BasicNoPutResultSetImpl
Returns:
int Point of attachment (result set number) for this subquery. (-1 if not a subquery - also Sanity violation)
See Also:
NoPutResultSet.getPointOfAttachment()

getTimeSpent

public long getTimeSpent(int type)
Return the total amount of time spent in this 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).

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.