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

java.lang.Object
  extended byorg.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
      extended byorg.apache.derby.impl.sql.execute.NoPutResultSetImpl
          extended byorg.apache.derby.impl.sql.execute.SetOpResultSet
All Implemented Interfaces:
CursorResultSet, NoPutResultSet, ResultSet, RowLocationRetRowSource, RowSource

public class SetOpResultSet
extends NoPutResultSetImpl
implements CursorResultSet

Takes the result set produced by an ordered UNION ALL of two tagged result sets and produces the INTERSECT or EXCEPT of the two input result sets. This also projects out the tag, the last column of the input rows.


Field Summary
private  Activation activation
           
private  boolean all
           
 long beginTime
           
(package private)  GeneratedMethod checkGM
           
protected  int[] checkNullCols
           
protected  ExecRow clonedExecRow
           
private  GeneratedMethod closeCleanup
           
 long closeTime
           
protected  int cncLen
           
(package private)  ExecRow compactRow
           
 long constructorTime
           
protected  ExecRow currentRow
           
protected  long endExecutionTime
           
protected  boolean finished
           
(package private)  long heapConglomerate
           
protected  java.lang.String indent
           
private  int[] intermediateOrderByColumns
           
private  int[] intermediateOrderByDirection
           
protected  boolean isOpen
           
protected  boolean isTopResultSet
           
protected  LanguageConnectionContext lcc
           
private  ExecRow leftInputRow
           
private  NoPutResultSet leftSource
           
 long nextTime
           
 int numOpens
           
 long openTime
           
 double optimizerEstimatedCost
           
 double optimizerEstimatedRowCount
           
private  int opType
           
private  DataValueDescriptor[] prevCols
           
(package private)  ResultDescription resultDescription
           
private  int resultSetNumber
           
private  int rightDuplicateCount
           
private  ExecRow rightInputRow
           
private  NoPutResultSet rightSource
           
 int rowsFiltered
           
 int rowsSeen
           
protected  int sourceDepth
           
protected  long startExecutionTime
           
protected  java.lang.String subIndent
           
 NoPutResultSet[] subqueryTrackingArray
           
protected  TargetResultSet targetResultSet
           
 
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
(package private) SetOpResultSet(NoPutResultSet leftSource, NoPutResultSet rightSource, Activation activation, int resultSetNumber, long optimizerEstimatedRowCount, double optimizerEstimatedCost, int opType, boolean all, GeneratedMethod closeCleanup, int intermediateOrderByColumnsSavedObject, int intermediateOrderByDirectionSavedObject)
           
 
Method Summary
protected  void addWarning(java.sql.SQLWarning w)
           
private  void advanceRightPastDuplicates(DataValueDescriptor[] leftColumns)
           
protected  void attachStatementContext()
          Attach this result set to the top statement context on the stack.
 boolean checkRowPosition(int isType)
          Determine if the cursor is before the first row in the result set.
 void cleanUp()
          Clean up on error
 void clearCurrentRow()
          Clear the current row
protected  void clearOrderableCache(Qualifier[][] qualifiers)
          Clear the Orderable cache for each qualifier.
 void close()
          If the result set has been opened, close the currently open source.
 void closeRowSource()
          closeRowSource tells the RowSource that it will no longer need to return any rows and it can release any resource it may have.
private  int compare(DataValueDescriptor[] leftCols, DataValueDescriptor[] rightCols)
           
protected  java.lang.String dumpTimeStats(java.lang.String indent, java.lang.String subIndent)
          Dump out the time information for run time stats.
 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().
protected  void finishAndRTS()
           
 ExecRow getAbsoluteRow(int row)
          Returns the row at the absolute position from the query, and returns NULL when there is no such position.
 ResultSet getAutoGeneratedKeysResultset()
          ResultSet for rows inserted into the table (contains auto-generated keys columns only)
 java.sql.Timestamp getBeginExecutionTimestamp()
          Get the Timestamp for the beginning of execution.
protected  ExecRow getCompactRow(ExecRow candidate, FormatableBitSet accessedCols, FormatableBitSet otherCols, boolean isKeyed)
          Get a compacted version of the candidate row according to the columns specified in the bit map.
 ExecRow getCurrentRow()
          Returns the current row of the result set.
