org.apache.derby.iapi.sql
Interface Activation

All Known Subinterfaces:
CursorActivation
All Known Implementing Classes:
BaseActivation, GenericActivationHolder

public interface Activation

An activation contains all the local state information necessary to execute a re-entrant PreparedStatement. The way it will actually work is that a PreparedStatement will have an executable plan, which will be a generated class. All of the local state will be variables in the class. Creating a new instance of the executable plan will create the local state variables. This means that an executable plan must implement this interface, and that the PreparedStatement.getActivation() method will do a "new" operation on the executable plan.

The fixed implementations of Activation in the Execution impl package are used as skeletons for the classes generated for statements when they are compiled.

There are no fixed implementations of Activation for statements; a statement has an activation generated for it when it is compiled.

Author:
Jeff Lichtman

Method Summary
 void addWarning(java.sql.SQLWarning w)
          Add a warning to the activation
 boolean checkIfThisActivationHasHoldCursor(java.lang.String tableName)
          Temporary tables can be declared with ON COMMIT DELETE ROWS.
 void checkStatementValidity()
          Check the validity of the current executing statement.
 void clearCurrentRow(int resultSetNumber)
          Generated plans have a current row field for ease in defining the methods and finding them dynamically.
 void clearHeapConglomerateController()
          Clear the ConglomerateController to be used for an update or delete.
 void clearIndexScanInfo()
          Clear the info for the index to be re-used for update/delete.
 void clearParentResultSets()
           
 void clearResultSet()
          Sets the ResultSet to be returned by getResultSet() to null.
 void clearWarnings()
          Clear the activation's warnings.
 void close()
          Closing an activation statement marks it as unusable.
 ResultSet execute()
          When the prepared statement is executed, it passes execution on to the activation execution was requested for.
 int[] getAutoGeneratedKeysColumnIndexes()
          Returns the column positions array of columns requested in auto-generated keys resultset for this avtivation.
 java.lang.String[] getAutoGeneratedKeysColumnNames()
          Returns the column names array of columns requested in auto-generated keys resultset for this avtivation.
 boolean getAutoGeneratedKeysResultsetMode()
          Returns true if auto-generated keys resultset request was made for this avtivation.
 ConstantAction getConstantAction()
           
 java.lang.String getCursorName()
          Return the cursor name of this activation.
 DataValueFactory getDataValueFactory()
          Get the DataValueFactory
 TableDescriptor getDDLTableDescriptor()
          Get the TableDescriptor for the target of DDL.
 java.sql.ResultSet[][] getDynamicResults()
          Return the set of dynamical created result sets, for procedures.
 ExecutionFactory getExecutionFactory()
          Get the ExecutionFactory
 boolean getForCreateTable()
          Get whether or not this activation is for create table.
 CursorResultSet getForUpdateIndexScan()
           
 ConglomerateController getHeapConglomerateController()
          Get the ConglomerateController, if any, that has already been opened for the heap when scaning for an update or delete.
 long getIndexConglomerateNumber()
          Get the conglomerate number of the index, if any, that has already been opened for scaning for an update or delete.
 ScanController getIndexScanController()
          Get the ScanController, if any, that has already been opened for the index when scaning for an update or delete.
 LanguageConnectionContext getLanguageConnectionContext()
          Get the language connection context associated with this activation
 int getMaxDynamicResults()
          Return the maximum number of dynamical created result sets from the procedure definition.
 int getMaxRows()
          Get the maximum # of rows. (# of rows that can be returned by a ResultSet. 0 means no limit.)
 int getNumSubqueries()
          Get the number of subqueries in the entire query.
 ParameterValueSet getParameterValueSet()
          Gets the ParameterValueSet for this execution of the statement.
 java.util.Vector getParentResultSet(java.lang.String resultSetId)
          get the reference to parent table ResultSets, that will be needed by the referential action dependent table scans.
 java.util.Hashtable getParentResultSets()
           
 ExecPreparedStatement getPreparedStatement()
          Get the prepared statement that this activation is for.
 ResultDescription getResultDescription()
          Get the result description for this activation, if it has one.
 ResultSet getResultSet()
          Returns the current result set for this activation, i.e.
 boolean getResultSetHoldability()
          Return the holdability of this activation.
 RowLocation getRowLocationTemplate(int itemNumber)
          Get the saved RowLocation.
 java.sql.ResultSet getTargetVTI()
          Get the ResultSet for the target of an update/delete to a VTI.
 TransactionController getTransactionController()
          Get the Execution TransactionController associated with this activation/lcc.
 java.sql.SQLWarning getWarnings()
          Returns the chained list of warnings.
 void informOfRowCount(NoPutResultSet resultSet, long rowCount)
          Tell this activation that the given ResultSet was found to have the given number of rows.
 boolean isClosed()
          Find out if the activation is closed or not.
 boolean isCursorActivation()
          Is this Activation for a cursor?
 boolean isInUse()
          Is the activation in use?
 boolean isSingleExecution()
          Returns true if this Activation is only going to be used for one execution.
 void markUnused()
          Mark the activation as unused.
 void reset()
          Resets the activation to the "pre-execution" state - that is, the state where it can be used to begin a new execution.
 void setAutoGeneratedKeysResultsetInfo(int[] columnIndexes, java.lang.String[] columnNames)
          Set the auto-generated keys resultset mode to true for this activation.
 void setCurrentRow(ExecRow currentRow, int resultSetNumber)
          Generated plans have a current row field for ease in defining the methods and finding them dynamically.
 void setCursorName(java.lang.String cursorName)
          JDBC requires that all select statements be converted into cursors, and that the cursor name be settable for each execution of a select statement.
 void setDDLTableDescriptor(TableDescriptor td)
          Save the TableDescriptor for the target of DDL so that it can be passed between the various ConstantActions during execution.
 void setForCreateTable()
          Mark the Activation as being for create table.
 void setForUpdateIndexScan(CursorResultSet forUpdateResultSet)
          beetle 3865: updateable cursor using index.
 void setHeapConglomerateController(ConglomerateController updateHeapCC)
          Set the ConglomerateController to be used for an update or delete.
 void setIndexConglomerateNumber(long indexConglomerateNumber)
          Set the conglomerate number of the index to be used for an update or delete, when scanning an index that will also be updated (Saves opening the ScanController twice.)
 void setIndexScanController(ScanController indexSC)
          Set the ScanController to be used for an update or delete, when scanning an index that will also be updated (Saves opening the ScanController twice.)
 void setMaxRows(int maxRows)
          Set the maximum # of rows. (# of rows that can be returned by a ResultSet. 0 means no limit.)
 void setParameters(ParameterValueSet parameterValues, DataTypeDescriptor[] parameterTypes)
          Sets the parameter values for this execution of the statement.
 void setParentResultSet(TemporaryRowHolder rs, java.lang.String resultSetId)
           
 void setResultSetHoldability(boolean resultSetHoldability)
          Set current resultset holdability.
 void setSingleExecution()
          Set this Activation for a single execution.
 void setTargetVTI(java.sql.ResultSet targetVTI)
          Save the ResultSet for the target of an update/delete to a VTI.
 

