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

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

 class VTIResultSet
extends NoPutResultSetImpl
implements CursorResultSet, VTIEnvironment


Field Summary
private  ExecRow allocatedRow
           
private  ClassInspector classInspector
           
private  FormatableHashtable compileTimeConstants
           
private  GeneratedMethod constructor
           
private  int ctcNumber
           
private  IFastPath fastPath
           
private  boolean isDerbyStyleTableFunction
           
private  boolean isTarget
           
 java.lang.String javaClassName
           
private  boolean next
           
private  boolean pushedProjection
           
private  Qualifier[][] pushedQualifiers
           
private  FormatableBitSet referencedColumns
           
private  DataTypeDescriptor[] returnColumnTypes
           
private  TypeDescriptor returnType
           
private  boolean reuseablePs
           
private  GeneratedMethod row
           
 int rowsReturned
           
private  boolean[] runtimeNullableColumn
           
private  int scanIsolationLevel
          Specified isolation level of SELECT (scan).
private  java.sql.PreparedStatement userPS
           
private  java.sql.ResultSet userVTI
           
private  boolean version2
           
private  java.lang.String[] vtiProjection
           
private  Restriction vtiRestriction
           
 
Fields inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
checkNullCols, clonedExecRow, cncLen, resultSetNumber, targetResultSet
 
Fields inherited from class org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
activation, beginTime, closeTime, compactRow, constructorTime, currentRow, endExecutionTime, finished, isOpen, isTopResultSet, nextTime, numOpens, openTime, optimizerEstimatedCost, optimizerEstimatedRowCount, resultDescription, rowsFiltered, rowsSeen, startExecutionTime, subqueryTrackingArray
 
Fields inherited from interface org.apache.derby.iapi.sql.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
VTIResultSet(Activation activation, GeneratedMethod row, int resultSetNumber, GeneratedMethod constructor, java.lang.String javaClassName, Qualifier[][] pushedQualifiers, int erdNumber, boolean version2, boolean reuseablePs, int ctcNumber, boolean isTarget, int scanIsolationLevel, double optimizerEstimatedRowCount, double optimizerEstimatedCost, boolean isDerbyStyleTableFunction, int returnTypeNumber, int vtiProjectionNumber, int vtiRestrictionNumber)
           
 
Method Summary
private  void cast(DataTypeDescriptor dtd, DataValueDescriptor dvd)
           Cast the value coming out of the user-coded ResultSet.
private  void castDecimal(DataTypeDescriptor dtd, DataValueDescriptor dvd)
           Set the correct precision and scale for a decimal value.
private  void castLongvarbinary(DataTypeDescriptor dtd, DataValueDescriptor dvd)
           Truncate long varbinary values to the legal maximum.
private  void castLongvarchar(DataTypeDescriptor dtd, DataValueDescriptor dvd)
           Truncate long varchars to the legal maximum.
private  Restriction cloneRestriction(Activation activation)
          Clone the restriction for a Restricted VTI, filling in parameter values as necessary.
private  Restriction cloneRestriction(Activation activation, Restriction original)
           
 void close()
          Close needs to invalidate any dependent statements, if this is a cursor.
 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  ExecRow getAllocatedRow()
          Cache the ExecRow for this result set.
 ExecRow getCurrentRow()
          This is not used in positioned update and delete, so just return a null.
 ExecRow getNextRowCore()
          If open and not returned yet, returns the row after plugging the parameters into the expressions.
 java.lang.String getOriginalSQL()
          Return the SQL text of the original SQL statement.
private  int[] getProjectedColList()
           
private  DataTypeDescriptor[] getReturnColumnTypes()
           Get the types of the columns returned by a Derby-style table function.
 RowLocation getRowLocation()
          This is not operating against a stored table, so it has no row location to report.
 int getScanIsolationLevel()
          Return the isolation level of the scan in the result set.
 java.lang.Object getSharedState(java.lang.String key)
          Get an object associated with a key from set of objects maintained with the statement plan.
 int getStatementIsolationLevel()
          Get the specific JDBC isolation of the statement.
 long getTimeSpent(int type)
          Return the total amount of time spent in this ResultSet
(package private)  GeneratedMethod getVTIConstructor()
          Return the GeneratedMethod for instantiating the VTI.
 boolean isCompileTime()
          Return true if this instance of the Table Function has been created for compilation, false if it is for runtime execution.
(package private)  boolean isReuseablePs()
           
 void openCore()
          Sets state to 'open'.
 void populateFromResultSet(ExecRow row)
           
 void reopenCore()
          If the VTI is a version2 vti that does not need to be instantiated multiple times then we simply close the current ResultSet and create a new one via a call to PreparedStatement.executeQuery().