protected  long getCurrentTimeMillis()
          Return the current time in milliseconds, if DEBUG and RunTimeStats is on, else return 0.
 java.lang.String getCursorName()
          Return my cursor name for JDBC.
protected  long getElapsedMillis(long beginTime)
          Return the elapsed time in milliseconds, between now and the beginTime, if DEBUG and RunTimeStats is on, else return 0.
 java.sql.Timestamp getEndExecutionTimestamp()
          Get the Timestamp for the end of execution.
 double getEstimatedRowCount()
          Get the estimated row count from this result set.
 long getExecuteTime()
          Get the execution time in milliseconds.
(package private)  ExecutionFactory getExecutionFactory()
          Get a execution factory
 ExecRow getFirstRow()
          Returns the first row from the query, and returns NULL when there are no rows.
protected  LanguageConnectionContext getLanguageConnectionContext()
          Cache the language connection context.
 ExecRow getLastRow()
          Returns the last row from the query, and returns NULL when there are no rows.
 ExecRow getNextRow()
          Return the requested values computed from the next row (if any) for which the restriction evaluates to true.
 ExecRow getNextRowCore()
          Return the requested values computed from the next row (if any) for which the restriction evaluates to true.
 DataValueDescriptor[] getNextRowFromRowSource()
          Get the next row as an array of column objects.
 int getPointOfAttachment()
          Return the point of attachment for this subquery.
 ExecRow getPreviousRow()
          Returns the previous row from the query, and returns NULL when there are no more previous rows.
 ExecRow getRelativeRow(int row)
          Returns the row at the relative position from the current cursor position, and returns NULL when there is no such position.
 ResultDescription getResultDescription()
          Returns the description of the table's rows
 RowLocation getRowLocation()
          Returns the row location of the current base table row of the cursor.
 int getRowNumber()
          Returns the row number of the current row.
 int getScanIsolationLevel()
          Return the isolation level of the scan in the result set.
 NoPutResultSet[] getSubqueryTrackingArray(int numSubqueries)
          Get the subquery ResultSet tracking array from the top ResultSet.
 long getTimeSpent(int type)
          Return the total amount of time spent in this ResultSet
(package private)  TransactionController getTransactionController()
          Get the current transaction controller.
 FormatableBitSet getValidColumns()
          getValidColumns describes the DataValueDescriptor[] returned by all calls to the getNextRowFromRowSource() call.
 java.sql.SQLWarning getWarnings()
          Return the set of warnings generated during the execution of this result set.
 boolean isClosed()
          Report if closed.
private  boolean isDuplicate(DataValueDescriptor[] curColumns)
           
 boolean isForUpdate()
          Is this ResultSet or it's source result set for update This method will be overriden in the inherited Classes if it is true
 void markAsTopResultSet()
          Mark the ResultSet as the topmost one in the ResultSet tree.
 int modifiedRowCount()
          Returns the number of rows affected by the statement.
 boolean needsRowLocation()
          needsRowLocation returns true iff this the row source expects the drainer of the row source to call rowLocation after getting a row from getNextRowFromRowSource.
 boolean needsToClone()
          Does the caller of getNextRowFromRowSource() need to clone the row in order to keep a reference to the row past the getNextRowFromRowSource() call which returned the row.
 void open()
          open a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...
 void openCore()
          open the first source.
static java.lang.String printQualifiers(Qualifier[][] qualifiers)
          Return a 2-d array of Qualifiers as a String
 void reopenCore()
          This is the default implementation of reopenCore().
 boolean requiresRelocking()
          Do we need to relock the row when going to the heap.
 int resultSetNumber()
          Get the number of this ResultSet, which is guaranteed to be unique within a statement.
 boolean returnsRows()
          Returns true.
 void rowLocation(RowLocation rl)
          rowLocation is a callback for the drainer of the row source to return the rowLocation of the current row, i.e, the row that is being returned by getNextRowFromRowSource.
 ExecRow setAfterLastRow()
          Sets the current position to after the last row and returns NULL because there is no current row.
 ExecRow setBeforeFirstRow()
          Sets the current position to before the first row and returns NULL because there is no current row.
protected  void setCheckConstraints(GeneratedMethod checkGM)
          Set the GeneratedMethod for enforcing check constraints
protected  ExecRow setCompactRow(ExecRow candidateRow, ExecRow compactRow)
          Copy columns from the candidate row from the store to the given compact row.