Method Detail

reset

public void reset()
           throws StandardException
Resets the activation to the "pre-execution" state - that is, the state where it can be used to begin a new execution. Frees local buffers, stops scans, resets counters to zero, sets current date and time to an unitialized state, etc.

Returns:
Nothing
Throws:
StandardException - thrown on failure

setCursorName

public void setCursorName(java.lang.String cursorName)
JDBC requires that all select statements be converted into cursors, and that the cursor name be settable for each execution of a select statement. The Language Module will support this, so that the JDBC driver will not have to parse JSQL text. This method will have no effect when called on non-select statements.

There will be a JSQL statement to disable the "cursorization" of all select statements. For non-cursorized select statements, this method will have no effect.

This has no effect if the activation has been closed.

Parameters:
cursorName - The cursor name to use.

checkIfThisActivationHasHoldCursor

public boolean checkIfThisActivationHasHoldCursor(java.lang.String tableName)
Temporary tables can be declared with ON COMMIT DELETE ROWS. But if the table has a held curosr open at commit time, data should not be deleted from the table. This method, (gets called at commit time) checks if this activation held cursor and if so, does that cursor reference the passed temp table name.

Returns:
true if this activation has held cursor and if it references the passed temp table name

getParameterValueSet

public ParameterValueSet getParameterValueSet()
Gets the ParameterValueSet for this execution of the statement.

Returns:
The ParameterValueSet for this execution of the statement. Returns NULL if there are no parameters.

