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

java.lang.Object
  extended by org.apache.derby.impl.sql.execute.NoRowsResultSetImpl
All Implemented Interfaces:
ResultSet
Direct Known Subclasses:
CallStatementResultSet, DMLWriteResultSet, MiscResultSet

abstract class NoRowsResultSetImpl
extends java.lang.Object
implements ResultSet

Abstract ResultSet for implementations that do not return rows. Examples are DDL statements, CALL statements and DML.

An implementation must provide a ResultSet.open() method that performs the required action.

ResultSet.returnsRows() returns false and any method that fetches a row will throw an exception.


Field Summary
(package private)  Activation activation
           
protected  long beginExecutionTime
           
protected  long beginTime
           
protected  long endExecutionTime
           
protected  long endTime
           
private  int firstColumn
           
private  int[] generatedColumnPositions
           
private  boolean isOpen
          True if the result set has been opened, and not yet closed.
(package private)  LanguageConnectionContext lcc
           
private  DataValueDescriptor[] normalizedGeneratedValues
           
private  boolean statisticsTimingOn
           
private  NoPutResultSet[] subqueryTrackingArray
           
 
Fields inherited from interface org.apache.derby.iapi.sql.ResultSet
CURRENT_RESULTSET_ONLY, ENTIRE_RESULTSET_TREE, ISAFTERLAST, ISBEFOREFIRST, ISFIRST, ISLAST
 
Constructor Summary
NoRowsResultSetImpl(Activation activation)
           
 
Method Summary
 boolean checkRowPosition(int isType)
          Determine if the cursor is before the first row in the result set.
 void clearCurrentRow()
          Clear the current row.
 void close()
          Dump the stat if not already done so.
 boolean doesCommit()
          Does this ResultSet cause a commit or rollback.
static void evaluateACheckConstraint(GeneratedMethod checkGM, java.lang.String checkName, long heapConglom, Activation activation)
          Run a check constraint against the current row.
static void evaluateCheckConstraints(GeneratedMethod checkGM, Activation activation)
          Run check constraints against the current row.
 void evaluateGenerationClauses(GeneratedMethod generationClauses, Activation activation, NoPutResultSet source, ExecRow newRow, boolean isUpdate)
          Compute the generation clauses on the current row in order to fill in computed columns.
 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 getAbsoluteRow(int row)
          Returns the row at the absolute position from the query, and returns NULL when there is no such position.
 Activation getActivation()
           
 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  long getCurrentTimeMillis()
          Return the current time in milliseconds, if DEBUG and RunTimeStats is on, else return 0.
 java.lang.String getCursorName()
          Return the cursor name, null in this case.
 java.sql.Timestamp getEndExecutionTimestamp()
          Get the Timestamp for the end of execution.
 long getExecuteTime()
          Get the execution time in milliseconds.
 ExecRow getFirstRow()
          Returns the first row from the query, and returns NULL when there are no rows.
 ExecRow getLastRow()
          Returns the last row from the query, and returns NULL when there are no rows.
 ExecRow getNextRow()
          No rows to return, so throw an exception.
 ExecRow getPreviousRow()
          Returns the previous row from the query, and returns NULL when there are no more previous rows.
 java.lang.String getQueryPlanText(int depth)
          RESOLVE - This method will go away once it is overloaded in all subclasses.
 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 null.
 int getRowNumber()
          Returns the row number of the current row.
 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
 java.sql.SQLWarning getWarnings()
          Return the set of warnings generated during the execution of this result set.
 boolean isClosed()
          Find out if the ResultSet is closed.
 int modifiedRowCount()
          Returns zero.
 boolean returnsRows()
          Returns FALSE
 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.
(package private)  void setup()
          Set up the result set for use.
private  void setupGeneratedColumns(Activation activation, ValueRow newRow)
          Construct support for normalizing generated columns.
 
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
cleanUp, open
 

Field Detail

activation

final Activation activation

subqueryTrackingArray

private NoPutResultSet[] subqueryTrackingArray

statisticsTimingOn

private final boolean statisticsTimingOn

isOpen

private boolean isOpen
True if the result set has been opened, and not yet closed.


lcc

final LanguageConnectionContext lcc

beginTime

protected long beginTime

endTime

protected long endTime

beginExecutionTime

protected long beginExecutionTime

endExecutionTime