protected  void setCompatRow(ExecRow compactRow, java.lang.Object[] sourceRow)
           
 void setCurrentRow(ExecRow row)
          Set the current row to the row passed in.
protected  void setHeapConglomerate(long heapConglomerate)
          Set the heap conglomerate number (used in enforcing check constraints)
 void setNeedsRowLocation(boolean needsRowLocation)
          Set whether or not the NPRS need the row location when acting as a row source.
 void setTargetResultSet(TargetResultSet trs)
          Notify a NPRS that it is the source for the specified TargetResultSet.
protected  boolean skipRow(ExecRow row)
          Return true if we should skip the scan due to nulls in the row when the start or stop positioners on the columns containing null do not implement ordered null semantics.
protected  boolean skipScan(ExecIndexRow startPosition, ExecIndexRow stopPosition)
          Return true if we should skip the scan due to nulls in the start or stop position when the predicate on the column(s) in question do not implement ordered null semantics. beetle 4464, we also compact the areNullsOrdered flags into checkNullCols here.
 
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, getAbsoluteRow, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCursorName, getEndExecutionTimestamp, getExecuteTime, getFirstRow, getLastRow, getNextRow, getPreviousRow, getRelativeRow, getResultDescription, getRowNumber, getSubqueryTrackingArray, getWarnings, isClosed, modifiedRowCount, open, returnsRows, setAfterLastRow, setBeforeFirstRow
 

Field Detail

leftSource

private final NoPutResultSet leftSource

rightSource

private final NoPutResultSet rightSource

closeCleanup

private final GeneratedMethod closeCleanup

activation

private final Activation activation

opType

private final int opType

all

private final boolean all

resultSetNumber

private final int resultSetNumber

prevCols

private DataValueDescriptor[] prevCols

rightDuplicateCount

private int rightDuplicateCount

leftInputRow

private ExecRow leftInputRow

rightInputRow

private ExecRow rightInputRow

intermediateOrderByColumns

private final int[] intermediateOrderByColumns

intermediateOrderByDirection

private final int[] intermediateOrderByDirection

indent

protected java.lang.String indent

subIndent

protected java.lang.String subIndent

sourceDepth

protected int sourceDepth

clonedExecRow

protected ExecRow clonedExecRow

checkGM

GeneratedMethod checkGM

heapConglomerate

long heapConglomerate

targetResultSet

protected TargetResultSet targetResultSet

checkNullCols

protected int[] checkNullCols

cncLen

protected int cncLen

isOpen

protected boolean isOpen

finished

protected boolean finished

currentRow

protected ExecRow currentRow

isTopResultSet

protected boolean isTopResultSet

lcc

protected LanguageConnectionContext lcc

numOpens

public int numOpens

rowsSeen

public int rowsSeen

rowsFiltered

public int rowsFiltered

startExecutionTime

protected long startExecutionTime

endExecutionTime

protected long endExecutionTime

beginTime

public long beginTime

constructorTime

public long constructorTime

openTime

public long openTime

nextTime

public long nextTime

closeTime

public long closeTime

optimizerEstimatedRowCount

public double optimizerEstimatedRowCount

optimizerEstimatedCost

public double optimizerEstimatedCost

subqueryTrackingArray

public NoPutResultSet[] subqueryTrackingArray

compactRow

ExecRow compactRow

resultDescription

ResultDescription resultDescription
Constructor Detail

SetOpResultSet

SetOpResultSet(NoPutResultSet leftSource,
               NoPutResultSet rightSource,
               Activation activation,
               int resultSetNumber,
               long optimizerEstimatedRowCount,
               double optimizerEstimatedCost,
               int opType,
               boolean all,
               GeneratedMethod closeCleanup,
               int intermediateOrderByColumnsSavedObject,
               int intermediateOrderByDirectionSavedObject)
Method Detail

openCore

public void openCore()
              throws StandardException
open the first source.

Specified by:
openCore in interface NoPutResultSet
Specified by:
openCore in class BasicNoPutResultSetImpl
Throws:
StandardException - thrown on failure
See Also:
NoPutResultSet.openCore()

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 of the intersect or except, null if there is none
Throws:
StandardException - thrown on failure
See Also:
NoPutResultSet.getNextRowCore()