setParameters

public void setParameters(ParameterValueSet parameterValues,
                          DataTypeDescriptor[] parameterTypes)
                   throws StandardException
Sets the parameter values for this execution of the statement.

Has no effect if the activation has been closed.

NOTE: The setParameters() method is currently unimplemented. A statement with parameters will generate its own ParameterValueSet, which can be gotten with the getParameterValueSet() method (above). The idea behind setParameters() is to improve performance when operating across a network by allowing all the parameters to be set in one call, as opposed to one call per parameter.

Parameters:
parameterValues - The values of the parameters.
Returns:
Nothing
Throws:
StandardException

execute

public ResultSet execute()
                  throws StandardException
When the prepared statement is executed, it passes execution on to the activation execution was requested for.

Returns:
the ResultSet for further manipulation, if any.
Throws:
StandardException - Thrown on failure

close

public void close()
           throws StandardException
Closing an activation statement marks it as unusable. Any other requests made on it will fail. An activation should be marked closed when it is expected to not be used any longer, i.e. when the connection for it is closed, or it has suffered some sort of severe error. This will also close its result set and release any resources it holds e.g. for parameters.

Any class that implements this must be prepared to be executed from garbage collection, ie. there is no matching context stack.

Throws:
StandardException - Thrown on failure

isClosed

public boolean isClosed()
Find out if the activation is closed or not.

Returns:
true if the Activation has been closed.

setSingleExecution

public void setSingleExecution()
Set this Activation for a single execution. E.g. a java.sql.Statement execution.


isSingleExecution

public boolean isSingleExecution()
Returns true if this Activation is only going to be used for one execution.


getWarnings

public java.sql.SQLWarning getWarnings()
Returns the chained list of warnings. Returns null if there are no warnings.


addWarning

public void addWarning(java.sql.SQLWarning w)
Add a warning to the activation


clearWarnings

public void clearWarnings()
Clear the activation's warnings.


getLanguageConnectionContext

public LanguageConnectionContext getLanguageConnectionContext()
Get the language connection context associated with this activation


getTransactionController

public TransactionController getTransactionController()
Get the Execution TransactionController associated with this activation/lcc.


getResultSet

public ResultSet getResultSet()
Returns the current result set for this activation, i.e. the one returned by the last execute() call. If there has been no execute call or the activation has been reset or closed, a null is returned.

Returns:
the current ResultSet of this activation.

clearResultSet

public void clearResultSet()
Sets the ResultSet to be returned by getResultSet() to null.


setCurrentRow

public void setCurrentRow(ExecRow currentRow,
                          int resultSetNumber)
Generated plans have a current row field for ease in defining the methods and finding them dynamically. The interface is used to set the row before a dynamic method that uses it is invoked.

When all processing on the currentRow has been completed, callers should call activation.clearCurrentRow(resultSetNumber) to ensure that no unnecessary references are retained to rows. This will allow the rows no longer in use to be collected by the garbage collecter.

Parameters:
currentRow - The row to be operated upon.
resultSetNumber - The resultSetNumber for the current ResultSet
Returns:
Nothing

clearCurrentRow

public void clearCurrentRow(int resultSetNumber)
Generated plans have a current row field for ease in defining the methods and finding them dynamically. The interface is used to set the row before a dynamic method that uses it is invoked.

When all processing on the currentRow has been completed, callers should call activation.clearCurrentRow(resultSetNumber) to ensure that no unnecessary references are retained to rows. This will allow the rows no longer in use to be collected by the garbage collecter.

Parameters:
resultSetNumber - The resultSetNumber for the current ResultSet
Returns:
Nothing

getPreparedStatement

public ExecPreparedStatement getPreparedStatement()
Get the prepared statement that this activation is for.

Returns:
the prepared statement this activation is for.

checkStatementValidity

public void checkStatementValidity()
                            throws StandardException
Check the validity of the current executing statement. Needs to be called after a statement has obtained the relevant table locks on the

Throws:
StandardException

getResultDescription

public ResultDescription getResultDescription()
Get the result description for this activation, if it has one.

Returns:
result description for this activation, if it has one; otherwise, null.

getDataValueFactory

public DataValueFactory getDataValueFactory()
Get the DataValueFactory

Returns:
DataValueFactory

getExecutionFactory

