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

java.lang.Object
  extended byorg.apache.derby.impl.sql.execute.NoRowsResultSetImpl
      extended byorg.apache.derby.impl.sql.execute.DMLWriteResultSet
          extended byorg.apache.derby.impl.sql.execute.InsertResultSet
All Implemented Interfaces:
ResultSet, TargetResultSet

public class InsertResultSet
extends DMLWriteResultSet
implements TargetResultSet

Insert the rows from the source into the specified base table. This will cause constraints to be checked and triggers to be executed based on the c's and t's compiled into the insert plan.


Nested Class Summary
(package private)  class InsertResultSet.MyRowAllocator
           
 
Field Summary
protected  Activation activation
           
private  NumberDataValue[] aiCache
          keeps track of autoincrement values that are generated by getSetAutoincrementValues.
 ResultSet autoGeneratedKeysResultSet
           
private  TemporaryRowHolderImpl autoGeneratedKeysRowsHolder
           
protected  boolean autoincrementGenerated
          If set to true, implies that this (rep)insertresultset has generated autoincrement values.
protected  int[] baseRowReadMap
           
protected  long beginExecutionTime
           
protected  long beginTime
           
private  ConglomerateController bulkHeapCC
           
private  ScanController bulkHeapSC
           
protected  boolean bulkInsert
           
 boolean bulkInsertPerformed
           
private  boolean bulkInsertReplace
           
private  GeneratedMethod checkGM
           
protected  WriteCursorConstantAction constantAction
           
 InsertConstantAction constants
           
protected  DataDictionary dd
           
protected  ExecRow deferredSparseRow
           
protected  long endExecutionTime
           
protected  long endTime
           
private  boolean firstExecute
           
private  boolean firstRow
           
private  RISetChecker fkChecker
           
private  FKInfo[] fkInfoArray
           
private  ExecRow fullTemplate
           
private  boolean hasBeforeRowTrigger
           
private  boolean hasBeforeStatementTrigger
           
private  long heapConglom
           
protected  DynamicCompiledOpenConglomInfo heapDCOCI
           
private  long identityVal
           
protected  java.lang.String indent
           
private  java.util.Hashtable indexConversionTable
           
protected  DynamicCompiledOpenConglomInfo[] indexDCOCIs
           
private  FormatableBitSet indexedCols
           
private  ExecIndexRow[] indexRows
           
 LanguageConnectionContext lcc
           
private  boolean[] needToDropSort
           
private  int numOpens
           
private  ColumnOrdering[][] ordering
           
 ResultDescription resultDescription
           
private  RowLocation rl
           
 ExecRow row
           
private  RowChanger rowChanger
           
 int rowCount
           
private  TemporaryRowHolderImpl rowHolder
           
private  RowLocationRetRowSource[] rowSources
           
 NoPutResultSet savedSource
           
private  boolean setIdentity
           
private  SortController[] sorters
           
private  long[] sortIds
           
protected  int sourceDepth
           
private  NoPutResultSet sourceResultSet
           
protected  int[] streamStorableHeapColIds
           
protected  java.lang.String subIndent
           
protected  NoPutResultSet[] subqueryTrackingArray
           
private  BulkTableScanResultSet tableScan
           
 TransactionController tc
           
protected  TableDescriptor td
           
private  TriggerEventActivator triggerActivator
           
private  TriggerInfo triggerInfo
           
 boolean userSpecifiedBulkInsert
           
 
Fields inherited from interface org.apache.derby.iapi.sql.ResultSet
CURRENT_RESULTSET_ONLY, ENTIRE_RESULTSET_TREE, ISAFTERLAST, ISBEFOREFIRST, ISFIRST, ISLAST
 
Constructor Summary
InsertResultSet(NoPutResultSet source, GeneratedMethod checkGM, Activation activation)
           
 
Method Summary
private  long bulkInsertCore(LanguageConnectionContext lcc, long oldHeapConglom)
           
private  void bulkValidateForeignKeys(TransactionController tc, ContextManager cm)
           