advanceRightPastDuplicates

private void advanceRightPastDuplicates(DataValueDescriptor[] leftColumns)
                                 throws StandardException
Throws:
StandardException

compare

private int compare(DataValueDescriptor[] leftCols,
                    DataValueDescriptor[] rightCols)
             throws StandardException
Throws:
StandardException

isDuplicate

private boolean isDuplicate(DataValueDescriptor[] curColumns)
                     throws StandardException
Throws:
StandardException

getCurrentRow

public ExecRow getCurrentRow()
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.

close

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

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

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

getTimeSpent

public long getTimeSpent(int type)
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
See Also:
CursorResultSet

getResultDescription

public ResultDescription getResultDescription()
Returns the description of the table's rows

Specified by:
getResultDescription in interface ResultSet
Overrides:
getResultDescription in class BasicNoPutResultSetImpl

getCursorName

public java.lang.String getCursorName()
Return my cursor name for JDBC. Can be null.

Returns:
A String with the name of the cursor, if any. Returns NULL if this is not a cursor statement.

resultSetNumber

public int resultSetNumber()
Description copied from interface: NoPutResultSet
Get the number of this ResultSet, which is guaranteed to be unique within a statement.

Specified by:
resultSetNumber in interface NoPutResultSet
Overrides:
resultSetNumber in class BasicNoPutResultSetImpl
See Also:
NoPutResultSet.resultSetNumber()

setTargetResultSet

public void setTargetResultSet(TargetResultSet trs)
Description copied from interface: NoPutResultSet
Notify a NPRS that it is the source for the specified TargetResultSet. This is useful when doing bulk insert.

Parameters:
trs - The TargetResultSet.
Returns:
Nothing.
See Also:
NoPutResultSet.setTargetResultSet(org.apache.derby.iapi.sql.execute.TargetResultSet)

setNeedsRowLocation

public void setNeedsRowLocation(boolean needsRowLocation)
Description copied from interface: NoPutResultSet
Set whether or not the NPRS need the row location when acting as a row source. (The target result set determines this.)

Returns:
Nothing.
See Also:
NoPutResultSet.setNeedsRowLocation(boolean)

getValidColumns

public FormatableBitSet getValidColumns()
Description copied from interface: RowSource
getValidColumns describes the DataValueDescriptor[] returned by all calls to the getNextRowFromRowSource() call. If getValidColumns returns null, the number of columns is given by the DataValueDescriptor.length where DataValueDescriptor[] is returned by the preceeding getNextRowFromRowSource() call. Column N maps to DataValueDescriptor[N], where column numbers start at zero. If getValidColumns return a non null validColumns FormatableBitSet the number of columns is given by the number of bits set in validColumns. Column N is not in the partial row if validColumns.get(N) returns false. Column N is in the partial row if validColumns.get(N) returns true. If column N is in the partial row then it maps to DataValueDescriptor[M] where M is the count of calls to validColumns.get(i) that return true where i < N. If DataValueDescriptor.length is greater than the number of columns indicated by validColumns the extra entries are ignored.

See Also:
RowSource.getValidColumns()

getNextRowFromRowSource

public DataValueDescriptor[] getNextRowFromRowSource()
                                              throws StandardException
Description copied from interface: RowSource
Get the next row as an array of column objects. The column objects can be a JBMS Storable or any Serializable/Externalizable/Formattable/Streaming type.
A return of null indicates that the complete set of rows has been read.

A null column can be specified by leaving the object null, or indicated by returning a non-null getValidColumns. On streaming columns, it can be indicated by returning a non-null get FieldStates.

If RowSource.needToClone() is true then the returned row (the DataValueDescriptor[]) is guaranteed not to be modified by drainer of the RowSource (except that the input stream will be read, of course) and drainer will keep no reference to it before making the subsequent nextRow call. So it is safe to return the same DataValueDescriptor[] in subsequent nextRow calls if that is desirable for performance reasons.

If RowSource.needToClone() is false then the returned row (the DataValueDescriptor[]) may be be modified by drainer of the RowSource, and the drainer may keep a reference to it after making the subsequent nextRow call. In this case the client should severe all references to the row after returning it from getNextRowFromRowSource().

Throws:
StandardException - on error
See Also:
RowSource.getNextRowFromRowSource()