public ExecutionFactory getExecutionFactory()
Get the ExecutionFactory

Returns:
ExecutionFactory

getRowLocationTemplate

public RowLocation getRowLocationTemplate(int itemNumber)
Get the saved RowLocation.

Parameters:
itemNumber - The saved item number.
Returns:
A RowLocation template for the conglomerate

getNumSubqueries

public int getNumSubqueries()
Get the number of subqueries in the entire query.

Returns:
int The number of subqueries in the entire query.

getCursorName

public java.lang.String getCursorName()
Return the cursor name of this activation. This will differ from its ResultSet's cursor name if it has been altered with setCursorName. Thus this always returns the cursor name of the next execution of this activation. The cursor name of the current execution must be obtained from the ResultSet. or this.getResultSet.getCursorName() [with null checking].

Statements that do not support cursors will return a null.

Returns:
The cursor name.

getResultSetHoldability

public boolean getResultSetHoldability()
Return the holdability of this activation.

Returns:
The holdability of this activation.

setResultSetHoldability

public void setResultSetHoldability(boolean resultSetHoldability)
Set current resultset holdability.

Parameters:
resultSetHoldability - The new resultset holdability.
Returns:
Nothing.

setAutoGeneratedKeysResultsetInfo

public void setAutoGeneratedKeysResultsetInfo(int[] columnIndexes,
                                              java.lang.String[] columnNames)
Set the auto-generated keys resultset mode to true for this activation. The specific columns for auto-generated keys resultset can be requested by passing column positions array The specific columns for auto-generated keys resultset can be requested by passing column names array Both the parameters would be null if user didn't request specific keys. Otherwise, the user could request specific columns by passing column positions or names array but not both.

Parameters:
columnIndexes - Request specific columns in auto-generated keys resultset by passing column positions. null means no specific columns requested by position
columnNames - Request specific columns in auto-generated keys resultset by passing column names. null means no specific columns requested by position
Returns:
Nothing.

getAutoGeneratedKeysResultsetMode

public boolean getAutoGeneratedKeysResultsetMode()
Returns true if auto-generated keys resultset request was made for this avtivation.

Returns:
auto-generated keys resultset mode for this activation.

getAutoGeneratedKeysColumnIndexes

public int[] getAutoGeneratedKeysColumnIndexes()
Returns the column positions array of columns requested in auto-generated keys resultset for this avtivation. Returns null if no specific column requested by positions

Returns:
column positions array of columns requested.

getAutoGeneratedKeysColumnNames

public java.lang.String[] getAutoGeneratedKeysColumnNames()
Returns the column names array of columns requested in auto-generated keys resultset for this avtivation. Returns null if no specific column requested by names

Returns:
column names array of columns requested.

markUnused

public void markUnused()
Mark the activation as unused.


isInUse

public boolean isInUse()
Is the activation in use?

Returns:
true/false

informOfRowCount

public void informOfRowCount(NoPutResultSet resultSet,
                             long rowCount)
                      throws StandardException
Tell this activation that the given ResultSet was found to have the given number of rows. This is used during execution to determine whether a table has grown or shrunk. If a table's size changes significantly, the activation may invalidate its PreparedStatement to force recompilation. Note that the association of row counts with ResultSets is kept in the activation class, not in the activation itself. This means that this method must be synchronized. This method is not required to check the number of rows on each call. Because of synchronization, this check is likely to be expensive, so it may only check every hundred calls or so.

Throws:
StandardException - Thrown on error

getHeapConglomerateController

public ConglomerateController getHeapConglomerateController()
Get the ConglomerateController, if any, that has already been opened for the heap when scaning for an update or delete. (Saves opening the ConglomerateController twice.)

Returns:
The ConglomerateController, if available, to use for the update.

setHeapConglomerateController

public void setHeapConglomerateController(ConglomerateController updateHeapCC)
Set the ConglomerateController to be used for an update or delete. (Saves opening the ConglomerateController twice.)

Parameters:
updateHeapCC - The ConglomerateController to reuse for the update or delete.
Returns:
Nothing.

clearHeapConglomerateController

public void clearHeapConglomerateController()
Clear the ConglomerateController to be used for an update or delete. (Saves opening the ConglomerateController twice.)

Returns:
Nothing.

getIndexScanController