private  void bulkValidateForeignKeysCore(TransactionController tc, ContextManager cm, FKInfo fkInfo, long fkConglom, long pkConglom, java.lang.String fkConstraintName)
           
 void changedRow(ExecRow execRow, RowLocation rowLocation)
          Pass a changed row and the row location for that row to the target result set.
 boolean checkRowPosition(int isType)
          Determine if the cursor is before the first row in the result set.
 void cleanUp()
          Tells the system to clean up on an error.
 void close()
          No rows to return, does nothing
 boolean doesCommit()
          Does this ResultSet cause a commit or rollback.
private  void emptyIndexes(long newHeapConglom, InsertConstantAction constants, TableDescriptor td, DataDictionary dd, ExecRow fullTemplate)
          Empty the indexes after doing a bulk insert replace where the table has 0 rows after the replace.
static void evaluateACheckConstraint(GeneratedMethod checkGM, java.lang.String checkName, long heapConglom, Activation activation)
          Run a check constraint against the current row.
private  void evaluateCheckConstraints()
          Run the check constraints against the current row.
static void evaluateCheckConstraints(GeneratedMethod checkGM, Activation activation)
          Run check constraints against the current row.
 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().
private  int[] generatedColumnPositionsArray()
           
 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.
private  java.lang.String[] getColumnNames(int[] baseColumnPositions)
           
private  ExecRow getCompactRow(ExecRow inputRow, int[] columnIndexes)
           
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.
private  boolean getExclusiveTableLock()
          Get an exclusive table lock on the target table (and check to see if the table is populated if this is not a bulk insert replace).
 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.
(package private)  java.lang.String getIndexNameFromCID(long indexCID)
          get the index name given the conglomerate id of the index.
 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.
protected  ExecRow getNextRowCore(NoPutResultSet source)
          Get next row from the source result set.
 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 the description of the inserted rows.
 int getRowNumber()
          Returns the row number of the current row.
 NumberDataValue getSetAutoincrementValue(int columnPosition, long increment)
          getSetAutoincrementValue will get the autoincrement value of the columnPosition specified for the target table.
 NoPutResultSet[] getSubqueryTrackingArray(int numSubqueries)
          Get the subquery ResultSet tracking array from the top ResultSet.
private  BulkTableScanResultSet getTableScanResultSet(long conglomId)
          Get me a table scan result set, preferably a bulk table scan, thank you.
 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()
          Just report that it is always closed.
private  boolean isSourceRowResultSet()
           
protected  ExecRow makeDeferredSparseRow(ExecRow deferredBaseRow, FormatableBitSet baseRowReadList, LanguageConnectionContext lcc)
          For deferred update, get a deferred sparse row based on the deferred non-sparse row.
private  ExecRow makeIndexTemplate(FKInfo fkInfo, ExecRow fullTemplate, ContextManager cm)
          Make a template row with the correct columns.
 int modifiedRowCount()
          Returns the number of rows affected by the statement.
private  void normalInsertCore(LanguageConnectionContext lcc, boolean firstExecute)
           
 void open()
          Needs to be called before the result set will do anything.
 ExecRow preprocessSourceRow(ExecRow execRow)
          Preprocess the source row.
 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.
private  void setEstimatedRowCount(long heapConglom)
          Set the estimated row count for this table.
private  void setUpAllSorts(ExecRow sourceRow, RowLocation rl)
          Set up to update all of the indexes on a table when doing a bulk insert on an empty table.
private  int[] uniqueColumnPositionArray(int[] columnIndexes)
           
private  void updateAllIndexes(long newHeapConglom, InsertConstantAction constants, TableDescriptor td, DataDictionary dd, ExecRow fullTemplate)
          Update all of the indexes on a table when doing a bulk insert on an empty table.
private  void verifyAutoGeneratedColumnsIndexes(int[] columnIndexes)
           
private  void verifyAutoGeneratedColumnsNames(java.lang.String[] columnNames)
          Verify that the auto-generated columns list (by name) has valid column names for the table.
protected  boolean verifyBulkInsert()
          Verify that bulkInsert is allowed on this table.
 
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, close, getAbsoluteRow, getBeginExecutionTimestamp, getCursorName, getEndExecutionTimestamp, getExecuteTime, getFirstRow, getLastRow, getNextRow, getPreviousRow, getRelativeRow, getRowNumber, getSubqueryTrackingArray, getTimeSpent, getWarnings, isClosed, modifiedRowCount, returnsRows, setAfterLastRow, setBeforeFirstRow
 

Field Detail

sourceResultSet