needsToClone

public boolean needsToClone()
Description copied from interface: RowSource
Does the caller of getNextRowFromRowSource() need to clone the row in order to keep a reference to the row past the getNextRowFromRowSource() call which returned the row. This call must always return the same for all rows in a RowSource (ie. the caller will call this once per scan from a RowSource and assume the behavior is true for all rows in the RowSource).

See Also:
RowSource.needsToClone()

closeRowSource

public void closeRowSource()
Description copied from interface: RowSource
closeRowSource tells the RowSource that it will no longer need to return any rows and it can release any resource it may have. Subsequent call to any method on the RowSource will result in undefined behavior. A closed rowSource can be closed again.

See Also:
RowSource.closeRowSource()

needsRowLocation

public boolean needsRowLocation()
Description copied from interface: RowLocationRetRowSource
needsRowLocation returns true iff this the row source expects the drainer of the row source to call rowLocation after getting a row from getNextRowFromRowSource.

Returns:
true iff this row source expects some row location to be returned
See Also:
RowLocationRetRowSource.needsRowLocation()

rowLocation

public void rowLocation(RowLocation rl)
                 throws StandardException
Description copied from interface: RowLocationRetRowSource
rowLocation is a callback for the drainer of the row source to return the rowLocation of the current row, i.e, the row that is being returned by getNextRowFromRowSource. This interface is for the purpose of loading a base table with index. In that case, the indices can be built at the same time the base table is laid down once the row location of the base row is known. This is an example pseudo code on how this call is expected to be used:
                boolean needsRL = rowSource.needsRowLocation();
                DataValueDescriptor[] row;
                while((row = rowSource.getNextRowFromRowSource()) != null)
                {
                        RowLocation rl = heapConglomerate.insertRow(row);
                        if (needsRL)
                                rowSource.rowLocation(rl);
                }
                

NeedsRowLocation and rowLocation will ONLY be called by a drainer of the row source which CAN return a row location. Drainer of row source which cannot return rowLocation will guarentee to not call either callbacks. Conversely, if NeedsRowLocation is called and it returns true, then for every row return by getNextRowFromRowSource, a rowLocation callback must also be issued with the row location of the row. Implementor of both the source and the drain of the row source must be aware of this protocol.
The RowLocation object is own by the caller of rowLocation, in other words, the drainer of the RowSource. This is so that we don't need to new a row location for every row. If the Row Source wants to keep the row location, it needs to clone it (RowLocation is a ClonableObject).

Throws:
StandardException - on error
See Also:
RowLocationRetRowSource.rowLocation(org.apache.derby.iapi.types.RowLocation)

clearOrderableCache

protected void clearOrderableCache(Qualifier[][] qualifiers)
                            throws StandardException
Clear the Orderable cache for each qualifier. (This should be done each time a scan/conglomerate with qualifiers is reopened.)

Parameters:
qualifiers - The Qualifiers to clear
Returns:
Nothing.
Throws:
StandardException

setCheckConstraints

protected void setCheckConstraints(GeneratedMethod checkGM)
Set the GeneratedMethod for enforcing check constraints

Parameters:
checkGM - The GeneratedMethod for enforcing any check constraints.
Returns:
Nothing.

setHeapConglomerate

protected void setHeapConglomerate(long heapConglomerate)
Set the heap conglomerate number (used in enforcing check constraints)

Parameters:
heapConglomerate - The heap conglomerate number.
Returns:
Nothing.

setCurrentRow

public final void setCurrentRow(ExecRow row)
Set the current row to the row passed in.

Parameters:
row - the new current row

clearCurrentRow

public final void clearCurrentRow()
Clear the current row


isForUpdate

public boolean isForUpdate()
Is this ResultSet or it's source result set for update This method will be overriden in the inherited Classes if it is true

Specified by:
isForUpdate in interface NoPutResultSet
Overrides:
isForUpdate in class BasicNoPutResultSetImpl
Returns:
Whether or not the result set is for update.

skipScan

protected boolean skipScan(ExecIndexRow startPosition,
                           ExecIndexRow stopPosition)
                    throws StandardException
Return true if we should skip the scan due to nulls in the start or stop position when the predicate on the column(s) in question do not implement ordered null semantics. beetle 4464, we also compact the areNullsOrdered flags into checkNullCols here.