private  boolean[] setNullableColumnList()
           
 void setSharedState(java.lang.String key, java.io.Serializable value)
          Saves an object associated with a key that will be maintained for the lifetime of the statement plan.
 
Methods inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
clearCurrentRow, clearOrderableCache, closeRowSource, getCursorName, getNextRowFromRowSource, getResultDescription, getValidColumns, isForUpdate, markRowAsDeleted, needsRowLocation, needsToClone, positionScanAtRowLocation, printQualifiers, resultSetNumber, rowLocation, setCurrentRow, setNeedsRowLocation, setTargetResultSet, skipRow, skipScan, updateRow
 
Methods inherited from class org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
addWarning, attachStatementContext, checkCancellationFlag, checkRowPosition, cleanUp, dumpTimeStats, finishAndRTS, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCompactRow, getCurrentTimeMillis, getElapsedMillis, getEndExecutionTimestamp, getEstimatedRowCount, getExecuteTime, getExecutionFactory, getFirstRow, getLanguageConnectionContext, getLastRow, getNextRow, getPointOfAttachment, getPreviousRow, getRelativeRow, getRowNumber, getSubqueryTrackingArray, getTransactionController, getWarnings, isClosed, markAsTopResultSet, modifiedRowCount, open, recordConstructorTime, requiresRelocking, returnsRows, setAfterLastRow, setBeforeFirstRow, setCompactRow, setCompatRow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.derby.iapi.sql.ResultSet
checkRowPosition, cleanUp, clearCurrentRow, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCursorName, getEndExecutionTimestamp, getExecuteTime, getFirstRow, getLastRow, getNextRow, getPreviousRow, getRelativeRow, getResultDescription, getRowNumber, getSubqueryTrackingArray, getWarnings, isClosed, modifiedRowCount, open, returnsRows, setAfterLastRow, setBeforeFirstRow
 

Field Detail

rowsReturned

public int rowsReturned

javaClassName

public java.lang.String javaClassName

next

private boolean next

classInspector

private ClassInspector classInspector

row

private GeneratedMethod row

constructor

private GeneratedMethod constructor

userPS

private java.sql.PreparedStatement userPS

userVTI

private java.sql.ResultSet userVTI

allocatedRow

private ExecRow allocatedRow

referencedColumns

private FormatableBitSet referencedColumns

version2

private boolean version2

reuseablePs

private boolean reuseablePs

isTarget

private boolean isTarget

compileTimeConstants

private FormatableHashtable compileTimeConstants

ctcNumber

private int ctcNumber

pushedProjection

private boolean pushedProjection

fastPath

private IFastPath fastPath

pushedQualifiers

private Qualifier[][] pushedQualifiers

runtimeNullableColumn

private boolean[] runtimeNullableColumn

isDerbyStyleTableFunction

private boolean isDerbyStyleTableFunction

returnType

private final TypeDescriptor returnType

returnColumnTypes

private DataTypeDescriptor[] returnColumnTypes

vtiProjection

private java.lang.String[] vtiProjection

vtiRestriction

private Restriction vtiRestriction

scanIsolationLevel

private int scanIsolationLevel
Specified isolation level of SELECT (scan). If not set or not application, it will be set to ExecutionContext.UNSPECIFIED_ISOLATION_LEVEL

Constructor Detail

VTIResultSet

VTIResultSet(Activation activation,
             GeneratedMethod row,
             int resultSetNumber,
             GeneratedMethod constructor,
             java.lang.String javaClassName,
             Qualifier[][] pushedQualifiers,
             int erdNumber,
             boolean version2,
             boolean reuseablePs,
             int ctcNumber,
             boolean isTarget,
             int scanIsolationLevel,
             double optimizerEstimatedRowCount,
             double optimizerEstimatedCost,
             boolean isDerbyStyleTableFunction,
             int returnTypeNumber,
             int vtiProjectionNumber,
             int vtiRestrictionNumber)
       throws StandardException
Throws:
StandardException
Method Detail

openCore

public void openCore()
              throws StandardException
Sets state to 'open'.

Specified by:
openCore in interface NoPutResultSet
Throws:
StandardException - thrown if activation closed.

cloneRestriction

private Restriction cloneRestriction(Activation activation)
                              throws StandardException
Clone the restriction for a Restricted VTI, filling in parameter values as necessary.

Throws:
StandardException

cloneRestriction

private Restriction cloneRestriction(Activation activation,
                                     Restriction original)
                              throws StandardException
Throws:
StandardException

setNullableColumnList

private boolean[] setNullableColumnList()
                                 throws java.sql.SQLException,
                                        StandardException