protected long endExecutionTime

firstColumn

private int firstColumn

generatedColumnPositions

private int[] generatedColumnPositions

normalizedGeneratedValues

private DataValueDescriptor[] normalizedGeneratedValues
Constructor Detail

NoRowsResultSetImpl

NoRowsResultSetImpl(Activation activation)
Method Detail

setup

void setup()
     throws StandardException
Set up the result set for use. Should always be called from open().

Throws:
StandardException - thrown on error

returnsRows

public final boolean returnsRows()
Returns FALSE

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

modifiedRowCount

public int modifiedRowCount()
Returns zero.

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

getResultDescription

public ResultDescription getResultDescription()
Returns null.

Specified by:
getResultDescription in interface ResultSet
Returns:
A ResultDescription describing the results of the statement.

getActivation

public final Activation getActivation()
Specified by:
getActivation in interface ResultSet

getAbsoluteRow

public final 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 final 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 final 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

getFirstRow

public final 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
No rows to return, so throw an exception.

Specified by:
getNextRow in interface ResultSet
Returns:
The next row, or NULL if no more rows.
Throws:
StandardException - Always throws a StandardException to indicate that this method is not intended to be used.
See Also:
Row

getPreviousRow

public final 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 final 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 final 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

clearCurrentRow

public final void clearCurrentRow()
Clear the current row. This is done after a commit on holdable result sets. This is a no-op on result set which do not provide rows.

Specified by:
clearCurrentRow in interface ResultSet

checkRowPosition

public final boolean checkRowPosition(int isType)
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.

getRowNumber

public final 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

close

public void close()
           throws StandardException
Dump the stat if not already done so. Close all of the open subqueries.

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

isClosed

public boolean isClosed()
Find out if the ResultSet is closed.

Specified by:
isClosed in interface ResultSet
Returns:
true if closed, false otherwise

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
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.

getQueryPlanText

public java.lang.String getQueryPlanText(int depth)
RESOLVE - This method will go away once it is overloaded in all subclasses. Return the query plan as a String.

Parameters:
depth - Indentation level.
Returns:
String The query plan as a String.

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).

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)

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()

getCursorName

public java.lang.String getCursorName()
Return the cursor name, null in this case.

Specified by:
getCursorName in interface ResultSet
Returns:
A String with the name of the cursor, if any. Returns NULL if this is not a cursor statement.
See Also:
ResultSet.getCursorName()

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.

evaluateACheckConstraint

public static void evaluateACheckConstraint(GeneratedMethod checkGM,
                                            java.lang.String checkName,
                                            long heapConglom,
                                            Activation activation)
                                     throws StandardException
Run a check constraint against the current row. Raise an error if the check constraint is violated.

Parameters:
checkGM - Generated code to run the check constraint.
checkName - Name of the constraint to check.
heapConglom - Number of heap conglomerate.
activation - Class in which checkGM lives.
Throws:
StandardException - thrown on error

evaluateGenerationClauses

public void evaluateGenerationClauses(GeneratedMethod generationClauses,
                                      Activation activation,
                                      NoPutResultSet source,
                                      ExecRow newRow,
                                      boolean isUpdate)
                               throws StandardException
Compute the generation clauses on the current row in order to fill in computed columns.

Parameters:
generationClauses - the generated method which evaluates generation clauses
activation - the thread-specific instance of the generated class
source - the tuple stream driving this INSERT/UPDATE
newRow - the base row being stuffed
isUpdate - true if this is an UPDATE. false otherwise.
Throws:
StandardException

setupGeneratedColumns

private void setupGeneratedColumns(Activation activation,
                                   ValueRow newRow)
                            throws StandardException
Construct support for normalizing generated columns. This figures out which columns in the target row have generation clauses which need to be run.

Throws:
StandardException

evaluateCheckConstraints

public static void evaluateCheckConstraints(GeneratedMethod checkGM,
                                            Activation activation)
                                     throws StandardException
Run check constraints against the current row. Raise an error if a check constraint is violated.

Parameters:
checkGM - Generated code to run the check constraint.
activation - Class in which checkGM lives.
Throws:
StandardException - thrown on error

doesCommit

public boolean doesCommit()
Does this ResultSet cause a commit or rollback.

Returns:
Whether or not this ResultSet cause a commit or rollback.

getWarnings

public 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 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.