Parameters:
startPosition - An index row for the start position
stopPosition - An index row for the stop position
Returns:
true means not to do the scan
Throws:
StandardException

skipRow

protected boolean skipRow(ExecRow row)
                   throws StandardException
Return true if we should skip the scan due to nulls in the row when the start or stop positioners on the columns containing null do not implement ordered null semantics.

Parameters:
row - An index row
Returns:
true means skip the row because it has null
Throws:
StandardException

printQualifiers

public static java.lang.String printQualifiers(Qualifier[][] qualifiers)
Return a 2-d array of Qualifiers as a String


reopenCore

public void reopenCore()
                throws StandardException
This is the default implementation of reopenCore(). It simply does a close() followed by an open(). If there are optimizations to be made (caching, etc), this is a good place to do it -- this will be overridden by a number of resultSet imlementations. and SHOULD be overridden by any node that can get between a base table and a join.

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

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
Returns:
int Point of attachment (result set number) for this subquery. (-1 if not a subquery - also Sanity violation)
See Also:
NoPutResultSet.getPointOfAttachment()

markAsTopResultSet

public void markAsTopResultSet()
Mark the ResultSet as the topmost one in the ResultSet tree. Useful for closing down the ResultSet on an error.

Specified by:
markAsTopResultSet in interface NoPutResultSet
Returns:
Nothing.

getScanIsolationLevel

public int getScanIsolationLevel()
Description copied from interface: NoPutResultSet
Return the isolation level of the scan in the result set. Only expected to be called for those ResultSets that contain a scan.

Specified by:
getScanIsolationLevel in interface NoPutResultSet
Returns:
The isolation level of the scan (in TransactionController constants).
See Also:
NoPutResultSet.getScanIsolationLevel()

getEstimatedRowCount

public double getEstimatedRowCount()
Description copied from interface: NoPutResultSet
Get the estimated row count from this result set.

Specified by:
getEstimatedRowCount in interface NoPutResultSet
Returns:
The estimated row count (as a double) from this result set.
See Also:
NoPutResultSet.getEstimatedRowCount()

requiresRelocking

public boolean requiresRelocking()
Description copied from interface: NoPutResultSet
Do we need to relock the row when going to the heap.

Specified by:
requiresRelocking in interface NoPutResultSet
Returns:
Whether or not we need to relock the row when going to the heap.
See Also:
NoPutResultSet.requiresRelocking()

open

public final void open()
                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... NOTE: This method should only be called on the top ResultSet of a ResultSet tree to ensure that the entire ResultSet tree gets closed down on an error. the openCore() method will be called for all other ResultSets in the tree.

Specified by:
open in interface ResultSet
Returns:
Nothing
Throws:
StandardException - thrown if cursor finished.

getAbsoluteRow

public ExecRow getAbsoluteRow(int row)
                       throws StandardException
Returns the row at the absolute position from the query, and returns NULL when there is no such position. (Negative position means from the end of the result set.) Moving the cursor to an invalid position leaves the cursor positioned either before the first row (negative position) or after the last row (positive position). NOTE: An exception will be thrown on 0.

Specified by:
getAbsoluteRow in interface ResultSet
Parameters:
row - The position.
Returns:
The row at the absolute position, or NULL if no such position.
Throws:
StandardException - Thrown on failure
See Also:
Row

getRelativeRow

public ExecRow getRelativeRow(int row)
                       throws StandardException
Returns the row at the relative position from the current cursor position, and returns NULL when there is no such position. (Negative position means toward the beginning of the result set.) Moving the cursor to an invalid position leaves the cursor positioned either before the first row (negative position) or after the last row (positive position). NOTE: 0 is valid. NOTE: An exception is thrown if the cursor is not currently positioned on a row.

Specified by:
getRelativeRow in interface ResultSet
Parameters:
row - The position.
Returns:
The row at the relative position, or NULL if no such position.
Throws:
StandardException - Thrown on failure
See Also:
Row

setBeforeFirstRow

public ExecRow setBeforeFirstRow()
                          throws StandardException
Sets the current position to before the first row and returns NULL because there is no current row.

Specified by:
setBeforeFirstRow in interface ResultSet
Returns:
NULL.
Throws:
StandardException - Thrown on failure
See Also:
Row

checkRowPosition