Throws:
java.sql.SQLException
StandardException

reopenCore

public void reopenCore()
                throws StandardException
If the VTI is a version2 vti that does not need to be instantiated multiple times then we simply close the current ResultSet and create a new one via a call to PreparedStatement.executeQuery().

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

getNextRowCore

public ExecRow getNextRowCore()
                       throws StandardException
If open and not returned yet, returns the row after plugging the parameters into the expressions.

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

close

public void close()
           throws StandardException
Description copied from class: NoPutResultSetImpl
Close needs to invalidate any dependent statements, if this is a cursor. Must be called by any subclasses that override close().

Specified by:
close in interface ResultSet
Overrides:
close in class NoPutResultSetImpl
Throws:
StandardException - thrown on error
See Also:
ResultSet.close()

finish

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

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

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()
This is not operating against a stored table, so it has no row location to report.

Specified by:
getRowLocation in interface CursorResultSet
Returns:
a null.
See Also:
CursorResultSet

getCurrentRow

public ExecRow getCurrentRow()
This is not used in positioned update and delete, so just return a null.

Specified by:
getCurrentRow in interface CursorResultSet
Returns:
a null.
See Also:
CursorResultSet

getVTIConstructor

GeneratedMethod getVTIConstructor()
Return the GeneratedMethod for instantiating the VTI.

Returns:
The GeneratedMethod for instantiating the VTI.

isReuseablePs

boolean isReuseablePs()

getAllocatedRow

private ExecRow getAllocatedRow()
                         throws StandardException
Cache the ExecRow for this result set.

Returns:
The cached ExecRow for this ResultSet
Throws:
StandardException - thrown on failure.

getProjectedColList

private int[] getProjectedColList()

populateFromResultSet

public void populateFromResultSet(ExecRow row)
                           throws StandardException
Throws:
StandardException - thrown on failure to open

getScanIsolationLevel

public final 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
Overrides:
getScanIsolationLevel in class BasicNoPutResultSetImpl
Returns:
The isolation level of the scan (in TransactionController constants).
See Also:
NoPutResultSet.getScanIsolationLevel()

isCompileTime

public final boolean isCompileTime()
Description copied from interface: VTIEnvironment
Return true if this instance of the Table Function has been created for compilation, false if it is for runtime execution.

Specified by:
isCompileTime in interface VTIEnvironment

getOriginalSQL

public final java.lang.String getOriginalSQL()
Description copied from interface: VTIEnvironment
Return the SQL text of the original SQL statement.

Specified by:
getOriginalSQL in interface VTIEnvironment

getStatementIsolationLevel

public final int getStatementIsolationLevel()
Description copied from interface: VTIEnvironment
Get the specific JDBC isolation of the statement. If it returns Connection.TRANSACTION_NONE then no isolation was specified and the connection's isolation level is implied.

Specified by:
getStatementIsolationLevel in interface VTIEnvironment

setSharedState

public final void setSharedState(java.lang.String key,
                                 java.io.Serializable value)
Description copied from interface: VTIEnvironment
Saves an object associated with a key that will be maintained for the lifetime of the statement plan. Any previous value associated with the key is discarded. Any saved object can be seen by any JDBC Connection that has a Statement object that references the same statement plan.

Specified by:
setSharedState in interface VTIEnvironment

getSharedState

public java.lang.Object getSharedState(java.lang.String key)
Description copied from interface: VTIEnvironment
Get an object associated with a key from set of objects maintained with the statement plan.

Specified by:
getSharedState in interface VTIEnvironment

getReturnColumnTypes

private DataTypeDescriptor[] getReturnColumnTypes()
                                           throws StandardException

Get the types of the columns returned by a Derby-style table function.

Throws:
StandardException

cast

private void cast(DataTypeDescriptor dtd,
                  DataValueDescriptor dvd)
           throws StandardException

Cast the value coming out of the user-coded ResultSet. The rules are described in CastNode.getDataValueConversion().

Throws:
StandardException

castLongvarchar

private void castLongvarchar(DataTypeDescriptor dtd,
                             DataValueDescriptor dvd)
                      throws StandardException

Truncate long varchars to the legal maximum.

Throws:
StandardException

castLongvarbinary

private void castLongvarbinary(DataTypeDescriptor dtd,
                               DataValueDescriptor dvd)
                        throws StandardException

Truncate long varbinary values to the legal maximum.

Throws:
StandardException

castDecimal

private void castDecimal(DataTypeDescriptor dtd,
                         DataValueDescriptor dvd)
                  throws StandardException

Set the correct precision and scale for a decimal value.

Throws:
StandardException

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.