private NoPutResultSet sourceResultSet

savedSource

public NoPutResultSet savedSource

constants

public InsertConstantAction constants

checkGM

private GeneratedMethod checkGM

heapConglom

private long heapConglom

autoGeneratedKeysResultSet

public ResultSet autoGeneratedKeysResultSet

autoGeneratedKeysRowsHolder

private TemporaryRowHolderImpl autoGeneratedKeysRowsHolder

resultDescription

public ResultDescription resultDescription

rowChanger

private RowChanger rowChanger

tc

public TransactionController tc

row

public ExecRow row

lcc

public LanguageConnectionContext lcc

userSpecifiedBulkInsert

public boolean userSpecifiedBulkInsert

bulkInsertPerformed

public boolean bulkInsertPerformed

bulkInsert

protected boolean bulkInsert

bulkInsertReplace

private boolean bulkInsertReplace

firstRow

private boolean firstRow

needToDropSort

private boolean[] needToDropSort

indexConversionTable

private java.util.Hashtable indexConversionTable

indexedCols

private FormatableBitSet indexedCols

bulkHeapCC

private ConglomerateController bulkHeapCC

dd

protected DataDictionary dd

td

protected TableDescriptor td

indexRows

private ExecIndexRow[] indexRows

fullTemplate

private ExecRow fullTemplate

sortIds

private long[] sortIds

rowSources

private RowLocationRetRowSource[] rowSources

bulkHeapSC

private ScanController bulkHeapSC

ordering

private ColumnOrdering[][] ordering

sorters

private SortController[] sorters

rowHolder

private TemporaryRowHolderImpl rowHolder

rl

private RowLocation rl

hasBeforeStatementTrigger

private boolean hasBeforeStatementTrigger

hasBeforeRowTrigger

private boolean hasBeforeRowTrigger

tableScan

private BulkTableScanResultSet tableScan

numOpens

private int numOpens

firstExecute

private boolean firstExecute

fkInfoArray

private FKInfo[] fkInfoArray

triggerInfo

private TriggerInfo triggerInfo

fkChecker

private RISetChecker fkChecker

triggerActivator

private TriggerEventActivator triggerActivator

aiCache

private NumberDataValue[] aiCache
keeps track of autoincrement values that are generated by getSetAutoincrementValues.


autoincrementGenerated

protected boolean autoincrementGenerated
If set to true, implies that this (rep)insertresultset has generated autoincrement values. During refresh for example, the autoincrement values are not generated but sent from the source to target or vice-versa.


identityVal

private long identityVal

setIdentity

private boolean setIdentity

constantAction

protected WriteCursorConstantAction constantAction

baseRowReadMap

protected int[] baseRowReadMap

streamStorableHeapColIds

protected int[] streamStorableHeapColIds

deferredSparseRow

protected ExecRow deferredSparseRow

heapDCOCI

protected DynamicCompiledOpenConglomInfo heapDCOCI

indexDCOCIs

protected DynamicCompiledOpenConglomInfo[] indexDCOCIs

rowCount

public int rowCount

activation

protected final Activation activation

subqueryTrackingArray

protected NoPutResultSet[] subqueryTrackingArray

indent

protected java.lang.String indent

subIndent

protected java.lang.String subIndent

sourceDepth

protected int sourceDepth

beginTime

protected long beginTime

endTime

protected long endTime

beginExecutionTime

protected long beginExecutionTime

endExecutionTime

protected long endExecutionTime
Constructor Detail

InsertResultSet

public InsertResultSet(NoPutResultSet source,
                       GeneratedMethod checkGM,
                       Activation activation)
                throws StandardException
Throws:
StandardException - Thrown on error
Method Detail

getResultDescription

public ResultDescription getResultDescription()
Returns the description of the inserted rows. REVISIT: Do we want this to return NULL instead?

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

changedRow

public void changedRow(ExecRow execRow,
                       RowLocation rowLocation)
                throws StandardException
Description copied from interface: TargetResultSet
Pass a changed row and the row location for that row to the target result set.

Specified by:
changedRow in interface TargetResultSet
Parameters:
execRow - The changed row.
rowLocation - The row location of the row.
Returns:
Nothing.
Throws:
StandardException - thrown if cursor finish ed.
See Also:
TargetResultSet.changedRow(org.apache.derby.iapi.sql.execute.ExecRow, org.apache.derby.iapi.types.RowLocation)