public boolean checkRowPosition(int isType)
                         throws StandardException
Determine if the cursor is before the first row in the result set.

Specified by:
checkRowPosition in interface ResultSet
Returns:
true if before the first row, false otherwise. Returns false when the result set contains no rows.
Throws:
StandardException - Thrown on error.

getRowNumber

public int getRowNumber()
Returns the row number of the current row. Row numbers start from 1 and go to 'n'. Corresponds to row numbering used to position current row in the result set (as per JDBC).

Specified by:
getRowNumber in interface ResultSet
Returns:
the row number, or 0 if not on a row

getFirstRow

public ExecRow getFirstRow()
                    throws StandardException
Returns the first row from the query, and returns NULL when there are no rows.

Specified by:
getFirstRow in interface ResultSet
Returns:
The first row, or NULL if no rows.
Throws:
StandardException - Thrown on failure
See Also:
Row

getNextRow

public final ExecRow getNextRow()
                         throws StandardException
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. NOTE: This method should only be called on the top ResultSet of a ResultSet tree to ensure that the entire ResultSet tree gets closed down on an error. the getNextRowCore() method will be called for all other ResultSets in the tree.

Specified by:
getNextRow in interface ResultSet
Returns:
the next row in the result
Throws:
StandardException - thrown on failure.
StandardException - ResultSetNotOpen thrown if not yet open.
See Also:
Row

getPreviousRow

public ExecRow getPreviousRow()
                       throws StandardException
Returns the previous row from the query, and returns NULL when there are no more previous rows.

Specified by:
getPreviousRow in interface ResultSet
Returns:
The previous row, or NULL if no more previous rows.
Throws:
StandardException - Thrown on failure
See Also:
Row

getLastRow

public ExecRow getLastRow()
                   throws StandardException
Returns the last row from the query, and returns NULL when there are no rows.

Specified by:
getLastRow in interface ResultSet
Returns:
The last row, or NULL if no rows.
Throws:
StandardException - Thrown on failure
See Also:
Row

setAfterLastRow

public ExecRow setAfterLastRow()
                        throws StandardException
Sets the current position to after the last row and returns NULL because there is no current row.

Specified by:
setAfterLastRow in interface ResultSet
Returns:
NULL.
Throws:
StandardException - Thrown on failure
See Also:
Row

returnsRows

public boolean returnsRows()
Returns true.

Specified by:
returnsRows in interface ResultSet
Returns:
TRUE if the statement returns rows, FALSE if not.

modifiedRowCount

public final int modifiedRowCount()
Description copied from interface: ResultSet
Returns the number of rows affected by the statement. Only valid of returnsRows() returns false. For other DML statements, it returns the number of rows modified by the statement. For statements that do not affect rows (like DDL statements), it returns zero.

Specified by:
modifiedRowCount in interface ResultSet
Returns:
The number of rows affect by the statement, so far.

cleanUp

public void cleanUp()
             throws StandardException
Clean up on error

Specified by:
cleanUp in interface ResultSet
Returns:
Nothing
Throws:
StandardException - Thrown on failure

isClosed

public boolean isClosed()
Report if closed.

Specified by:
isClosed in interface ResultSet
Returns:
true if the ResultSet has been closed.

finishAndRTS

protected final void finishAndRTS()
                           throws StandardException
Throws:
StandardException - on error

getExecuteTime

public long getExecuteTime()
Get the execution time in milliseconds.

Specified by:
getExecuteTime in interface ResultSet
Returns:
long The execution time in milliseconds.

getBeginExecutionTimestamp

public java.sql.Timestamp getBeginExecutionTimestamp()
Get the Timestamp for the beginning of execution.

Specified by:
getBeginExecutionTimestamp in interface ResultSet
Returns:
Timestamp The Timestamp for the beginning of execution.

getEndExecutionTimestamp

public java.sql.Timestamp getEndExecutionTimestamp()
Get the Timestamp for the end of execution.

Specified by:
getEndExecutionTimestamp in interface ResultSet
Returns:
Timestamp The Timestamp for the end of execution.

getSubqueryTrackingArray

public final NoPutResultSet[] getSubqueryTrackingArray(int numSubqueries)
Description copied from interface: ResultSet
Get the subquery ResultSet tracking array from the top ResultSet. (Used for tracking open subqueries when closing down on an error.)