public ScanController getIndexScanController()
Get the ScanController, if any, that has already been opened for the index when scaning for an update or delete. (Saves opening the ScanController twice.)

Returns:
The ScanController, if available, to use for the update.

setIndexScanController

public void setIndexScanController(ScanController indexSC)
Set the ScanController to be used for an update or delete, when scanning an index that will also be updated (Saves opening the ScanController twice.)

Parameters:
indexSC - The ScanController to reuse for the update or delete.
Returns:
Nothing.

getIndexConglomerateNumber

public long getIndexConglomerateNumber()
Get the conglomerate number of the index, if any, that has already been opened for scaning for an update or delete. (Saves opening the ScanController twice.)

Returns:
The conglomerate number, if available, to use for the update.

setIndexConglomerateNumber

public void setIndexConglomerateNumber(long indexConglomerateNumber)
Set the conglomerate number of the index to be used for an update or delete, when scanning an index that will also be updated (Saves opening the ScanController twice.)

Parameters:
indexConglomerateNumber - The conglomerate number of the index to reuse for the update or delete.
Returns:
Nothing.

clearIndexScanInfo

public void clearIndexScanInfo()
Clear the info for the index to be re-used for update/delete. (ScanController and conglomerate number.)

Returns:
Nothing.

setForCreateTable

public void setForCreateTable()
Mark the Activation as being for create table. (NOTE: We can do certain optimizations for create table that we can't do for other DDL.)

Returns:
Nothing.

getForCreateTable

public boolean getForCreateTable()
Get whether or not this activation is for create table. (NOTE: We can do certain optimizations for create table that we can't do for other DDL.)

Returns:
Whether or not this activation is for create table.

setDDLTableDescriptor

public void setDDLTableDescriptor(TableDescriptor td)
Save the TableDescriptor for the target of DDL so that it can be passed between the various ConstantActions during execution.

Returns:
Nothing.

getDDLTableDescriptor

public TableDescriptor getDDLTableDescriptor()
Get the TableDescriptor for the target of DDL.

Returns:
The TableDescriptor for the target of DDL.

setMaxRows

public void setMaxRows(int maxRows)
Set the maximum # of rows. (# of rows that can be returned by a ResultSet. 0 means no limit.)

Parameters:
maxRows - Maximum # of rows. (0 means no limit.)
Returns:
Nothing.

getMaxRows

public int getMaxRows()
Get the maximum # of rows. (# of rows that can be returned by a ResultSet. 0 means no limit.)

Returns:
Maximum # of rows. (0 means no limit.)

isCursorActivation

public boolean isCursorActivation()
Is this Activation for a cursor?

Returns:
Whether or not this Activation is for a cursor.

setTargetVTI

public void setTargetVTI(java.sql.ResultSet targetVTI)
Save the ResultSet for the target of an update/delete to a VTI.

Returns:
Nothing.

getTargetVTI

public java.sql.ResultSet getTargetVTI()
Get the ResultSet for the target of an update/delete to a VTI.

Returns:
The ResultSet for the target of an update/delete to a VTI.

getConstantAction

public ConstantAction getConstantAction()

setParentResultSet

public void setParentResultSet(TemporaryRowHolder rs,
                               java.lang.String resultSetId)

getParentResultSet

public java.util.Vector getParentResultSet(java.lang.String resultSetId)
get the reference to parent table ResultSets, that will be needed by the referential action dependent table scans.


clearParentResultSets

public void clearParentResultSets()

getParentResultSets

public java.util.Hashtable getParentResultSets()

setForUpdateIndexScan

public void setForUpdateIndexScan(CursorResultSet forUpdateResultSet)
beetle 3865: updateable cursor using index. A way of communication between cursor activation and update activation.


getForUpdateIndexScan

public CursorResultSet getForUpdateIndexScan()

getDynamicResults

public java.sql.ResultSet[][] getDynamicResults()
Return the set of dynamical created result sets, for procedures. Base implementation returns null, a generated class for a procedure overwrites this with a real implementation.

Returns:
null if no dynamic results exists. Otherwise an array of ResultSet arrays, each of length one containing null or a reference to a ResultSet.

getMaxDynamicResults

public int getMaxDynamicResults()
Return the maximum number of dynamical created result sets from the procedure definition. Base implementation returns 0, a generated class for a procedure overwrites this with a real implementation.



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