preprocessSourceRow

public ExecRow preprocessSourceRow(ExecRow execRow)
                            throws StandardException
Preprocess the source row. Apply any check constraints here. Do an inplace cloning of all key columns. For triggers, if we have a before row trigger, we fire it here if we can. This is useful for bulk insert where the store stands between the source and us.

Specified by:
preprocessSourceRow in interface TargetResultSet
Parameters:
execRow - The source row.
Returns:
The preprocessed source row.
Throws:
StandardException - thrown on error

evaluateCheckConstraints

private void evaluateCheckConstraints()
                               throws StandardException
Run the check constraints against the current row. Raise an error if a check constraint is violated.

Returns:
Nothing.
Throws:
StandardException - thrown on error

open

public void open()
          throws StandardException
Description copied from interface: ResultSet
Needs to be called before the result set will do anything. Need to call before getNextRow(), or for a result set that doesn't return rows, this is the call that will cause all the work to be done.

Specified by:
open in interface ResultSet
Returns:
Nothing
Throws:
StandardException - Standard Cloudscape error policy

verifyAutoGeneratedColumnsIndexes

private void verifyAutoGeneratedColumnsIndexes(int[] columnIndexes)
                                        throws StandardException
Throws:
StandardException

generatedColumnPositionsArray

private int[] generatedColumnPositionsArray()
                                     throws StandardException
Throws:
StandardException

uniqueColumnPositionArray

private int[] uniqueColumnPositionArray(int[] columnIndexes)
                                 throws StandardException
Throws:
StandardException

verifyAutoGeneratedColumnsNames

private void verifyAutoGeneratedColumnsNames(java.lang.String[] columnNames)
                                      throws StandardException
Verify that the auto-generated columns list (by name) has valid column names for the table. If all the column names are valid, convert column names array to corresponding column positions array Save that column positions array in activation. We do this to simplify the rest of the logic(it only has to deal with column positions here after).

Returns:
Nothing.
Throws:
StandardException - Thrown on error if invalid column name in the list.

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
Overrides:
getAutoGeneratedKeysResultset in class NoRowsResultSetImpl
See Also:
ResultSet.getAutoGeneratedKeysResultset()

getSetAutoincrementValue

public NumberDataValue getSetAutoincrementValue(int columnPosition,
                                                long increment)
                                         throws StandardException
getSetAutoincrementValue will get the autoincrement value of the columnPosition specified for the target table. If increment is non-zero we will also update the autoincrement value.

Parameters:
columnPosition - position of the column in the table (1-based)
increment - amount of increment.
Throws:
StandardException - if anything goes wrong.

isSourceRowResultSet

private boolean isSourceRowResultSet()

normalInsertCore

private void normalInsertCore(LanguageConnectionContext lcc,
                              boolean firstExecute)
                       throws StandardException
Throws:
StandardException

getCompactRow

private ExecRow getCompactRow(ExecRow inputRow,
                              int[] columnIndexes)
                       throws StandardException
Throws:
StandardException

bulkInsertCore

private long bulkInsertCore(LanguageConnectionContext lcc,
                            long oldHeapConglom)
                     throws StandardException
Throws:
StandardException

bulkValidateForeignKeys

private void bulkValidateForeignKeys(TransactionController tc,
                                     ContextManager cm)
                              throws StandardException
Throws:
StandardException

bulkValidateForeignKeysCore

private void bulkValidateForeignKeysCore(TransactionController tc,
                                         ContextManager cm,
                                         FKInfo fkInfo,
                                         long fkConglom,
                                         long pkConglom,
                                         java.lang.String fkConstraintName)
                                  throws StandardException
Throws:
StandardException

makeIndexTemplate

private ExecRow makeIndexTemplate(FKInfo fkInfo,
                                  ExecRow fullTemplate,
                                  ContextManager cm)
                           throws StandardException
Make a template row with the correct columns.

Throws:
StandardException

setUpAllSorts

private void setUpAllSorts(ExecRow sourceRow,
                           RowLocation rl)
                    throws StandardException
Set up to update all of the indexes on a table when doing a bulk insert on an empty table.

Throws:
StandardException - thrown on error

updateAllIndexes