Specified by:
getSubqueryTrackingArray in interface ResultSet
Parameters:
numSubqueries - The size of the array (For allocation on demand.)
Returns:
NoPutResultSet[] Array of NoPutResultSets for subqueries.
See Also:
ResultSet.getSubqueryTrackingArray(int)

getCurrentTimeMillis

protected final long getCurrentTimeMillis()
Return the current time in milliseconds, if DEBUG and RunTimeStats is on, else return 0. (Only pay price of system call if need to.)

Returns:
long Current time in milliseconds.

getAutoGeneratedKeysResultset

public ResultSet getAutoGeneratedKeysResultset()
Description copied from interface: ResultSet
ResultSet for rows inserted into the table (contains auto-generated keys columns only)

Specified by:
getAutoGeneratedKeysResultset in interface ResultSet
Returns:
NoPutResultSet NoPutResultSets for rows inserted into the table.
See Also:
ResultSet.getAutoGeneratedKeysResultset()

getElapsedMillis

protected final long getElapsedMillis(long beginTime)
Return the elapsed time in milliseconds, between now and the beginTime, if DEBUG and RunTimeStats is on, else return 0. (Only pay price of system call if need to.)

Returns:
long Elapsed time in milliseconds.

dumpTimeStats

protected final java.lang.String dumpTimeStats(java.lang.String indent,
                                               java.lang.String subIndent)
Dump out the time information for run time stats.

Returns:
Nothing.

attachStatementContext

protected void attachStatementContext()
                               throws StandardException
Attach this result set to the top statement context on the stack. Result sets can be directly read from the JDBC layer. The JDBC layer will push and pop a statement context around each ResultSet.getNext(). There's no guarantee that the statement context used for the last getNext() will be the context used for the current getNext(). The last statement context may have been popped off the stack and so will not be available for cleanup if an error occurs. To make sure that we will be cleaned up, we always attach ourselves to the top context. The fun and games occur in nested contexts: using JDBC result sets inside user code that is itself invoked from queries or CALL statements.

Throws:
StandardException - thrown if cursor finished.

getLanguageConnectionContext

protected final LanguageConnectionContext getLanguageConnectionContext()
Cache the language connection context. Return it.

Returns:
the language connection context

getExecutionFactory

final ExecutionFactory getExecutionFactory()
Get a execution factory

Returns:
the execution factory

getTransactionController

final TransactionController getTransactionController()
Get the current transaction controller.


getCompactRow

protected ExecRow getCompactRow(ExecRow candidate,
                                FormatableBitSet accessedCols,
                                FormatableBitSet otherCols,
                                boolean isKeyed)
                         throws StandardException
Get a compacted version of the candidate row according to the columns specified in the bit map. Share the holders between rows. If there is no bit map, use the candidate row as the compact row. Also, create an array of ints mapping base column positions to compact column positions, to make it cheaper to copy columns to the compact row, if we ever have to do it again.

Parameters:
candidate - The row to get the columns from
accessedCols - A bit map of the columns that are accessed in the candidate row
otherCols - An bit map of other column ids - this is used in case columns from an index row will be copied into a heap row - in this case, we need to be sure there are enough columns in the compact row. This parameter is null if columns will not be copied from an index row to a compact heap row. The column numbers in the bit map are zero-based.
isKeyed - Tells whether to return a ValueRow or an IndexRow
Returns:
A compact row.
Throws:
StandardException

setCompactRow

protected ExecRow setCompactRow(ExecRow candidateRow,
                                ExecRow compactRow)
Copy columns from the candidate row from the store to the given compact row. If there is no column map, just use the candidate row. This method assumes the above method (getCompactRow()) was called first. getCompactRow() sets up the baseColumnMap.

Parameters:
candidateRow - The candidate row from the store
compactRow - The compact row to fill in
Returns:
The compact row to use

setCompatRow

protected final void setCompatRow(ExecRow compactRow,
                                  java.lang.Object[] sourceRow)

addWarning

protected final void addWarning(java.sql.SQLWarning w)

getWarnings

public final java.sql.SQLWarning getWarnings()
Description copied from interface: ResultSet
Return the set of warnings generated during the execution of this result set. The warnings are cleared once this call returns.

Specified by:
getWarnings in interface ResultSet

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.