private void updateAllIndexes(long newHeapConglom,
                              InsertConstantAction constants,
                              TableDescriptor td,
                              DataDictionary dd,
                              ExecRow fullTemplate)
                       throws StandardException
Update all of the indexes on a table when doing a bulk insert on an empty table.

Throws:
StandardException - thrown on error

cleanUp

public void cleanUp()
             throws StandardException
Description copied from interface: ResultSet
Tells the system to clean up on an error.

Specified by:
cleanUp in interface ResultSet
Returns:
Nothing
Throws:
StandardException - Thrown on error
See Also:
ResultSet.cleanUp()

verifyBulkInsert

protected boolean verifyBulkInsert()
                            throws StandardException
Verify that bulkInsert is allowed on this table. The execution time check to see if bulkInsert is allowed simply consists of checking to see if this is not a deferred mode insert and that the table is empty if this is not replace. A side effect of calling this method is to get an exclusive table lock on the table.

Returns:
Whether or not bulkInsert is allowed on this table.
Throws:
StandardException - Thrown on error

getExclusiveTableLock

private boolean getExclusiveTableLock()
                               throws StandardException
Get an exclusive table lock on the target table (and check to see if the table is populated if this is not a bulk insert replace).

Returns:
Whether or not bulkInsert is allowed on this table.
Throws:
StandardException - Thrown on error

setEstimatedRowCount

private void setEstimatedRowCount(long heapConglom)
                           throws StandardException
Set the estimated row count for this table.

Parameters:
heapConglom - Conglomerate number for the heap
Returns:
Nothing
Throws:
StandardException - Thrown on failure

emptyIndexes

private void emptyIndexes(long newHeapConglom,
                          InsertConstantAction constants,
                          TableDescriptor td,
                          DataDictionary dd,
                          ExecRow fullTemplate)
                   throws StandardException
Empty the indexes after doing a bulk insert replace where the table has 0 rows after the replace. RESOLVE: This method is ugly! Prior to 2.0, we simply scanned back across the table to build the indexes. We changed this in 2.0 to populate the sorters via a call back as we populated the table. Doing a 0 row replace into a table with indexes is a degenerate case, hence we allow ugly and unoptimized code.

Returns:
Nothing.
Throws:
StandardException - Thrown on failure

getTableScanResultSet

private BulkTableScanResultSet getTableScanResultSet(long conglomId)
                                              throws StandardException
Get me a table scan result set, preferably a bulk table scan, thank you. If we already have one, reopen it.

Throws:
StandardException

getColumnNames

private java.lang.String[] getColumnNames(int[] baseColumnPositions)

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 NoRowsResultSetImpl
Throws:
StandardException - on error

modifiedRowCount

public final int modifiedRowCount()
Description copied from class: NoRowsResultSetImpl
Returns zero.

Specified by:
modifiedRowCount in interface ResultSet
Overrides:
modifiedRowCount in class NoRowsResultSetImpl

getNextRowCore

protected ExecRow getNextRowCore(NoPutResultSet source)
                          throws StandardException
Get next row from the source result set.

Parameters:
source - SourceResultSet Also look at Track#2432/change 12433
Throws:
StandardException

makeDeferredSparseRow

protected ExecRow makeDeferredSparseRow(ExecRow deferredBaseRow,
                                        FormatableBitSet baseRowReadList,
                                        LanguageConnectionContext lcc)
                                 throws StandardException
For deferred update, get a deferred sparse row based on the deferred non-sparse row. Share the underlying columns. If there is no column bit map, make them the same row.

Throws:
StandardException - Thrown on error

getIndexNameFromCID

java.lang.String getIndexNameFromCID(long indexCID)
get the index name given the conglomerate id of the index.

Parameters:
indexCID - conglomerate ID of the index.
Returns:
index name of given index.

returnsRows

public final boolean returnsRows()
Returns FALSE

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

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

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

checkRowPosition

public 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 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
No rows to return, does nothing

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

isClosed

public boolean isClosed()
Just report that it is always closed. RESOLVE: if we don't report that we are closed, then we will wind up with a dependency problem when we send an invalidateFor on our own Statement. It will call lcc.verifyNoOpenResultSets(), which is really supposed to be verify that there are no read only result sets that are open.

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

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)

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.
Throws:
StandardException - thrown on error

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